PDA

View Full Version : Texture mapping into a square.



boulbo
04-30-2014, 08:47 AM
Hello,
I have a 3D mesh of a face where I want to map it with a texture.
I need to compute UV texture coordinates from the vertex coordinates.
How can I compute these coordinates? and How can I do it with openGL?

Agent D
04-30-2014, 06:13 PM
The texture coordinates come from the same source as the vertex coordinates. Your model file or wherever else your vertex data comes from.

The texture coordinate is a vertex attribute. The veretx shader passes it to the fragment shader wich performs the texture lookup.

boulbo
05-01-2014, 09:38 AM
The texture coordinates come from the same source as the vertex coordinates. Your model file or wherever else your vertex data comes from.

The texture coordinate is a vertex attribute. The veretx shader passes it to the fragment shader wich performs the texture lookup.

I am using OFF (Open File Format) files, where there is only vertex coordinates and face indices.
So I have to compute the texture coordinates by my self.

Agent D
05-02-2014, 11:43 AM
Do you mean this (http://en.wikipedia.org/wiki/OFF_%28file_format%29)? It doesn't even store surface normals or indices. That's a pretty useless model file format.

If you don't know preciesly what you are rendering and how it should be texture, I suggest using a better file format.