Skip to content

Commit 473ded1

Browse files
Fix for NaN that can happen on area lights at a certain angle. (#4081)
* Fix NaN with V1oV2 == -1 * Changelog * Use clamping instead Co-authored-by: sebastienlagarde <[email protected]>
1 parent cb740a9 commit 473ded1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

com.unity.render-pipelines.core/ShaderLibrary/AreaLighting.hlsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ real3 ComputeEdgeFactor(real3 V1, real3 V2)
2121
if (V1oV2 < 0)
2222
{
2323
// Undo range reduction.
24-
y = PI * rsqrt(saturate(1 - V1oV2 * V1oV2)) - y;
24+
const float epsilon = 1e-5f;
25+
y = PI * (max(epsilon, saturate(1 - V1oV2 * V1oV2))) - y;
2526
}
2627

2728
return V1xV2 * y;

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
146146
- Fixed issue with the color space of AOVs (case 1324759)
147147
- Fixed issue with history buffers when using multiple AOVs (case 1323684).
148148
- Fixed camera preview with multi selection (case 1324126).
149+
- Fixed a NaN generating in Area light code.
149150

150151
### Changed
151152
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard

0 commit comments

Comments
 (0)