Sign in to follow this  
Medo Mex

Multi-Textures Terrain

Recommended Posts

I have a terrain that I created in 3Ds Max, I'm able to add UVW map to result tiled texture, and it works perfectly.

 

Now, I'm looking to use more than one texture in the terrain (for example: grass and stone) instead of one texture, I use the following code:

 

device->SetTexture(0, &grassTexture);
device->SetTexture(1, &stoneTexture);
device->SetTexture(2, &blendingMap);

// Code to draw the terrain here...

 

If I created a blending map image, how do I apply the blending map to the terrain?

Share this post


Link to post
Share on other sites

Well, if you are using shaders, it is very simple to blend 2 different textures with a blend map. For example, you could use the textures and blending map as parameter for lerp and you'd get a nice blended output. 

 

I think that the same effect is possible also with fixed function pipeline. Can you tell a bit more about your framework?

 

Chheers!

Share this post


Link to post
Share on other sites

No, I want to accomplish it without shaders, I guess I need to set some values in SetTextureStageState and SetRenderState to do to make this works:

 

device->SetTexture(0, &grassTexture);
device->SetTexture(1, &stoneTexture);
device->SetTexture(2, &blendingMap);

Share this post


Link to post
Share on other sites

Tried the following code and it's not working:

 

// Alphamap: take the alpha from the alphamap, we don't care about the color
device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
device->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

// Texture: take the color from the texture, take the alpha from the previous stage
device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);

// Set textures
device->SetTexture(0, &texture1);
device->SetTexture(1, &blendingTexture);

// Code to draw the mesh here...

What's wrong with the above code?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this