# is Z linear?

This topic is 3127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

from my oldschool days I know, when writing a rasterizer, I could interpolate x and y linearly in screenspace, but z was hyperbolic, so I had to interpolate 1/z and calculate the reciprocal per pixel. Now, working on a homogenous rasterizer, interpolating with 1/z wasn't working properly and I seeked some paper that would explain what I miss and it looks to me like z is interpolated linearly. http://escience.anu.edu.au/lecture/cg/Texture/perspectiveCorrection.en.html http://www-graphics.stanford.edu/courses/cs248-07/lectures/2007.11.06%20CS248-13%20Z-buffer/2007.11.06%20CS248-13%20Z-buffer.ppt (page 18) it sounds logical
Quote:
 When projecting a homogenous vector we divide by the homogenous coordinate: (xw/w, yw/w, zw/w, w/w, u/w, v/w, 1/w, R/w, G/w, B/w, A/w)
so you end up with (x, y, z, 1, u/w, v/w, 1/w, R/w, G/w, B/w, A/w) BUT on the other side, I KNOW the ZBuffer on hardware is not linear. what do I miss?

##### Share on other sites
z-buffer is just a buffer, it has nothing to do with linear or non-linear.
It's all depend on transformation in vertex stage.
In fact, the hardware will do homogeneous divide, the homogeneous coordinates is linearly interpolated. So if you use perspective projection, depth is non-linear. If orthogonal projection, depth is linear.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 11
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632650
• Total Posts
3007645
• ### Who's Online (See full list)

There are no registered users currently online

×