Browse Source

Fix crash when replacing shader with unshadowed or non-specular variation, and geometry type is something else than static.
Add billboard variation to Vegatation shader. The effect is not very good though, as the billboard vertices do not move individually.

Lasse Öörni 12 years ago
parent
commit
f3fa29a614

+ 1 - 0
Bin/CoreData/Shaders/GLSL/Vegetation.xml

@@ -22,5 +22,6 @@
         <option name="Shadow" define="SHADOW" require="PERPIXEL" />
         <variation name="" />
         <variation name="Instanced" define="INSTANCED" />
+        <variation name="Billboard" define="BILLBOARD" />
     </shader>
 </shaders>

+ 1 - 0
Bin/CoreData/Shaders/HLSL/Vegetation.xml

@@ -22,5 +22,6 @@
         <option name="Shadow" define="SHADOW" require="PERPIXEL" />
         <variation name="" />
         <variation name="Instanced" define="INSTANCED" require="SM3" />
+        <variation name="Billboard" define="BILLBOARD" />
     </shader>
 </shaders>

+ 2 - 2
Source/Engine/Graphics/Renderer.cpp

@@ -1161,14 +1161,14 @@ void Renderer::SetBatchShaders(Batch& batch, Technique* tech, bool allowShadows)
             batch.pixelShader_ = pixelShaders[psi];
             
             // If shadow or specular variations do not exist, try without them
-            if ((!batch.vertexShader_ || !batch.pixelShader_) && (vsi >= LVS_SHADOW))
+            if ((!batch.vertexShader_ || !batch.pixelShader_) && ((vsi % MAX_LIGHT_VS_VARIATIONS) >= LVS_SHADOW))
             {
                 vsi -= LVS_SHADOW;
                 psi -= LPS_SHADOW;
                 batch.vertexShader_ = vertexShaders[vsi];
                 batch.pixelShader_ = pixelShaders[psi];
             }
-            if ((!batch.vertexShader_ || !batch.pixelShader_) && (vsi >= LVS_SPEC))
+            if ((!batch.vertexShader_ || !batch.pixelShader_) && ((vsi % MAX_LIGHT_VS_VARIATIONS) >= LVS_SPEC))
             {
                 vsi -= LVS_SPEC;
                 psi -= LPS_SPEC;