Hi, I would like a texture to look the same on all triangles, no matter what size, how skinny/stretched they are.
How can I do this with u,v coordinates?
[Edit] I also need the texture to repeat (so < 0 and > 1 coordinates are ok)
Thanks,
roland
Hi, I would like a texture to look the same on all triangles, no matter what size, how skinny/stretched they are.
How can I do this with u,v coordinates?
[Edit] I also need the texture to repeat (so < 0 and > 1 coordinates are ok)
Thanks,
roland
Do you mean same size when projected onto the screen or when in 3D space?
You would assign your largest triangles UV coordinates so that the maximum vertex of the triangle has coordinates referencing the maximum edge of the texture. Then you compare a triangles dimensions to with the largest and scale its UVs by the same ratio. This will only have a subset of the image on the smaller textures. I’m not entirely sure of the math, I’m sleepy, but it would create a reasonable effect.
Another alternative is to have your smallest triangles map the entire image, and then use a UV wrapping mode so that the image is repeated or mirrored. The UVs for your larger triangles will then be scaled up by the ratio of their dimension increase (i.e. the opposite of above, where you would scale down).
thanks for the reply, lhkbob.
Edit: sorry, my program was working, I was just using the wrong texture coordinates.
Thanks again 
That picture helps a lot, I misunderstood your question. I thought you wanted the same image to be shown within each triangle.
What the picture looks like is that each triangle is accessing a different part of a single image, you just want the picture data to not be stretched and skewed. If this is the right interpretation, you can fix it pretty easily by imagining how the triangles lie on the image. Since they are 2D (I think so in your case since you said it was 2D world), this is pretty easy.
Your UV coordinates for every triangle share the same coordinate space, and you consider the origin to be the bottom left of the image. Then you determine where each triangle’s 3 vertices would lie within the image and use those values from 0 to 1 (where 1 is the far edge, either top or right).
If you’re in 3D, it’s much the same logic but you have to figure out some way to unwrap your 3D set of triangles to all lie flat within the image plane. Since you’re 2D, everything is already unwrapped for you.
Thanks, that’s a better way to do it. Then you don’t have to loop through all the vertices to find the largest 
Even though my problem turned out to be my own fault I think this might come in handy sometime.