Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Drawing OpenGL into PGraphics with alpha 0.5f produces extremely faint output, more like 0.1f

$
0
0
blendMode(BLEND) (which is the default blending mode in P2D and P2D) just calls glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA). However, I think that a problem in your code is that the triangle pixels are being alpha-blended twice, first with the black background in the pg object and then with the main surface, and this leads to a fainter color. 

If we follow the notation of the article on blending from the opengl wiki, the alpha value of the triangle pixels in the pg surfaces would be:

Oa = sa * Sa + da * Da

where sa = Sa = 0.5, da = 1 - 0.5, Da = 0, because the source and destination blending factors are the source alpha and one minus source alpha (the equation above) and source alpha is simply the alpha of the triangles. So you get:

Oa = 0.25 

Is this correct?

Viewing all articles
Browse latest Browse all 1768

Trending Articles