Possibility of a new node for Eevee that tells you whether the fragment is shadowed or not, per light

Hello, would this be possible? before looking into the source code and the structure, I would like to know if there would be any issues with this feature: test the per light shadow maps against the fragment depth, and let the users access an is_shadowed boolean result through a node (with a light selector).

My motivation is, for example, to make fake volumetric effects for lights that are also dynamically occluded instead of being static: e.g. a surface resembling the cone of light with an alpha blended texture and an emissive shader, which is cheaper and easier to stylize than actual volumetric shading. This effect could be achieved with vertex or texture paint right now, provided the occluding geometry is static, but I wanted a more general solution to this problem.


I’d love this is cycles. Also you can break the scene into render layers with different light in each. Enabling the shadow passes should give you that kind a control. BUT. It’s not a shader thing and it’s going to take way longer to set up each time.

I like the idea of some compositing in the shader level. Maybe a bunch of simple filters could be applied to shaders. Like blur on a transparent shader. That acts like a blurring mask in 3D space. Without a need for compositing.

Technically this is possible, but I am not sure this is the right way to solve the issue. What would be a good use case what you want to solve?

In EEVEE the shader might get undesired results when using soft lights. When softlights are enabled, the edges of a shadow could get in shadow for some samples and not in shadow for the other samples. Using post processing in the compositor would get better results as you have more control on how to mix the edges.

Related solutions would be light groups and light linking.


Here is an image illustrating what this would be useful for. The fake volumetric effect is done with a surface with an emissive shader (it resembles the spotlight cone). But it can’t be occluded so the effect is very limited.

I agree that some features like fading the effect near the intersection would be more easily achievable with the compositor, but that would require setting up a new, to be implemented, separate shadow pass for every light with this effect (since the current Eevee shadow pass won’t give you anything in this example). If done on the shader itself, it would be just a matter of setting up the material once. For the fading, Unreal 4 has a node called Depth Fade that handles such issues: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/ExpressionReference/Depth/index.html , so it would be doable.

As a side note, some first attempt at occlusion can be achieved with the Shader to RGB node, but it’s still considering all lights, and trying to derive occlusion from shading seems silly considering you should already have the occlusion info itself at that stage.

In any case, I just wanted to know, before digging and investing time into it, if it was possible or if there was a conflict with the way Eevee implements shading.

1 Like