Add Global Surface Atlas missing surface data debug visualization
This commit is contained in:
@@ -268,11 +268,15 @@ bool GlobalSurfaceAtlasPass::setupResources()
|
||||
|
||||
// Create pipeline state
|
||||
GPUPipelineState::Description psDesc = GPUPipelineState::Description::DefaultFullscreenTriangle;
|
||||
if (!_psDebug)
|
||||
if (!_psDebug0)
|
||||
{
|
||||
_psDebug = device->CreatePipelineState();
|
||||
psDesc.PS = shader->GetPS("PS_Debug");
|
||||
if (_psDebug->Init(psDesc))
|
||||
_psDebug0 = device->CreatePipelineState();
|
||||
_psDebug1 = device->CreatePipelineState();
|
||||
psDesc.PS = shader->GetPS("PS_Debug", 0);
|
||||
if (_psDebug0->Init(psDesc))
|
||||
return true;
|
||||
psDesc.PS = shader->GetPS("PS_Debug", 1);
|
||||
if (_psDebug1->Init(psDesc))
|
||||
return true;
|
||||
}
|
||||
if (!_psClear)
|
||||
@@ -327,7 +331,8 @@ void GlobalSurfaceAtlasPass::OnShaderReloading(Asset* obj)
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDirectLighting0);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDirectLighting1);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psIndirectLighting);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDebug);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDebug0);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDebug1);
|
||||
invalidateResources();
|
||||
}
|
||||
|
||||
@@ -345,7 +350,8 @@ void GlobalSurfaceAtlasPass::Dispose()
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDirectLighting0);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDirectLighting1);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psIndirectLighting);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDebug);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDebug0);
|
||||
SAFE_DELETE_GPU_RESOURCE(_psDebug1);
|
||||
_cb0 = nullptr;
|
||||
_shader = nullptr;
|
||||
}
|
||||
@@ -1091,7 +1097,7 @@ void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContex
|
||||
context->BindSR(4, bindingData.Objects ? bindingData.Objects->View() : nullptr);
|
||||
context->BindSR(6, bindingData.AtlasDepth->View());
|
||||
context->BindSR(7, skybox);
|
||||
context->SetState(_psDebug);
|
||||
context->SetState(_psDebug0);
|
||||
{
|
||||
Float2 outputSizeThird = outputSize * 0.333f;
|
||||
Float2 outputSizeTwoThird = outputSize * 0.666f;
|
||||
@@ -1123,19 +1129,20 @@ void GlobalSurfaceAtlasPass::RenderDebug(RenderContext& renderContext, GPUContex
|
||||
context->BindSR(6, bindingData.AtlasDepth->View());
|
||||
context->BindSR(7, skybox);
|
||||
context->BindCB(0, _cb0);
|
||||
context->SetState(_psDebug);
|
||||
context->SetRenderTarget(output->View());
|
||||
|
||||
// Disable skybox
|
||||
data.SkyboxIntensity = 0.0f;
|
||||
context->UpdateCB(_cb0, &data);
|
||||
|
||||
// Bottom left - diffuse
|
||||
// Bottom left - diffuse (with missing surface coverage debug)
|
||||
context->SetState(_psDebug1);
|
||||
context->BindSR(5, bindingData.AtlasGBuffer0->View());
|
||||
context->SetViewportAndScissors(Viewport(outputSizeTwoThird.X, 0, outputSizeThird.X, outputSizeThird.Y));
|
||||
context->DrawFullscreenTriangle();
|
||||
|
||||
// Bottom middle - normals
|
||||
context->SetState(_psDebug0);
|
||||
context->BindSR(5, bindingData.AtlasGBuffer1->View());
|
||||
context->SetViewportAndScissors(Viewport(outputSizeTwoThird.X, outputSizeThird.Y, outputSizeThird.X, outputSizeThird.Y));
|
||||
context->DrawFullscreenTriangle();
|
||||
|
||||
@@ -50,7 +50,8 @@ private:
|
||||
GPUPipelineState* _psDirectLighting0 = nullptr;
|
||||
GPUPipelineState* _psDirectLighting1 = nullptr;
|
||||
GPUPipelineState* _psIndirectLighting = nullptr;
|
||||
GPUPipelineState* _psDebug = nullptr;
|
||||
GPUPipelineState* _psDebug0 = nullptr;
|
||||
GPUPipelineState* _psDebug1 = nullptr;
|
||||
GPUConstantBuffer* _cb0 = nullptr;
|
||||
GPUShaderProgramCS* _csCullObjects;
|
||||
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
#define GLOBAL_SURFACE_ATLAS_TILE_NORMAL_THRESHOLD_ENABLED 0 // Enables using tile normal threshold to prevent sampling pixels behind the view point (but might cause back artifacts)
|
||||
#define GLOBAL_SURFACE_ATLAS_TILE_NORMAL_THRESHOLD 0.05f // Cut-off value for tiles transitions blending during sampling
|
||||
#define GLOBAL_SURFACE_ATLAS_TILE_PROJ_PLANE_OFFSET 0.1f // Small offset to prevent clipping with the closest triangles (shifts near and far planes)
|
||||
#ifndef GLOBAL_SURFACE_ATLAS_DEBUG_MODE
|
||||
// 0 - disabled
|
||||
// 1 - atlas coverage (pink for missing surface data)
|
||||
#define GLOBAL_SURFACE_ATLAS_DEBUG_MODE 0
|
||||
#elif GLOBAL_SURFACE_ATLAS_DEBUG_MODE == 1
|
||||
#define GLOBAL_SURFACE_ATLAS_TILE_NORMAL_WEIGHT_ENABLED 0
|
||||
#define GLOBAL_SURFACE_ATLAS_TILE_NORMAL_THRESHOLD 0
|
||||
#endif
|
||||
|
||||
struct GlobalSurfaceTile
|
||||
{
|
||||
@@ -268,6 +276,11 @@ float4 SampleGlobalSurfaceAtlas(const GlobalSurfaceAtlasData data, ByteAddressBu
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if GLOBAL_SURFACE_ATLAS_DEBUG_MODE
|
||||
if (result.a < 0.05f)
|
||||
result = float4(1, 0, 1, 1);
|
||||
#endif
|
||||
|
||||
// Normalize result
|
||||
result.rgb /= max(result.a, 0.0001f);
|
||||
|
||||
@@ -302,6 +302,8 @@ TextureCube Skybox : register(t7);
|
||||
|
||||
// Pixel shader for Global Surface Atlas debug drawing
|
||||
META_PS(true, FEATURE_LEVEL_SM5)
|
||||
META_PERMUTATION_1(GLOBAL_SURFACE_ATLAS_DEBUG_MODE=0)
|
||||
META_PERMUTATION_1(GLOBAL_SURFACE_ATLAS_DEBUG_MODE=1)
|
||||
float4 PS_Debug(Quad_VS2PS input) : SV_Target
|
||||
{
|
||||
#if 0
|
||||
|
||||
Reference in New Issue
Block a user