Jump to content
  • Advertisement
Sign in to follow this  
DvDmanDT

Is this a good idea?

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

Hello.. I was thinking about something.. I'm going to use a really lame square/tile based map.. And well.. The VertexBuffer for the map will be generated, and until now, I've setup 4 vertices for each quad, just because of the UV coordinates.. But at some point I read that you could have like 5 and 6 instead of 0 and 1, and still get the same effect? Umm.. Like this (the values are UV coordinates)?
(0,0)--(1,0)--(2,0)
  |      |      |
  |      |      |
(0,1)--(1,1)--(2,1)
  |      |      |
  |      |      |
(0,2)--(1,2)--(2,2)
If I do that, I can reuse all vertices, instead of always ranging from 0-1.. Now, is this a good idea? Can I do the same thing in OGL? Thanks

Share this post


Link to post
Share on other sites
Advertisement
If you move your texcoords outside of the [0..1] (or is it -1..0..+1??) range you are subject to the various wrapping, tiling and clamping rules that you configure...

Even then you tend to be limited by the capabilities of your hardware, as they tend to have a maximum number of times they can wrap/repeat textures.

If you're using fairly trivial geometry I'd just settle with duplicating it.. for a relatively common 16mb of VRAM you could fit around 600,000 vertices -> or about a 385x385 grid [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Ok.. well, I don't really care about the memory usage (it'll only run on 128mb+ cards anyway), but more about how lazy I can be when I code, without doing anything that's strictly not recommended..

I think I read that if I have texture, and four vertices, with these UV coordinates


(0,0)--(2,0)
| |
| |
(0,2)--(2,2)


Then it would draw the texture 4 times (a lazy way to get rid of some vertices.. ).. And if I did things like 0..-1 then it would invert the texture (same as doing 1..0 instead of 0..1 I suppose)...

Share this post


Link to post
Share on other sites
Quote:
Original post by DvDmanDT
I think I read that if I have texture, and four vertices, with these UV coordinates

(snip)

Then it would draw the texture 4 times (a lazy way to get rid of some vertices.. ).. And if I did things like 0..-1 then it would invert the texture (same as doing 1..0 instead of 0..1 I suppose)...


Yup, providing that you set the addressing mode to WRAP, which may be the default, but set it anyway.

Of course this limits you to using the same tile image on those 4 tiles, but maybe that isn't an issue in this case.

Share this post


Link to post
Share on other sites
Quote:
Original post by DvDmanDT
Thanks, both of you.. Just one more thing.. Does the same apply in OGL?

I would be surprised if OGL doesn't have an equivalent, but I'm a D3D programmer - you're probably far better off talking to the guys in the OpenGL Forum.

hth
Jack

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!