Skip to main content
gamedev.net
🔒 Locked

Z-Buffer question...

Started by Kaesebrot 2 replies 200+ views
Original Post
Kaesebrot
Kaesebrot
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..
Corpse
Corpse
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
Pavel "Corpse" Zuna
S1CA
S1CA
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
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
TerranFury
TerranFury
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.