Skip to content

Fixed Clear GBuffer frame setting. #4130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed the camera controller in the template with the old input system (case 1326816).
- Fixed broken Lanczos filter artifacts on ps4, caused by a very aggressive epsilon (case 1328904)
- Fixed global Settings ignore the path set via Fix All in HDRP wizard (case 1327978)
- Fixed GBuffer clear option in FrameSettings not working

### Changed
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ 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 +117,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 +128,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 +401,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 +459,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 +563,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 +700,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