I am rendering 4 vertices (a square) in front of a colored cube. The vertices are colored white, but are blended at 0.5f.
Please could someone tell me why the colored cube appears brighter when obscured by the semi-opaque square?
Cube rendered without square in front:

And, rendered with the square:

Please see the code used to create the colored cube, the code used to actually draw the cube, and the code where the cube and square are rendered.
This is the code in my init function:
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
-
I'd say it's because your semi-transparent square gets added to the existing pixels, thus incrementing their intensity.
The documentation for
glBlendFunc()recommends setting the second parameter toGL_ONE_MINUS_SRC_ALPHA, that is the boilerplate for implementing transparency. Try it.Karl : Yeah, looks like a white translucent square, I don't see the problem.nbolton : Excellent, thanks! GL_ONE_MINUS_SRC_ALPHA fixed the problem.
0 comments:
Post a Comment