logo

Moth Mansion - Shadow Occluders

time2 d agoview2 views

I have spent a good deal of time learning about shaders while working on this project. One of the things I would like to have are fake-3D shadow shaders. The game will require a lot of playing around with lighting, so it would be great to have crispy looking shadows.

In this case the approach in the shader is to periodically generate a texture around each object which encodes in RGB where a potential occluder is, only for the shader to then run a ray between the point of the shadow and the source sprite. If the ray ends up in the red field of the texture, it assumes that the shadow has been blocked and does not draw it.

You can see what happens when the occluder texture gets disabled at the end of the video.

Loading comments...