Skip to content

Commit 6b50ce2

Browse files
adrien-de-tocquevilleEvergreen
authored andcommitted
[APV] Fix floating point issue when sampling
When the sampling position was located exactly on the boundary of the last brick of the cell, we would sample the wrong cell due to floating point precision issue. Fixed by clamping the brick index to the size of the cell.
1 parent 227b911 commit 6b50ce2

File tree

1 file changed

+1
-0
lines changed
  • Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume

1 file changed

+1
-0
lines changed

Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ uint GetIndexData(APVResources apvRes, float3 posWS)
304304
{
305305
float3 residualPosWS = posWS - topLeftEntryWS;
306306
int3 localBrickIndex = floor(residualPosWS / (_MinBrickSize * stepSize));
307+
localBrickIndex = min(localBrickIndex, (int3)(3 * 3 * 3 - 1)); // due to floating point issue, we may query an invalid brick
307308

308309
// Out of bounds.
309310
isValidBrick = all(localBrickIndex >= minRelativeIdx) && all(localBrickIndex < maxRelativeIdxPlusOne);

0 commit comments

Comments
 (0)