View Full Version : absolutely weird blending problem

05-07-2008, 05:19 PM
I am currently implementing per pixel lighting and have created shader programs that can process up to 8 lights per pass (including a lightmap). If there are more than 8 lights for a face, multipass rendering is applied with glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_COLOR) to minimize saturation.

Now as soon as multipass rendering kicks in for a face, the face gets pretty dark instead of brighter as I would expect for that blend mode. Particularly the lightmap doesn't seem to have an influence on the face's color (lightmaps only get rendered during the first pass). Same happens with GL_ONE, GL_ONE which imo should lead to color saturation pretty quickly.

The weird thing about this is that the problem gets worse if more lights are rendered per pass and disappears if only one light per pass gets rendered (in which case blending works fine).

This is when only the first pass is being rendered: The floor face to the left of the Z shaped wall panel is properly lit (no lightmaps involved here).

good blending (http://www.descent2.de/images/temp/good-blending.jpg)

This is with 6 lights/pass, 11 lights total. The floor face to the left of the Z shaped wall panel lacks the green tone coming from the panel. I'd have it expected to be just somewhat darker.

faulty blending (http://www.descent2.de/images/temp/faulty-blending.jpg)

Any ideas?

I can post code if required.

05-08-2008, 11:42 AM
Use e.g. floating point render targets to sum the light, then a tone mapping operator to map the final scene into a displayable range. Pretty standard practice nowadays. Search for HDR rendering.

Btw, use additive blending when summing light contributions, else your results, while they may be in range, are likely to be totally wrong (or more wrong than they would be otherwise).