Archived

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

Z-Buffer question...

This topic is 5849 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 am curently writing my own 3D-Software-Renderer.. it´s just for fun... I write it with TurboPascal.. it''s crazy, isn''t it? until now I have just rendered Points to the screen, but now I have programmed an procedure which draws triangles. At this Point it´s time to use an Z-Buffer. My triangle is defined as a list of three points.. I convert these points into my 2D Space. I still have the Z-Values saved, but how can I calculate the Z-Value of the points in the inner of my triangle. please help me..

Share this post


Link to post
Share on other sites
If you''re doing perspective correct texturing you''ll have a useful value there. But generally you just do a linear interpolation between the Z values of the vertices - this is just the same as you would also do with colours for Gouraud shading.

If you''re using homogeneous coordinates to do your perspective projection (w divide) - you can interpolate by multiplying with 1/w.

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
I''m assuming you break your triangle into spans. To do this for triangle ABC, you''re interpolating between A and B, and B and C, to get for each iteration two points, D (on segment AB) and E (on segment BC). Then, to draw each span, you''re essentially interpolating between D and E. Interpolate the Z value as well.

Share this post


Link to post
Share on other sites