I’ve looked through all the old topics on masking and blending but none of them help me much.
I have a dynamic alpha map that needs to be combined with an RGB texture.
I’m using multipass rendering and cannot use RGBA or multitexturing due to the dynamic alpha maps and many texture layers that I will add later.
So far I have placed my alpha map onto the primitive (pass 1) and then I blend my texture onto the primitive using the previous passes alpha map as the transparency (pass 2).
However it doesn’t work and I can’t figure out why.
Here is my code.
// Sand texture loaded in RGB format
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, Image);
// Alpha map loaded in ALPHA format
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512, 512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, Image);
glColor3f(1,1,1);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, AlphaMap);
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0,0);
glVertex3f(0,400,0);
glTexCoord2f(0,1);
glVertex3f(0,0,0);
glTexCoord2f(1,0);
glVertex3f(400,400,0);
glTexCoord2f(1,1);
glVertex3f(400,0,0);
glEnd();
glDisable(GL_TEXTURE_2D);
// sand
glBlendFunc(GL_SRC_COLOR, GL_DST_ALPHA);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, SandTexture);
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0,0);
glVertex3f(0,400,0);
glTexCoord2f(0,1);
glVertex3f(0,0,0);
glTexCoord2f(1,0);
glVertex3f(400,400,0);
glTexCoord2f(1,1);
glVertex3f(400,0,0);
glEnd();
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
My blending equation should be :
(Dr; Dg; Db; Da) = (SrDa; SgDa, SbDa; SaDa)
Why doesn’t glBlendFunc(GL_SRC_COLOR, GL_DST_ALPHA) seem to work?
Paul
[This message has been edited by surgptr (edited 05-05-2003).]