Skip to content

Commit 22f340a

Browse files
committed
Added light boundaries debug visualization to particles.
1 parent c5f0174 commit 22f340a

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

ThreeL/Main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ static int MainImpl()
595595
ScopedTimer(context, Timer::ParticleRender);
596596
context.SetRenderTarget(swapChain, depthBuffer.ReadOnlyView());
597597
context.SetFullViewportScissor(screenSize);
598-
smoke.Render(context, perFrameCbAddress, lightHeap, lightLinkedList);
598+
smoke.Render(context, perFrameCbAddress, lightHeap, lightLinkedList, debugSettings.ShowLightBoundaries);
599599
}
600600

601601
//-------------------------------------------------------------------------------------------------------------

ThreeL/ParticleSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void ParticleSystem::Update(ComputeContext& context, float deltaTime, D3D12_GPU_
223223
{ m_UpdateSyncPoint = context.Flush(); }
224224
}
225225

226-
void ParticleSystem::Render(GraphicsContext& context, D3D12_GPU_VIRTUAL_ADDRESS perFrameCb, LightHeap& lightHeap, LightLinkedList& lightLinkedList)
226+
void ParticleSystem::Render(GraphicsContext& context, D3D12_GPU_VIRTUAL_ADDRESS perFrameCb, LightHeap& lightHeap, LightLinkedList& lightLinkedList, bool showLightBoundaries)
227227
{
228228
PIXBeginEvent(&context, 42, L"Render '%s' particle system", m_DebugName.c_str());
229229

@@ -247,7 +247,7 @@ void ParticleSystem::Render(GraphicsContext& context, D3D12_GPU_VIRTUAL_ADDRESS
247247
context->SetGraphicsRootDescriptorTable(ShaderInterop::ParticleRender::RpSamplerHeap, m_Graphics.SamplerHeap().GpuHeap()->GetGPUDescriptorHandleForHeapStart());
248248
context->SetGraphicsRootDescriptorTable(ShaderInterop::ParticleRender::RpBindlessHeap, m_Graphics.ResourceDescriptorManager().GpuHeap()->GetGPUDescriptorHandleForHeapStart());
249249

250-
context->SetPipelineState(m_Resources.ParticleRender);
250+
context->SetPipelineState(showLightBoundaries ? m_Resources.ParticleRenderLightDebug : m_Resources.ParticleRender);
251251
context->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
252252
context.DrawIndirect(m_DrawIndirectArguments);
253253

ThreeL/ParticleSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class ParticleSystem
5353
inline void Update(ComputeContext& context, float deltaTime, D3D12_GPU_VIRTUAL_ADDRESS perFrameCb)
5454
{ Update(context, deltaTime, perFrameCb, false); }
5555

56-
void Render(GraphicsContext& context, D3D12_GPU_VIRTUAL_ADDRESS perFrameCb, LightHeap& lightHeap, LightLinkedList& lightLinkedList);
56+
void Render(GraphicsContext& context, D3D12_GPU_VIRTUAL_ADDRESS perFrameCb, LightHeap& lightHeap, LightLinkedList& lightLinkedList, bool showLightBoundaries = false);
5757

5858
//! Seeds the state of the particle system by simulating it for the specified number of (simulated) seconds
5959
void SeedState(float numSeconds);

ThreeL/ResourceManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ ResourceManager::ResourceManager(GraphicsCore& graphics)
4747

4848
ShaderBlobs particleRenderVs = hlslCompiler.CompileShader(L"Shaders/ParticleRender.hlsl", L"VsMainParticle", L"vs_6_0");
4949
ShaderBlobs particleRenderPs = hlslCompiler.CompileShader(L"Shaders/ParticleRender.hlsl", L"PsMain", L"ps_6_0");
50+
ShaderBlobs particleRenderPsLightDebug = hlslCompiler.CompileShader(L"Shaders/ParticleRender.hlsl", L"PsMain", L"ps_6_0", { L"DEBUG_LIGHT_BOUNDARIES" });
5051

5152
// Create root signatures
5253
PbrRootSignature = RootSignature(Graphics, pbrVs, L"PBR Root Signature");
@@ -265,5 +266,8 @@ ResourceManager::ResourceManager(GraphicsCore& graphics)
265266
};
266267

267268
ParticleRender = PipelineStateObject(Graphics, description, L"Particle Render PSO");
269+
270+
description.PS = particleRenderPsLightDebug.ShaderBytecode();
271+
ParticleRenderLightDebug = PipelineStateObject(Graphics, description, L"Particle Render PSO - Light Debug");
268272
}
269273
}

ThreeL/ResourceManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct ResourceManager
6464

6565
RootSignature ParticleRenderRootSignature;
6666
PipelineStateObject ParticleRender;
67+
PipelineStateObject ParticleRenderLightDebug;
6768

6869
explicit ResourceManager(GraphicsCore& graphics);
6970
ResourceManager(const ResourceManager&) = delete;

0 commit comments

Comments
 (0)