How to avoid saturation with multi-pass lighting?

Hi,

is there a way to avoid saturation with multi-pass lighting (i.e. where a triangle is rendered N times for N light sources affecting it, using glBlendFunc (GL_ONE, GL_ONE) for each except the first pass)?

(Please don’t propose deferred shading, that’s not what I am looking for. :))

The correct way is to use a floating point render target then tone map.

For older hardware there is a hack called smooth blend:
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Board=3&Number=134442

You right it’s not, if your stuck using RGB8 then the only way is to lower the intensity of the lights, but more importantly reduce the number of lights used at any one point as no more than 4-5 is ever needed (Main with ambience, limited area, fill, highlight and effect if your doing that stuff).

but as sqrt[-1] said the best way is using floating point textures.

Thanks.

Either I have understood something wrong, or I cannot render volume shadows if I use a texture as render target (to get an fp render target). Binding a stencil buffer to it failed when I tried to.

The link is dead. Someone mind explaining this to me a little more detailed? I cannot figure it from that short remark.

you need to setup your fbo with a depth/stencil render buffer, like this:

glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, x, y );

I tried that, didn’t work.

I’d like to know more about that inverse blending technique.

Don’t forget that you also need to bind the GL_DEPTH24_STENCIL8_EXT texture to the STENCIL_ATTACHMENT_EXT target.

Did you try the smooth blend hack I mentioned above?

First geometry pass : ONE, ZERO
all other passes: ONE, ONE_MINUS_SRC_COLOR

Yes I did, thanks for the hint. I have run into problems when using multi-light per pixel shaders with that method though (see other thread).