Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Terrain Multi-texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 02 December 2012 - 03:52 AM

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.

Sponsor:

#2 Alin   Members   -  Reputation: 391

Like
0Likes
Like

Posted 02 December 2012 - 07:02 AM

If you want to use multiple textures in .x files, your 3ds max plugin must support exporting multiple UV coordinates and .fx files.
You can try to use Alin's DirectX Exporter for 3ds Max,

#3 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 02 December 2012 - 03:20 PM

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, 02 December 2012 - 03:20 PM.


#4 AdeptStrain   Members   -  Reputation: 369

Like
3Likes
Like

Posted 04 December 2012 - 10:15 AM

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:

http://www.gamerende...ture-splatting/

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;





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS