tags:

views:

405

answers:

1

Hi,

I've been working on a graphics project doing Depth of Field. The method is doing several passes, each rendering the scene with different near and far clipping-parameters, such that it renders different depth ranges at each pass.

The idea is to apply a blur kernel on each individual layer by rendering to a texture and doing the blur on a rendered quad (with the texture). This is all fairly basic stuff. As is working fine. However, the part I can't get working is the combining of the layers:

The color buffer is cleared with color4(0,0,0,0) before each pass is drawn. However, the accumulation does not seem to allow the usage of glBlendFunc such that it accumulates taking the alpha channel into account (i.e. glBlendFunc(GL_SRC_ALPHA, GL_SRC_ONE_MINUS_ALPHA)).

The question is then: - Does the glBlendFunc affect the glAccum? - If not, how can I work around this?

Based on the documentation, this doesn't seem to be the case as it is not mentioned, however it feels this is a very useful feature.

Regards, R

A: 

Your question doesn't explain why you need blending and accum, so this answer may not be real useful. The accum buffer does not blend. But there are two routes that might be useful:

  1. Most modern hardware can do "Separate" blending, so you can, for example, do an additive operation on the alpha channel while doing real blending on the framebuffer.

  2. Many modern setups will let you render to multiple draw buffers at the same time, sometimes with separate blending modes.

So you might be able to use a second framebuffer via an FBO as sort of a "fake accum buffer", using a blending mode to "accumulate". If you can find a blending mode that is close enough to the accumulate operation you want, you might be able to take advantage of the blend equation.

Take a look at these GL extensions:

http://www.opengl.org/registry/specs/ARB/draw_buffers.txt

http://www.opengl.org/registry/specs/ARB/draw_buffers_blend.txt

http://www.opengl.org/registry/specs/EXT/draw_buffers2.txt

Ben Supnik