Jump to content
  • Advertisement
Sign in to follow this  
psyjax

Texturing a Heightmap

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

Hey all, In my game I have a large overworld heightmap I created. The map is stored as a 2D array of 3D points that is: Point3D **WorldMap; To render the map, I just itterate thrugh this and push the points off to the renderer, works great! Now the problem comes when trying to texture the thing. I have explored two options, either using one large texture streateched over the whole map, or use lots of tiny textures "tiled" over the map. When I did the "tiling" method I got better results, so I decided to go this route. Now, I want the tiles to vary according to the height of the given ppoint on the map. So rock tiles will apear on mountains, grass on plains, etc. Do you guys have any advice on how to go about doing this? My initial expiriments with this led to less than stellar results.

Share this post


Link to post
Share on other sites
Advertisement
Just do several rendering passes,each time using a different texture.
Say the first rendering pass is with a rock texture.Calculate for each vertex the blend factor. For this case, say it's 0.0 for lower and 1.0 for highest. Set the color of each vertex to this factor, and render the scene. Do the same with other kinds of materials, and use additive blending of course.
The rule is, all the factors of all the materials should have a sum of 1.0 for every vertex.
I suppose you can make several rendering passes collapse into one with multitexturing later, but I think that's a start.
Also, google for "texture splatting" to get more details about the subject.

Share this post


Link to post
Share on other sites
i myself too would love to learn how to do this...but not only achieve what you are looking for but also do it effeciently and an "interpolation" if you will between textures.. for instance.. lets say you have height ranges that change between 2 vertices. the height ranges differ from lets say mountains to hills. well you could just place a tile of a mountain texture on one side and the hill texture on its side. but wouldnt this look blocky? i think thats what you mean by additive blending..?

also what about simply making a 1-D texture? how would you do this and would this be easier? the idea is to create an array of colors for the texture and then use that to color your heightmap based on height values.. i like this idea but have really no idea how to implement it. i hope we can converse more on this and hopefully i at least gave you some ideas or thoughts.

Share this post


Link to post
Share on other sites
Hi,

Heightbased texturing can be taken to the next level by using detailmaps...


have a single texture for the whole terrain say a 128 X 128 base texture for the whole terrain....


now have another detailmap grayscale texture... which is multitextured on say a Y x Y grid in the camera direction where you apply multitexturing with the gray scale texture...this basically blends with your base low res texture and looks like you can see cracks and all ...

another multitexture technique can be ... you use four or five textures like snow, rock, mountains etc... and generate a single texture which has different textures belnded in a single continous strip... so depending on theheight of the point just access (0.5, height / maxHeight) on this texture map...

Share this post


Link to post
Share on other sites
Hey all!

Thanks for teh replies!

Texture Spaltting is it? Well the principal sounds pretty sound, but I can't seem to get my blending to work that way.

My blend function looks like this:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glAlphaFunc(GL_GEQUAL, 0.0f);
glEnable(GL_ALPHA_TEST);

I guess Im asking... What should it be :)

Because in this mode it works great for PNG files that are transparent, but I cant seem to make any other textures transparant by just tweeking the alpha. Any ideas?

Also, I tried looking into the DigiBen Multitexturing tutorial, but couldn't get it to compile in Dev-C++ with SDL.

Not sure why... After looking at the code, it seems its calling some OpenGL headers I don't have installed. Are there separete libarys for ARB extensions which need to be linked to?

Thank you all for your valuable input.

Share this post


Link to post
Share on other sites
Texture splatting is definatly the way to go for high detail texturing on terrains. Google should point you to Charles Bloom's original splatting description. It works well with most LOD methods as well I've found, you can see some shots of my own implementation here: http://www.gamedev.net/community/forums/topic.asp?topic_id=272151

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!