Fox NoPostFx debug view when using Linear Color Space
This commit is contained in:
Binary file not shown.
@@ -44,6 +44,7 @@ bool GBufferPass::Init()
|
||||
{
|
||||
// Create pipeline state
|
||||
_psDebug = GPUDevice::Instance->CreatePipelineState();
|
||||
_psLinearToSrgb = GPUDevice::Instance->CreatePipelineState();
|
||||
|
||||
// Load assets
|
||||
_gBufferShader = Content::LoadAsyncInternal<Shader>(TEXT("Shaders/GBuffer"));
|
||||
@@ -81,6 +82,12 @@ bool GBufferPass::setupResources()
|
||||
if (_psDebug->Init(psDesc))
|
||||
return true;
|
||||
}
|
||||
if (!_psLinearToSrgb->IsValid())
|
||||
{
|
||||
psDesc.PS = gbuffer->GetPS("PS_LinearToSrgb");
|
||||
if (_psLinearToSrgb->Init(psDesc))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -92,6 +99,7 @@ void GBufferPass::Dispose()
|
||||
|
||||
// Cleanup
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDebug);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psLinearToSrgb);
|
||||
_gBufferShader = nullptr;
|
||||
_skyModel = nullptr;
|
||||
_boxModel = nullptr;
|
||||
@@ -254,6 +262,7 @@ void GBufferPass::RenderDebug(RenderContext& renderContext)
|
||||
switch (renderContext.View.Mode)
|
||||
{
|
||||
case ViewMode::Diffuse:
|
||||
case ViewMode::Unlit:
|
||||
data.ViewLinear = !Graphics::GammaColorSpace;
|
||||
break;
|
||||
}
|
||||
@@ -277,6 +286,19 @@ void GBufferPass::RenderDebug(RenderContext& renderContext)
|
||||
context->ResetSR();
|
||||
}
|
||||
|
||||
void GBufferPass::DrawLinearToSrgb(RenderContext& renderContext, GPUTexture* input)
|
||||
{
|
||||
auto context = GPUDevice::Instance->GetMainContext();
|
||||
if (checkIfSkipPass())
|
||||
{
|
||||
context->Draw(input);
|
||||
return;
|
||||
}
|
||||
context->BindSR(0, input);
|
||||
context->SetState(_psLinearToSrgb);
|
||||
context->DrawFullscreenTriangle();
|
||||
}
|
||||
|
||||
// Custom render buffer for realtime skybox capturing (eg. used by GI).
|
||||
class SkyboxCustomBuffer : public RenderBuffers::CustomBuffer
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ private:
|
||||
|
||||
AssetReference<Shader> _gBufferShader;
|
||||
GPUPipelineState* _psDebug = nullptr;
|
||||
GPUPipelineState* _psLinearToSrgb = nullptr;
|
||||
AssetReference<Model> _skyModel;
|
||||
AssetReference<Model> _boxModel;
|
||||
#if USE_EDITOR
|
||||
@@ -40,6 +41,14 @@ public:
|
||||
/// <param name="renderContext">The rendering context.</param>
|
||||
void RenderDebug(RenderContext& renderContext);
|
||||
|
||||
/// <summary>
|
||||
/// Draws the shader that converts texture from Linear to sRGB color space. Can be used to display internal lighting buffer that is not matching gamma of the output display.
|
||||
/// </summary>
|
||||
/// <remarks>Assumes the output render target and viewport has been set.</remarks>
|
||||
/// <param name="renderContext">The rendering context.</param>
|
||||
/// <param name="input">The input texture to blit.</param>
|
||||
void DrawLinearToSrgb(RenderContext& renderContext, GPUTexture* input);
|
||||
|
||||
/// <summary>
|
||||
/// Renders the sky or skybox into low-resolution cubemap. Can be used to sample realtime sky lighting in GI passes.
|
||||
/// </summary>
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "Engine/Level/Level.h"
|
||||
#include "Engine/Level/Scene/SceneRendering.h"
|
||||
#include "Engine/Core/Config/GraphicsSettings.h"
|
||||
#include "Engine/Graphics/Graphics.h"
|
||||
#include "Engine/Threading/JobSystem.h"
|
||||
#include "Engine/Profiler/ProfilerMemory.h"
|
||||
#if USE_EDITOR
|
||||
@@ -714,6 +715,9 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
|
||||
{
|
||||
context->SetRenderTarget(task->GetOutputView());
|
||||
context->SetViewportAndScissors(task->GetOutputViewport());
|
||||
if (!Graphics::GammaColorSpace)
|
||||
GBufferPass::Instance()->DrawLinearToSrgb(renderContext, frameBuffer);
|
||||
else
|
||||
context->Draw(frameBuffer);
|
||||
RenderTargetPool::Release(frameBuffer);
|
||||
return;
|
||||
|
||||
@@ -73,3 +73,12 @@ float4 PS_DebugView(Quad_VS2PS input) : SV_Target
|
||||
result = LinearToSrgb(result);
|
||||
return float4(result, 1);
|
||||
}
|
||||
|
||||
// Pixel shader for color space conversion
|
||||
META_PS(true, FEATURE_LEVEL_ES2)
|
||||
float4 PS_LinearToSrgb(Quad_VS2PS input) : SV_Target
|
||||
{
|
||||
float4 result = SAMPLE_RT(GBuffer0, input.TexCoord);
|
||||
result.rgb = LinearToSrgb(result.rgb);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user