Skip to content

Fixed Nans happening in RTR when the history render target is bigger than the current viewport (case 1321139). #3876

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 2 commits into from
Mar 16, 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 @@ -104,6 +104,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed HDRPAsset loosing its reference to the ray tracing resources when clicking on a different quality level that doesn't have ray tracing (case 1320304).
- Fixed SRP batcher not compatible with Decal (case 1311586).
- Fixed error message when having MSAA and Screen Space Shadows (case 1318698).
- Fixed Nans happening when the history render target is bigger than the current viewport (case 1321139).

### 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 @@ -29,7 +29,7 @@
// Thereshold at which we decide to reject the reflection history
#define REFLECTION_HISTORY_REJECTION_THRESHOLD 0.75
// Threshold at which we go from accumulation to clampiong
#define SMOOTHNESS_ACCUMULATION_THRESHOLD 0.5
#define ROUGHNESS_ACCUMULATION_THRESHOLD 0.5

// Input textures
TEXTURE2D_X(_DenoiseInputTexture);
Expand Down Expand Up @@ -86,7 +86,7 @@ void TEMPORAL_ACCUMULATION(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 g
// Compute the current and history UV coordinates
float2 currentUV = (mainCoord + 0.5f) * _ScreenSize.zw;
float2 historyCoordinate = ((float2)(mainCoord + 0.5f) - velocity * _CurrentEffectResolution.xy);
float2 historyUV = historyCoordinate * _HistoryBufferSize.xy;
float2 historyUV = clamp(historyCoordinate, 0.0f, _CurrentEffectResolution.xy - 1.0f) * _HistoryBufferSize.xy;

// Fetch the current and history values and apply the exposition to it.
float3 color = Fetch(_DenoiseInputTexture, currentUV, 0.0, _RTHandleScale.xy) * GetCurrentExposureMultiplier();
Expand All @@ -102,12 +102,13 @@ void TEMPORAL_ACCUMULATION(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 g

float sampleCount = historyRaw.w;
float3 result;
if (normalData.perceptualRoughness > SMOOTHNESS_ACCUMULATION_THRESHOLD)
if (normalData.perceptualRoughness > ROUGHNESS_ACCUMULATION_THRESHOLD)
{
bool canBeReprojected = true;

// If the pixel was outside of the screen during the previous frame, invalidate the history
if (historyCoordinate.x >= _CurrentEffectResolution.x || historyCoordinate.x < 0 || historyCoordinate.y >= _CurrentEffectResolution.y || historyCoordinate.y < 0)
if (historyCoordinate.x >= _CurrentEffectResolution.x || historyCoordinate.x < 0
|| historyCoordinate.y >= _CurrentEffectResolution.y || historyCoordinate.y < 0)
canBeReprojected = false;

#ifdef HALF_RESOLUTION
Expand Down