ext/ffs_engine — pull request #74 by torandi (2014-01-28 20:36:08+00:00)
Title: Deferred lighting

Rewrites the whole light system and adds a deferred pipeline.

"Extras"
========
* Adds shader "material" system.
* Support for stencil buffers in RenderTarget
* mat3 upload support in Shader::uniform

RFC
======
* General API, especially for the layered rendering in deferred.
* Name for the "base" shaders for materials. Atm they are called just that, and located in /shaders/base_shaders

Known issues
=========
* No culling of lights (could be done rather easily, since all non-directional lights now have a length or radius)
* Directional light still have the old shadow issue (but it actually seems a bit better now)
* Spot lights have problems with the shadow bias, we should probably use some kind of slope scale-based depth bias. The flickering seems worst when the surface is orthogonal to the light direction.

Future work
=========
* Use a stencil buffer to prevent doing light pass on full alpha or materials with intensity 1. This could be done with a extra pass with alpha test writing to a stencil buffer.
* Optimize the sky fog color code in the light pass. At the moment it requires the inverse camera matrix to be uploaded, since it must be done in world space. There might be a way to do it in camera space, which would save both the upload and the matrix multiplication (per fragment!).