# 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.

## 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 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.

Good luck!

Josh

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

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

• Total Topics
632969
• Total Posts
3009594
• ### Who's Online (See full list)

There are no registered users currently online

×