Does anyone know if you can sample the main directional light's shadow map INSTEAD of the screen space shadow map? From the AutoLight.cginc file it looks like if you have shadow cascades off and SHADOWS_SCREEN defined, calling unitySampleShadow with the transformed world position to shadow space should work. I am rebuilding the world position in the fragment shader using depth so I am not using unity's macros SHADOW_COORDS and TRANSFER_SHADOW but rather transforming the rebuilt worldPos into shadow space. Oddly enough defining UNITY_NO_SCREENSPACE_SHADOWS myself seemed to get it to sample the screenSpace shadows. Otherwise calling unitySampleShadow just returns 1. Advice greatly appreciated. I can post the code I am using if that would be helpful.
https://github.com/Gaxil/Unity-Inte...Assets/Scripts/SetShadowMapAsGlobalTexture.cs https://github.com/Gaxil/Unity-InteriorMapping/blob/master/Assets/Shaders/Shadows.cginc
Wow, thanks so much. Works so good and was super easy. My volumetric lighting now takes shadows into account. Surprised that Unity's include files don't allow for this on there own. I know URP can do this but still.
I've been doing something along those lines, but I keep getting issues when there are multiple lights in the scene, as soon as any spot light enters the camera frustum, the shader breaks because unity_WorldToShadow[0] returns the coordinates of the spot light instead of the directional light anymore..., is there anyway to get the coordinates of only the directional light? EDIT: managed to make it work, I rendered my shader using a commandbuffer on my directional light using LightEvent.Beforescreenmask, i tried using Aftershadowmap and still had the issue but before screen mask is actually working