Is there a way to make a mesh able to switch between invisible and visible but always casts shadow as if it is always opaque just from the shader script?
I’m aware of GeometryInstance3D:cast_shadow, but I’m trying to make Grid Map usable for my use case. Grid map doesn’t store its mesh as GeometryInstance3D, meaning I don’t have access to that, and I haven’t found a way to manipulate each cell without affecting other cell using the same MeshLibrary item. Hence I’m trying to do it via shader only.
I have found a way to identify which mesh located in which cell using VERTEX variable in vertex function and use that in fragment as an indication which grid the current mesh at, but I have not found a way to make it invisible but still cast shadow to other surface.
IN_SHADOW_PASS isn’t an existing variable, I’m afraid (list of variables). I don’t see any bool that might indicate that the current pass is a shadow pass.
But thank you for responding. Hopefully someone else know.
You’re right. It is present in 4.5 despite it isn’t listed in the docs. Thank you thank you!!
Upgrading is a big ask in my current state. But it there’s no other way, I would have to. At least now I know it’s possible. I’ll play around with the latest version some more.
I won’t mark it as Solution for now in case someone else know the solution in 4.3. If nothing comes up after a few days, I’ll go with your suggestion. Thanks, once again.
On what criteria do you need to switch visibility? Can you describe your specific use case in more detail? There could be a non shader solution.
Also, if you only have a directional light source, it can be determined if you’re in the shadow pass by looking at the projection matrix, assuming your main camera is not orthographic.