Jump to content

  • Log In with Google      Sign In   
  • Create Account

Multi-Textures Terrain


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
5 replies to this topic

#1 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 22 March 2013 - 08:02 PM

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?



Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2514

Like
0Likes
Like

Posted 23 March 2013 - 12:48 AM

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!



#3 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 23 March 2013 - 05:08 AM

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


#4 kauna   Crossbones+   -  Reputation: 2514

Like
0Likes
Like

Posted 23 March 2013 - 12:08 PM

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!



#5 Medo3337   Members   -  Reputation: 665

Like
0Likes
Like

Posted 24 March 2013 - 07:36 AM

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?



#6 Steve_Segreto   Crossbones+   -  Reputation: 1530

Like
0Likes
Like

Posted 24 March 2013 - 10:53 AM

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






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