Browse Source

Fixed an issue with incorrectly specified texture format
Added offsets for DX9 pixel <-> texel mapping in builtin GUI materials

Marko Pintera 12 years ago
parent
commit
605061be36

+ 4 - 4
BansheeEngine/Source/BsD3D9BuiltinMaterialFactory.cpp

@@ -56,8 +56,8 @@ namespace BansheeEngine
 			{													\
 			{													\
 				float4 tfrmdPos = mul(worldTransform, float4(inPos.xy, 0, 1));	\
 				float4 tfrmdPos = mul(worldTransform, float4(inPos.xy, 0, 1));	\
 																\
 																\
-				float tfrmdX = (tfrmdPos.x / halfViewportWidth) - 1.0f;			\
-				float tfrmdY = (tfrmdPos.y / halfViewportHeight) + 1.0f;		\
+				float tfrmdX = ((tfrmdPos.x - 0.5f) / halfViewportWidth) - 1.0f;			\
+				float tfrmdY = ((tfrmdPos.y + 0.5f) / halfViewportHeight) + 1.0f;		\
 																\
 																\
 				oPosition = float4(tfrmdX, tfrmdY, 0, 1);		\
 				oPosition = float4(tfrmdX, tfrmdY, 0, 1);		\
 				oUv = uv;										\
 				oUv = uv;										\
@@ -117,8 +117,8 @@ namespace BansheeEngine
 						{													\
 						{													\
 						float4 tfrmdPos = mul(worldTransform, float4(inPos.xy, 0, 1));	\
 						float4 tfrmdPos = mul(worldTransform, float4(inPos.xy, 0, 1));	\
 						\
 						\
-						float tfrmdX = (tfrmdPos.x / halfViewportWidth) - 1.0f;			\
-						float tfrmdY = (tfrmdPos.y / halfViewportHeight) + 1.0f;		\
+						float tfrmdX = ((tfrmdPos.x - 0.5f) / halfViewportWidth) - 1.0f;			\
+						float tfrmdY = ((tfrmdPos.y + 0.5f) / halfViewportHeight) + 1.0f;		\
 						\
 						\
 						oPosition = float4(tfrmdX, tfrmdY, 0, 1);		\
 						oPosition = float4(tfrmdX, tfrmdY, 0, 1);		\
 						oUv = uv;										\
 						oUv = uv;										\

+ 2 - 2
CamelotClient/CamelotClient.cpp

@@ -28,8 +28,8 @@
 #include "CmTestTextSprite.h"
 #include "CmTestTextSprite.h"
 #include "CmEditorWindow.h"
 #include "CmEditorWindow.h"
 
 
-//#define DX11
-#define DX9
+#define DX11
+//#define DX9
 //#define GL
 //#define GL
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;

+ 4 - 4
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -365,10 +365,10 @@ namespace CamelotFramework
 		// determine wich D3D9 pixel format we'll use
 		// determine wich D3D9 pixel format we'll use
 		HRESULT hr;
 		HRESULT hr;
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
-		mFormat = D3D9Mappings::_getPF(d3dPF);
-
+		
 		// let's D3DX check the corrected pixel format
 		// let's D3DX check the corrected pixel format
 		hr = D3DXCheckTextureRequirements(d3d9Device, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 		hr = D3DXCheckTextureRequirements(d3d9Device, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
+		mFormat = D3D9Mappings::_getPF(d3dPF);
 
 
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		DWORD usage = 0;
 		DWORD usage = 0;
@@ -540,10 +540,10 @@ namespace CamelotFramework
 		// determine wich D3D9 pixel format we'll use
 		// determine wich D3D9 pixel format we'll use
 		HRESULT hr;
 		HRESULT hr;
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
-		mFormat = D3D9Mappings::_getPF(d3dPF);
 
 
 		// let's D3DX check the corrected pixel format
 		// let's D3DX check the corrected pixel format
 		hr = D3DXCheckCubeTextureRequirements(d3d9Device, NULL, NULL, 0, &d3dPF, mD3DPool);
 		hr = D3DXCheckCubeTextureRequirements(d3d9Device, NULL, NULL, 0, &d3dPF, mD3DPool);
+		mFormat = D3D9Mappings::_getPF(d3dPF);
 
 
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;
 		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;
@@ -647,10 +647,10 @@ namespace CamelotFramework
 		// determine which D3D9 pixel format we'll use
 		// determine which D3D9 pixel format we'll use
 		HRESULT hr;
 		HRESULT hr;
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
 		D3DFORMAT d3dPF = _chooseD3DFormat(d3d9Device);
-		mFormat = D3D9Mappings::_getPF(d3dPF);
 
 
 		// let's D3DX check the corrected pixel format
 		// let's D3DX check the corrected pixel format
 		hr = D3DXCheckVolumeTextureRequirements(d3d9Device, NULL, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
 		hr = D3DXCheckVolumeTextureRequirements(d3d9Device, NULL, NULL, NULL, NULL, 0, &d3dPF, mD3DPool);
+		mFormat = D3D9Mappings::_getPF(d3dPF);
 
 
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		// Use D3DX to help us create the texture, this way it can adjust any relevant sizes
 		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;
 		DWORD usage = (mUsage & TU_RENDERTARGET) ? D3DUSAGE_RENDERTARGET : 0;

+ 6 - 6
CamelotUtility/Source/CmPixelUtil.cpp

@@ -525,7 +525,7 @@ namespace CamelotFramework {
 		24, 16, 8, 0
 		24, 16, 8, 0
 		},
 		},
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
-		{"PF_B8G8R8X8",
+		{"PF_R8G8B8X8",
 		/* Bytes per element */
 		/* Bytes per element */
 		4,
 		4,
 		/* Flags */
 		/* Flags */
@@ -535,11 +535,11 @@ namespace CamelotFramework {
 		/* rbits, gbits, bbits, abits */
 		/* rbits, gbits, bbits, abits */
 		8, 8, 8, 0,
 		8, 8, 8, 0,
 		/* Masks and shifts */
 		/* Masks and shifts */
-		0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
-		16, 8, 0, 0
+		0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000,
+		0, 8, 16, 0
 		},
 		},
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
-		{"PF_R8G8B8X8",
+		{"PF_B8G8R8X8",
 		/* Bytes per element */
 		/* Bytes per element */
 		4,
 		4,
 		/* Flags */
 		/* Flags */
@@ -549,8 +549,8 @@ namespace CamelotFramework {
 		/* rbits, gbits, bbits, abits */
 		/* rbits, gbits, bbits, abits */
 		8, 8, 8, 0,
 		8, 8, 8, 0,
 		/* Masks and shifts */
 		/* Masks and shifts */
-		0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000,
-		0, 8, 16, 0
+		0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
+		16, 8, 0, 0
 		},
 		},
 	//-----------------------------------------------------------------------
 	//-----------------------------------------------------------------------
         {"PF_DXT1",
         {"PF_DXT1",

+ 1 - 0
Notes.txt

@@ -15,6 +15,7 @@ Reminders:
 	components. Therefore is there any purpose of having C++ only inspector parsing code?
 	components. Therefore is there any purpose of having C++ only inspector parsing code?
   - When I'll be doing SRGB write make sure GUI textures are handled properly. Right now they are read in gamma space, and displayed
   - When I'll be doing SRGB write make sure GUI textures are handled properly. Right now they are read in gamma space, and displayed
     as normal, but if I switch to SRGB write then gamma would be applied twice to those textures.
     as normal, but if I switch to SRGB write then gamma would be applied twice to those textures.
+  - Make editor background have a tileable pattern (see Mini paper app on my cell). Since tileable images wouldn't work with scale9grid, it should be an overlay over the solid background.
 
 
 ----------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------
 More detailed thought out system descriptions:
 More detailed thought out system descriptions:

+ 3 - 14
TODO.txt

@@ -2,20 +2,11 @@
 
 
 ----------------------------------------------------------------------------------------------
 ----------------------------------------------------------------------------------------------
 
 
-Texture format changes:
-I screwed up R8G8 format by making it NATIVENDIAN
-
-Unify formats and their masks/shifts - Use DX11 model everywhere (already used on floating point formats)
-
-DirectX9 - most significant to least significant - ARGB is actually BGRA in memory
-DirectX11 - least significant to most significant - RGBA is RGBA in memory
-OpenGL seems to be the same as DirectX11 although I can't confirm
-
-Go through all formats and check if they match this. (Ogre components seem to assume the DX9 model)
-Floating point formats all seem to be in DX11 order in memory for all render systems
- 
 When loading WindowFrameTex manually, it doesn't get released properly
 When loading WindowFrameTex manually, it doesn't get released properly
 
 
+ - My test model is rendering back faces. I need to flip them.
+  - Although more than likely I am loading the model incorrectly since it works in Unity?
+  - I probably want to determine front faces based on normals
 
 
 Immediate TODO:
 Immediate TODO:
  - Issue with rendering same object from multiple cameras:
  - Issue with rendering same object from multiple cameras:
@@ -30,8 +21,6 @@ Immediate TODO:
  - TextSprite bounds are wrong. Y coordinate is flipped
  - TextSprite bounds are wrong. Y coordinate is flipped
  - Calculate entire GUIWidget bounds and store them
  - Calculate entire GUIWidget bounds and store them
  - Current way of transforming ORect from GUIWidget is almost certainly not correct
  - Current way of transforming ORect from GUIWidget is almost certainly not correct
- - Implement image shader for D3D11BuiltinMaterialManager
- - Improve text shader so it doesn't have resolution values hardcoded in
  - Implement D3D9 and GL BuiltInMaterialManager
  - Implement D3D9 and GL BuiltInMaterialManager
  - A way to update mesh buffers without recreating vertex/index buffers (Setting data currently does exactly that)
  - A way to update mesh buffers without recreating vertex/index buffers (Setting data currently does exactly that)
  - Transformable GUI elements and their bounds
  - Transformable GUI elements and their bounds