Why must specify a customDepthMaterial for proper shadows when modifying vertex positions

from the docs it states that:
" When shadow-casting with a DirectionalLight or SpotLight, if you are modifying vertex positions in the vertex shader you must specify a customDepthMaterial for proper shadows"

what causes the shadows to break when changing the vertices? and how does customDepthMaterial mitigate this? what is customDepthMaterial instance of? can it be an instance of THREE.MeshBasicMaterial etc?
how do i approach answering these kinds of questions from the source code itself? how do i navigate the codebase / repo history to get this answer?

thank you so much

two shaders are needed to make the shadows. Some shader X and a “depth shader”. Since these are two different shaders/materials, if you change one you have to change the other.

Say you make your own shader that transforms the vertices just like everything else in three, but then you add your own logic that says that vertices should move 3 units in world z. If you don’t modify the other shader, shadows will be cast as if the model has not moved by 3 units in world z…

1 Like

Thanks so much