PDA

View Full Version : some question about blending



Lee_Jennifer_82
11-05-2015, 06:11 PM
I was just taking a look at the following tutorial:

http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-10-transparency/

But a bit confused at the end. It tries to draw a red rectangle on the top of a blue rectangle with alpha value 0.5;

In the end it calculated the final color (orange) as follows:


New color in framebuffer =
current alpha in framebuffer * current color in framebuffer + (1 - current alpha in framebuffer) * shader's output color



next it does computation as follows:



new color = 0.5*(0,1,0) + (1-0.5)*(1,0.5,0.5); // (the red was already blended with the white background)
new color = (1, 0.75, 0.25) = the same orange <-- confusion here;



Should not the new color be: (0.5, 0.75, 0.25)

Could any one clarify me?

Thank you.

Alfonse Reinheart
11-06-2015, 05:38 AM
Should not the new color be: (0.5, 0.75, 0.25)

Given the math shown, yes.

Lee_Jennifer_82
11-06-2015, 08:59 AM
But when red is at top, shouldn't be the red component more prominent? The resulting color (0.5, 0.75, 0.25) shows green is prominent here.

GClements
11-06-2015, 10:30 PM
But when red is at top, shouldn't be the red component more prominent?
Yes.

That tutorial seems incoherent and self-contradictory. I suggest looking for a better tutorial.