libgdx/libgdx — pull request #567 by xoppa (2013-09-07 20:57:56+00:00)
Title: 3dapi: add basic shadow mapping

Small warning upfront: This changes the uniforms used by the DefaultShader, if someone has a custom implementation based on those it probably needs to be changed also. Previously the uniform u_projTrans was set to the Camera.combined matrix, this change sets it to Camera.projection and adds additional uniforms, like u_projViewTrans which is set to Camera.combined.

https://github.com/xoppa/libgdx/commit/9f56fefef0da7512bcff3d5250e50dd390029b1d: add DepthShader and DepthShaderProvider. The implementation is very basic, the glsl files are on the class path (might require a GWT change). Only two options skinned/non-skinned, blending (based on e.g. diffuse texture) is not implemented yet.

I'm not very happy with this solution, but its better than nothing I guess. Implementing a good depth/shadow shader (depth textures, cubemaps) requires a more fundamental change (mainly Texture and FrameBuffer) and can be device specific, e.g.:
- The GL20 interface doesn't provide all LWJGL OpenGL functions (like glDrawBuffers)
- afaik iOS always supports OES_depth_texture (and OES_depth_texture_cube_map?)
- on Android its of course GPU specific, but can be checked against extensions (e.g on my Adreno its a NV extension)

https://github.com/xoppa/libgdx/commit/f36cc96f7a1398470d199047ea4d207a4d46c2e3: add ShadowMap interface (provides a Texture and Matrix4). Added DirectionalShadowLight class, a shadowMap member to the Lights class and shadow mapping to the DefaultShader. Because of above reasons and this being a first draft and likely to be changed, I marked them as deprecated.

https://github.com/xoppa/libgdx/commit/8b702873f2cdc19476c699acb2c6e248ab665987: Add shadow mapping to the Bullet and Animation3D tests.