Advertisement

Need help with textureblending (alpha)

Started by November 04, 2004 05:06 AM
4 comments, last by wolf_10 20 years ago
Hi, i have several textures. this is my basetexture: http://www.wr-media.net/tmp/base.jpg my blendtexture: http://www.wr-media.net/tmp/blue.jpg my alphatexture: http://www.wr-media.net/tmp/alpha.jpg an the final: http://www.wr-media.net/tmp/result.jpg an now i try to blend each texture to get my result texture

     glActiveTextureARB( GL_TEXTURE0_ARB );
     glEnable( GL_TEXTURE_2D );
     glBindTexture( GL_TEXTURE_2D, tex[0].GetID() );//base

     glActiveTextureARB( GL_TEXTURE1_ARB );
     glEnable( GL_TEXTURE_2D );
     glBindTexture( GL_TEXTURE_2D, tex[1].GetID() );//blue
     glTexEnvi( GL_TEXTURE_ENV, ?????????? );
     glTexEnvi( GL_TEXTURE_ENV, ??????????);

     glActiveTextureARB( GL_TEXTURE2_ARB );
     glEnable( GL_TEXTURE_2D );
     glBindTexture( GL_TEXTURE_2D, alpha.GetID() );//alpha
     glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,??????? );
     glTexEnvi( GL_TEXTURE_ENV, ????????? );

	glBegin(GL_QUADS);
		 SetTextureCoord(0.0f, 0.0f); glVertex3f(0,0,1);//links
		 SetTextureCoord(1.0f, 0.0f); glVertex3f(1,0,1);//unten
		 SetTextureCoord(1.0f, 1.0f); glVertex3f( 1,1,1);//rechts
		 SetTextureCoord(0.0f, 1.0f); glVertex3f(0,1,1);//oben
	glEnd();

but i dont no the right parameters for glTexEnvi. I have try different ones but that dont works. can anyone help me please????
I would suggest either using a fragment shader to do the blending, or you could add the alphamap to the blue texture and go on from there.
Advertisement
Quote: Original post by lc_overlord
I would suggest either using a fragment shader to do the blending, or you could add the alphamap to the blue texture and go on from there.


I like to use the alphamap in any other textures, and dont like to make the same alpha for all my textures.
glActiveTextureARB(GL_TEXTURE0_ARB);glEnable(GL_TEXTURE_2D);tex[0].bind();glActiveTextureARB(GL_TEXTURE1_ARB);glEnable(GL_TEXTURE_2D);tex[1].bind();glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);glActiveTextureARB(GL_TEXTURE2_ARB);glEnable(GL_TEXTURE_2D);tex[2].bind();glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB);glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PREVIOUS_ARB);glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA);

Where tex[0] is base.jpg in RGB format, tex[1] is alpha.jpg in ALPHA format and tex[2] is blue.jpg in RGB format.

Enigma
thanks you


[Edited by - wolf_10 on November 5, 2004 9:36:50 AM]
mh,
from the blendteture i get only the color but not the 'real' texture :-(


glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture( GL_TEXTURE_2D, tex[1].GetID( ) );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB);


glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); <---- ??? right????
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);<---??? right ????

glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_ONE_MINUS_SRC_ALPHA);

[Edited by - wolf_10 on November 6, 2004 4:15:06 AM]

This topic is closed to new replies.

Advertisement