简体   繁体   中英

OpenGL: Combining glBlendFunc with glAccum

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 (ie 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM