Cloud Shadows Artifact Sky Atmosphere

With Cloud Shadows enabled it seems that the SkyAtmosphere is getting shadowed using the volumetric cloud shadow map.

I would expect the atmosphere beyond the clouds to not blend with the shadow map.

The artifacts disappear if “Cloud Shadow On Atmosphere Strength” is set to 0 but then too much light gets through a full density cloud.

Reducing the shadow map extent also alleviates the issue but then restricts the distance of the shadow generation.

[Image Removed]

The dark areas of the image above flicker in and out.

Steps to Reproduce
Start Repro project (ue5.5 w/Lumen)

Insure TOD is set to 18.792345 but the effect happens at all TODs

View artifacts on skyAtmosphere

I will note that adjusting the FastSkyLUT resolutions and sampling simply make the artifacts more high resolution and defined.

Hi,

Thanks for reaching out and providing a repro scene. I started investigating the issue and found that changing the Trace Sample Count Scale on the SkyAtmosphere to 8 or higher reduces the artifacts (at a performance cost), and makes them look more like “god rays”. I believe these artifacts are an inherent limitation of how the volumetric sampling for the volumetric cloud and atmosphere system works (reducing the blocky artifacts would require a lot more samples, with performance and memory impacts).

If you have more questions, I can pass it to Epic so someone with more experience with the internals of the volumetric clouds and atmosphere can have a look.

Thanks,

Sam

I’m not sure I accept that explanation. Increasing that value does make the effect sharper and more defined but does not eliminate or reduce the problem.

The “rays” themselves seem to appear where clouds are not present.

I agree that they look like god rays but they do not emanate from a light source and are shadowed based on the shadow magnitude. Disabling the shadow map removes the issue completely but then also disables cloud shadows.

Decreasing the “Cloud Shadows on Atmosphere Strength” to will reduce the effect with it fully disappearing when the value is 0. This also effectively disables the diffused cloud shadowing so I’ll still get full light intensity with a completely cloudy sky.

In the below image the sun is on the horizon out of picture but I still get shadows cast on seemingly nothing in the middle of the sky.

Here is another example that I could not easily get to replicate in the repro:

[Image Removed]

Hi,

I investigated the repro scene a bit more and noticed that there are two volumetric cloud components, one at the world level and one inside the SunSky actor. Adding a second volumetric cloud component will cause the first one to disappear. Just confirming if this is intentional?

I’ve deleted the VolumetricCloud at the world level and experimented with the settings on the remaining VolumetricCloud (in SunSky) and found that reducing the Tracing Max Distance to 0 removes the clouds from the scene, but still preserves their shadows on the atmosphere. This may (partially) explain why you are seeing shadows cast without clouds. Increasing the Tracing Max Distance should reveal the shadow casting clouds.

Changing the z value of the Rotation on the DirectionalLight should show off the god rays emanating from the sun moving around the horizon (Atmosphere Sun Light Index on the DirectionalLight component should be 0).

Hopefully that helps to clarify some things, but let me know if you have further questions,

Sam

Also, if you look at the first image posted I believe the shadow artifacts might just be misaligned with the clouds as they seem to mimic the overall cloud pattern and density but don’t line up correctly with the rendered clouds themselves. It is as if they are rotated or translated incorrectly.

[Image Removed]

Hi,

>> I’ve tried increasing the TracingMaxDistance value to max and it still didn’t draw clouds at the issue area above nor did it resolve the issue. The shadow artifacts are unaffected by altering this value.

Indeed, I meant that the cloud shadows on the atmosphere seem to be drawn independently from the clouds.

>> I do see the god rays but this seems to be a completely different issue. The “shadow rays” do not emanate from the sun but do seem to get worse when the sun is close to the horizon line as if the shadows are getting cast from below the clouds and into the sky.

That’s strange, to me these rays do seem to come from the sun, like in the image below. I’ve set the Tracing Max Distance on the VolumetricCloud to 0.0 to hide the clouds and Trace Sample Count Scale on the SkyAtmosphere to 8 which seems to increase the resolution of the shadows. Admittedly, these rays do seem to converge to a point at the horizon on the opposite side of the sun, which looks a bit weird.

[Image Removed]

>> Is there a render target somewhere that I can use to inspect the resulting shadow map generation?

I’ve tried searching with the “vis” console command (which lists all the available debug views), the closest I could find were Cloud.ShadowTexture0 and Cloud.ShadowTexture2, both of which don’t seem to show the cloud shadows on the atmosphere. The “dumpgpu” console command, while easier to inspect, also didn’t provide much additional info.

