Scene is rendered from the light’s viewpoint into a texture. Generating the Shadow Map:The “shadow map” (aka a depth map) is just a texture which stores the depth of the scene from the viewpoint of the (directional) light.If you are reading this chances are that you already know what shadow mapping is and how it works, but let me give a quick overview of the steps involved: I looked at his DEngine code as an example. I would like to credit Fabien Sanglard for his shadow mapping tutorials which I used as a basis for my code. Here are the updated images (I changed the color of the plane to get a better contrast): Shadow-mapping is prone to many artifacts, which I wasn’t able to properly fix (UPDATE: Main artifacts fixed).I am posting this without the fix in the hopes that somebody can help me out too as to what I am doing wrong. While my implementation “works”, it does not good look at all.
Given how GPUs on mobile devices (iPhone/Android/whatever) are getting more and more powerful every day I thought I might try implementing it on my Samsung Captivate (Galaxy S). Shadow Mapping is a popular technique for rendering shadows in games and other real-time applications. Updated images below – it works but has very slight artifacts when it comes to the mesh’s self-shadows. Turns out I had dithering enabled, so I had to disable it to remove the dithering effect. Thanks to Henry’s comment below I was able to fix most of the artifacts showing up.
I’ll first link to the apk, source code and the repository:
NOTE: This tutorial builds up on my previous 2 tutorials: how to setup OpenGL ES 2.0 on Android and how to render to texture.