Jump to content
  • Advertisement
Sign in to follow this  
Toolmaker

2D Texture mapping in software

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

I'm currently attempting to implement 2D texture mapping in software(In Java for that matter). I'm not trying to get things to run fast, nor get the best results. I'm trying to understand the basics here for a school assignment. Now, I found an article here on gamedev(http://www.gamedev.net/reference/articles/article337.asp) which explains the texture mapping, but it's all assuming 3D space, while I'm in 2D space. Can I still apply the regular algorithm and use a substitute value for the Z angle(Such as 1 or 0)? Or is this algorithm complete useless in 2D space? Toolmaker

Share this post


Link to post
Share on other sites
Advertisement
It looks like he's doing perspective-correct texture mapping (a good thing if you're working in 3D). It interpolates u/z, v/z, and 1/z across the polygon, and at each pixel divides that scaled u and v by the reciprocal z to get the final u and v.

For 2D you can just interpolate u and v directly and get rid of the divides in the inner loop.

But to answer your specific question, yes, you can just plug in any non-zero z value and it will look right, as long as the z is the same on all vertices. The perspective correction only looks different when the z is different between vertices.

Share this post


Link to post
Share on other sites
That article is 14 years old. Whilst it is great way to look at how far we've come, it's also extremely outdated, and goes into a lot of assembly code that wont help much.
You may be able to work out what you need from it, but you'd probably be far better off referring to an article about 2D texture mapping.

Here's some other links:
http://www.exaflop.org/docs/fatmap/
http://www.gamedev.net/reference/articles/article852.asp
http://cg.cs.tu-berlin.de/~ki/3del_1419_src_feat_tmap.html

I must admit that it's not as easy to find what you're after as it used to be.
Some key phrases are "Affine texture mapping" or "linear texture mapping".
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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!