View Full Version : A new way of color blending

06-20-2003, 06:17 PM
I was looking through the Fragment Program specs and began wondering. Is there a way to determine the color of a destination point? When using color blending, there is a source and destination, the source being the incoming color/fragment. I want to know if a fragment program can use that color, along with its alpha value and depth in calculations. The first and probably obvious reason for this is to make my own color blending routines.

Next, I have some ideas on transparency and refraction code I would like to try out, but I need to be able to know what the color "behind" an incoming fragment is. Any thoughts or suggestions? Thanks. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

06-20-2003, 06:58 PM
Do ping-pong rendering to two offscreen textures.
1. When rendering to the 1st texture, bind the 2nd texture to read RGBA values at the current window position (WPOS) and combine them with your incoming fragment RGBA values.
2. Then render to the 2nd texture and bind the first texture to read the accumulated RGBA values at the current WPOS.
3. repeat

Ping-pong blending is required because you cannot read and write to a texture at the same time.

Hope that helps,

06-20-2003, 07:58 PM
Using GL2 fragment programs, you can read the colour/depth/stencil values from the existing fragment in the framebuffer.