blending function problem with halo-effects

Hi. I’m currently trying to render some visual links (lines) with a nice halo-effect.

My lines are produced as quadstrips. What I’m trying to do now is to render the line twice, the second time with a higher width and less alpha.

This looks OK, but my problem is the following: At the nodes where one line is splitted up into many, the halo get’s too opaque. This is because there are many lines on top of each other, so the alpha values are adding up.

Here is a picture. Or three pictures in one. :wink:

(you should be able to klick on the thumbnail to open it at full size)

The first picture is without halo, so you can see where the lines split up and what causes the problem. The other two pictures show the unwanted effect, with and w/o comments.

I hope this gives a good picture of my problem. I want to get rid of this effect or at least reduce it to a maximum. I guess this should be manageable through blending functions. I already tried some, but couldn’t get the wanted results.

Maybe you guys can help me. Thanks!

P.S.: I also tried the method described in NeHe turoials (lesson 36, radial blurr) but didn’t get this to work. There are some problems, because the lines are not drawn at once and… so the described method above is how I want to solve this problem now. I already spent too much time on the render-to-texture approach. Many thanks guys.

You could use the stencil buffer. Write to the stencil buffer when you add a halo, then when you draw the next one, make sure that you did not already draw a halo there.

Just an idea, using some extensions I have no experience with: glBlendEquationEXT with GL_MAX_EXT . Clear a RGBA FBO to (0,0,0,0). draw the yellow stuff on it with the gl_max_ext blending mode. Draw that fbo’s texture onscreen via regular alphablending.

The stencil approach might not be able to handle some artifacts even if you make it 8-bit with comparison+conditional pass, I think.

Hey guys, thanks for your tipps. I will try these tomorrow and will report back in.
(Tomorrow because of the fact that I’m european and Champions League Group Stage starts in 30 minutes :wink: )

Couldn’t get this to work so far. glBlendEquationEXT isn’t supported by JOGL (I’m programming in Java and use the JOGL Binding).

If GL_MAX and glBlendEquation (which have been added to core) are inaccessible, then the post-process method is your only way.

The proposed stencil idea will work very nicely to prevent overdraw on the transparent lines. You will have to draw ALL lines of a given transparency with the requisite stencil write and test. Then clear or change the reference value for the next width & transparency.

Zbuffer would also work.