Due to your comment, you could just render each pass indivually into a texture best done using fbos, using your needed blend function. When more than one color buffer is enabled for drawing, the gl performs blending separately for each enabled buffer, using the contents of that buffer for destination color. Transparency can be achieved by adding the translucent objects color. The dst alpha factor for the fourth argument of glblendfuncseparate. If you had any issues regarding this video, feel free to comment below and ask. Blending in opengl is commonly known as the technique to implement transparency within objects. Function definition void glblendfunc glenum sfactor, glenum dfactor. Specifies how the red, green, blue, and alpha destination blending factors are computed. In webgl, constant color and constant alpha cannot be used together as source and destination factors in the blend function. These equations use the source and destination blend factors specified by either glblendfunc or glblendfuncseparate. The multiply blend mode only supports a grey scale value when using premultiplied alpha. See glblendfunc or glblendfuncseparate for a description of the various blend factors. Transparency is all about objects or parts of them not having a solid color, but having a combination of colors from the object itself and any other object behind it with varying intensity. Weird problem rendering semitransparent image to fbo.
What i do think is that i should use a second glblendfunc which allows to blend the two passes, but i cant think of a way to not touch any of the alpha values, which would destroy the wished effect. How to handle alpha compositing correctly with opengl stack. This demo program demonstrates using pyopengl via pygame for 2d alpha blended texturesprites specified by a vertex array and the standard sdl api exposed by pygame for sound and keyboard control. Visual glblendfunc and glblendequation tool anders riggelsen. Alpha is a 4th color component usually specified at the end. Specifies how the red, green, blue, and alpha destinationblending factors are computed. For example, i have 2 gl textures, where the alpha is on tex1, i want to have alpha in my final image. Incoming source alpha is correctly thought of as a material opacity, ranging from 1. This function sets both the rgb blend equation and the alpha blend equation to a single equation. Specifies how the red, green, blue, and alpha source blending factors a. Specifies how the red, green, blue, and alpha source blending. For glblendfunci, specifies the index of the draw buffer for which to set the blend function.
248 231 834 492 1252 11 708 913 1122 1611 769 602 1527 412 905 48 1563 681 1010 622 1004 496 119 1006 359 452 1628 755 541 885 355 420 911 438 124 659 1485 383