Skip to content

Commit ef2550b

Browse files
Fix warning in PCSS code when using Vulkan (#229)
* Fix warning * changelog
1 parent 1b48567 commit ef2550b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
562562
- Fixed scalarization code for contact shadows.
563563
- Fixed volume debug in playmode
564564
- Fixed issue when toggling anything in HDRP asset that will produce an error (case 1238155)
565+
- Fixed shader warning in PCSS code when using Vulkan.
565566

566567
### Changed
567568
- Improve MIP selection for decals on Transparents

com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ float SampleShadow_PCSS(float3 tcs, float2 posSS, float2 scale, float2 offset, f
291291
//1) Blocker Search
292292
float averageBlockerDepth = 0.0;
293293
float numBlockers = 0.0;
294-
if (!BlockerSearch(averageBlockerDepth, numBlockers, min((shadowSoftness + 0.000001), resIndepenentMaxSoftness) * atlasResFactor, tcs, sampleJitter, tex, samp, blockerSampleCount))
295-
return 1.0;
294+
bool blockerFound = BlockerSearch(averageBlockerDepth, numBlockers, min((shadowSoftness + 0.000001), resIndepenentMaxSoftness) * atlasResFactor, tcs, sampleJitter, tex, samp, blockerSampleCount);
296295

297296
// We scale the softness also based on the distance between the occluder if we assume that the light is a sphere source.
298-
if (isPerspective)
297+
// Also, we don't bother if the blocker has not been found.
298+
if (isPerspective && blockerFound)
299299
{
300300
float dist = 1.0f / (zParams.z * averageBlockerDepth + zParams.w);
301301
dist = min(dist, 7.5); // We need to clamp the distance as the fitted curve will do strange things after this and because there is no point in scale further after this point.
@@ -310,13 +310,14 @@ float SampleShadow_PCSS(float3 tcs, float2 posSS, float2 scale, float2 offset, f
310310
}
311311

312312
//2) Penumbra Estimation
313-
float filterSize = shadowSoftness * (isPerspective ? PenumbraSizePunctual(tcs.z, averageBlockerDepth) :
313+
float filterSize = shadowSoftness * (isPerspective ? PenumbraSizePunctual(tcs.z, averageBlockerDepth) :
314314
PenumbraSizeDirectional(tcs.z, averageBlockerDepth, zParams.x));
315315
filterSize = max(filterSize, minFilterRadius);
316316
filterSize *= atlasResFactor;
317317

318318
//3) Filter
319-
return PCSS(tcs, filterSize, scale, offset, sampleJitter, tex, compSamp, filterSampleCount);
319+
// Note: we can't early out of the function if blockers are not found since Vulkan triggers a warning otherwise. Hence, we check for blockerFound here.
320+
return blockerFound ? PCSS(tcs, filterSize, scale, offset, sampleJitter, tex, compSamp, filterSampleCount) : 1.0f;
320321
}
321322

322323
// Note this is currently not available as an option, but is left here to show what needs including if IMS is to be used.

0 commit comments

Comments
 (0)