# unity 5 how to get a shadowmap

I'm writing a custom shader in unity 5 that requires a shadowmap (not just for drawing shadows but also for different computations involving scattering particles through fog). Does anybody know how to actually get the shadow map in unity rather than just using the fallback option? That is including the actual Z buffer not just the resulting 1's and 0's.

I could also use the depth buffer from the camera but that only appears to apply to camera used by the player rather than the second one I can add to replace the light (inside the light).

• Maybe this Helps: alastaira.wordpress.com/2014/12/30/… – Anthony Raimondo Mar 10 '15 at 13:51
• That uses the LIGHT_ATTENUATION which automatically samples if something is within the light but does not actually give the Z values of the shadowmap. – Thijser Mar 10 '15 at 15:57

UNITY_DECLARE_SHADOWMAP(tex) - declares a shadowmap texture variable with name “tex”.