Add GammaColorSpace to Graphics for simplicity

This commit is contained in:
Wojtek Figat
2026-01-12 18:49:10 +01:00
parent 827ad85651
commit 223d4f64eb
4 changed files with 12 additions and 4 deletions

View File

@@ -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

View File

@@ -78,6 +78,12 @@ public:
/// </summary>
API_FIELD() static PostProcessSettings PostProcessSettings;
/// <summary>
/// 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.
/// </summary>
API_FIELD(ReadOnly) static bool GammaColorSpace;
public:
/// <summary>
/// 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).

View File

@@ -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;

View File

@@ -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<float>(w1), static_cast<float>(h1));
data.InvInputSize = Float2(1.0f / static_cast<float>(w1), 1.0f / static_cast<float>(h1));
data.InputAspect = static_cast<float>(w1) / h1;
if (GraphicsSettings::Get()->GammaColorSpace)
if (Graphics::GammaColorSpace)
{
// Gamma-space colors always present image 'as-is'
data.OutputColorSpace = OUTPUT_LINEAR;