Browse Source

Optimized depth tests used in light volume rendering and stencil masking.

Lasse Öörni 14 years ago
parent
commit
bd75b09b65
2 changed files with 8 additions and 8 deletions
  1. 5 5
      Engine/Graphics/Renderer.cpp
  2. 3 3
      Engine/Graphics/View.cpp

+ 5 - 5
Engine/Graphics/Renderer.cpp

@@ -1360,7 +1360,7 @@ void Renderer::SetupLightBatch(Batch& batch)
         if (light->GetNearSplit() <= batch.camera_->GetNearClip())
         {
             graphics_->SetCullMode(CULL_NONE);
-            graphics_->SetDepthTest(CMP_GREATEREQUAL);
+            graphics_->SetDepthTest(CMP_GREATER);
             graphics_->SetStencilTest(false);
         }
         else
@@ -1382,7 +1382,7 @@ void Renderer::SetupLightBatch(Batch& batch)
             
             // Re-enable color write, set test for rendering the actual light
             graphics_->SetColorWrite(true);
-            graphics_->SetDepthTest(CMP_GREATEREQUAL);
+            graphics_->SetDepthTest(CMP_GREATER);
             graphics_->SetStencilTest(true, CMP_EQUAL, OP_ZERO, OP_KEEP, OP_ZERO, 1);
         }
     }
@@ -1398,7 +1398,7 @@ void Renderer::SetupLightBatch(Batch& batch)
             bool drawBackFaces = lightViewDist < (lightExtent + batch.camera_->GetNearClip());
             graphics_->SetColorWrite(false);
             graphics_->SetCullMode(drawBackFaces ? CULL_CCW : CULL_CW);
-            graphics_->SetDepthTest(drawBackFaces ? CMP_GREATEREQUAL : CMP_LESSEQUAL);
+            graphics_->SetDepthTest(drawBackFaces ? CMP_GREATER : CMP_LESS);
             graphics_->SetStencilTest(true, CMP_EQUAL, OP_INCR, OP_KEEP, OP_KEEP, 0);
             graphics_->SetShaders(stencilVS_, stencilPS_);
             graphics_->SetShaderParameter(VSP_VIEWPROJ, projection * view);
@@ -1418,7 +1418,7 @@ void Renderer::SetupLightBatch(Batch& batch)
             {
                 // In this case reverse cull mode & depth test and render back faces
                 graphics_->SetCullMode(CULL_CW);
-                graphics_->SetDepthTest(CMP_GREATEREQUAL);
+                graphics_->SetDepthTest(CMP_GREATER);
                 graphics_->SetStencilTest(false);
             }
             else
@@ -1430,7 +1430,7 @@ void Renderer::SetupLightBatch(Batch& batch)
                     // Set state for stencil rendering
                     graphics_->SetColorWrite(false);
                     graphics_->SetCullMode(CULL_CW);
-                    graphics_->SetDepthTest(CMP_GREATEREQUAL);
+                    graphics_->SetDepthTest(CMP_GREATER);
                     graphics_->SetStencilTest(true, CMP_ALWAYS, OP_INCR, OP_KEEP, OP_KEEP, 1);
                     graphics_->SetShaders(stencilVS_, stencilPS_);
                     graphics_->SetShaderParameter(VSP_VIEWPROJ, projection * view);

+ 3 - 3
Engine/Graphics/View.cpp

@@ -1964,13 +1964,13 @@ void View::DrawSplitLightToStencil(Camera& camera, Light* light, bool clear)
             graphics_->SetColorWrite(false);
             graphics_->SetDepthWrite(false);
             graphics_->SetCullMode(drawBackFaces ? CULL_CW : CULL_CCW);
-            graphics_->SetDepthTest(drawBackFaces ? CMP_GREATEREQUAL : CMP_LESSEQUAL);
+            graphics_->SetDepthTest(drawBackFaces ? CMP_GREATER : CMP_LESS);
             graphics_->SetShaders(renderer_->stencilVS_, renderer_->stencilPS_);
             graphics_->SetShaderParameter(VSP_MODEL, model);
             graphics_->SetShaderParameter(VSP_VIEWPROJ, projection * view);
             graphics_->ClearTransformSources();
             
-            // Draw the faces to stencil which we should draw (where no light has not been rendered yet)
+            // Draw the faces to stencil which we should draw (where no light has been rendered yet)
             graphics_->SetStencilTest(true, CMP_EQUAL, OP_INCR, OP_KEEP, OP_KEEP, 0);
             renderer_->spotLightGeometry_->Draw(graphics_);
             
@@ -2016,7 +2016,7 @@ void View::DrawSplitLightToStencil(Camera& camera, Light* light, bool clear)
                 
                 // If the split begins at the near plane (first split), draw at split far plane, otherwise at near plane
                 bool firstSplit = light->GetNearSplit() <= camera.GetNearClip();
-                graphics_->SetDepthTest(firstSplit ? CMP_GREATEREQUAL : CMP_LESSEQUAL);
+                graphics_->SetDepthTest(firstSplit ? CMP_GREATER : CMP_LESS);
                 graphics_->SetShaders(renderer_->stencilVS_, renderer_->stencilPS_);
                 graphics_->SetShaderParameter(VSP_MODEL, firstSplit ? farTransform : nearTransform);
                 graphics_->SetShaderParameter(VSP_VIEWPROJ, projection);