PDA

View Full Version : Separate blend equations for FBO color attachments



addmx
06-25-2009, 06:26 AM
Hi

Is there any way to set separate blend equations to differend color attachments of one FBO.
(at least on nvidia 280 class cards with opengl 3.0 support)

Example:
I have fbo with 2 color attachments (GL_COLOR_ATTACHMENT0_EXT and GL_COLOR_ATTACHMENT1_EXT)
and the glsl shader that outputs to gl_FragData[0] and gl_FragData[1].

Now i want the first glsl output to be blended with attachment 0
(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA))
and the second output to be added to attachment 1
(glBlendFunc(GL_ONE, GL_ONE))

How to do the trick ? It is possible ?
I need to out a lot of quads, each should blend with one attachment and add to another - the fragment shader that calculates outputs is non-trivial - so running it 2 times is a big waste of computing power :p

Jan
06-25-2009, 08:09 AM
OpenGL can only enable or disable blending differently on each render target. There is no way to set different blend equations. I actually wrote a post about this myself:

http://www.opengl.org/discussion_boards/...5723#Post255723 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Main=49673&Number=2557 23#Post255723)

Jan.