Download

using shadow in material

Hi guys,
I was wondering if it somehow possible to get the shadowmap into the materials and do something with it. Or someone knows how to fake shadow cast within a material.

What I want to do is:
I noticed one sunny morning that the dust on old wood is lit, it looks really fuzzy and velvet, while in de shadow area and self shadowing area the same wood doesn’t look fuzzy.
It kind of makes sense that the very tiny dust particles are lit and gives this velvet cloth like shining.

I know that I can try to use fresnel to fake this behaviour and use some math to remove the fresnel from the self shadowing part, but the fresnel remains on the casting shadow area.

Any tips, tricks etc on this approach would be helpful!
Best regards! Tom

Hi Millionviews,

I was looking for the exact same thing and I think I found it when checking the shader source code:

066af1fb3561d187b92bf1684f3e3c8354240981.jpeg

This results that even unlit materials can have shadow information. With the custom node you can configure your material to behave different in lighted and shadowed part.

02b686aae29a4d44b30202510fd68a4214314a3b.jpeg

I’m using Forward Shading, not sure if it works with Deferred Shading too.

wow, nice trick!! I just tried but it indeed does not work with deferred shading. I not sure, but I guess it is because that lighting data is just not there during the material / shading setup, while in forward mode it is there. Hopefully there is any other magic? Because this kind of tricks are just really usefull to have.

Hi, I’m trying to use this on the mobile renderer, but I’m having some issues. Does this still work for you in 4.20? The ScreenPosition node has changed. It now outputs two options: ViewportUV and PixelPosition. When using the ViewportUV output, I can see the shadow map, but the shadows are located in the wrong location (like it’s just reading straight from the shadow map rather than projecting it into the world). Since I’m able to see the shadow map, I’m assuming I can get it to work if I feed in the correct UV’s.

This doesnt seem to work. I think the sample its ok, but the coord are wrong.

anyone know how to get this to work in forward shading in v23?
I tried this custom node and

I don’t know any hlsl so I’m not even sure if I’m implementing it correctly

This is exactly what I’m looking for. Has anyone updated this?

We’re in 2020, and this doesn’t work anymore.

Would be much appreciated to know if there is a new solution to the problem ?