Terminating the Shadow Terminator Problem (Jagged Shadows)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody just wanted to make a quick video on the shadow Terminator problem uh if you haven't experienced this before consider yourself lucky it's actually really common and really well known in the 3D modeling and rendering space and first let's talk about what the shadow Terminator actually is Shadow Terminator is The Edge transition point between the light part of a shaded object and the shadowed parts of the Shaded object um so if we look here we can see some of the Shadow Terminator problem on this sphere on the left and we can see that on the sphere on the right it appears to be absent uh so why does the shadow Terminator problem occur well this is because the surface of the mesh is shaded by its smooth normals so if we go ahead and go to the pixel normals here I just apply that this is the pixel normal of the mesh and let me go ahead and uh actually give this the same material right so these are the pixel normals but Shadows aren't cast by the pixel normal so the lighting the vertex lighting is calculated based off Shadows are cast off of the actual geometry so the geometry is not smooth like that right it's faceted and so the reason here you can probably see what's going on the difference between these two spheres the sphere on the left has a relatively low poly count and so it's very faceted on that here the difference between its vertex normals and its P between its faceted geometry and the smooth pixel normals are quite extreme whereas the one on the right here has been subdivided a couple of times and the discrepancies between those are very minimal we can actually visualize the difference between them by taking the dot product of the faceted normals and the true pixel normals based off of the shading so if I do that here you can see once again on the left the sphere along the edges of the polygons deviates right the dot product will be one when the vectors are aligned so the vectors are out of alignment along the edges and that's creating areas where Shadow discrepancies can occur between the core Shadow and the cast Shadow and to explain that the core Shadow is the um the actual shading that appears on an object and that's handled by the vertex lighting the lighting engine and the cast Shadow is the shadow that appears on usually the other surfaces in the scene like the ground but also self-shadowing when one part of an object casts a shadow on itself typically another part of that same object right so this is something that causes a lot of confusion for beginners but these are all handled by different systems right so the vertex lighting is one system and I can actually show that here right if we go to our Global illumination and we turn off lumen this is the vertex lighting so you can see it's purely lighting based off of the vertex then if we turn off our Shadows here well I guess first note that with the vertex lighting without Lumen the shadow Terminator issue is still there but as soon as I disable Shadows we still have a core shadow but we don't have any cast Shadow and we can see that when we get rid of that cast Shadow we got rid of our shadow Terminator problem as well because the shadow Terminator is an artifact of the cast shadow in the lower polygon detail that exists when you're casting that Shadow versus when you're shading with pixel normals so how can we solve this well I already mentioned earlier we can solve this by having a higher polygon count right so if I go ahead and turn Lumen back on here you know higher polygon counts will reduce the discrepancies and make those um issues less visible another thing we can do is change our shadow technology right so shadow Maps right so with virtual Shadow Maps we get this type of artifact which is pretty bad on low polygon meshes looks pretty decent on high poly meshes if we go to traditional Shadow Maps we actually get a different type of artifact entirely but it's not artifact free you can see here that we get this kind of Blocky appearance to our shadows and it's much less visible on the subdivided mesh and we actually have controls for this here on on cascaded Shadow maps that don't work for virtual Shadow Maps unfortunately right now so we have the shadow bias and as I change this you can see that it reduces the amount of artifacting or increases increases it as we eliminate and increase the bias so this is basically shifting where the shadow Caster is slightly by default it's at 0.5 which is enough to fix meshes with relatively High detail but as you can see it leads to pretty bad looking shading on meshes with uh relatively low poly counts so if we go back over to our shadow settings here and we switch over to Ray Trace Shadows we'll actually see that the shadow Terminators look really good there are still and this probably won't even show up here but there are actually still some um issues here and maybe if I get rid of lumen maybe this will be more visible so there is a a bit of a shadow Terminator problem visible there but it's it's not noticeable and it's pretty much non-existent on the higher polygon mesh as well so in my experience um you know with different types of rendering you will get different results none of them out of the box offer a completely perfect result but you have some control over it that way the other way you have control over this when you are using either virtual Shadow Maps or cascaded Shadow Maps is in the Shader with the shadow path switch so there's a couple of ways that you can do this you can actually essentially offset the position of the Shadow from the Shader and that will act as a bias similar to the setting in the light so if I go ahead and just apply this let me pull this out here you'll see that as I move this I'm actually able to control the Shadow and if I slide it here see let's go negative three I've actually eliminated most of the Shadow Terminator problem not quite let's go negative five it's still there a teeny bit negative six okay at negative six I can't see any more of the Shadow Terminator problem on this mesh so this seems like a really good solution what this is doing is it is looking at the light Vector of the Sun and it's just shifting the mesh in space right so if I get rid of this Shadow pass switch and we just shift it you can see that the whole mesh is just moving right but rather than actually moving the mesh I'm moving the point which the mesh's shadow is being cast into the shadow maps and that will displace it doing this in the material has one big problem though depending on your project which is that it doesn't work per light like the um the option for the bias in the light settings do so if I go ahead and drop in a point light here you can see that we get this pretty hideous artifact so this method only works if you have just one Shadow casting light it will not work if you have multiple Shadow casting lights so if I go ahead and disable Shadow casting on this right if I'm just using it purely for lighting but not Shadow casting then this particular option essentially eliminates the shadow Terminator problem for low poly meshes easily without really any noticeable problems right we go from having Shadow Terminator problems to um completely gone without really any drawbacks at all so so that's you know assuming you are just using one Shadow casting light and a lot of projects will only be using one Shadow casting light so that will work great but if you are using more than one Shadow casting light then this isn't going to be a viable option for you instead you're going to need to shift the vertices some other way um and bias it you know in a different direction so rather than biasing it in the sun's Vector Direction you can actually just shrink the entire mesh slightly and this can have some some visible issues but generally speaking they'll look better than the shadow Terminator artifact and you can you can fade these effects out um as you get close to a mesh and you switch to the higher polys that don't need it and then only have it happen when you're farther away when you're using a lower poly mesh where it might be um more visible so if I go ahead and see here we've got a bias parameter if I go ahead and actually we need to compile the Shader here if I shrink this number here to about we'll call it 0.15 I've effectively just shrunk the the mesh when it's casting a shadow so I've made the shadow casting mesh smaller than the physical mesh which is making it so that it can't cast Shadows onto its own surface problem with this technique is that um can actually see if you are really astute the difference in the size of the Shadow which most of the time is not going to be noticeable at all but if I just go ahead and reset that you can see that the shadow just changed size a tiny bit and so that could be a problem in some cases so you have to use it carefully in this case I'm just shifting along the vertex normals which will work great for a lot of different types of assets but not every asset for example a cube couldn't really do that because um it would cross itself right because it has split normals so you know if you're using split normal meshes uh like hard edges then that could be a problem instead you might need to do something different to choose the direction to shift to normals if you're experiencing the problem on terrain then you can probably just shift the normals vertically in the um the Z direction or in their normal Direction depending on the surface of the terrain and eliminate Shadow Terminator issues that way so that just about covers the options here for eliminating the shadow Terminator problems in Unreal Engine and these techniques will also work in other 3D software generally as well you might need to modify them slightly but hopefully you've found it helpful and again just to recap option one is to use more geometry to eliminate the discrepancies between the um the shadowing mesh and the you know the actual pixel normals themselves and the other options would be to bias Your Shadow Caster in some capacity so thanks again for watching and hope you have a great day
Info
Channel: Alex
Views: 12,357
Rating: undefined out of 5
Keywords:
Id: Bp08KAt19_M
Channel Id: undefined
Length: 14min 4sec (844 seconds)
Published: Tue Jan 17 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.