From: Phil Keslin (philk++at++cthulhu.engr.sgi.com)
Date: 01/26/2000 23:03:46
"Paik, Charles C" wrote:
>
> Hi,
>
> I am rendering a scene with 2 different sets of material properties. I
> would like to display the scene as if the scene was rendered separately and
> additively superimposed. My thought was that the accumulation buffer would
> be ideal for this application. I could render each scene independently and
> use the accumulation buffer to mix the imagery. However, it seems that
> there is a serious performance penalty with the accumulation buffer.
This works so long as the sum of the rendered pixels is not outside the range [-1,1]. Since the results of your
rendering will be in the range [0,1] and you are doing an add, the resulting operation could result in pixel values in
the range [0,2] which will be clamped to [0,1].
> I used an onyx2 at 1280x1024 resolution as a test bed. It seems that it
> takes approximately 3.5 ms for each glAccum operation. In my experiments, I
> would
>
> 1) Render the scene with the first material property to the color buffer,
> 2) Copy the color buffer to the accumulation buffer,
> 3) Render the scene with the second material property to the color buffer,
> 4) Additively transfer the color buffer to the accumulation buffer, and
> 5) Copy the accumulation buffer back to the color buffer.
>
> There are three transfers between the color and accumulation buffers (Steps
> 2, 4, & 5). Those three steps have caused an additional 10.5 ms of fill
> time. 10.5 ms is a very heavy hit for my application.
>
> My next thought was to render the second scene directly in the accumulation
> buffer, and additively transfer the accumulation buffer back to the color
> buffer. But I do not know how to do either of those steps. (Or even if it
> is possible.)
>
> Can anyone offer any suggestions? I am open to any hints, hacks, or
> altogether different approaches. Thanks.
Why not just use the blender (see glBlendFunc for more information). Through careful selection of the constant alpha
term in the blend equation, you should be able to create the effect you desire without the copy overhead of the
accumulate operation.
To affect the operation you requested (without alpha multiplication), just do...
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_BLEND);
... render your scene with the second material.
If you really to need the pixel values to be scaled, you can use a constant alpha and the following.
glBlendFunc(GL_CONSTANT_ALPHA_EXT, GL_ONE_MINUS_CONSTANT_ALPHA_EXT);
glBlendColorEXT(0, 0, 0, .5); /* don't really care about rgb here just alpha */
glEnable(GL_BLEND);
You can vary the alpha factor to better suit your needs.
- Phil
-- Phil Keslin <philk++at++engr.sgi.com>
This archive was generated by hypermail 2b29 : Wed Jan 26 2000 - 23:04:03 PST