Sign in to follow this  

Frustum clipping - depth interpolation

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

Hi,

I have implemented a software rasterizer for occlusion culling. However, In some cases I get strange depth map results when polygons get clipped by frustum, especially when clipped by near plane. I am clipping points in homogenous coordinates (before w division) using -w <= x,y,z <= w.
Point interpolation along the edge (for near plane) is done like this:

newPoint = p1 + (p2-p1) * t;

where:

t = (-p1.w - p1.z) / (p2.z - p1.z + p2.w - p1.w);

Depth map with wrong depth interpolation is in the attachment.

Does anybody know what is wrong here?

Thanks!

Share this post


Link to post
Share on other sites
I think I solved it. I haven't used perspective correct depth interpolation, and now I have fixed it.

I did it this way:

I write z/w and 1/w per vertex

In rasterizer I do linear interpolation of both (z/w)' and (1/w)'

PixelDepth = (z/w)'/ (1/w)'


Please, can someone confirm this is OK? Occlusion map looks good but I want to be sure this is how it's done.

Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this