Bläddra i källkod

Albedo surface in G-buffer now stores its data in sRGB so that we don't lose colors

BearishSun 9 år sedan
förälder
incheckning
cbd7b0af8b

+ 2 - 2
Source/BansheeGLRenderAPI/Include/BsGLRenderTexture.h

@@ -29,13 +29,13 @@ namespace BansheeEngine
 		virtual ~GLRenderTextureCore();
 		virtual ~GLRenderTextureCore();
 
 
 		/** @copydoc RenderTextureCore::getCustomAttribute */
 		/** @copydoc RenderTextureCore::getCustomAttribute */
-		virtual void getCustomAttribute(const String& name, void* data) const override;
+		void getCustomAttribute(const String& name, void* data) const override;
 
 
 	protected:
 	protected:
 		friend class GLRenderTexture;
 		friend class GLRenderTexture;
 
 
 		/** @copydoc RenderTextureCore::initialize */
 		/** @copydoc RenderTextureCore::initialize */
-		virtual void initialize() override;
+		void initialize() override;
 
 
 		/** @copydoc RenderTextureCore::getProperties */
 		/** @copydoc RenderTextureCore::getProperties */
 		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
 		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }

+ 1 - 1
Source/RenderBeast/Include/BsRenderTargets.h

@@ -88,7 +88,7 @@ namespace BansheeEngine
 		SPtr<RenderTextureCore> mSceneColorRT;
 		SPtr<RenderTextureCore> mSceneColorRT;
 
 
 		PixelFormat mSceneColorFormat;
 		PixelFormat mSceneColorFormat;
-		PixelFormat mDiffuseFormat;
+		PixelFormat mAlbedoFormat;
 		PixelFormat mNormalFormat;
 		PixelFormat mNormalFormat;
 		UINT32 mNumSamples;
 		UINT32 mNumSamples;
 		bool mHDR;
 		bool mHDR;

+ 7 - 3
Source/RenderBeast/Source/BsRenderTargets.cpp

@@ -14,7 +14,7 @@ namespace BansheeEngine
 	{
 	{
 		// Note: Consider customizable HDR format via options? e.g. smaller PF_FLOAT_R11G11B10 or larger 32-bit format
 		// Note: Consider customizable HDR format via options? e.g. smaller PF_FLOAT_R11G11B10 or larger 32-bit format
 		mSceneColorFormat = hdr ? PF_FLOAT16_RGBA : PF_B8G8R8A8;
 		mSceneColorFormat = hdr ? PF_FLOAT16_RGBA : PF_B8G8R8A8;
-		mDiffuseFormat = PF_B8G8R8X8; // Note: Also consider customizable format (e.g. 16-bit float?)
+		mAlbedoFormat = PF_B8G8R8X8; // Note: Also consider customizable format (e.g. 16-bit float?)
 		mNormalFormat = PF_UNORM_R10G10B10A2; // Note: Also consider customizable format (e.g. 16-bit float?)
 		mNormalFormat = PF_UNORM_R10G10B10A2; // Note: Also consider customizable format (e.g. 16-bit float?)
 	}
 	}
 
 
@@ -30,10 +30,14 @@ namespace BansheeEngine
 		UINT32 width = getWidth();
 		UINT32 width = getWidth();
 		UINT32 height = getHeight();
 		UINT32 height = getHeight();
 
 
+		// Note: Albedo is allocated as SRGB, meaning when reading from textures during depth pass we decode from sRGB into linear,
+		// then back into sRGB when writing to albedo, and back to linear when reading from albedo during light pass. This /might/ have
+		// a performance impact. In which case we could just use a higher precision albedo buffer, which can then store linear color
+		// directly (storing linear in 8bit buffer causes too much detail to be lost in the blacks).
 		SPtr<PooledRenderTexture> newColorRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(mSceneColorFormat, width, height, TU_RENDERTARGET,
 		SPtr<PooledRenderTexture> newColorRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(mSceneColorFormat, width, height, TU_RENDERTARGET,
 			mNumSamples, false));
 			mNumSamples, false));
-		SPtr<PooledRenderTexture> newAlbedoRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(mDiffuseFormat, width, 
-			height, TU_RENDERTARGET, mNumSamples, false));
+		SPtr<PooledRenderTexture> newAlbedoRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(mAlbedoFormat, width, 
+			height, TU_RENDERTARGET, mNumSamples, true));
 		SPtr<PooledRenderTexture> newNormalRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(mNormalFormat, width, 
 		SPtr<PooledRenderTexture> newNormalRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(mNormalFormat, width, 
 			height, TU_RENDERTARGET, mNumSamples, false));
 			height, TU_RENDERTARGET, mNumSamples, false));
 		SPtr<PooledRenderTexture> newDepthRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(PF_D24S8, width, height, 
 		SPtr<PooledRenderTexture> newDepthRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(PF_D24S8, width, height,