Fix GBuffer debug view when using Lienar Color Space

This commit is contained in:
2026-04-07 11:51:20 +02:00
parent e501d10ac1
commit 862fc69460
2 changed files with 15 additions and 2 deletions
+10 -1
View File
@@ -21,10 +21,12 @@
#include "Engine/Level/Actors/Decal.h" #include "Engine/Level/Actors/Decal.h"
#include "Engine/Level/Actors/Sky.h" #include "Engine/Level/Actors/Sky.h"
#include "Engine/Engine/Engine.h" #include "Engine/Engine/Engine.h"
#include "Engine/Graphics/Graphics.h"
GPU_CB_STRUCT(GBufferPassData { GPU_CB_STRUCT(GBufferPassData {
ShaderGBufferData GBuffer; ShaderGBufferData GBuffer;
Float3 Dummy0; Float2 Dummy0;
int32 ViewLinear;
int32 ViewMode; int32 ViewMode;
}); });
@@ -248,6 +250,13 @@ void GBufferPass::RenderDebug(RenderContext& renderContext)
// Set constants buffer // Set constants buffer
SetInputs(renderContext.View, data.GBuffer); SetInputs(renderContext.View, data.GBuffer);
data.ViewLinear = 0;
switch (renderContext.View.Mode)
{
case ViewMode::Diffuse:
data.ViewLinear = !Graphics::GammaColorSpace;
break;
}
data.ViewMode = static_cast<int32>(renderContext.View.Mode); data.ViewMode = static_cast<int32>(renderContext.View.Mode);
auto cb = lights->GetCB(0); auto cb = lights->GetCB(0);
context->UpdateCB(cb, &data); context->UpdateCB(cb, &data);
+5 -1
View File
@@ -5,10 +5,12 @@
#include "./Flax/Common.hlsl" #include "./Flax/Common.hlsl"
#include "./Flax/GBuffer.hlsl" #include "./Flax/GBuffer.hlsl"
#include "./Flax/BRDF.hlsl" #include "./Flax/BRDF.hlsl"
#include "./Flax/GammaCorrectionCommon.hlsl"
META_CB_BEGIN(0, Data) META_CB_BEGIN(0, Data)
GBufferData GBuffer; GBufferData GBuffer;
float3 Dummy0; float2 Dummy0;
int ViewLinear;
int ViewMode; int ViewMode;
META_CB_END META_CB_END
@@ -67,5 +69,7 @@ float4 PS_DebugView(Quad_VS2PS input) : SV_Target
case View_Mode_SubsurfaceColor: result = gBuffer.CustomData.rgb; break; case View_Mode_SubsurfaceColor: result = gBuffer.CustomData.rgb; break;
case View_Mode_Unlit: result = gBuffer.Color * gBuffer.AO; break; case View_Mode_Unlit: result = gBuffer.Color * gBuffer.AO; break;
} }
if (ViewLinear)
result = LinearToSrgb(result);
return float4(result, 1); return float4(result, 1);
} }