Jump to content
  • Advertisement
Sign in to follow this  
cforlife

Multitexturing 2 textures 1 with alpha

This topic is 5469 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a problem finding what paramiters to use with multitexturing to blend two textures. The first texture is a rock texture that will be repeated over the whole terrain. The second one is a low detail texture that will be streched over the whole terrain and will have an alpha channel in it. Where the alpha is less than one in the low detail texture it should blend with the rock texture. So the over all goal is to have some parts of my terrain with rock showing through, like on a side of a hill. [Edited by - cforlife on September 26, 2004 11:08:21 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by cforlife
I'm having a problem finding what paramiters to use with multitexturing to blend two textures. The first texture is a rock texture that will be repeated over the whole terrain. The second one is a low detail texture that will be streched over the whole terrain and will have an alpha channel in it. Where the alpha is less than one in the low detail texture it should blend with the rock texture. So the over all goal is to have some parts of my terrain with rock showing through, like on a side of a hill.



I had almost the same problem as you, cept i was doing 1 base texture and multiple detail textures over it.

the thread is here

you just wouldn't need to modulate with the detail texture and just replace it.

Hope that helped

Share this post


Link to post
Share on other sites
This should do it:


// Your diffuse texture 1
glActiveTexture(GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);

// Your detail texture with alpha
glActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_ONE_MINUS_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);



Note: Might have to swap GL_ONE_MINUS_SRC_ALPHA with GL_SRC_ALPHA if the rock/detail texture turn out to be backwards.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!