Skip to content

[HDRP] Fix NaNs when denoising pixels with near zero dot(normal, view) #4342

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
Apr 28, 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 @@ -166,6 +166,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue with RAS build fail when LOD was missing a renderer
- Fixed an issue where sometime a docked lookdev could be rendered at zero size and break.
- Fixed an issue where runtime debug window UI would leak game objects.
- Fixed NaNs when denoising pixels where the dot product between normal and view direction is near zero (case 1329624).

### 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
@@ -1,12 +1,13 @@

#define MAX_REPROJECTION_DISTANCE 0.1
#define MAX_PIXEL_TOLERANCE 4
#define PROJECTION_EPSILON 0.000001

float ComputeMaxReprojectionWorldRadius(float3 positionWS, float3 normalWS, float pixelSpreadAngleTangent, float maxDistance, float pixelTolerance)
{
const float3 viewWS = GetWorldSpaceNormalizeViewDir(positionWS);
float parallelPixelFootPrint = pixelSpreadAngleTangent * length(positionWS);
float realPixelFootPrint = parallelPixelFootPrint / abs(dot(normalWS, viewWS));
float realPixelFootPrint = parallelPixelFootPrint / max(abs(dot(normalWS, viewWS)), PROJECTION_EPSILON);
return max(maxDistance, realPixelFootPrint * pixelTolerance);
}

Expand Down