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
Hi, thank you for the quick and thorough reply!

From your response and from reading the link, I see what is going on now, and I see two options for getting what I'm after:

A: knowing from advance the number of times the drawing will be made, and calculate an initial alpha value to counter that, so that the final transparency is the desired one, in this case 0.5.

B: from reading the OpenGL wiki article, I found a mention of this:

It is often useful to perform premultiplied alpha blending. This means that texture values have multiplied the alpha with the texel before accessing it (or in the shader). So you don't want to multiply the source color by the source alpha, as this has already been done for you by the texture. So the setup for this is as follows:

glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);

...which to me sounds like what I'm after. While I made some attempts to make use of these functions before drawing my images it didn't work, obviously(?) because Processing is doing a lot behind the scenes which prevents jumping back and forth between opengl calls and Processing calls.

The last thing that I might do, is fetch and read the relevant code of Processing 2.0.2, since it does something wrong, but closer to what I want for some reason, probably due to a bug in blendMode that has since been fixed in 2.0.3 :)

Also thank you for not telling me to STFU and RTFM but instead giving me a good reply when of course what I've been talking about is not a bug at all, your pedagogic attitude is what makes Processing's forum a good place to be at!

Best,
Onar3D

Viewing all articles
Browse latest Browse all 1768

Trending Articles