PDA

View Full Version : How to avoid saturation with multi-pass lighting?



karx11erx
05-01-2008, 03:33 AM
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. :))

sqrt[-1]
05-01-2008, 05:28 AM
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

zeoverlord
05-01-2008, 07:19 AM
Hi,
(Please don't propose deferred shading, that's not what I am looking for. :))

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.

karx11erx
05-01-2008, 01:40 PM
Thanks.

karx11erx
05-01-2008, 06:13 PM
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.


Hi,

It's possible to get that too, as I describe in this old thread: http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=008447

Same thing in short: Start from white, render with negative colors, modulate lights instead of adding them and negate the final result.

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

Vexator
05-06-2008, 09:21 AM
you need to setup your fbo with a depth/stencil render buffer, like this:

glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, x, y );

karx11erx
05-07-2008, 12:51 PM
I tried that, didn't work.

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

-NiCo-
05-07-2008, 03:17 PM
Don't forget that you also need to bind the GL_DEPTH24_STENCIL8_EXT texture to the STENCIL_ATTACHMENT_EXT target.

sqrt[-1]
05-07-2008, 08:17 PM
Did you try the smooth blend hack I mentioned above?

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

karx11erx
05-08-2008, 01:53 AM
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).