#### Archived

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

# Z-Buffer question...

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

## 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 on other sites
I''m actually doing the sam thing (but not in Turbo Pascal) and it''s just the question I wanted to ask ...

Pavel "Corpse" Zuna

##### 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 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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631781
• Total Posts
3002316
×