Helloo,
I’m trying my hand at raymarched volumetric lighting, i’m using a directional light’s shadowmap to get whether or not any point is in shadow.
I’m using this in my shader to get the UVs required to sample my cascaded shadowmap.
float3 shadowUv0 = mul(unity_WorldToShadow[0], float4(pos.xyz, 1)).xyz; float3 shadowUv1 = mul(unity_WorldToShadow[1], float4(pos.xyz, 1)).xyz; float3 shadowUv2 = mul(unity_WorldToShadow[2], float4(pos.xyz, 1)).xyz; float3 shadowUv3 = mul(unity_WorldToShadow[3], float4(pos.xyz, 1)).xyz;
It works perfectly if I have only my directional light in the scene.
But as soon as any spot light with shadows enters my camera’s frustum, the shader breaks…
Having looked at the documentation, it seems “unity_WorldToShadow” only contains 4 elements, and the spot light replaces the first element for some reason.
Is there any way to get the shadow coordinates of only my directional light?
Thank you very much