alpha

OpenGL - don't write depth if alpha

孤人 提交于 2019-12-04 19:13:05
What I'm want to do in OpenGL using C++ and GLSL: When texture has alpha (texture.a! = 1.0;) then this pixel is not written to the depth buffer. (for color buffer it is written) Write depth occurs only when a pixel texture.a == 1.0; Discarding in shader is not a solution - then this pixel is not written to color buffer. Any ideas? @UPDATE: Example: I've got some UI images rendered by OpenGL. Some of them have alpha in corners. In scene rendering I have "depth prepass" to save some pixels by not calculating light on them. I want to also get UI images to that prepass - but only completely opaque

Alpha blending a red, blue, and green image to produce an image tinted to any rgb value?

﹥>﹥吖頭↗ 提交于 2019-12-04 18:50:16
Basically, I have a context where I can't programatically tint an image, though I can change it's alpha value. With some experimentation, I've found that I can layer a red, blue, and green version of the image, with specific alpha values, to produce a wide range of colors. However, I am wondering if it's possible to achieve a true RGB representation through this method? If so, what is the formula for converting an RGB value into different alpha values for the red, blue, and green layers. The basic "equation" of alpha combination is: alpha * (R1,G1,B1) + (1-alpha) * (R2,G2,B2) When you have