Jump to content
  • Advertisement
Sign in to follow this  

inverse texture mapping

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

Hey, I am trying to figure out how to implement inverse texture mapping. Currently I am loading a single image and I allow the user to rotate the image theta degrees. Using the standard point rotation algorithms I get my new points and give those new points the color of the pixel they came from. This causes a bunch of holes and so, I wanted to implement inverse mapping. My problem is that I am not quite sure how to get my destination rect. I have the original orientation of the pic obviously and I can get the four corners of the new rect by rotating the four corners of the original rect but I cant figure out how to get the pixels I need to inverse map. Suppose the following four stars are the corners of my new rect *________* / / / / / / / / *---------* How can I use those values to get all of the pixels of the rect? It looks like I need to split that into one rect and two triangles but I cant seem to work it out. Thanks in advance.

Share this post

Link to post
Share on other sites
In the Graphics articles section on gamedev.net, there are a lot of articles about texture mapping.

The basic idea for texture mapping a quad is the following:

You want to interpolate the edges, and then interpolate between.

So you'd start by calculating the endpoints for each horizontal scanline of the polygon on-screen (look up any of the polygon-drawing tutorials in the article page linked above). Then, given the endpoints and the distance from the texture coordinates at those coordinates, you can interpolate between them.

After you have the pixel coordinates and texel coordinates at the endpoints of the scanline, you can scan horizontally across the line, interpolating each time.

Now, whether you want to do perspective-correct texture mapping or not is a different story.

I'm sure I'm not doing the algorithm justice (it's too late at night for me to give a proper write-up), but there are a bazillion articles at that link.

Here's the link again.

Good luck!


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!