So I have a scene with a tile based grid with a cursor that you move around, and based on the relative position of the cursor and the camera certain obstacle mesh instances get turned semi-transparent so you can see through them to where the cursor is. This all works great.
My issue is that I want to also have the objects continue to cast shadows while they are turned transparent, so I am dynamically creating a shadow_mesh duplicate of the original MeshInstance3D, putting it on layer 2, and setting the camera to not see layer 1. This all works perfectly. My transparency continues to work, and the duplicate mesh is not seen by the camera.
However, no matter what I do with the layers, caster cull layers, etc. in my DirectionalLight3D, the shadow meshes will not cast shadows.
I know the duplicate shadow mesh instances are there in the right place, because when I set the camera to see layer 2, they are properly there in the same place when the original mesh is turned transparent. And when I set the camera to see layer 2, they cast shadows.
Why would they cast shadows when the camera can see them, and not when the camera can't? I thought you were supposed to be able to use the visibility layers to have an invisible object cast a shadow? What am I misundertanding/doing wrong?