This is an experiment for a research I did in one of my course. I took a paper about an enhanced algorithm to create a 'proper' shadow mapping, reference can be found here. So I did an experiment doing a shadow mapping from scratch, try to understand how a basic traditional technique of shadow mapping can be done. I enhanced my program to do a shadow mapping feature. I hasn't done yet but its getting somewhere indeed :)
This is the result of a shadow mapping algorithm:
The half left is the light from the top of the scene. The right is the light from the top right of the scene. In short explanation, the shadow mapping technique is quite simple: you get the image from the light point of view, get the frontmost pixel and save it as a texture, go to the eye point of view, compare the pixels using the z-buffer, if its 'lower' then the first texture, draw as a shadow. And the last part is to draw everything else that are not shadowed.
This algorithm however, is full of artifact, depends on the scene. This is the first half zoomed version so you can notice the artifact:
As you might notice, the resolution of the shadow is low. That because the near frustum of the light is too far, so the light details of the scene captured from light point of view is low. This can be solved by an advanced method, for example the one that explained here. Next step: Shadow Mapping in GLSL. Stay tuned :)
Special thanks to Paul's Project for the reference and libs.
Update: Made a few tweaks according to the paper stated before, and got a pretty nice result to remove those artifacts. This is the result after modifying near and far plane for the shadow mapping:
Notice that the border of the shadow are much smoother in this version. This tweaking however, does not run automatically, means a different scene may require a different value.
Also notice that this is a texture, so zooming the view creates more artifact. But I think thats the best you can get for a real time rendering.
You can see the comparison video here. Notice that it runs smoothly at 60 frame per second. The jaggy experience caused by bad screen recording.