# Texturing problem

This topic is 3830 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi! This is a screenshot of a textured cube. Suppose that I read the frame buffer and that I've stored the data on a image, the result is the precedent image. Now, I take the model, in the same position but without the original texture, I want texture my model with the precedent image. So, I load the image, now I must calcolate the texture co-ordinate: 1) I project each vertex 2) The texture is rectangular so I calculate the co-ordinate in this manner
v[0] = (v[0]*(width/2))+(width/2);
v[1] = (v[1]*(height/2))+(height/2);

Now in v I've the texture co-ordinate. See the result screenshot: Because I've this distortion? Thanks!

##### Share on other sites
What are the values for width and height?

##### Share on other sites
Quote:
 Original post by MARS_999What are the values for width and height?

Width=1280
Height=800
Those are the dimension of my window, and the size of the texture.

##### Share on other sites
It looks like the distortion is caused by affine texture mapping. I don't know much about it, but basically, the texture coordinates for each pixel can't be simply linearly interpolated (like in 2d texture mapping) when in 3d, you have to do some stuff regarding the depth of the pixel. Here is the wikipedia article on it, maybe there's solutions on google.

##### Share on other sites
Gumgo is heading you in the right direction but it's kind of the opposite of affine mapping.

You're applying a texture which is already in perspective to a surface parallel to the view (your projected vertices in screen coordinates) and then applying perspective to it a second time.

##### Share on other sites
It's clear.
So I must use the pseudo-depth value. And I must use glTexCoord3f() or glTexCoord4f function...

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633726
• Total Posts
3013569
×