Skip to content

Fix for shadows disappearing when no dynamic shadow caster is available #6296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed nullref from debug menu in release build (case 1381556).
- Fixed debug window reset.
- Fixed camera bridge action in release build (case 1367866).
- Fixed contact shadow disappearing when shadowmask is used and no non-static object is available.

### Changed
- Optimizations for the physically based depth of field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ private void GetContactShadowMask(HDAdditionalLightData hdAdditionalLightData, B
return;

// Evaluate the contact shadow index of this light
contactShadowMask = 1 << m_ContactShadowIndex++;
contactShadowMask = 1 << m_ContactShadowIndex;
m_ContactShadowIndex++; // Update the index for next light that will need to cast contact shadows.

// If this light has ray traced contact shadow
if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && hdAdditionalLightData.rayTraceContactShadow)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ void DeferredContactShadow(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId
// Do the contact shadow for the directional light
if (featureFlags & LIGHTFEATUREFLAGS_DIRECTIONAL)
{
if (_DirectionalShadowIndex >= 0)
for (int i = 0; i < _DirectionalLightCount; ++i)
{
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
DirectionalLightData light = _DirectionalLightDatas[i];

if (light.contactShadowMask != 0 && light.isRayTracedContactShadow == 0.0)
{
Expand All @@ -214,6 +214,7 @@ void DeferredContactShadow(uint2 groupThreadId : SV_GroupThreadID, uint2 groupId
// we take full bits at one multiplied by contact shadow and filter the bit at the contact shadow index.
contactShadowMask |= light.contactShadowMask * occluded;
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ void RayGenContactShadows()
uint contactShadowMask = 0;
UnpackContactShadowData(_ContactShadowTextureUAV[COORD_TEXTURE2D_X(pixelCoord)], fade, contactShadowMask);

// Let's first process the directional shadow
if (_DirectionalShadowIndex >= 0)
for (int i = 0; i < _DirectionalLightCount; ++i)
{
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
DirectionalLightData light = _DirectionalLightDatas[i];

if (light.contactShadowMask != 0 && light.isRayTracedContactShadow == 1.0)
{
Expand Down