Skip to content

Commit

Permalink
Added light boundaries debug visualization to particles.
Browse files Browse the repository at this point in the history
  • Loading branch information
PathogenDavid committed Jul 27, 2023
1 parent c5f0174 commit 22f340a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ThreeL/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static int MainImpl()
ScopedTimer(context, Timer::ParticleRender);
context.SetRenderTarget(swapChain, depthBuffer.ReadOnlyView());
context.SetFullViewportScissor(screenSize);
smoke.Render(context, perFrameCbAddress, lightHeap, lightLinkedList);
smoke.Render(context, perFrameCbAddress, lightHeap, lightLinkedList, debugSettings.ShowLightBoundaries);
}

//-------------------------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions ThreeL/ParticleSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void ParticleSystem::Update(ComputeContext& context, float deltaTime, D3D12_GPU_
{ m_UpdateSyncPoint = context.Flush(); }
}

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

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

context->SetPipelineState(m_Resources.ParticleRender);
context->SetPipelineState(showLightBoundaries ? m_Resources.ParticleRenderLightDebug : m_Resources.ParticleRender);
context->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
context.DrawIndirect(m_DrawIndirectArguments);

Expand Down
2 changes: 1 addition & 1 deletion ThreeL/ParticleSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ParticleSystem
inline void Update(ComputeContext& context, float deltaTime, D3D12_GPU_VIRTUAL_ADDRESS perFrameCb)
{ Update(context, deltaTime, perFrameCb, false); }

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

//! Seeds the state of the particle system by simulating it for the specified number of (simulated) seconds
void SeedState(float numSeconds);
Expand Down
4 changes: 4 additions & 0 deletions ThreeL/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ResourceManager::ResourceManager(GraphicsCore& graphics)

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

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

ParticleRender = PipelineStateObject(Graphics, description, L"Particle Render PSO");

description.PS = particleRenderPsLightDebug.ShaderBytecode();
ParticleRenderLightDebug = PipelineStateObject(Graphics, description, L"Particle Render PSO - Light Debug");
}
}
1 change: 1 addition & 0 deletions ThreeL/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct ResourceManager

RootSignature ParticleRenderRootSignature;
PipelineStateObject ParticleRender;
PipelineStateObject ParticleRenderLightDebug;

explicit ResourceManager(GraphicsCore& graphics);
ResourceManager(const ResourceManager&) = delete;
Expand Down

0 comments on commit 22f340a

Please sign in to comment.