Hello there, In Unity I'm trying to create a underwater Caustics shader to use in a Projector (or should I rather do this in a Post Process Mat? Will this be problematic with other Post effects like Depth of File?), that's additive on top of all the existing materials in the scene.
Because a projector can't cast shadows, I would have to manually multiply my Caustics textures by the realtime shadowmap pass and the pre-baked Lightmaps pass, to darken the texture where shadows are supposed to be. How can I grab those two passes (of course it's also okay if they are already combined!) and use them in my shader?
Hello, thank you for getting in touch and for your support!
There are several ways to create caustics effects, we would need more context to know which would be the most viable to you.
Regarding what you've stated, you are correct, projectors are not lights so they won't "cast shadows" onto surfaces. We do, however, have a Light Attentuation node that does provide shadow information for that object but that only works properly for opaque objects that write to depth.
That node uses a built-in function that samples the shadowmap, but I'm not sure if that node will solve your problems, if the object does not write to depth you should be able to pick the shadow information of what's behind it. If that works you could try to use it as your shadowmap to mask out the caustics but, since projectors have their own requirements, I'm not entirely sure if will break it.
You should be careful when considering the use of projectors though, they create too many draw calls because they are called at least once for every object their frustum touches.