Browse Source

Add NOUV define to LitParticle, LitSolid & Unlit HLSL shaders when used as untextured, to prevent vertex layout creation problem on D3D11 when model has no UVs. Remove texcoords from the editor grid as they're no longer necessary. Closes #712.

Lasse Öörni 10 years ago
parent
commit
aa65cedefd

+ 8 - 1
bin/CoreData/Shaders/HLSL/LitParticle.hlsl

@@ -8,7 +8,9 @@ void VS(float4 iPos : POSITION,
     #ifndef BILLBOARD
         float3 iNormal : NORMAL,
     #endif
-    float2 iTexCoord : TEXCOORD0,
+    #ifndef NOUV
+        float2 iTexCoord : TEXCOORD0,
+    #endif
     #ifdef VERTEXCOLOR
         float4 iColor : COLOR0,
     #endif
@@ -45,6 +47,11 @@ void VS(float4 iPos : POSITION,
     #endif
     out float4 oPos : OUTPOSITION)
 {
+    // Define a 0,0 UV coord if not expected from the vertex data
+    #ifdef NOUV
+    float2 iTexCoord = float2(0.0, 0.0);
+    #endif
+    
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     oPos = GetClipPos(worldPos);

+ 9 - 2
bin/CoreData/Shaders/HLSL/LitSolid.hlsl

@@ -9,7 +9,9 @@ void VS(float4 iPos : POSITION,
     #ifndef BILLBOARD
         float3 iNormal : NORMAL,
     #endif
-    float2 iTexCoord : TEXCOORD0,
+    #ifndef NOUV
+        float2 iTexCoord : TEXCOORD0,
+    #endif
     #if defined(LIGHTMAP) || defined(AO)
         float2 iTexCoord2 : TEXCOORD1,
     #endif
@@ -59,12 +61,17 @@ void VS(float4 iPos : POSITION,
     #endif
     out float4 oPos : OUTPOSITION)
 {
+    // Define a 0,0 UV coord if not expected from the vertex data
+    #ifdef NOUV
+    float2 iTexCoord = float2(0.0, 0.0);
+    #endif
+
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     oPos = GetClipPos(worldPos);
     oNormal = GetWorldNormal(modelMatrix);
     oWorldPos = float4(worldPos, GetDepth(oPos));
-    
+
     #if defined(D3D11) && defined(CLIPPLANE)
         oClip = dot(oPos, cClipPlane);
     #endif

+ 8 - 1
bin/CoreData/Shaders/HLSL/Unlit.hlsl

@@ -4,7 +4,9 @@
 #include "Fog.hlsl"
 
 void VS(float4 iPos : POSITION,
-    float2 iTexCoord : TEXCOORD0,
+    #ifndef NOUV
+        float2 iTexCoord : TEXCOORD0,
+    #endif
     #ifdef VERTEXCOLOR
         float4 iColor : COLOR0,
     #endif
@@ -28,6 +30,11 @@ void VS(float4 iPos : POSITION,
     #endif
     out float4 oPos : OUTPOSITION)
 {
+    // Define a 0,0 UV coord if not expected from the vertex data
+    #ifdef NOUV
+    float2 iTexCoord = float2(0.0, 0.0);
+    #endif
+
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     oPos = GetClipPos(worldPos);

+ 1 - 1
bin/CoreData/Techniques/NoTexture.xml

@@ -1,4 +1,4 @@
-<technique vs="LitSolid" ps="LitSolid">
+<technique vs="LitSolid" ps="LitSolid" vsdefines="NOUV" >
     <pass name="base" />
     <pass name="litbase" psdefines="AMBIENT" />
     <pass name="light" depthtest="equal" depthwrite="false" blend="add" />

+ 1 - 1
bin/CoreData/Techniques/NoTextureAdd.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="alpha" depthwrite="false" blend="add" />
 </technique>

+ 1 - 1
bin/CoreData/Techniques/NoTextureAddAlpha.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="alpha" depthwrite="false" blend="addalpha" />
 </technique>

+ 1 - 1
bin/CoreData/Techniques/NoTextureAlpha.xml

@@ -1,4 +1,4 @@
-<technique vs="LitSolid" ps="LitSolid">
+<technique vs="LitSolid" ps="LitSolid" vsdefines="NOUV" >
     <pass name="alpha"  depthwrite="false" blend="alpha" />
     <pass name="litalpha" depthwrite="false" blend="addalpha" />
     <pass name="shadow" vs="Shadow" ps="Shadow" />

+ 1 - 1
bin/CoreData/Techniques/NoTextureMultiply.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="alpha" depthwrite="false" blend="multiply" />
 </technique>

+ 1 - 1
bin/CoreData/Techniques/NoTextureOverlay.xml

@@ -1,3 +1,3 @@
-<technique vs="Basic" ps="Basic">
+<technique vs="Basic" ps="Basic" vsdefines="NOUV" >
     <pass name="postalpha" depthtest="always" depthwrite="false" />
 </technique>

+ 1 - 1
bin/CoreData/Techniques/NoTextureUnlit.xml

@@ -1,4 +1,4 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="base" />
     <pass name="prepass" psdefines="PREPASS" />
     <pass name="material" />

+ 1 - 1
bin/CoreData/Techniques/NoTextureUnlitAlpha.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit">
+<technique vs="Unlit" ps="Unlit" vsdefines="NOUV" >
     <pass name="alpha" depthwrite="false" blend="alpha" />
 </technique>

+ 1 - 1
bin/CoreData/Techniques/NoTextureUnlitVCol.xml

@@ -1,4 +1,4 @@
-<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR" psdefines="VERTEXCOLOR">
+<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR NOUV" psdefines="VERTEXCOLOR">
     <pass name="base" />
     <pass name="prepass" psdefines="PREPASS" />
     <pass name="material" />

+ 1 - 1
bin/CoreData/Techniques/NoTextureVColAdd.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR" psdefines="VERTEXCOLOR">
+<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR NOUV" psdefines="VERTEXCOLOR">
     <pass name="alpha" depthwrite="false" blend="add" />
 </technique>

+ 1 - 1
bin/CoreData/Techniques/NoTextureVColAddAlpha.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR" psdefines="VERTEXCOLOR">
+<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR NOUV" psdefines="VERTEXCOLOR">
     <pass name="alpha" depthwrite="false" blend="addalpha" />
 </technique>

+ 1 - 1
bin/CoreData/Techniques/NoTextureVColMultiply.xml

@@ -1,3 +1,3 @@
-<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR" psdefines="VERTEXCOLOR">
+<technique vs="Unlit" ps="Unlit" vsdefines="VERTEXCOLOR NOUV" psdefines="VERTEXCOLOR">
     <pass name="alpha" depthwrite="false" blend="multiply" />
 </technique>

+ 0 - 8
bin/Data/Scripts/Editor/EditorView.as

@@ -1054,33 +1054,25 @@ void UpdateGrid(bool updateGridGeometry = true)
         {
             grid.DefineVertex(Vector3(lineOffset, 0.0, halfSizeScaled));
             grid.DefineColor(lineCenter ? gridZColor : (lineSubdiv ? gridSubdivisionColor : gridColor));
-            grid.DefineTexCoord(Vector2(0.0f, 0.0f));
             grid.DefineVertex(Vector3(lineOffset, 0.0, -halfSizeScaled));
             grid.DefineColor(lineCenter ? gridZColor : (lineSubdiv ? gridSubdivisionColor : gridColor));
-            grid.DefineTexCoord(Vector2(0.0f, 0.0f));
 
             grid.DefineVertex(Vector3(-halfSizeScaled, 0.0, lineOffset));
             grid.DefineColor(lineCenter ? gridXColor : (lineSubdiv ? gridSubdivisionColor : gridColor));
-            grid.DefineTexCoord(Vector2(0.0f, 0.0f));
             grid.DefineVertex(Vector3(halfSizeScaled, 0.0, lineOffset));
             grid.DefineColor(lineCenter ? gridXColor : (lineSubdiv ? gridSubdivisionColor : gridColor));
-            grid.DefineTexCoord(Vector2(0.0f, 0.0f));
         }
         else
         {
             grid.DefineVertex(Vector3(lineOffset, halfSizeScaled, 0.0));
             grid.DefineColor(lineCenter ? gridYColor : (lineSubdiv ? gridSubdivisionColor : gridColor));
-            grid.DefineTexCoord(Vector2(0.0f, 0.0f));
             grid.DefineVertex(Vector3(lineOffset, -halfSizeScaled, 0.0));
             grid.DefineColor(lineCenter ? gridYColor : (lineSubdiv ? gridSubdivisionColor : gridColor));
-            grid.DefineTexCoord(Vector2(0.0f, 0.0f));
 
             grid.DefineVertex(Vector3(-halfSizeScaled, lineOffset, 0.0));
             grid.DefineColor(lineCenter ? gridXColor : (lineSubdiv ? gridSubdivisionColor : gridColor));
-            grid.DefineTexCoord(Vector2(0.0f, 0.0f));
             grid.DefineVertex(Vector3(halfSizeScaled, lineOffset, 0.0));
             grid.DefineColor(lineCenter ? gridXColor : (lineSubdiv ? gridSubdivisionColor : gridColor));
-            grid.DefineTexCoord(Vector2(0.0f, 0.0f));
         }
 
         lineOffset  += scale;