Monday 23 January 2012

Advanced Lighting

I have been thinking about ways to implement more dynamic lighting.

My previous system required each model to be rendered a second time, where only the transparent areas of the texture would be saved.  (This Render Target is then passed to the Gausian Blur shaders)  The old system also arbitrarily set a specific color, and a fixed intensity for any alpha value.  Since only lights were saved, the old system also was quite buggy if there was a light behind an object.

I am using textures where you can specify the light color, and the parts of the "light" that are brighter (Lamps in head lights, LED truck lights, etc)  Here is a test for this implementation:




 Basic implementation of Advanced Lighting

Now the model is only rendered once.  The entire scene's alpha values are saved into the main Render Target, then a new shader isolates the transparent areas, and then saturates and brightens these light sources depending on the input values.  (Brightness and Saturation should be stored in each model for individual light animations and effects... this may be tricky to implement)  I have made a few different sample lights simply by increasing the opacity in certain areas.

When the initial scene is blended with the blurred light map, the transparent light sources are desaturated and become completely opaque.  This gives a good effect that the lights are "off" when the light intensity is set to 0.  
Further work is still needed for this system. 

No comments:

Post a Comment