Jump to content
  • Advertisement
Sign in to follow this  
moetman

Controlling multitexture transitioning

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

Hi, I want to texture a terrain heightmap using multitexturing and vertex arrays and to transition between grass , rock , snow based on the height of the vertices at any one point I've constructed a mixmap which is just the heightmap image of the terrain in the hope of somehow using it to control the transitioning or alpha of the textures but have had no success. What's the best way to go about this ?

Share this post


Link to post
Share on other sites
Advertisement
You should either use a pixel shader or perform some very tricky calls to glTexGeni. The easiest approach, if your card supports it, is to use pixel shaders.

Share this post


Link to post
Share on other sites
Another possibility might be to use a 3d texture with interpolation which would effectively automatically blend them depending on height.

Just send the appropriate texture z coordinate with each vertex (or if you like, get a vertex shader to do it for you)

Mark

Share this post


Link to post
Share on other sites
I use texture splatting, and each texture has an alpha map the size of the height map, and that controls how much of the texture is rendered onto the terrain. VertexNormal has some stuff in his journal about it.

You could use 3D Texturing. For what you want to do, that could well possibly be the best solution, as that 3rd dimension could map to the height of the height map, as markr has already beaten me to saying....by about 20 minutes.

Share this post


Link to post
Share on other sites
The problems with 3D texturing are memory consumption and speed - bilinear filtering on a 3D texture is obviously a bit more involved as you have to sample and blend across an extra axis.

I'd recommend a pixel/vertex shader solution. In the vertex shader, you take the worldspace height of the vertex and use it to work out how much of each of your four texture types should be applied - you'll usually be looking at three channels @ 0.f and one channel @ 1.f for a 'solid' section, and two channels @ 0.f and two channels adding up to 1.f for a 'transition' section. It's not too hard to calculate the coefficients based on heights. You chuck those four coefficients out into the channels of the vertex colour, and replicate your vertex texture coordinates to all four channels.

In the pixel shader, you sample all four textures using the texture coordinates you threw out, and then multiply each one by the corresponding channel in the vertex colour (selecting channels either through swizzling or through the dot-constant approach). Sum the results and write it out.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!