diff --git a/Source/Engine/Graphics/Graphics.cpp b/Source/Engine/Graphics/Graphics.cpp index dd3344f5d..6410124c2 100644 --- a/Source/Engine/Graphics/Graphics.cpp +++ b/Source/Engine/Graphics/Graphics.cpp @@ -27,6 +27,7 @@ Quality Graphics::GlobalSDFQuality = Quality::High; Quality Graphics::GIQuality = Quality::High; bool Graphics::GICascadesBlending = false; PostProcessSettings Graphics::PostProcessSettings; +bool Graphics::GammaColorSpace = true; bool Graphics::SpreadWorkload = true; bool Graphics::PostProcessing::ColorGradingVolumeLUT = true; @@ -73,6 +74,7 @@ void GraphicsSettings::Apply() Graphics::GICascadesBlending = GICascadesBlending; Graphics::PostProcessSettings = ::PostProcessSettings(); Graphics::PostProcessSettings.BlendWith(PostProcessSettings, 1.0f); + Graphics::GammaColorSpace = GammaColorSpace; #if !USE_EDITOR // OptionsModule handles fallback fonts in Editor Font::FallbackFonts = FallbackFonts; #endif diff --git a/Source/Engine/Graphics/Graphics.h b/Source/Engine/Graphics/Graphics.h index d328431b0..194339a97 100644 --- a/Source/Engine/Graphics/Graphics.h +++ b/Source/Engine/Graphics/Graphics.h @@ -78,6 +78,12 @@ public: /// API_FIELD() static PostProcessSettings PostProcessSettings; + /// + /// Enables Gamma color space workflow (instead of Linear). Gamma color space defines colors with an applied a gamma curve (sRGB) so they are perceptually linear. + /// This makes sense when the output of the rendering represent final color values that will be presented to a non-HDR screen. + /// + API_FIELD(ReadOnly) static bool GammaColorSpace; + public: /// /// Debug utility to toggle graphics workloads amortization over several frames by systems such as shadows mapping, global illumination or surface atlas. Can be used to test performance in the worst-case scenario (eg. camera-cut). diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index aa61603d7..e642adbea 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -7,11 +7,11 @@ #include "RotatedRectangle.h" #include "SpriteAtlas.h" #include "Engine/Core/Math/Matrix3x3.h" -#include "Engine/Core/Config/GraphicsSettings.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Assets/MaterialBase.h" #include "Engine/Content/Content.h" #include "Engine/Profiler/Profiler.h" +#include "Engine/Graphics/Graphics.h" #include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/GPUDevice.h" #include "Engine/Graphics/GPUPipelineState.h" @@ -689,7 +689,7 @@ void Render2D::Begin(GPUContext* context, GPUTextureView* output, GPUTextureView View = viewport; ViewProjection = viewProjection; DrawCalls.Clear(); - IsRemoveGammaEnabled = GraphicsSettings::Get()->GammaColorSpace == false; + IsRemoveGammaEnabled = Graphics::GammaColorSpace == false; // Initialize default transform const Matrix3x3 defaultTransform = Matrix3x3::Identity; diff --git a/Source/Engine/Renderer/PostProcessingPass.cpp b/Source/Engine/Renderer/PostProcessingPass.cpp index 2bac6bf76..529c66f2d 100644 --- a/Source/Engine/Renderer/PostProcessingPass.cpp +++ b/Source/Engine/Renderer/PostProcessingPass.cpp @@ -2,9 +2,9 @@ #include "PostProcessingPass.h" #include "RenderList.h" -#include "Engine/Core/Config/GraphicsSettings.h" #include "Engine/Content/Assets/Shader.h" #include "Engine/Content/Content.h" +#include "Engine/Graphics/Graphics.h" #include "Engine/Graphics/GPUContext.h" #include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTargetPool.h" @@ -363,7 +363,7 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input, data.InputSize = Float2(static_cast(w1), static_cast(h1)); data.InvInputSize = Float2(1.0f / static_cast(w1), 1.0f / static_cast(h1)); data.InputAspect = static_cast(w1) / h1; - if (GraphicsSettings::Get()->GammaColorSpace) + if (Graphics::GammaColorSpace) { // Gamma-space colors always present image 'as-is' data.OutputColorSpace = OUTPUT_LINEAR;