Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multi-Textures Terrain

Started by Medo Mex Mar 23, 2013 at 2:02 AM 4 replies 2k views
Original Post
Medo Mex
Medo Mex

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?

kauna
kauna

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!

Medo Mex
Medo Mex

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);
Medo Mex
Medo Mex

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?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.