Extract Shadows and use as Mask

Hey so i’m trying to figure out how i can extract the shaded part of a object and use it as a mask to lerp between two textures. So when it’s in darkness it uses one texture and when it’s in light it uses another texture.

Anyone have any idea how i could do this?
Thanks.

Shortly speaking, you can’t do that. There is no shadow information at stage where your material is being processed.

A typical workaround is to render a depth capture into a render target from your light’s perspective, and use it in object’s material to determine if this part is shadowed or not, though this is a bit more advanced.

Hm, not sure if this would solve your problem but you might be able to use the “PrecomputedAOMask” node in the material editor. This would allow you to mask out your shaded areas with other textures using the scene’s AO. But this would require lightmaps and would not work on anything movable.

To use this, you first need to enable “Use Ambient Occlusion” and " Generate Ambient Occlusion Material Mask" in the World settings before adding the node to your material.

Hm interesting. Thanks for letting me know this is a step in the right direction! :o