Raytraced shadows are incomplete due to nanite meshes are not fully streamed yet

Hi,

in our UE5.5 application we’re seeing an undesired behavior which we’re struggling to reduce or remove.

The application renders images of different car configurations and when switching between certain configurations we’re observing holes in the raytraced shadow of the car. The light is a directional light with the property “Cast Ray Traced Shadows” set to “Enabled”. [Image Removed]

Sorry I can’t share a video or full image since the car showing the worst behavior is still secret.

Depending on the model and the hardware the application runs on the broken shadows are visible long enough to end up in our produced images.

We tested a bunch of CVars with different values to narrow down the issue:

  • r.RayTracing.Scene.BuildMode
  • r.RayTracing.UseReferenceBasedResidency
  • r.D3D12.RayTracing.AllowCompaction
  • r.RayTracing.Nanite.StreamOut.MaxNumIndices
  • r.RayTracing.Nanite.StreamOut.MaxNumVertices
  • r.RayTracing.Shadows.LODTransitionStart

There were no improvements until we forced raytracing to use Nanite fallback meshes by setting r.RayTracing.Nanite.Mode 0.

Unfortunately this CVar is normally set to 1 to fix another issue we had with raytracing effects and Nanite:

[Image Removed]

So, unfortunately, we’re in a “pick your poison” situation and wanted to know if we missed some settings/CVars we missed which might improve the situation. Additionally we’re pretty limited in RAM & VRAM and had to do some compromises already which might rule out some solutions, but maybe you can help nonetheless.

I attached our DefaultEngine.ini so you can get an idea what’s already set by default.

Grateful for any help.

Cheers,

Simon

[Attachment Removed]

Hi,

if I understand your question, the shadow artifacts (holes) is just a temporary thing, until the Nanite geometry has had sufficient time to stream in?

There are a few things you can try when using Nanite’s fallback mesh for shadow tracing while minimising artifacts. This will require r.RayTracing.Nanite.Mode to be set to 0 again:

  • Set Fallback Relative Error to 0 in the static mesh editor’s Nanite settings and click “Apply Changes”. This will force the fallback mesh to be as close as possible to the actual geometry used by Nanite. This is probably the most robust method to tackle shadow artifacts.
  • Increase r.RayTracing.NormalBias to e.g. 5. This will bias the shading normal and should reduce or eliminate artifacts caused by the fallback mesh geometry not fully matching the Nanite mesh geometry. Take care not to set this value too high, as that may reduce overall shadow quality.
  • Setting r.RayTacing.Shadows.EnableTwoSidedGeometry to 0 might also help to reduce shadow artifacts.

You might have to check each of these workarounds separately, and assess their impact on shadow quality. Some workarounds may also work better than others, this is highly dependent on your scene geometry.

Let me know if this works or if you have any further questions.

Regards,

Sam

[Attachment Removed]

Hi Sam,

thanks, this is exactly what I was looking for. I did a quick check and with r.RayTracing.Nanite.Mode 0 and r.RayTracing.NormalBias 2.5 and all artefacts in the car paint are gone.

we will check for any other undesired artefact which might be cause by this change. Might this setting affect how lighting or reflections are rendered? I didn’t notice something obvious, but I didn’t look deep, yet.

Fallback Relative Error is something we don’t want to change too much since we’re quite limited in available memory, but we will include it in the fine tuning since it positively affects the rendering artefacts.

Cheers,

Simon

[Attachment Removed]

Hi Sam,

thanks for the additional explanation. I’ll take it into account.

Cheers,

Simon

[Attachment Removed]

Hi,

good to know the normal bias workaround helps to reduce artifacts. Changing that setting will affect all ray tracing calculations that rely on normals, including reflections and lighting. The setting was introduced to reduce shading artifacts that arise when the shading normals are too different from the geometric normals (this may happen if the shading normals represent a smooth curved surface, but the underlying mesh geometry has not enough triangles), which might lead to self-shadowing artifacts (blotchy shadows). It works by offsetting the start position of shadow rays by a small distance away from the surface. This helps to prevent rays from intersecting the geometry they originate from, but increasing it too much creates inaccurate, shifted shadows.

The units are in cm, so setting it to 2.5 will effectively shift shadow (and reflection) rays by 2.5 cm away from the geometry of the fallback mesh casting the shadow. In most cases this should not be perceivable, but the shift might be visible in close-up shots when this value is set too high, resulting in disconnected or “floating” shadows.

I hope that helps answer your question.

Regards,

Sam

[Attachment Removed]

Hi,

No problem, I’ll close this case for now, but feel free to open a new one if you encounter more issues.

Regards,

Sam

[Attachment Removed]