How to make transitions between two textures?
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.
Multi-texturing? Just a guess as to one way you could do this. Essentially blending textures together.
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
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
Game production:Good, quick, cheap: Choose two.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement