Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Absolution

Perspective correct texture mapping

This topic is 5797 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 have an interesting problem that I thought I could work out here. I''m writing a little 3D software engine in Java and right now I''m writing the scan-line texture mapping routines. Somehow I occasionally get a texture coordinate that is slightly over the bounds (i.e. i''ll get 256 or 257 for a 256x256 tex map). I put in some temporary ''fudge'' code to bound these and you can''t really tell when it''s displayed, but obviously it bugs me. My current theory is it''s just a floating point precision problem. :/ Has anybody else had this problem when writing a software engine? Heres a brief summary of what I''m doing in case it may help: For each vertex of a triangle I have (u,v) and the transformed coordinates (x,y,z,w) with w saved before the perspective division/view-port transform. So along one edge I get u=lerp(u1/w1, u2/w2) and iw=lerp(1/w1, 1/w2) and the same for the other edge for each y. Then along each scan line I lerp these u and iw values and my tex coordinate comes out as u/iw. Sounds right to me, but that is a lot of interpolating and dividing. I could be getting round off errors. Not to mention I''m clipping to the view fustrum before hand and that''s a further interpolation of the texture coordinates. Yep, I just checked and right now it only seems to happen when I clip to the fustrum (at least from the angles my camera is at). Sigh. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
EDIT: No, I was wrong. Check your clipper is stable and you are getting good clipped w values, floating point might be the problem, depends on how large/small values we're talking.

[edited by - JuNC on December 6, 2002 12:03:49 PM]

Share this post


Link to post
Share on other sites

  • 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!