Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / General Programming / Your opinions on the idea. Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

January 30, 2005, 11:10 PM

Ok, i want to use as many opengl lights as i want. So to do this, i thought of a relatively simple loop (its more like a modified version of paul's projects multi-light example). Here is a pseudo code structure, and i need ur opinions whether it is going to work. Btw, i dont care about speed (i will optimize it relative to distance later):

  2. Enable all 8 lights;
  3. for every object
  4. {
  5.         for every 8 lights
  6.         {
  7.                 Set up all 8;
  8.                 Enable blending;
  9.                 Draw that object;
  10.         }
  11. }
  12. disable all 8 lights;

So do you think it will work?

Victor Widell

January 31, 2005, 02:23 AM

The lights should be drawn additively, or they will just replace each other. Also, the texture of your object could be drawn last by multiplying it by the sum of lights.


January 31, 2005, 10:38 AM

OH, so ur saying i should use only ONE model's texture, light it with many lights, and then blend it, making it sort of like only 2 passes?

Oh, and the replacing the attributes of lights is the whole point of the loop. I render all the lights, replacing the attributes each pass. That way i have unlimited lights.



January 31, 2005, 03:11 PM

What Victor means is that during the lighting passes you draw the objects without any textures, using (GL_ONE, GL_ONE) blending to add up the contributions of each set of lights in the framebuffer. Then you make one final pass, drawing the objects with textures but without any lighting, using (GL_DST_COLOR, GL_ZERO) blending to multiply the textures by the lighting values already in the framebuffer. This should save time since OpenGL will need to calculate the textures only once at the end instead of for every light.


January 31, 2005, 08:15 PM

Oh i see what u mean. Thanks. Its a good idea.


Erik Faye-Lund

February 01, 2005, 12:02 AM

well, sure, it'll save a tad of textureacesses, but then again you have the problem of getting correct specular. as specular should be added to the diffuse-pass, multiplying in the texture in the end will give the wrong result.


February 01, 2005, 02:35 AM

Of course this is true. If specular is needed he will have to do all the diffuse+specular passes with textures on. Or go back and add specular after doing the texture pass =/

Victor Widell

February 02, 2005, 11:24 AM

I guess I'm not as clever as I thought. :-)

Still, it could be useful to create a nice "metallic" effect, like the thin, translucent paint on some soft-drink cans. You could also render an enviroment map additively before the texture, to get the right filter effect of the "paint".

in some cases, this method will create some ugly clamping errors if you don't have a HDR framebuffer.

This thread contains 8 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.