Software rendering 3d triangles in the proper order
Posted
by
at.
on Game Development
See other posts from Game Development
or by at.
Published on 2012-11-21T19:48:20Z
Indexed on
2012/11/21
23:12 UTC
Read the original article
Hit count: 430
I'm implementing a basic 3d rendering engine in software (for education purposes, please don't mention to use an API). When I project a triangle from 3d to 2d coordinates, I draw the triangle. However, it's in a random order and so whatever gets drawn last draws on top of all other triangles (which might be in front of triangles it shouldn't be in front of)...
Intuitively, seems I need to draw the triangles in the correct order. So I can calculate all their distances to the camera and sort by that. The objects furthest away get drawn last. Is this the proper way to render triangles? If I'm sorting all the objects, this is n*log(n) now. Is this the most efficient way to do this?
© Game Development or respective owner