Sign in to follow this  

may seem simple question about tex coords but...

This topic is 4864 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

Hey people, I've got a grid of Vertices that define a landscape like so (just a small example)

5----4----8
|  / |  / |
| /  | /  |
1----0----7
|  / |  / |
| /  | /  |
2----3----6
Now the problem comes when i want to define the texture coordinates. Technically each quad lower left vertex will have tex (0,0) and upper right (1,1) with the other two being (0,1) or (1,0). But that means that vertex 0 (for example) will have to have several texture coordinates depending on which quad. Does this mean i have to duplicate vertices at that point for each quad or is there a way around this?

Share this post


Link to post
Share on other sites
Well, every vertex can only have one texture coordinate* (and one normal etc.)
But there's no problem anyway - just set texture wrapping mode to GL_REPEAT.
In your example you would give vertex 2 the texture coordinates (0,0), vertex 0 would have (1,1) and 8 would have (2,2) and so on.

* per texture unit, that is.

Share this post


Link to post
Share on other sites
okay and i assume vertex 7 would have coords (2,1) and vertex 1 would have (0,1)?

Also i'm using directX and GL_REPEAT is openGL (isn't it?)

Anyway i thought that maybe the directX equvilant would be to set the texture wrapper SetRenderState(D3DRS_WRAP0, D3DWRAPCOORD_2)

But i don't think that's right anyway cuz it states:
"Be sure the texture wrapping data does not contain any texture coordinates outside of the range of [0.0, 1.0] because this will produce undefined results."

Share this post


Link to post
Share on other sites
Yes, in OpenGL vertex 7 would have texture coordinates (2,1).. I have no idea what you should do in D3D to get the same effect - I've never used it. Someone else will have to answer here...

Share this post


Link to post
Share on other sites
Quote:
Original post by LifeOfTamir
Technically each quad lower left vertex will have tex (0,0) and upper right (1,1) with the other two being (0,1) or (1,0).


That is correct for OpenGL.

However, in DirectGraphics, the texture coordinate (0, 0) is the upper-left of the texture and (1, 1) represents the lower-right of the texture.

Share this post


Link to post
Share on other sites
Thanks for the replies guys. But it's still not quite working yet.

What i've got now is a combinatino of all your suggestions.
So my upper left vertex (5 is diagram above) had tex coords (0,0)
vertices 0 and 6 have (1,1) and (2,2) respectively. vertex 4 would have (1,0) vertex 1 (0,1) and so forth for the rest.

then i've used
device->SetSamplerState (0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
device->SetSamplerState (0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);

to render and while there is a mark improvement it's still not really correct as demonstrated below:



at first i thought it might be because i've got some of my tex coords wrong but i've double checked and they are definitely correct (at least correct in the way i've described)

any ideas what could be wrong?

--edit--
actually the SetSamplerState seems to be having no effect, if i comment out the code i still get exactly the same display

Share this post


Link to post
Share on other sites

This topic is 4864 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this