edge-blending overlap

I want to do soft edge-blending (of 2 projected images from 2 graphic cards, lets say Quadro 3000G) with OpenGL on a 3D engine (60Hz).
(Explanation on edge-blending: here ).
So I want to do blending and intensity (gamma) correction on the output frame. Do you have any idea of the best way to do it with OpenGL (I need performance, then minimize pixel-fill !)?

  • GLSL (fragment prog) ?
  • any extension to access the pixel ?
  • any Opengl instruction (stencil) ?
  • draw to texture then filter ?
    Any examples ?

You probably only have to draw a vertical quad with blending on, mapped with the mask shown on the page you linked.

So you save fillrate for all the untouched parts.

The mask texture would be black, only having the gradient shown on the alpha channel.
A simple blendfunc GL_ZERO, GL_ONE_MINUS_ALPHA should be enougth.

For the gamma etc, simply adjust your alpha gradient. Of course, to have separate gamma correction for each color channel will be a bit harder.

Whether or not it’s relevant, if the two projected images are taken from the two outputs of the Quadro 3000, then the Windows driver is capable of doing the edge blending for you. The overlap and fadeouts can be configured in the control panel. This allows you to simply grab a big framebuffer and not worry about it in your code.

Originally posted by jmaupay:
[QB]I want to do soft edge-blending (of 2 projected images from 2 graphic cards, lets say Quadro 3000G) with OpenGL on a 3D engine (60Hz).

So I want to do blending and intensity (gamma) correction on the output frame. Do you have any idea of the best way to do it with OpenGL (I need performance, then minimize pixel-fill !)?

This won’t do gamma correction for you, but if a constant attenuation factor (per pixel) is sufficient (as it often can be for overlap blending) then you can accomplish it with a blending pass.

  • GLSL (fragment prog) ?

In my experience it is too slow. On faster hardware, and perhaps a tweaked FP, it may be better. (I was using a FX 5700 and barely maintaining 30 fps at 1024x768)

  • any extension to access the pixel ?

not sure what you mean.

  • any Opengl instruction (stencil) ?

I don’t think the stencil buffer is what you want…

  • draw to texture then filter ?

You don’t need to draw to texture, but you could do it that way. If your data is pre-rendered, then drawing and blending could be done in the same pass – maybe not as flexible as drawing first, though.

One way to do it is to draw your scene (however you might do that), and then draw a screen aligned quad textured with your blending texture, using a blending function like this:

glEnable(GL_BLEND);
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, 1.0, 0.0, 1);
… (might want to disable lighting, depth test, etc)
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

unitQuad(); // draws a screen-aligned quad with proper texture coords…

Like ZbuffeR has said, applying this only to the pixels that actually need “fixing” will save you fillrate…

In order for this to work there has to be something in the framebuffer already…(in other words, this will not work as the second stage of a multitexture pass, it has to be done as a second pass)

In my experience it is plenty fast.

-Steve