Texture mixing with a gradient of Alpha Values?

Hello,

This question may be tough, or may be easy, but I’m not sure how to do it so I thought I’d ask.

Let’s say that I want to create a terrain, and the interface between two parts of the terrain, say rock and grass, need to be smoothly mixed at a certain height, so that the rock slowly fades into grass as you get to lower heights until you get to pure grass. So, it goes from rock, to mixture rock & grass, to grass. I want to use the alpha value to make sure that the percentage of mix changes appropriately according to height.

I’d use multitexturing for this.

How could I create an alpha value on the fly when out putting using the height as the determinate of value?

I’m not sure how to do this as I’m outputting quads are triangles thus:

glBegin(GL_QUADS);
//out put textured quad here
glEnd();

Thanks for any response or if anyone has any other ideas that’d be great as well!

[This message has been edited by Archimedes (edited 03-16-2003).]

I can think of several ways:

  1. generate the alpha as part of the vertex color
  2. use TexGen to generate an offset into a texture map
  3. use a “mix map” texture map that’s coarsly mapped across your terrain and determines how much of each other texture to use

Originally posted by jwatte:
[b]I can think of several ways:

  1. generate the alpha as part of the vertex color
  2. use TexGen to generate an offset into a texture map
  3. use a “mix map” texture map that’s coarsly mapped across your terrain and determines how much of each other texture to use[/b]

Thanks for your response.

I have a general idea of what you’re referring to, but I guess what I’m looking for are very concrete specifics. How do I get the alpha value to change according to height when I output a simple quad, say.

For instance, if I have a rectangle in three space and I want the positions with the higher y values (heights) to have more of one texture.

The code would be between glBegin and glEnd.

glBegin(GL_QUADS);

glEnd();

[This message has been edited by Archimedes (edited 03-16-2003).]

this is really interesting…

Originally posted by jwatte:
3) use a “mix map” texture map that’s coarsly mapped across your terrain and determines how much of each other texture to use

…could you write more about “mix map”, please

I guess he means a texture that encodes in its RGB components the contributions of the other textures.

Ex.: say you assign the R component to grass, G to sand and B to rock, then

R=0.2 G=0.3 B=0.6

Means a blend between a little grass, a bit more sand and a lot of rocks.

Y.

could you tell how to implement it? (because i just can’t realize which gl calls could do effect you described?)

Originally posted by miko:
could you tell how to implement it? (because i just can’t realize which gl calls could do effect you described?)

Shameless plug: http://www.delphi3d.net/articles/viewarticle.php?article=terraintex.htm

– Tom

hmmm that could work…