PDA

View Full Version : Transparency/color masking blending help!!



RS543
04-06-2009, 08:20 PM
I'm currently making a particle editor for a game I'm working on for school and I have implemented color masking. I tried implementing transparency and I can either get one or the other working now but not both and I can't seem to find any information on how to do both simultaneously. Any help would be appreciated!

Thanks


Gl.glPushMatrix();
Gl.glColor4f(CurrentColor.x, CurrentColor.y, CurrentColor.z, Opacity);
Gl.glTranslatef(Position.x, Position.y, Position.z);
Gl.glEnable(Gl.GL_BLEND);
Gl.glDisable(Gl.GL_DEPTH_TEST);

Gl.glBlendFunc(Gl.GL_DST_COLOR, Gl.GL_ZERO);

//draw mask texture
Gl.glBindTexture(Gl.GL_TEXTURE_2D, Owner.TextureHandles[Owner.MaskTextureID]);
DrawQuad(quadsizeX, quadsizeY);
Gl.glBlendFunc(Gl.GL_ONE, Gl.GL_ONE);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, Owner.TextureHandles[Owner.TextureID]);
DrawQuad(quadsizeX, quadsizeY);

if (Owner.FadeType != 2)
{
Gl.glBindTexture(Gl.GL_TEXTURE_2D, Owner.TextureHandles[Owner.TextureID]);
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
Gl.glCullFace(Gl.GL_BACK);
DrawQuad(quadsizeX, quadsizeY);
Gl.glCullFace(Gl.GL_FRONT);
DrawQuad(quadsizeX, quadsizeY);
Gl.glDisable(Gl.GL_CULL_FACE);
}
Gl.glEnable(Gl.GL_DEPTH_TEST);

Gl.glDisable(Gl.GL_BLEND);

Gl.glPopMatrix();