Skip to content

Commit

Permalink
2023.2/graphics/hd/fix/clouds debug mode
Browse files Browse the repository at this point in the history
Reported here https://unity.slack.com/archives/C6Y79CZM0/p1696952455221199
Fixed error in the console when enbling a debug mode and volumetric clouds are on

This acutally fixes a more serious issue where volumetric clouds shadow would be computed on all directional lights
introduced by https://github.cds.internal.unity3d.com/unity/unity/pull/19281
  • Loading branch information
adrien-de-tocqueville authored and Evergreen committed Nov 15, 2023
1 parent cc2608f commit 3d760ab
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ float4 EvaluateLight_Directional(LightLoopContext lightLoopContext, PositionInpu
}
#endif

#ifndef LIGHT_EVALUATION_NO_CLOUDS_SHADOWS
// Apply the volumetric cloud shadow if relevant
if (_VolumetricCloudsShadowOriginToggle.w == 1.0)
color.rgb *= EvaluateVolumetricCloudsShadows(lightLoopContext, light, posInput.positionWS);
#endif

return color;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
posInput.positionSS, posInput.positionWS, GetNormalForShadowBias(bsdfData),
light.shadowIndex, L);

#ifndef LIGHT_EVALUATION_NO_CLOUDS_SHADOWS
// Apply the volumetric cloud shadow if relevant
if (_VolumetricCloudsShadowOriginToggle.w == 1.0)
context.shadowValue *= EvaluateVolumetricCloudsShadows(light, posInput.positionWS);
#endif
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef VOLUMETRIC_CLOUDS_SHADOW_SAMPLING
#define VOLUMETRIC_CLOUDS_SHADOW_SAMPLING

float EvaluateVolumetricCloudsShadows(LightLoopContext lightLoopContext, DirectionalLightData light, float3 positionWS)
float EvaluateVolumetricCloudsShadows(DirectionalLightData light, float3 positionWS)
{
// Compute the vector from the shadow origin to the point to shade
float3 shadowOriginVec = positionWS - _VolumetricCloudsShadowOriginToggle.xyz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ VoxelLighting EvaluateVoxelLightingDirectional(LightLoopContext context, uint fe
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
posInput.positionSS, posInput.positionWS, shadowN,
light.shadowIndex, L);

// Apply the volumetric cloud shadow if relevant
if (_VolumetricCloudsShadowOriginToggle.w == 1.0)
context.shadowValue *= EvaluateVolumetricCloudsShadows(light, posInput.positionWS);
}
}
else
Expand Down

0 comments on commit 3d760ab

Please sign in to comment.