#### Archived

This topic is now archived and is closed to further replies.

# How to set tu an tv beetwen shared indicize vertices

This topic is 5645 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m making myself a terrain engine, every "tile" is a join of two triangle 3 + 3 vertex, of course to optimize i use 4 vertex indicized for two triangle, but how can i do for texture cordinates... i mean how can i set the tu and tv for vertex that are shared between more tile ???


*---------*---------*---------*---------*
|\	  |\	    |\	      | \       |
|  \    0 |  \    2 |  \    4 |  \   6  |
|    \    |    \    |    \    |    \    |
|      \  |      \  |      \  |      \  |
|  1     \|  3     \|  5     \|  7     \|
*---------[*]---------*---------*---------*
|\	  |\	    |\	      |\	|
|  \   8  |  \   10 |  \   12 |  \   14 |
|    \    |    \    |    \    |    \    |
|      \  |      \  |      \  |      \  |
|  9     \|  11    \|  13    \|   15   \|
*---------*---------*---------*---------*

[*] = this vertex is shared and indicezed so his tu and tv changes for every triangle around it..... how can i manage this?

##### Share on other sites
I think that it doesnt work unless maybe you use two indexed streams though dont bother trying until some with more expertise comments. I think it would be rather unefficient anyway. What you can easily do is this though:
u coord
v 0,1,2,3,4,5,
c 1,
o 2,
o 3,
r 4,
d 5,

##### Share on other sites
As usual that topic has been covered before on the forums. If only you could search for it. Here is a thread in which we learned how to do this: http://www.gamedev.net/community/forums/topic.asp?topic_id=120797

##### Share on other sites
thx lot Drath and sorry Igilima but did you seen how many topics are posted every single day... anyway thx.

##### Share on other sites
I didn't mean to imply that you had failed to search for it. I meant the 'you' in a general 'everybody' sense because the search function doesnt work. Maybe I should have said, "If only the search function worked." I wouldn't have expected you to be able to dig that particular post up.

Hopefully, that post helps, though here is a summary.

Basically, when texturing to shared vertices, you want to set the vertex tu and tv values in increments of 1.0 starting with 0.0 and then enable texture repetition. Put your whole terrain in a vertex buffer. Vertices starting from left and going right will have tu values 0.0, 1.0, 2.0, 3.0 and so on while vertices starting from top and going down will have tv values 0.0, 1.0, 2.0, 3.0 and so on. Create an index buffer for each set of tiles that has a different texture. A checkerboard, for example, would have one vertex buffer and two index buffers (one for black and one for red textures). Set texture to red, and drawindexedprimitive with the red index buffer then do the same for the black index buffer.

When DX repeats a texture, it renders the whole texture from tu and tv coordinate 0.0 to 1.0 then it renders the whole texture again from 1.0 to 2.0 and so on, repeating the entire texture every 1.0 units.

[edited by - Igilima on January 30, 2003 11:20:27 AM]

##### Share on other sites
I''m using shared vertices in a tile-based format in my engine. I don''t suggest you setting this up because when you get textures with different colors, you will get the offset problem where the texels don''t match up with the pixels.

I''ve tried to fix this by the usual method of subtracting 0.05f from one side and adding 0.05f to the other side of the tile coordinates. The problem is taht with shared vertices, this isn''t possible. You will still have the texture seam problem.

Maybe someone with more experience on this can help out? Also, using the texture clamp method doesn''t work since you need your texture to repeat on all the tiles used.

1. 1
Rutin
21
2. 2
3. 3
JoeJ
16
4. 4
5. 5

• 26
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001781
×