Friday 22 February 2013

Deferred Rendering Fixed!

Finally! I managed to get deferred rendering to work nicely, without lighting artifacts! Also added some nice stuff to fix weapons jittering around and to allow for undecorated, native resolution windows on desktop :)

For the more technical minded of you heres some information about my deferred rendering woes.

Due to aiming the game to eventually work on android I need to make it compatible with OpenGL ES 2.0, and therefore I cannot use MRT for deferred rendering. This is a massive bummer, but seeing as I want loads of light sources in scenes (lots of torches, flashy spells, shiny weapons, glowy stuff) using a forward rendering approach is not feasible. For example, to get the same lighting quality, the cost for each approach is:

Deferred Rendering cost = Objects * 2 + Lights
Forward Rendering cost = Objects * Lights

As you can see deferred is much cheaper (btw with MRT that would be Objects + Lights).

So, without MRT I am limited to a maximum of 4 x 8 bit channels (rgba) output per scene pass. Obviously I'd prefer to keep the passes to a minimum (i.e. 2) so I settled to only being able to output the normals and the pixel depth (so that the position can be reconstructed). Now normals are 3 dimensional, but depth requires more than 8 bits or it'll have artifacts when reconstructed due to rounding errors. Obviously an issue with only 4 channels :p

This site to the rescue! After much googling I came across this site, with information for packing normals in 2 channels, leaving me 2 channels to pack depth into. Yay! Problems all soved! Woot!

Anyway hoped you like that narrative :p I'm off to work on more UI Screens (boring but necessary) so sometime soon I should be able to have a new and improved build of the game out for you lot to try :)

No comments:

Post a Comment