Multi-Textures Terrain

Started by
4 comments, last by Steve_Segreto 11 years ago

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?

Advertisement

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!

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

Well then, I guess that you are looking for this : http://www.gamedev.net/page/resources/_/technical/game-programming/texture-splatting-in-direct3d-r2238

Good luck!

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?

Hmm, you're using the fixed function pipeline. Try this link: http://msdn.microsoft.com/en-us/library/windows/desktop/bb206241(v=vs.85).aspx

This topic is closed to new replies.

Advertisement