Browse Source

Added missing vertex color variation to the LitSolid shaders.

Lasse Öörni 10 years ago
parent
commit
2a34d35dec
2 changed files with 28 additions and 0 deletions
  1. 11 0
      bin/CoreData/Shaders/GLSL/LitSolid.glsl
  2. 17 0
      bin/CoreData/Shaders/HLSL/LitSolid.hlsl

+ 11 - 0
bin/CoreData/Shaders/GLSL/LitSolid.glsl

@@ -13,6 +13,9 @@
 #endif
 #endif
 varying vec3 vNormal;
 varying vec3 vNormal;
 varying vec4 vWorldPos;
 varying vec4 vWorldPos;
+#ifdef VERTEXCOLOR
+    varying vec4 vColor;
+#endif
 #ifdef PERPIXEL
 #ifdef PERPIXEL
     #ifdef SHADOW
     #ifdef SHADOW
         varying vec4 vShadowPos[NUMCASCADES];
         varying vec4 vShadowPos[NUMCASCADES];
@@ -42,6 +45,10 @@ void VS()
     vNormal = GetWorldNormal(modelMatrix);
     vNormal = GetWorldNormal(modelMatrix);
     vWorldPos = vec4(worldPos, GetDepth(gl_Position));
     vWorldPos = vec4(worldPos, GetDepth(gl_Position));
 
 
+    #ifdef VERTEXCOLOR
+        vColor = iColor;
+    #endif
+
     #ifdef NORMALMAP
     #ifdef NORMALMAP
         vec3 tangent = GetWorldTangent(modelMatrix);
         vec3 tangent = GetWorldTangent(modelMatrix);
         vec3 bitangent = cross(tangent, vNormal) * iTangent.w;
         vec3 bitangent = cross(tangent, vNormal) * iTangent.w;
@@ -106,6 +113,10 @@ void PS()
     #else
     #else
         vec4 diffColor = cMatDiffColor;
         vec4 diffColor = cMatDiffColor;
     #endif
     #endif
+
+    #ifdef VERTEXCOLOR
+        diffColor *= vColor;
+    #endif
     
     
     // Get material specular albedo
     // Get material specular albedo
     #ifdef SPECMAP
     #ifdef SPECMAP

+ 17 - 0
bin/CoreData/Shaders/HLSL/LitSolid.hlsl

@@ -12,6 +12,9 @@ void VS(float4 iPos : POSITION,
     #ifndef NOUV
     #ifndef NOUV
         float2 iTexCoord : TEXCOORD0,
         float2 iTexCoord : TEXCOORD0,
     #endif
     #endif
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
     #if defined(LIGHTMAP) || defined(AO)
     #if defined(LIGHTMAP) || defined(AO)
         float2 iTexCoord2 : TEXCOORD1,
         float2 iTexCoord2 : TEXCOORD1,
     #endif
     #endif
@@ -56,6 +59,9 @@ void VS(float4 iPos : POSITION,
             out float2 oTexCoord2 : TEXCOORD7,
             out float2 oTexCoord2 : TEXCOORD7,
         #endif
         #endif
     #endif
     #endif
+    #ifdef VERTEXCOLOR
+        out float4 oColor : COLOR0,
+    #endif
     #if defined(D3D11) && defined(CLIPPLANE)
     #if defined(D3D11) && defined(CLIPPLANE)
         out float oClip : SV_CLIPDISTANCE0,
         out float oClip : SV_CLIPDISTANCE0,
     #endif
     #endif
@@ -76,6 +82,10 @@ void VS(float4 iPos : POSITION,
         oClip = dot(oPos, cClipPlane);
         oClip = dot(oPos, cClipPlane);
     #endif
     #endif
 
 
+    #ifdef VERTEXCOLOR
+        oColor = iColor;
+    #endif
+
     #ifdef NORMALMAP
     #ifdef NORMALMAP
         float3 tangent = GetWorldTangent(modelMatrix);
         float3 tangent = GetWorldTangent(modelMatrix);
         float3 bitangent = cross(tangent, oNormal) * iTangent.w;
         float3 bitangent = cross(tangent, oNormal) * iTangent.w;
@@ -155,6 +165,9 @@ void PS(
             float2 iTexCoord2 : TEXCOORD7,
             float2 iTexCoord2 : TEXCOORD7,
         #endif
         #endif
     #endif
     #endif
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
     #if defined(D3D11) && defined(CLIPPLANE)
     #if defined(D3D11) && defined(CLIPPLANE)
         float iClip : SV_CLIPDISTANCE0,
         float iClip : SV_CLIPDISTANCE0,
     #endif
     #endif
@@ -180,6 +193,10 @@ void PS(
         float4 diffColor = cMatDiffColor;
         float4 diffColor = cMatDiffColor;
     #endif
     #endif
 
 
+    #ifdef VERTEXCOLOR
+        diffColor *= iColor;
+    #endif
+
     // Get material specular albedo
     // Get material specular albedo
     #ifdef SPECMAP
     #ifdef SPECMAP
         float3 specColor = cMatSpecColor.rgb * Sample2D(SpecMap, iTexCoord.xy).rgb;
         float3 specColor = cMatSpecColor.rgb * Sample2D(SpecMap, iTexCoord.xy).rgb;