Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


DirectX Terrain Tiled Texture


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

#1 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 14 November 2012 - 03:14 AM

I'm trying to make the texture tiled for the terrain, so I'm using the following:
device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
device->SetSamplerState(0, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);

// Code to render terrain here...

After using the above code, the texture is still not tiled, how do I make it tiled?

Sponsor:

#2 TiagoCosta   Crossbones+   -  Reputation: 2487

Like
0Likes
Like

Posted 14 November 2012 - 04:36 AM

It depends on the texture coordinates of the terrain vertices. Wrapping mode will repeat the texture every integer junction. So if the texture coordinates of the vertices only go from 0.0f to 1.0f (or they are continuous along the terrain) it wont tile the texture.

So you're left with two options:
-You can manually change the texture coordinates of your terrain vertices which will give you the best results and most freedom;
-In the vertex shader before outputting the texture coordinates multiply them by the number of tiles you want, so if you multiply by 2 in both axis, if you had a plane with texture coordinates from 0.0 to 1.0 you would end up with 4 tiles of the texture.

I'm guessing you terrain is a big plane made of rows/columns of triangles, if so you're probably setting the texture coordinates of one of the corners (0.0f, 0.0f) and the opposite corner (1.0f, 1.0f) and interpolating the coordinates of the other vertices, if so you just have to change the coordinates of the last corner to (2.0f, 2.0f) and you will end of with 4 tiles.

Edited by TiagoCosta, 14 November 2012 - 04:41 AM.


#3 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 14 November 2012 - 11:37 AM

I'm not using vertex shader yet, how do I set the texture coordinates?

(I made the terrain in 3Ds Max and exported it as .x file)

#4 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 14 November 2012 - 12:10 PM

Thanks, I had to set the UVW values in 3Ds Max, the problem is now resolved.




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