Shaders, Part 3 – Shadows

First of all, Happy Lunar New Year!

Because of this exact reason, I’ll keep this very brief. This is also extended from my last post with my original research.

Also, Because of this exact reason, I dragged the posting time of this one later than a few days to evade posting this on new year’s eve and new year’s day, because working on these two days means very bad luck in the next year.

Picture1

Last week I talked about lighting and lighting techniques. However, sometimes, only light is not enough, whenever there is light, there would be also shadow created by the light projecting onto a surface as one can see from this screenshot taken directly from the notes. Luckily, creating a shadow effect in GLSL is not harder than creating a lighting effect.

Firstly, we need to know the distance of the object in relation to the light source. Since a shadow is created when a light ray is projected on a object surface, the distance of the said object is very important. To measure that, a unique shadow map is created by first rendering the scene from the point of the view of the light itself, then, render the scene as usual but checking if the current sample pixel is further from the shadow map version, it means there is a shadow there, and the shader will draw it. That’s it.

I do believe we’ll learn something more about shadowmapping later on and by that time I’ll revisit this topic as well, until that time.

This week there won’t be a screenshot from a video game since playing games on Lunar New Year week is also a unlucky thing.

Post a Comment