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
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 @@ -72,6 +72,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed the point distribution for the diffuse denoiser sometimes not being properly intialized.
- Fixed the bad blending between the sun and the clouds (case 1373282).
- Fixed and optimize distance shadowmask fade.
- Fixed flickering / edge aliasing issue when DoF and TAAU or DLSS are enabled (case 1381858).

### Changed
- Use RayTracingAccelerationStructure.CullInstances to filter Renderers and populate the acceleration structure with ray tracing instances for improved CPU performance on the main thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ void KMain(uint3 dispatchThreadId : SV_DispatchThreadID)
float coc3 = cocBR.x;
float coc4 = cocBR.z;
#else
float coc1 = LOAD_TEXTURE2D_X(_InputCoCTexture, posInputs.positionSS - uint2(1u, 0u)).x; // Left
float coc2 = LOAD_TEXTURE2D_X(_InputCoCTexture, posInputs.positionSS - uint2(0u, 1u)).x; // Top
float coc3 = LOAD_TEXTURE2D_X(_InputCoCTexture, posInputs.positionSS + uint2(0u, 1u)).x; // Bottom
float coc4 = LOAD_TEXTURE2D_X(_InputCoCTexture, posInputs.positionSS + uint2(1u, 0u)).x; // Right
float coc1 = LOAD_TEXTURE2D_X(_InputCoCTexture, ClampAndScaleUVPostProcessTextureForPoint(posInputs.positionSS) - uint2(1u, 0u)).x; // Left
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id say cache this result in a register. I dont trust dxc being smart enough to catch the renundant code below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point, thanks!

float coc2 = LOAD_TEXTURE2D_X(_InputCoCTexture, ClampAndScaleUVPostProcessTextureForPoint(posInputs.positionSS) - uint2(0u, 1u)).x; // Top
float coc3 = LOAD_TEXTURE2D_X(_InputCoCTexture, ClampAndScaleUVPostProcessTextureForPoint(posInputs.positionSS) + uint2(0u, 1u)).x; // Bottom
float coc4 = LOAD_TEXTURE2D_X(_InputCoCTexture, ClampAndScaleUVPostProcessTextureForPoint(posInputs.positionSS) + uint2(1u, 0u)).x; // Right
#endif

// Dejittered center sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2867,9 +2867,13 @@ TextureHandle DepthOfFieldPass(RenderGraph renderGraph, HDCamera hdCamera, Textu
{
bool postDoFTAAEnabled = false;
bool isSceneView = hdCamera.camera.cameraType == CameraType.SceneView;
bool taaEnabled = m_AntialiasingFS && hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing;
bool stabilizeCoC = m_AntialiasingFS && hdCamera.antialiasing == HDAdditionalCameraData.AntialiasingMode.TemporalAntialiasing;
bool isOrtho = hdCamera.camera.orthographic;

// If DLSS is enabled, we need to stabilize the CoC buffer (because the upsampled depth is jittered)
if (m_DLSSPassEnabled)
stabilizeCoC = true;

// If Path tracing is enabled, then DoF is computed in the path tracer by sampling the lens aperure (when using the physical camera mode)
bool isDoFPathTraced = (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) &&
hdCamera.volumeStack.GetComponent<PathTracing>().enable.value &&
Expand All @@ -2882,7 +2886,7 @@ TextureHandle DepthOfFieldPass(RenderGraph renderGraph, HDCamera hdCamera, Textu
{
// If we switch DoF modes and the old one was not using TAA, make sure we invalidate the history
// Note: for Rendergraph the m_IsDoFHisotoryValid perhaps should be moved to the "pass data" struct
if (taaEnabled && hdCamera.dofHistoryIsValid != m_DepthOfField.physicallyBased)
if (stabilizeCoC && hdCamera.dofHistoryIsValid != m_DepthOfField.physicallyBased)
{
hdCamera.resetPostProcessingHistory = true;
}
Expand Down Expand Up @@ -2911,7 +2915,7 @@ TextureHandle DepthOfFieldPass(RenderGraph renderGraph, HDCamera hdCamera, Textu
TextureHandle dest = GetPostprocessOutputHandle(renderGraph, "DoF Destination");
passData.destination = builder.WriteTexture(dest);
passData.motionVecTexture = builder.ReadTexture(motionVectors);
passData.taaEnabled = taaEnabled;
passData.taaEnabled = stabilizeCoC;

if (!m_DepthOfField.physicallyBased)
{
Expand Down Expand Up @@ -3062,7 +3066,7 @@ TextureHandle DepthOfFieldPass(RenderGraph renderGraph, HDCamera hdCamera, Textu
}

// When physically based DoF is enabled, TAA runs two times, first to stabilize the color buffer before DoF and then after DoF to accumulate more aperture samples
if (taaEnabled && m_DepthOfField.physicallyBased)
if (stabilizeCoC && m_DepthOfField.physicallyBased)
{
source = DoTemporalAntialiasing(renderGraph, hdCamera, depthBuffer, motionVectors, depthBufferMipChain, source, stencilTexture, postDoF: true, "Post-DoF TAA Destination");
hdCamera.dofHistoryIsValid = true;
Expand Down