I'm working on a shadow-mapping implementation for an OpenGLES 2.0 environment (Stage3D in Flash to be exact). This is how my current implementation works:
- Render the scene to backbuffer.
- Render depth map from the light's point of view.
- Render shadows on a texture from the camera's point of view.
- (Do blur and other effects to improve the shadow texture, not implemented yet)
- Render the shadow texture to the backbuffer with multiply.
Some pictures to help explaining. Note that the bunny is floating in the air on purpose.
Shadows rendered on a texture from the camera's view.
The final scene with shadow texture rendered on top with multiply.
The problem is the unshadowed pixels at the bottom of the bunny. Because the shadow texture is rendered with linear filter, the edge of the shadow loses its sharpness. This is mostly a good thing but not everywhere. I would like to do more filtering effects on the shadows but they would cause even bigger issues.
I haven't encountered this kind of problem in any tutorials or forums so either there is an obvious solution for this or there is something wrong with my approach. The question is, can I solve this somehow using my current approach? Or is there a bigger gap in my method?