texturing a heightmap

hmm… what are good ways to generate a texcoord for a heightmap??

I am using a height as one variable… but this makes all the heights have the SAME texcoord… looks very ugly in my opinion…

my texture file is layed out like this:
first 10% is like bluish watery color
then there is a big grassy texture
then last 20% is sorta like snow texture

any advice would be helpful!

Why not take the simple method and use the x/z (assuming y is your height) values for your heightmap to translate into texcoords?

For example, say your heightmap is from (-128.0, -128.0) to (128.0, 128.0). Make the texcoord for the first corner (0,0) and for the other corner (1,1) Anything in between, calculate as necessary.

That’s assuming you’re not tiling the texture… if you’re tiling that probably won’t work so well.

yes, that’s a good idea…

but the thing is then I can’t put any “snow” in the texture because it might be mapped to the flat ground… Yeah that happens rarely, but usually the higher alts have more snow…

so is there a way to combine the two techniques??

ok, I’ve implemented it… and it seems to work well. But I had to replace the watery and the snow parts of the textures… Is there anyway I can make multiple passes and re-texture the snowy tops??

This may not be the best way to do this, but if the landscape doesn’t change you can possibly pre-blend everything into one texture when the program first starts. If that would mean having a huge texture (bigger than the video card will handle) it may not be a very good idea, though.

You could also probably use multi-pass rendering and use alpha values based on the height. There may be other people with better ideas. I’d be interested in hearing more ideas myself.