Using Shadowmap pass + Lightmap Intensity in a Shader?

Node-based Shader Editor

Using Shadowmap pass + Lightmap Intensity in a Shader?

Postby JoaTschi » Wed Apr 10, 2019 9:38 am

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?

Thanks a lot in advance!
JoaTschi
 
Posts: 1
Joined: Wed Apr 10, 2019 9:29 am

Re: Using Shadowmap pass + Lightmap Intensity in a Shader?

Postby Amplify_Borba » Wed Apr 10, 2019 1:12 pm

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.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 5 guests

cron