Browse Source

Fixed missing light pre-pass rendering on OS X by not binding the light buffer to the same texture unit as the shadow map. Unbind buffer textures after use.

Lasse Öörni 14 years ago
parent
commit
0626f46fa8

+ 1 - 1
Engine/Graphics/GraphicsDefs.h

@@ -243,8 +243,8 @@ enum TextureUnit
     TU_ENVIRONMENT = 5,
     TU_ENVIRONMENT = 5,
     MAX_MATERIAL_TEXTURE_UNITS = 6,
     MAX_MATERIAL_TEXTURE_UNITS = 6,
     TU_SHADOWMAP = 6,
     TU_SHADOWMAP = 6,
-    TU_LIGHTBUFFER = 6,
     TU_LIGHTRAMP = 7,
     TU_LIGHTRAMP = 7,
+    TU_LIGHTBUFFER = 7,
     TU_LIGHTSHAPE = 8,
     TU_LIGHTSHAPE = 8,
     TU_FACESELECT = 9,
     TU_FACESELECT = 9,
     TU_INDIRECTION = 10,
     TU_INDIRECTION = 10,

+ 6 - 1
Engine/Graphics/View.cpp

@@ -1074,6 +1074,9 @@ void View::RenderBatchesLightPrepass()
         }
         }
     }
     }
     
     
+    graphics_->SetTexture(TU_DEPTHBUFFER, 0);
+    graphics_->SetTexture(TU_NORMALBUFFER, 0);    
+
     // Clear destination render target with fog color
     // Clear destination render target with fog color
     graphics_->SetScissorTest(false);
     graphics_->SetScissorTest(false);
     graphics_->SetStencilTest(false);
     graphics_->SetStencilTest(false);
@@ -1093,9 +1096,11 @@ void View::RenderBatchesLightPrepass()
         // Render opaque objects with deferred lighting result
         // Render opaque objects with deferred lighting result
         PROFILE(RenderBase);
         PROFILE(RenderBase);
         
         
-        graphics_->SetTexture(TU_LIGHTBUFFER, lightBuffer);
+        graphics_->SetTexture(TU_LIGHTBUFFER, lightBuffer);        
         
         
         RenderBatchQueue(baseQueue_);
         RenderBatchQueue(baseQueue_);
+        
+        graphics_->SetTexture(TU_LIGHTBUFFER, 0);
     }
     }
     
     
     if (!preAlphaQueue_.IsEmpty())
     if (!preAlphaQueue_.IsEmpty())

+ 1 - 1
SourceAssets/GLSLShaders/Samplers.frag

@@ -13,7 +13,7 @@ uniform samplerCube sLightCubeMap;
 uniform samplerCube sFaceSelectCubeMap;
 uniform samplerCube sFaceSelectCubeMap;
 uniform samplerCube sIndirectionCubeMap;
 uniform samplerCube sIndirectionCubeMap;
 uniform sampler2D sNormalBuffer;
 uniform sampler2D sNormalBuffer;
-uniform sampler2D sDepthBuffer;
+uniform sampler2D sDepthBuffer;
 uniform sampler2D sLightBuffer;
 uniform sampler2D sLightBuffer;
 
 
 vec3 DecodeNormal(vec4 normalInput)
 vec3 DecodeNormal(vec4 normalInput)