Question

This seems like a question for which an answer should readily available on the web or books but my quest for an answer has led me so far only to blind alleys that turned out to be dead ends.

I'm trying to draw 3D lines in real-time with hidden surface removal (the lines are edges of solid objects).

So I have two 3D points that were projected to 2D points using perspective projection. For each point I have computed the depth of the point. Now I want to draw the line segment that joins the 2 points, and for hidden surface removal to work I have to compute, for each intermediary 2D point on the 2D line (that results from the projection) the depth of the corresponding 3D point (the 3D point that is projected on that intermediary 2D point).

My problem is that, since the depth function isn't linear when you do perspective projection, I can't interpolate the depth of the 2 original 3D points to compute the depth of the intermediary point.

So how do I compute the depth of each point on the line with a method that's compatible with the constraints of real-time rendering?

Thanks in advance for any help.

Was it helpful?

Solution

Use homogeneous coordinates, which can be linearly interpolated in screen space: http://www.cs.unc.edu/~olano/papers/2dh-tri/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top