Archived

This topic is now archived and is closed to further replies.

jaba

Multitexture blend

Recommended Posts

Hello, I''m applying multitexture to an object, this is my code: glActiveTextureARB(GL_TEXTURE0_ARB); glBindTexture(GL_TEXTURE_2D,Texture[0]); glActiveTextureARB(GL_TEXTURE1_ARB); glBindTexture(GL_TEXTURE_2D,Texture[1]); DrawObject(); I don''t know how to regulate the blend of the textures, I want to make the second texture be less visible´ For example, This image made with 3DS Max http://www.geocities.com/opengladiator/pic.jpg left:Two textures, main texture is a photo of bricks and the second is a photo of a lake, reflection with spherical mapping. Both textures are full visible. right: the reflection texture is less visible, this is what I want

Share this post


Link to post
Share on other sites
You'll need to set the alpha value of the texture that you want to have blended.

First initialize that blending:

glEnable(GL_ALPHA_TEST); // enable alpha testing
glAlphaFunc(GL_GEQUAL, 0.05f); // if alpha < 0.05, don't draw pixel
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // enable blending through alpha channel
glEnable(GL_BLEND);

Then you'll just have to load a texture with an alpha-value.

Another way is to combine the current color with the texture and set that color alpha value.

float alphavalue = 0.5f;
glColor4f(1.0f, 1.0f, 1.0f, alphavalue );
glBindTexture(GL_TEXTURE_2D, texture);


[edited by - Vich on May 4, 2003 2:03:30 PM]

Share this post


Link to post
Share on other sites
Thank you, but I have tried with glColor and the object is transparent.

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL, 0.05f);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

glActiveTextureARB(GL_TEXTURE0_ARB);
float alphavalue = 0.9f;
glColor4f(1.0f, 1.0f, 1.0f, alphavalue );
glBindTexture(GL_TEXTURE_2D,texture[0]);
glActiveTextureARB(GL_TEXTURE1_ARB);
alphavalue = 0.1f;
glColor4f(1.0f, 1.0f, 1.0f, alphavalue );
glBindTexture(GL_TEXTURE_2D,texture[1]);

Share this post


Link to post
Share on other sites