Hello, i have a priblem with dynamic lighting. When there is two meshes (or one mesh with angle) meeting, the shadow is offset and very pixelated. Does anyone know how to fix this please? I tried all the possible settings… only thing that helps is the Contact shadow setting, but it creates other ugly artifacts:/
This is classic peter panning from shadowmap bias. Solution is to use thicker walls (best option), higher resolution shadowmaps (more expensive to render and costs more GPU memory), and/or adjust your shadow bias closer to 0 (will create shadow acne)
Alternatively just don’t use regular shadowmaps, switch to virtual shadowmaps which tend to handle this type of leaking much better. If possible you could use lightmaps with static shadows which are only limited by the texel density of the receiving meshes lightmap uvs.
Thank you very much for the reply. Unfortunately the issue is with a movable train. Thicker walls would look unrealistic and i can not use static shadows as the train moves… Virtual shadowmaps cause quite a hit on performance
I will try the higher res. shadowmaps, maybe it will be better. Thanks
If your project is using mesh distance fields you can try enabling distance field shadows. It will likely create other issues, but it generally doesn’t leak as long as your wall is thick enough to be represented in the mesh distance field.
More unrealistic than having light leaking through the walls?
The unfortunate fact is there is no perfect solution to this problem, this is just an inherent issue with the way shadowmaps work. At some point, you have to weigh your options and pick one you can live with.
Most of the time in realtime rendering we pick thicker walls, simply because it’s usually much more important to prevent light leak than it is to have dimensional accuracy.
This isn’t a problem with model complexity, any time a shadow needs to be projected at a steep angle this artifact will be apparent. If you would like a more technical explanation as to why this occurs you can read about it here: LearnOpenGL - Shadow Mapping
If anyone would have the same problem… this is what helped me the most. It is a compromise between artifacts and peter pan. It is not perfect but significantly better