PDA

View Full Version : Textures on 4 non coplanar points



alb84
04-15-2011, 12:24 AM
I was wondering what's the behaviour of OpenGL when one tries to apply a texture on a square whose vertices do not lay on the same plane.

What I would like to do is applying some textures downloaded from GoogleMaps on a squared elevation grid. Else you can advise me some other method? Should I triangulate the texures? If so how can I avoid to add discontinuities on the joints of triangles?

mobeen
04-15-2011, 01:15 AM
Even if it is a square it will ultimately become a triangle. Then gl will simply use the texture u have given and apply it to the triangle.

Should I triangulate the texures?
What do u mean triangulate a texture?

BionicBytes
04-15-2011, 01:36 AM
Not a problem to texture a non co-planar quad. Textures can be applied to a sphere if you want. The texture you bind will apply to all the vertex coordinates you send to OpenGL for that batch. The more tesselated the model the better the result when the vertex positions are not in the same plane.

alb84
04-15-2011, 04:21 AM
I mean, I suppose that I should divide the square in at least two triangles and then apply that texture to each triangle.
Let's say that I have a square with 4 vertices on 4 different altitudes. I can compute the altitude of the center of the square as a mean of the altitudes of the 4 vertices.
Then I can divide the square in 4 triangles joining in the center of the square.
The texture I have is a ortho projection of my "pyramid".
How can I map correctly that texture on the 4 triangles composing my pyramid?
Any help is much appreciated.

BionicBytes
04-15-2011, 04:52 AM
you have to compute texture coordinates at each vertex.