- Home /
Is it possible to get shadows of each light in seperate channel ?
Hi , I'm looking for a way to get shadows of each light in the scene in separate channel in shader.
I toke a look in Lighting.cgisnc
and AutoLight.cginc
& UnityShadowLibrary.cginc
and I think it's possible.
I need to mask a texture by shadows of different lights for example :
Masking Texture2D A with Point Light A Shadow
And Masking Texture2D B with Spot Light B Shadow
I saw shadows are generation to texture in UnityShadowLibrary or maybe I be wrong , I don't have good knowledge of shader writing.
But I understood a part of Shadow Mask Technique which I believe do the same thing , it will get each light shadow ( Up to 4 in RGBA ) and mix it with baked shadows in texture.
if defined (SHADOWS_SHADOWMASK)
#if defined(LIGHTMAP_ON)
fixed4 rawOcclusionMask = UNITY_SAMPLE_TEX2D(unity_ShadowMask, lightmapUV.xy);
#else
fixed4 rawOcclusionMask = fixed4(1.0, 1.0, 1.0, 1.0);
#if UNITY_LIGHT_PROBE_PROXY_VOLUME
if (unity_ProbeVolumeParams.x == 1.0)
rawOcclusionMask = LPPV_SampleProbeOcclusion(worldPos);
else
rawOcclusionMask = UNITY_SAMPLE_TEX2D(unity_ShadowMask, lightmapUV.xy);
#else
rawOcclusionMask = UNITY_SAMPLE_TEX2D(unity_ShadowMask, lightmapUV.xy);
#endif
#endif
return saturate(dot(rawOcclusionMask, unity_OcclusionMaskSelector));
#else
Please tell me is it possible and if yes , How can I reach that ?
Regards, Oliver
Your answer
Follow this Question
Related Questions
Shader Graph: Objects have no shadows opposite the Main Light 1 Answer
Unity Shader Render Queue Causing Various Problems. 0 Answers
Obtaining relative speed of vertex in a shader 1 Answer
Custom Shader in URP 0 Answers
Can ShaderLab be configured to use EXT_shader_texture_lod instead of ARB_shader_texture_lod on iOS? 1 Answer