>> From what I can tell the local references are calculated correctly for sampling the shadow map for the clouds.

I’m not entirely sure what you mean with local references. Could you elaborate please?

>> Also, if you look at the first image posted I believe the shadow artifacts might just be misaligned with the clouds as they seem to mimic the overall cloud pattern and density but don’t line up correctly with the rendered clouds themselves. It is as if they are rotated or translated incorrectly.

You may be right. I have spent some time with the repro scene trying to see if the position and shape of the cloud shadows match up with those of the clouds, but it’s hard to tell. It’s probably easier to debug these cloud shadows by creating simple disk shaped clouds (like in step 4 of this tutorial).

Thanks,

Sam

The issue definitely seems to be a misalignment of the shadow map. Our team has had a few other issues in UE where a shader’s calculations were not correct when we place the scene away from the north pole of the planet. In cases like the exponential height fog z-up was assumed. I suspect something similar is going on here but I am not certain.

I’ve been going through SkyAtmosphere.usf which definitely seems to be the culprit.

I believe I’ve narrowed down the issue to this line:

ShadowP0 = GetTranslatedCameraPlanetPos() + t * mul(LocalReferencial, WorldDir); // Inverse of the local SkyViewLUT referencial transformWhich is the matrix used to sample the cloud shadow map later in the shader:

		PlanetShadow0 *= saturate(lerp(1.0f, GetCloudVolumetricShadow(ShadowP0 * SKY_UNIT_TO_CM + View.SkyPlanetTranslatedWorldCenterAndViewHeight.xyz, VolumetricCloudCommonParameters.CloudShadowmapTranslatedWorldToLightClipMatrix[0],
			VolumetricCloudCommonParameters.CloudShadowmapFarDepthKm[0].x, VolumetricCloudShadowMapTexture0, VolumetricCloudShadowMapTexture0Sampler, OutOpticalDepth2), VolumetricCloudShadowStrength0));

It is used to sample the other shadow maps as well but I have not setup a test to see if the error is present there also.

GetTranslatedCameraPos() and WorldDir I believe are correct and are used elsehwere which leaves just LocalReferencial. That is a uniform set by SceneView() and is used in many different places.

The comment for the line suggests that it should be using the INVERSE of the LocalReferencial but I don’t see the code where this value is inverted which makes me think that it is not getting inverted at all. Perhaps this is the problem?

I haven’t looked into this theory much yet but I will try to do that today.

I was able to figure this out, at least partially. It turns out the lines mentioned above did need the LocalReferencial to be inverted but that was not being done in SkyAtmosphere.usf.

The code below fixes the shadowing artifacts in the sky.

		float3x3 InverseLocalReferencial = Inverse3x3(LocalReferencial);
		ShadowP0 = GetTranslatedCameraPlanetPos() + t * mul(InverseLocalReferencial, WorldDir); // Inverse of the local SkyViewLUT referencial transform

I cannot take credit as I found the fix in someone elses question on UDM found here: [Content removed]

I actually calculated the inverse in the CPP and passed it in as a uniform but the end effect is the same.

I’m still having other issues with the sky shadow map that I will address in another question as they are different than this problem.

Hi,

great find, thanks a lot for sharing this fix! As this bug has already been reported in the thread you linked (which also includes the suggested fix), is it okay to close this ticket?

Thanks again,

Sam

Yes, I think this issue has been resolved. There might still be an issue with the sun flickering in and out of shadow but I’m still investigating that issue.

The dual volumetric cloud systems was not intentional. I must have left that in when I was debugging another problem but removing it does not seem to change any of the above symptoms.

I’ve tried increasing the TracingMaxDistance value to max and it still didn’t draw clouds at the issue area above nor did it resolve the issue. The shadow artifacts are unaffected by altering this value.

I do see the god rays but this seems to be a completely different issue. The “shadow rays” do not emanate from the sun but do seem to get worse when the sun is close to the horizon line as if the shadows are getting cast from below the clouds and into the sky.

I believe there are two possible places that could be in error.

  1. Generation of the shadow map
  2. Sampling of the shadow map

Is there a render target somewhere that I can use to inspect the resulting shadow map generation? If I disable ray marching for the volumetric clouds the artifacts seem to be wide spread and can be seen throughout the cloud system not just in the area pictured in the previous post.

From what I can tell the local references are calculated correctly for sampling the shadow map for the clouds. I expected there to be an error with this since the effect seems to be worse when away from a perfect z-up orientation (away from north pole). I haven’t been able to debug the matrices but just reviewed the code.

Thanks a lot, in that case I will close this ticket. Please feel free to open a new case for the other issue.

Best,

Sam