Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ void CleanupPrepass()
CoreUtils.Destroy(m_DownsampleDepthMaterial);
}

bool NeedClearGBuffer()
bool NeedClearGBuffer(HDCamera hdCamera)
{
// TODO: Add an option to force clear
return m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled();
return m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() || hdCamera.frameSettings.IsEnabled(FrameSettingsField.ClearGBuffers);
}

HDUtils.PackedMipChainInfo GetDepthBufferMipChainInfo()
Expand Down Expand Up @@ -118,7 +118,7 @@ TextureHandle CreateDepthBuffer(RenderGraph renderGraph, bool clear, bool msaa)
return renderGraph.CreateTexture(depthDesc);
}

TextureHandle CreateNormalBuffer(RenderGraph renderGraph, bool msaa)
TextureHandle CreateNormalBuffer(RenderGraph renderGraph, HDCamera hdCamera, bool msaa)
{
#if UNITY_2020_2_OR_NEWER
FastMemoryDesc fastMemDesc;
Expand All @@ -129,7 +129,7 @@ TextureHandle CreateNormalBuffer(RenderGraph renderGraph, bool msaa)

TextureDesc normalDesc = new TextureDesc(Vector2.one, true, true)
{
colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = NeedClearGBuffer(), clearColor = Color.black, bindTextureMS = msaa, enableMSAA = msaa, enableRandomWrite = !msaa, name = msaa ? "NormalBufferMSAA" : "NormalBuffer"
colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = NeedClearGBuffer(hdCamera), clearColor = Color.black, bindTextureMS = msaa, enableMSAA = msaa, enableRandomWrite = !msaa, name = msaa ? "NormalBufferMSAA" : "NormalBuffer"
#if UNITY_2020_2_OR_NEWER
, fastMemoryDesc = fastMemDesc
#endif
Expand Down Expand Up @@ -402,7 +402,7 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h
{
decalBuffer = renderGraph.defaultResources.blackTextureXR;
output.depthAsColor = CreateDepthAsColorBuffer(renderGraph);
output.normalBuffer = CreateNormalBuffer(renderGraph, hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
output.normalBuffer = CreateNormalBuffer(renderGraph, hdCamera, hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA));
return false;
}

Expand Down Expand Up @@ -460,7 +460,7 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h
int mrtIndex = 0;
if (msaa)
output.depthAsColor = builder.UseColorBuffer(CreateDepthAsColorBuffer(renderGraph), mrtIndex++);
output.normalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, msaa), mrtIndex++);
output.normalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, hdCamera, msaa), mrtIndex++);
if (decalLayersEnabled)
decalBuffer = builder.UseColorBuffer(decalBuffer, mrtIndex++);

Expand Down Expand Up @@ -564,7 +564,7 @@ struct GBufferOutput

void SetupGBufferTargets(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle sssBuffer, TextureHandle vtFeedbackBuffer, ref PrepassOutput prepassOutput, FrameSettings frameSettings, RenderGraphBuilder builder)
{
bool clearGBuffer = NeedClearGBuffer();
bool clearGBuffer = NeedClearGBuffer(hdCamera);
bool lightLayers = frameSettings.IsEnabled(FrameSettingsField.LightLayers);
bool shadowMasks = frameSettings.IsEnabled(FrameSettingsField.Shadowmask);

Expand Down Expand Up @@ -701,7 +701,7 @@ void ResolvePrepassBuffers(RenderGraph renderGraph, HDCamera hdCamera, ref Prepa

output.resolvedDepthBuffer = builder.UseDepthBuffer(CreateDepthBuffer(renderGraph, true, false), DepthAccess.Write);
output.depthValuesMSAA = builder.UseColorBuffer(depthValuesBuffer, 0);
output.resolvedNormalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, false), 1);
output.resolvedNormalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, hdCamera, false), 1);
if (passData.needMotionVectors)
output.resolvedMotionVectorsBuffer = builder.UseColorBuffer(CreateMotionVectorBuffer(renderGraph, false, false), 2);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest,

LightingBuffers lightingBuffers = new LightingBuffers();
lightingBuffers.diffuseLightingBuffer = CreateDiffuseLightingBuffer(m_RenderGraph, msaa);
lightingBuffers.sssBuffer = CreateSSSBuffer(m_RenderGraph, msaa);
lightingBuffers.sssBuffer = CreateSSSBuffer(m_RenderGraph, hdCamera, msaa);

var prepassOutput = RenderPrepass(m_RenderGraph, colorBuffer, lightingBuffers.sssBuffer, vtFeedbackBuffer, cullingResults, customPassCullingResults, hdCamera, aovRequest, aovBuffers);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static bool NeedTemporarySubsurfaceBuffer()

// Albedo + SSS Profile and mask / Specular occlusion (when no SSS)
// This will be used during GBuffer and/or forward passes.
TextureHandle CreateSSSBuffer(RenderGraph renderGraph, bool msaa)
TextureHandle CreateSSSBuffer(RenderGraph renderGraph, HDCamera hdCamera, bool msaa)
{
#if UNITY_2020_2_OR_NEWER
FastMemoryDesc fastMemDesc;
Expand All @@ -177,7 +177,7 @@ TextureHandle CreateSSSBuffer(RenderGraph renderGraph, bool msaa)
enableRandomWrite = !msaa,
bindTextureMS = msaa,
enableMSAA = msaa,
clearBuffer = NeedClearGBuffer(),
clearBuffer = NeedClearGBuffer(hdCamera),
clearColor = Color.clear,
name = msaa ? "SSSBufferMSAA" : "SSSBuffer"
#if UNITY_2020_2_OR_NEWER
Expand Down