Jump to content
  • Advertisement
Sign in to follow this  
Medo Mex

Multi-Textures Terrain

This topic is 2033 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 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
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!

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!