Skip to content

Commit 2c759ca

Browse files
HDRenderLoop: Enable forward rendering correctly
1 parent 1f6bfc9 commit 2c759ca

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -360,18 +360,17 @@ void RenderGBuffer(CullResults cull, Camera camera, RenderLoop renderLoop)
360360
}
361361

362362
// This pass is use in case of forward opaque and deferred rendering. We need to render forward objects before tile lighting pass
363-
void RenderForwardOpaqueDepth(CullResults cull, Camera camera, RenderLoop renderLoop)
363+
void RenderForwardOnlyDepthPrepass(CullResults cull, Camera camera, RenderLoop renderLoop)
364364
{
365-
// If we have render a depth prepass, no need for this pass
366-
if (debugParameters.useDepthPrepass)
365+
// If we are forward only we don't need to render ForwardOpaqueDepth object
366+
// But in case we request a prepass we render it
367+
if (debugParameters.useForwardRenderingOnly && !debugParameters.useDepthPrepass)
367368
return;
368369

369370
using (new Utilities.ProfilingSample("Forward opaque depth", renderLoop))
370371
{
371-
// TODO: Use the render queue index to only send the forward opaque!
372-
// or use the new MAterial.SetPassEnable ?
373372
Utilities.SetRenderTarget(renderLoop, m_CameraDepthBufferRT);
374-
RenderOpaqueRenderList(cull, camera, renderLoop, "DepthOnly");
373+
RenderOpaqueRenderList(cull, camera, renderLoop, "ForwardOnlyDepthOnly");
375374
}
376375
}
377376

@@ -462,6 +461,22 @@ void RenderForward(CullResults cullResults, Camera camera, RenderLoop renderLoop
462461
}
463462
}
464463

464+
// Render material that are forward opaque only (like eye)
465+
// TODO: Think about hair that could be render both as opaque and transparent...
466+
void RenderForwardOnly(CullResults cullResults, Camera camera, RenderLoop renderLoop)
467+
{
468+
using (new Utilities.ProfilingSample("Forward Only Pass", renderLoop))
469+
{
470+
// Bind material data
471+
m_LitRenderLoop.Bind();
472+
473+
Utilities.SetRenderTarget(renderLoop, m_CameraColorBufferRT, m_CameraDepthBufferRT);
474+
475+
m_lightLoop.RenderForward(camera, renderLoop, true);
476+
RenderOpaqueRenderList(cullResults, camera, renderLoop, "ForwardOnly");
477+
}
478+
}
479+
465480
void RenderForwardUnlit(CullResults cullResults, Camera camera, RenderLoop renderLoop)
466481
{
467482
using (new Utilities.ProfilingSample("Forward Unlit Pass", renderLoop))
@@ -651,16 +666,11 @@ public override void Render(Camera[] cameras, RenderLoop renderLoop)
651666

652667
RenderDepthPrepass(cullResults, camera, renderLoop);
653668

654-
RenderGBuffer(cullResults, camera, renderLoop);
655-
656-
// Forward opaque with deferred tile require that we fill the depth buffer
669+
// Forward opaque with deferred/cluster tile require that we fill the depth buffer
657670
// correctly to build the light list.
658671
// TODO: avoid double lighting by tagging stencil or gbuffer that we must not lit.
659-
// TODO: ask Morten why this pass is not before GBuffer ? Will make more sense and avoid
660-
// to do gbuffer pass on unseen mesh.
661-
// TODO: how do we select only the object that must be render forward ?
662-
// this is all object with gbuffer pass disabled ?
663-
//RenderForwardOpaqueDepth(cullResults, camera, renderLoop);
672+
RenderForwardOnlyDepthPrepass(cullResults, camera, renderLoop);
673+
RenderGBuffer(cullResults, camera, renderLoop);
664674

665675
if (debugParameters.debugViewMaterial != 0)
666676
{
@@ -685,8 +695,8 @@ public override void Render(Camera[] cameras, RenderLoop renderLoop)
685695
}
686696
RenderDeferredLighting(camera, renderLoop);
687697

688-
// TODO: enable this for tile forward opaque
689-
// RenderForward(cullResults, camera, renderLoop, true);
698+
RenderForward(cullResults, camera, renderLoop, true);
699+
RenderForwardOnly(cullResults, camera, renderLoop);
690700

691701
RenderSky(camera, renderLoop);
692702

0 commit comments

Comments
 (0)