Ambient Lighting Research
Previously I talked about the idea of implementing a new "Ambient Point Light" into the engine. This would work by rendering the surrounding environment to a cubemap, just like a regular point light does. However, this type of light would render to a color buffer instead of just a depth buffer.
The light could then be rendered to display ambient reflections and soft lighting on the surrounding environment. While it would not provide perfect real-time reflections, it would give an extra boost to the appearance of scenes that make heavy use of reflective surfaces.
One of the problems in this type of system is how to handle overlapping lights. It would look weird to have an area where two lights are combining to make the ambient light or reflections brighter.
I found a could create a new "lighten" blend mode with the following code:
glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_MAX);
This ensures that a light will only brighten a pixel up to its own value, and never beyond. If the pixel is already brighter than the light color it will have no effect. Below you can see two spotlights using this new blend mode. Notice that the area where the two lights both illuminate is never any brighter than either one.
This also means soft ambient lighting will only appear in dark areas, and will have no effect on brightly lit surfaces, as it should.
- 5
4 Comments
Recommended Comments