Skip to content

Commit fcb3571

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.4] Fixed precision for shadows over large distances
1 parent ff5087a commit fcb3571

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ real ConvertLuminanceToEv(real luminance)
7979

8080
// Non physically based hack to limit light influence to attenuationRadius.
8181
// Square the result to smoothen the function.
82-
real DistanceWindowing(real distSquare, real rangeAttenuationScale, real rangeAttenuationBias)
82+
real DistanceWindowing(float distSquare, real rangeAttenuationScale, real rangeAttenuationBias)
8383
{
8484
// If (range attenuation is enabled)
8585
// rangeAttenuationScale = 1 / r^2

Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadow/ShadowSamplingTent.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void SampleShadow_GetTexelWeights_Tent_7x7(real offset, out real4 texelsWeightsA
106106
}
107107

108108
// 3x3 Tent filter (45 degree sloped triangles in U and V)
109-
void SampleShadow_ComputeSamples_Tent_3x3(real4 shadowMapTexture_TexelSize, real2 coord, out real fetchesWeights[4], out real2 fetchesUV[4])
109+
void SampleShadow_ComputeSamples_Tent_3x3(real4 shadowMapTexture_TexelSize, float2 coord, out real fetchesWeights[4], out real2 fetchesUV[4])
110110
{
111111
// tent base is 3x3 base thus covering from 9 to 12 texels, thus we need 4 bilinear PCF fetches
112112
real2 tentCenterInTexelSpace = coord.xy * shadowMapTexture_TexelSize.zw;
@@ -186,7 +186,7 @@ void SampleShadow_ComputeSamples_Tent_3x3(real4 shadowMapTexture_TexelSize, real
186186
(fetchesWeights)[8] = fetchesWeightsU.z * fetchesWeightsV.z; \
187187
}
188188

189-
void SampleShadow_ComputeSamples_Tent_5x5(real4 shadowMapTexture_TexelSize, real2 coord, out real fetchesWeights[9], out real2 fetchesUV[9])
189+
void SampleShadow_ComputeSamples_Tent_5x5(real4 shadowMapTexture_TexelSize, float2 coord, out real fetchesWeights[9], out real2 fetchesUV[9])
190190
{
191191
SampleShadow_ComputeSamples_Tent_Filter_5x5(real, shadowMapTexture_TexelSize, coord, fetchesWeights, fetchesUV);
192192
}
@@ -254,7 +254,7 @@ void SampleShadow_ComputeSamples_Tent_5x5(real4 shadowMapTexture_TexelSize, real
254254

255255

256256

257-
void SampleShadow_ComputeSamples_Tent_7x7(real4 shadowMapTexture_TexelSize, real2 coord, out real fetchesWeights[16], out real2 fetchesUV[16])
257+
void SampleShadow_ComputeSamples_Tent_7x7(real4 shadowMapTexture_TexelSize, float2 coord, out real fetchesWeights[16], out real2 fetchesUV[16])
258258
{
259259
SampleShadow_ComputeSamples_Tent_Filter_7x7(real, shadowMapTexture_TexelSize, coord, fetchesWeights, fetchesUV);
260260
}

Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ float4 EvaluateCookie_Punctual(LightLoopContext lightLoopContext, LightData ligh
464464
return cookie;
465465
}
466466

467-
real PunctualLightAttenuationWithDistanceModification(real4 distances, real rangeAttenuationScale, real rangeAttenuationBias,
467+
real PunctualLightAttenuationWithDistanceModification(float4 distances, real rangeAttenuationScale, real rangeAttenuationBias,
468468
real lightAngleScale, real lightAngleOffset)
469469
{
470-
real distSq = distances.y;
471-
real distRcp = distances.z; //distance contains light size modification. See ModifyDistancesForFillLighting
472-
real distProj = distances.w;
470+
float distSq = distances.y;
471+
float distRcp = distances.z; //distance contains light size modification. See ModifyDistancesForFillLighting
472+
float distProj = distances.w;
473473
real cosFwd = distProj * rcp(distances.x); //we recompute inv distance here
474474

475475
real attenuation = min(distRcp, 1.0 / PUNCTUAL_LIGHT_THRESHOLD);

0 commit comments

Comments
 (0)