Advertisement

per-pixel attenuation

Started by August 22, 2004 09:18 AM
39 comments, last by vincoof 20 years, 3 months ago
well I never worked with multipass rendering, I simply loop through all the light and render the faces again, I used GL_ONE, GL_ONE as blendmode..

for(int i=0;i<num_OfLights;i++) {    glBlendFunc(GL_ONE,GL_ONE);    glEnable(GL_BLEND);    RenderFace(faceIndex,i);}


i tried something like that yet... correct me if it is totally wrong :)
www.prsoftware.de
try this:

for(int i=0;i<num_OfLights;i++) {
glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ONE);
glEnable(GL_BLEND);
RenderFace(faceIndex,i);
}
glDisable(GL_BLEND);
Advertisement
JazzD : this is good, granted you have no ambient lighting and no material emission. Also, make sure you don't call glBegin/glEnd outside the for loop. Check for GL errors (call glGetError after the loop and check it returns GL_NO_ERROR).

b3rs3rk : you're talking about smooth additive blending. While it will still work somehow, and probably even give better result than plain additive, it's not how OpenGL's lighting model is specified.

Generally smooth additive is used in cunjunction with particle systems, not with lighting equations. But you're free to do it, as I said it could even look better.
Also make sure you set right depth-testing modes. So that you actuay draw other passes, otherwise you might only see first pass.

A bit of a sidenoe. Addive blending can lead to saturation in area with alot of lights. This can be solved by additional pass. In first n passes you accumulate only light intensitiy, then in n+1 pass you multiply this intensity with diffise(decal) texture. This way you get lighting as color = diffuse * sum[ normal dot light(i) ]. If you allso need specular you just add another n passes after that.
You should never let your fears become the boundaries of your dreams.
i tried it the way berserk said but the whole map is only drawn transparent and only one light is visible still. Also I tried to render every light in the map alone and they are all valid and work. hmmm have to check for the depth testing thing.
www.prsoftware.de
ah thanks darkwing :), the depth function is causing the problem, now I only have to find the right mode, when in GL_LESS the default mode it doesn't work right.
www.prsoftware.de
Advertisement
Either setup GL_LEQUAL for all passes, or setup GL_LESS for the first pass and GL_EQUAL for other passes (and don't forget to restore the depth function after the last pass).

Nice one Mirko ; I forgot to talk about this :) Nobody's perfect. hum.
lequal for all passes works, well now i get all passes drawn, but it's weird, the brightness of the light spots alter when i move arround them, move closer or farther etc... Mhhh could be a problem with the depth testing also :/.
www.prsoftware.de
When you render a second pass, shouldn't you also turn on polygon offset to prevent z fighting? Just like when you render a decal.
Quote: Original post by snisarenko
When you render a second pass, shouldn't you also turn on polygon offset to prevent z fighting?

This shouldn't be a problem since you are rendering the exact same geometry and using position invariant transformation.
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement