Jump to content
  • Advertisement

Archived

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

Sabat

How to make transitions between two textures?

This topic is 6929 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

Rendering a landscape, how can i blend a texture to make the transition between two (or more) textures?. I had seen this stuff in some terrain demos. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Do you mean like as you go up the side of a mountain you blend smoothly from a grass to a rock texture ?

If so then you can do it by rendering it twice and having per vertex alpha blending on the second go, ie you have a quad you want to blend the textures across

***********************
***********************
*Grass**Blend****Rock**
***********************
***********************
***********************

So you render it once as all Grass and then render it again, with the alpha values set at the vertices as shown:

0.0
*********************** 1.0
***********************
******Rock*************
***********************
*********************** 1.0
0.0

and using the blend function glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );


so the code would look like:

glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

glBegin( GL_QUADS );

glNormal3f( 0.0f , 1.0f, 0.0f );

glColor4f( 1.0f, 1.0f, 1.0f, 0.0f );
glTexCoord2f( 0.0f, 0.0f );
glVertex3f( ... );

glColor4f( 1.0f, 1.0f, 1.0f, 0.0f );
glTexCoord2f( 1.0f, 0.0f );
glVertex3f( ... );

glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
glTexCoord2f( 1.0f, 1.0f );
glVertex3f( ... );

glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
glTexCoord2f( 0.0f, 1.0f );
glVertex3f( ... );

glEnd();


You could probably also do this by using the multi-texturing extension but i don't know how to do this yet

dan

ps watch out! i think i might have the corners in the wrong order...


Edited by - Danack on 4/27/00 5:33:38 AM

Share this post


Link to post
Share on other sites

  • 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!