--- deliantra/Deliantra-Client/TODO 2006/06/04 01:14:02 1.121 +++ deliantra/Deliantra-Client/TODO 2006/06/04 23:05:05 1.122 @@ -92,3 +92,28 @@ set_face 4784 => 73 libpng warning: Ignoring gAMA chunk with gamma=0 + To achieve a more complete blending, you can have your drawing engine rasterize each transparent object more than once, altering in each pass the blending mode, object alpha channel, and buffer write masks. The first pass should perform RGB blending. Accordingly, you should disable writing any alpha channel or z buffer data during this pass. + /*first pass*/ + glColorMask(TRUE, TRUE, TRUE, FALSE); /*disable alpha channel*/ + glDepthMask(FALSE); /*disable Z buffer*/ + if (premultpliedTransparency) + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + else + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + /*render the object here*/ + + On the second pass, you should set the frame buffer alpha channel value to (1- a s )(1- a d ). To do this, you need to render the object again, with a different alpha value, as follows: + /*second pass*/ + glColorMask(FALSE, FALSE, FALSE, TRUE); /*enable alpha channel*/ + glDepthMask(FALSE); /*disable Z buffer*/ + glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ZERO); + /*render the object with alpha replaced with 1-a*/ + + Finally, the third pass should replace the value in the alpha channel with the final value 1-((1- a s )(1- a d )). To do this, you need to render the object again, with its alpha value set to 1, as follows: + /*third pass*/ + glColorMask(FALSE, FALSE, FALSE, TRUE); /*enable alpha channel*/ + glDepthMask(TRUE); /*enable Z buffer*/ + glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ZERO); + /*render the object with alpha replaced with 1*/ + +