Problems with blending

Started by
2 comments, last by V-man 15 years, 7 months ago
Hi all! I am having some problems with some alpha blending functionality that I am trying to work with. I will try to explain it all as best I can without any images (don't have anywhere to upload to). First off, I have one texture (128x128) which represents an image (can be anything). This texture is RGB. Second, I have an RGBA texture representing a filled circle in the middle. What I want to achieve is this: I want to render the RGB image (first) with the second (RGBA) image so that only the part of the first image that "can be seen" in the circular area of the second image is displayed, the rest is fully transparent (the alpha channel of the second image has this layout, that the outer parts are transparent). I know I can achieve this by using an alpha channel in the first image, but that is not what I want to do. Anyone got any good tips?
Advertisement
I'm no expert, but if I recall correctly, you can just turn off the depth test for that draw, so that the fragments beneath the hole aren't thrown out.
Google for multitexturing. Basically you bind both textures at the same time to different texture units and set up two sets of texture coords. The final RGBA value will be texture1RGBA * texture2RGBA, so your mask texture just needs to be a white circle with an appropriate alpha texture.
http://www.opengl.org/wiki/index.php/Multitexture_with_GLSL
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement