Jump to content
  • Advertisement

Archived

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

Rocket05

1/z

This topic is 5567 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've been working on a software rasterizer just for fun/educational purposes, and all the books and articles ive read, on the topic of zbuffering/perspective correct texture mapping, talk about the z value, or using 1/z. in everything i've read, its basically a one sentence explanation that goes like this "or use 1/z", and mentioning that it is more widely used. very descriptive. i can't understand exactly why you would do this instead of just using z. for one thing, z interpolates linearly and directly, 1/z creates a hyperbole and varies inversely. why do this then? the one place i could see it making some sense is when using fixed point and having the small whole number range, but to deal with the other problems this approach poses outweights this purpose. so why use 1/z? in any case? edit: fixed some typo's [edited by - Rocket05 on September 21, 2003 11:52:52 AM]

Share this post


Link to post
Share on other sites
Advertisement
1/z being linear in screen space is the raw output from perspective texture mapping, this value can go directly into the inverse zbuffer without having to convert it to Z.

Also using the small number range makes the accuracy much greater.

Share this post


Link to post
Share on other sites
Xe = x*foc/z;
Ye = y*foc/z;

Xe;YE => screen point
x;y;z => space point

replace it in ax+by+cz=0 you have

a(Xe*z)/foc + b(Ye*z)/foc + cz = 0 then

z(a*Xe + b*Ye + c) = foc
<=>
z = foc/...
<=>
1/z = (a*Xe+bYE+c)/foc that is linear like U*Xe + V*Ye + W!

then this is very fast to found 1/z and you have the right z easily.

After interpol the xmap/z and the ymap/z on all the polygon and at the end multiply with z for readjust.

(you can do the divide 1/z in one clock ! yes yes I do it, if you want to know how ... read the next episode)

Just a question : what do you use like graphics librairy (see topics on top )?

Share this post


Link to post
Share on other sites
well 1/z is linear in screen space, but wouldn''t using an inverse z buffer, for one thing, make any ztesting close to the camera inaccurate due to the hyperbole result? and it would also throw off the ztesting procedure -- instead of less than or equal to like usual, it''d actually be greater than or equal too -- not a problem, but that wouldn''t explain how 3d api''s do it.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!