- Home /
How can I get shadow matrices in LightEvent.AfterShadowmap event of directional lights
I'm currently implementing unique shadows for important characters like in the Blacksmith demo, but for deferred path.
For performance reasons(several thousand hair strands), drawing shadow map multiple times is not acceptable. So I'm trying to draw unique shadow maps only once. It will only contains the corresponding character. Then 'inject' the content of cascaded shadow map into the unique shadow map, and then 'inject' the content of unique shadow maps back into Unity's internal shadow maps using CommandBuffers. (The injection can be easily done by drawing a correctly placed and oriented quad and then output SV_Depth with unique shadow map in the pixel shader.)
The problem is: directional light has 4 shadow cascades(combined into one big shadow map). If I draw objects in the LightEvent.AfterShadowmap event, only the last cascade is affected.
Is there any way to get shadow matrices of each shadow cascades(in shaders or scripts)?
(BTW, there is actually an acceptable but not perfect workaround. Just draw 'injection quads' as normal mesh shadow casters, if the light is not the right one, shrink the quad to a point so no pixel will be written.
But the injection is not so 'clean' in this way....)
Hi !
Have you found a way to access these matrices somehow in the mean time ?
Your answer
Follow this Question
Related Questions
Need help with a shader that uses additive particle blending (worked in 4.6; broken in unity 5): 0 Answers
How to get pixelated shadows? 0 Answers
What game objects to declare static? 1 Answer
How to store directional light shadowmap? 1 Answer
Unity graphic looks more Ugly than Unreal engine ? 2 Answers