I’m writing to report an issue with VSM and Distance Field shadow casting. My current problem is that assets closer to the camera do not use distance field shadows, but the HLODs further away from the camera do, creating a visible “seam” in visuals. It’s not obviously noticeable with assets very close to the camera, but the closer to the HLOD boundary they are, they resemble the HLOD version more and more and at some point it can be clearly seen, that some of those lack the additional detail that distance field shadows provide. Depending on the setup this can be more or less visible, because VSM’s loose resolution with distance, making their impact smaller and smaller.
That problem can be however reduced to the provided repro steps and engine Cube. I’ve verified that the Cube does have distance field representation (see screen CubeDistanceField, it seems angled because I wanted to keep the screen small and moved the viewport closer to tab and stats display. It’s an effect of projection). By default it also has “Affect Distance Field Lighting” set to true, when placed on the scene.
Ideally I’d expect that the user sets the distance and bears responsibility for the visuals, not that there is some hidden engine variable which prevents distance field rendering on objects. If I misunderstood the documentation, please let me know.
[Attachment Removed]
Steps to Reproduce
Clean engine
- Open Open World Template map
- Place engine cube, scale it to 5,5,5 so the issue is easier to visualize
- Select the Directional light
- Set “Distance Field Shadows” to true and “Distance Field Shadow Distance” to 200000 to make sure nothing is cut by the range
- Set “Dynamic Shadow Distance” to 2000, so that we can se VSM up to 2000 range and then we expect to see distance fields
- Set the camera to see the cube’s shadow entirely in VSMs (screen Step 6)
- Zoom out the camera to see the shadow being correctly cut out at 2000 range. Notice that Distance Field Shadow does not replace the missing shadow (screen Step 7)
- Zoom out further, to see that even when the shadow is completely culled and no VSMs cast shadow from the cube, there is nothing that replaces it (screen Step 8)
[Attachment Removed]
Hi,
thanks for the repro steps, however I have not been able to reproduce the issue with those exact settings. When disabling “Distance Field Shadows”, I did see the same behaviour as what you see in the video, so I’m not sure if we have all the same settings. Would you be able to share the sample project you created?
Thanks,
Sam
[Attachment Removed]
Hi,
here’s the link to the issue on the public issue tracker: https://issues.unrealengine.com/issue/UE-365847
Thanks again,
Sam
[Attachment Removed]
Hey,
You are correct. For some reason I’ve had “r.DistanceFieldShadowing” set to 0, probably due to previous tests, since I’ve made several reports in the same time frame. I apologize for this error on my part.
However my real issue still exists, the problem just moves a bit deeper. What I’m experiencing now is that nanite-enabled meshes do not respect the “Dynamic Shadow Distance” property. They never show distance fields in the near range, they always use VSMs. I’ve copied to project contect and modified the engine cube to be nanite enabled and placed two cubes on the scene - one is using nanite (on the left on screen), the second not (on the right).
The non-nanite one behaves as expected, the nanite one ignores the setting and never goes into distance field. It’s not just the fact that the VSM stays forever and overlaps distance field shadow. That wouldn’t be so bad, though looses performance. I believe that the distance field shadow is never actually cast, which I’ve verified in my real project by using more complex meshes which show additional details gained thanks to distance fields, that VSM’s don’t provide. If you look on the screens I provided, the non nanite cube actually gains additional shadow on top, when enabling “Distance Field Shadows” on the directional light.
I’m also providing the project with this issue present.
[Attachment Removed]
Couldn’t attach more than 1 file so here’s the screen with enabled “Distance Field Shadows”. Notice the shadow outline closer to camera on the right cube changing, indicating that the shadow is visible even before the “Dynamic Shadow Distance” clamps it. I’m fine with that, it adds to visuals, but that does not happen on the nanite cube, which breaks scene if using both types of assets.
[Attachment Removed]
And here is the project with repro.
[Attachment Removed]
Hi,
thanks for the repro scene. I will file a bug report as this does seem like a bug and post the link to the public issue tracker here when it becomes available, so you can track its progress.
Thanks,
Sam
[Attachment Removed]