瀏覽代碼

Fixed sRGB flag in renderpath RT definitions not being taken into account.

Lasse Öörni 12 年之前
父節點
當前提交
6b6ab3da74
共有 4 個文件被更改,包括 8 次插入6 次删除
  1. 2 2
      Engine/Graphics/OpenGL/OGLGraphics.cpp
  2. 1 1
      Engine/Graphics/Renderer.cpp
  3. 1 1
      Engine/Graphics/Renderer.h
  4. 4 2
      Engine/Graphics/View.cpp

+ 2 - 2
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -2286,8 +2286,8 @@ void Graphics::CommitFramebuffer()
             impl_->sRGBWrite_ = sRGBWrite;
             impl_->sRGBWrite_ = sRGBWrite;
         }
         }
         #endif
         #endif
-
-	    return;
+        
+        return;
     }
     }
     
     
     // Search for a new framebuffer based on format & size, or create new
     // Search for a new framebuffer based on format & size, or create new

+ 1 - 1
Engine/Graphics/Renderer.cpp

@@ -977,7 +977,7 @@ RenderSurface* Renderer::GetDepthStencil(int width, int height)
     if (width == graphics_->GetWidth() && height == graphics_->GetHeight() && graphics_->GetMultiSample() <= 1)
     if (width == graphics_->GetWidth() && height == graphics_->GetHeight() && graphics_->GetMultiSample() <= 1)
         return 0;
         return 0;
     else
     else
-        return GetScreenBuffer(width, height, Graphics::GetDepthStencilFormat())->GetRenderSurface();
+        return GetScreenBuffer(width, height, Graphics::GetDepthStencilFormat(), false, false)->GetRenderSurface();
 }
 }
 
 
 OcclusionBuffer* Renderer::GetOcclusionBuffer(Camera* camera)
 OcclusionBuffer* Renderer::GetOcclusionBuffer(Camera* camera)

+ 1 - 1
Engine/Graphics/Renderer.h

@@ -307,7 +307,7 @@ public:
     /// Allocate a shadow map. If shadow map reuse is disabled, a different map is returned each time.
     /// Allocate a shadow map. If shadow map reuse is disabled, a different map is returned each time.
     Texture2D* GetShadowMap(Light* light, Camera* camera, unsigned viewWidth, unsigned viewHeight);
     Texture2D* GetShadowMap(Light* light, Camera* camera, unsigned viewWidth, unsigned viewHeight);
     /// Allocate a rendertarget or depth-stencil texture for deferred rendering or postprocessing. Should only be called during actual rendering, not before.
     /// Allocate a rendertarget or depth-stencil texture for deferred rendering or postprocessing. Should only be called during actual rendering, not before.
-    Texture2D* GetScreenBuffer(int width, int height, unsigned format, bool filtered = false, bool srgb = false);
+    Texture2D* GetScreenBuffer(int width, int height, unsigned format, bool filtered, bool srgb);
     /// Allocate a depth-stencil surface that does not need to be readable. Should only be called during actual rendering, not before.
     /// Allocate a depth-stencil surface that does not need to be readable. Should only be called during actual rendering, not before.
     RenderSurface* GetDepthStencil(int width, int height);
     RenderSurface* GetDepthStencil(int width, int height);
     /// Allocate an occlusion buffer.
     /// Allocate an occlusion buffer.

+ 4 - 2
Engine/Graphics/View.cpp

@@ -1534,8 +1534,10 @@ void View::AllocateScreenBuffers()
         neededBuffers = 2;
         neededBuffers = 2;
     
     
     // Allocate screen buffers with filtering active in case the quad commands need that
     // Allocate screen buffers with filtering active in case the quad commands need that
+    // Follow the sRGB mode of the destination rendertarget
+    bool sRGB = renderTarget_ ? renderTarget_->GetParentTexture()->GetSRGB() : graphics_->GetSRGB();
     for (unsigned i = 0; i < neededBuffers; ++i)
     for (unsigned i = 0; i < neededBuffers; ++i)
-        screenBuffers_.Push(renderer_->GetScreenBuffer(rtSize_.x_, rtSize_.y_, format, true));
+        screenBuffers_.Push(renderer_->GetScreenBuffer(rtSize_.x_, rtSize_.y_, format, true, sRGB));
     
     
     // Allocate extra render targets defined by the rendering path
     // Allocate extra render targets defined by the rendering path
     for (unsigned i = 0; i < renderPath_->renderTargets_.Size(); ++i)
     for (unsigned i = 0; i < renderPath_->renderTargets_.Size(); ++i)
@@ -1558,7 +1560,7 @@ void View::AllocateScreenBuffers()
             height = rtSize_.y_ / (height ? height : 1);
             height = rtSize_.y_ / (height ? height : 1);
         }
         }
         
         
-        renderTargets_[StringHash(rtInfo.name_)] = renderer_->GetScreenBuffer(width, height, rtInfo.format_, rtInfo.filtered_);
+        renderTargets_[StringHash(rtInfo.name_)] = renderer_->GetScreenBuffer(width, height, rtInfo.format_, rtInfo.filtered_, rtInfo.sRGB_);
     }
     }
 }
 }