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!
1 reply to this topic
Sponsor:
#2 Members - Reputation: 307
Posted 23 December 2012 - 08:18 AM
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!
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!







