Jump to content
  • Advertisement
Sign in to follow this  
enigmagame

Texturing problem

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

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by MARS_999
What 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 this post


Link to post
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 this post


Link to post
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 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!