Jump to content
  • Advertisement
Sign in to follow this  
Hedos

OpenGL How to align textures properly?

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

I'm currently working on a 2d OpenGL game.. I'm looking for advices on how to set up the textures on my polygons so they look to be all fitting together? For example, take a look at this screenshot from "Soldat": http://www.soldat.pl/pl/screens/screenshot5.jpg The grass texture fits everywhere, there's no "cut" in the texture between the triangles.. How would I be able to do that? Also, most of the polygons in liero are huge, and they contains concave segments.. How is it possible to have a concave polygon? If you know any good guide/tutorial which could help me, I'd be glad to know it. Thanks a lot.

Share this post


Link to post
Share on other sites
Advertisement
The easiest way is to find or create textures that fit well naturally. By that I mean squares that, when tiled, show no strange cuts.
You can also blend multiple textures in various stages, and there are many more options.

A polygon can be concave if it contains more than three sides. Polygons don't always have only three sides, although its common practice (video cards are optimized to handle triangles, the are al lot of mathematical issues, etc.)

Share this post


Link to post
Share on other sites
I think I'll go with a combinaison of triangles instead of complex polygons..
Anyway, I think an image would represents well what I think could work:

Image Hosted by ImageShack.us

The big square on the top left would be the main texture I want to apply on my polygons, in a sort of repeated way.
So you can see on the 3 triangles exactly how should the texture be applied.

The problem is that I really have no idea how to do that.

Share this post


Link to post
Share on other sites
Using your picture:



As you probably know, a vertex has (if you're using textures, that is) U and V coordinates for the texture mapping, ranging from 0 to 1 (represented on the left side of the picture). Point P is an example.

Using one of the polygons as an example, you can see where it fits right over the original square. Now you can simply calculate (or in my case, guess ;)), what the values for the U and V will be.

Does this answer your question?

Share this post


Link to post
Share on other sites
That led me in the right direction, everything works fine now!
It wasn't that hard after all, thanks a lot ;)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!