Browse Source

Moved maximum cascade check to Renderer.

Lasse Öörni 13 years ago
parent
commit
e645875fd6
3 changed files with 13 additions and 6 deletions
  1. 12 0
      Engine/Graphics/Renderer.cpp
  2. 1 1
      Engine/Graphics/Renderer.h
  3. 0 5
      Engine/Graphics/View.cpp

+ 12 - 0
Engine/Graphics/Renderer.cpp

@@ -355,6 +355,7 @@ void Renderer::SetRenderMode(RenderMode mode)
         }
         
         ResetBuffers();
+        ResetShadowMaps();
         renderMode_ = mode;
         shadersDirty_ = true;
     }
@@ -508,6 +509,17 @@ Viewport* Renderer::GetViewport(unsigned index) const
     return index < viewports_.Size() ? viewports_[index] : (Viewport*)0;
 }
 
+int Renderer::GetMaxShadowCascades() const
+{
+    // Due to instruction count limits, deferred modes in SM2.0 can only support up to 3 cascades
+    #ifndef USE_OPENGL
+    if (renderMode_ != RENDER_FORWARD && !graphics_->GetSM3Support())
+        return Max(maxShadowCascades_, 3);
+    #endif
+    
+    return maxShadowCascades_;
+}
+
 ShaderVariation* Renderer::GetVertexShader(const String& name, bool checkExists) const
 {
     return GetShader(VS, name, checkExists);

+ 1 - 1
Engine/Graphics/Renderer.h

@@ -231,7 +231,7 @@ public:
     /// Return maximum number of shadow maps per resolution.
     int GetMaxShadowMaps() const { return maxShadowMaps_; }
     /// Return maximum number of directional light shadow map cascades.
-    int GetMaxShadowCascades() const { return maxShadowCascades_; }
+    int GetMaxShadowCascades() const;
     /// Return whether dynamic instancing is in use.
     bool GetDynamicInstancing() const { return dynamicInstancing_; }
     /// Return maximum number of triangles per object for instancing.

+ 0 - 5
Engine/Graphics/View.cpp

@@ -1933,11 +1933,6 @@ IntRect View::GetShadowMapViewport(Light* light, unsigned splitIndex, Texture2D*
     unsigned width = shadowMap->GetWidth();
     unsigned height = shadowMap->GetHeight();
     int maxCascades = renderer_->GetMaxShadowCascades();
-    // Due to instruction count limits, deferred modes in SM2.0 can only support up to 3 cascades
-    #ifndef USE_OPENGL
-    if (renderMode_ != RENDER_FORWARD && !graphics_->GetSM3Support())
-        maxCascades = Max(maxCascades, 3);
-    #endif
     
     switch (light->GetLightType())
     {