Advertisement Jump to content
Sign in to follow this  
Medo Mex

Terrain Multi-texture

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

I have two textures, one for grass and the other is for sands, I'm trying to mix both in the terrain so I can have more realistic terrain, here is what I'm doing in the rendering code:

mD3dDevice->SetTexture(0, grassTexture);
mD3dDevice->SetTexture(1, sandsTexture);
// Code to render the terrain...

The problem is that the above code only render the grass texture.

I have created the terrain in 3Ds Max, How can I specify the areas that will use the texture 'sandsTexture'? Is there is a modifier in 3Ds max that I can use to do that?

I thought VertexPaint will work, but it doesn't work, I'm exporting .x file and loading the terrain from .x file.

Share this post

Link to post
Share on other sites
Most of the terrain will be using the grass texture, how can I specify the areas that will use the sands texture? Edited by Medo3337

Share this post

Link to post
Share on other sites
Most the times you use a blend map to describe what texture you want to apply where on your terrain. It's commonly referred to as Texture Splatting. There's a pretty good overview here:


Basically, you have an RGBA texture that has each channel dedicated to 1 texture (so, grass could be the red channel and sand the green channel). Then in your shader code you just sample all your textures and multiply them by the blend specified in the blend map:

float4 sand = textureSampler.Sample(textureSand, input.Tex);
float4 grass = textureSampler.Sample(textureGrass, input.Tex);
// Add up to 2 more textures (of course you can exceed that limit in various ways, but I'll keep it simple).
float4 blend = textureSampler.Sample(textureBlendMap, input.Tex);

float4 finalColor = grass * blend.r + sand * blend.g /*add other channels here*/;

return finalColor;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!