jeudi 12 novembre 2009

Very Fast Fake Radiosity

The concept is very simple:
we have RadiantProbes inside an object (a RadiantObject) which give the lighting information to the world. RadiantProbe are like colored spheres inside an object. We have to just transport the normal of the fragment in the RadiantProbe space, and get the color, fetching with the normal transformed.
My demo shows the concept only, for a real implementation in a game, a hard work with radiant probes sorting has to be done.
An enhancement could be to store with the colored spheres (RadiantProbes) others probes which have geometric information (a depth cube map transformed to SH coefficients), in this case occlusion could be achieved.



I took irrlicht as base.
The main class is CDemo. The core of the algorithm is in RadiosityManager / RadiantObject and in the shader (sh.hlsl).

Each object which emits light is called RadiantObject.
Each Radiant object has a number of RadiantProbes. RadiantProbes can be seen as a colored sphere. At each RadiantProbe, we generate a cube map, transform this cube map into SH coefficients and save them.
In the rendering step, the light manager will retrieve the lights/radiant probes which concern the object to be rendered, and send as shader constant the SH coefficients for this object.
These sources are the base for my framework, of course not finished. I'm doing a musical shoot them up (Battle Mode) in the same time, during my hobby time.
I've interfaced with Lua many things for the game (not seen here).
I have some maxscripts (you can see an example in the project) which generate lua file with data information, for my splines, enemy wave, weapons specs etc. The RadiantProbes will be exported in the same way.

source on google code here:
http://code.google.com/p/fakeradiosity/

Aucun commentaire: