|
61 | 61 | #define MAX_SKYBOX_VOLUMETRIC_CLOUDS_DISTANCE 200000.0f |
62 | 62 | // Maximal size of a light step |
63 | 63 | #define LIGHT_STEP_MAXIMAL_SIZE 1000.0f |
| 64 | +// Threshold at which the clouds are considered inexistant (Found experimentally) |
| 65 | +#define TRANSMITTANCE_DISCARD_THRESHOLD 0.992 |
64 | 66 |
|
65 | 67 | // HDRP generic includes |
66 | 68 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" |
@@ -1383,6 +1385,9 @@ void UPSAMPLE_KERNEL(uint3 finalCoord : SV_DispatchThreadID, |
1383 | 1385 | currentClouds.xyz = unapplyFastTonemapping(currentClouds.xyz); |
1384 | 1386 | currentClouds.w = saturate(currentClouds.w); |
1385 | 1387 |
|
| 1388 | + // Due to numerical precision issues, upscaling a bunch of 1.0 can lead to a slightly lower number, this fixes it. |
| 1389 | + currentClouds.w = currentClouds.w > TRANSMITTANCE_DISCARD_THRESHOLD ? 1.0 : currentClouds.w; |
| 1390 | + |
1386 | 1391 | #ifdef LOCAL_VOLUMETRIC_CLOUDS |
1387 | 1392 | float cloudDepth = GetCloudDepth_LDS(groupThreadId, IndexToLocalOffsetCoords[closestNeighbor]); |
1388 | 1393 | #else |
@@ -1460,6 +1465,9 @@ void UPSAMPLE_KERNEL_SKY(uint3 finalCoord : SV_DispatchThreadID, |
1460 | 1465 | currentClouds.xyz = unapplyFastTonemapping(currentClouds.xyz); |
1461 | 1466 | currentClouds.w = saturate(currentClouds.w); |
1462 | 1467 |
|
| 1468 | + // Due to numerical precision issues, upscaling a bunch of 1.0 can lead to a slightly lower number, this fixes it. |
| 1469 | + currentClouds.w = currentClouds.w > TRANSMITTANCE_DISCARD_THRESHOLD ? 1.0 : currentClouds.w; |
| 1470 | + |
1463 | 1471 | // Store the upscaled result only, composite in later pass. |
1464 | 1472 | _VolumetricCloudsUpscaleTextureRW[COORD_TEXTURE2D_X(finalCoord.xy)] = currentClouds; |
1465 | 1473 | } |
@@ -1491,6 +1499,9 @@ void COMBINE_KERNEL(uint3 finalCoord : SV_DispatchThreadID, |
1491 | 1499 | currentClouds.xyz = unapplyFastTonemapping(currentClouds.xyz); |
1492 | 1500 | currentClouds.w = saturate(currentClouds.w); |
1493 | 1501 |
|
| 1502 | + // Due to numerical precision issues, upscaling a bunch of 1.0 can lead to a slightly lower number, this fixes it. |
| 1503 | + currentClouds.w = currentClouds.w > TRANSMITTANCE_DISCARD_THRESHOLD ? 1.0 : currentClouds.w; |
| 1504 | + |
1494 | 1505 | #ifdef LOCAL_VOLUMETRIC_CLOUDS |
1495 | 1506 | float cloudsDepth = LOAD_TEXTURE2D_X(_DepthStatusTexture, finalCoord.xy).z; |
1496 | 1507 | #else |
@@ -1546,6 +1557,9 @@ void COMBINE_KERNEL_SKY(uint3 finalCoord : SV_DispatchThreadID) |
1546 | 1557 | currentClouds.xyz = unapplyFastTonemapping(currentClouds.xyz); |
1547 | 1558 | currentClouds.w = saturate(currentClouds.w); |
1548 | 1559 |
|
| 1560 | + // Due to numerical precision issues, upscaling a bunch of 1.0 can lead to a slightly lower number, this fixes it. |
| 1561 | + currentClouds.w = currentClouds.w > TRANSMITTANCE_DISCARD_THRESHOLD ? 1.0 : currentClouds.w; |
| 1562 | + |
1549 | 1563 | // Store the upscaled result only, composite in later pass. |
1550 | 1564 | _VolumetricCloudsUpscaleTextureRW[COORD_TEXTURE2D_X(finalCoord.xy)] = currentClouds; |
1551 | 1565 | } |
|
0 commit comments