I am making a 3D renderer in Java from scratch with no external libraries. As I am trying to optimize I want to know a general/average answer whether the Painter's Algorithm is faster than Z-Buffering. Say if I was rendering one cube that was the same which would be faster. But I don't want intersecting polygons to mess up so I probably want to implement Newell's edition of the Painter's Algorithm that cuts the polygons so they don't intersect and mess up.
So can I have an order of what would averagely be faster rendering a single cube:
Painter's Algorithm
Newell's Painter's Algorithm
Z-Buffering
Also if anyone has any other good suggestions I could possibly use?
In computer graphics the painter's algorithm is called Z-Sorting
sometimes it is faster sometimes not. It depends on how many objects you have, how big is the resolution you are rendering and what precision of Z coordinate you need.
Z-Buffering is better for:
high object/polygon count
dynamic scene (objects or camera are moving/rotating)
it needs additional buffer in the same resolution as rendered image and it performs single condition per fragment (rendered pixel of each polygon even unseen ones). After render the 3D z coordinate of each visible pixel is at disposal which is required for many advanced rendering techniques.
Z-Sorting is better for:
(relatively) static scenes or very low object/polygon count
if very little memory is at disposal (on 8bit computers most 3D apps used Z-sorting because there was no memory for Z-buffer)
it need index buffer to store all the object/polygon indexes and it performs sorting on each scene change (sorting many objects by Z coordinate can be slow). Nowadays it is used because of:
transparent polygons need Z-sorting
if program already have Z sorted scene for some other reason so it take advantage of it
Sometimes these two techniques are combined together
especially for high dynamic range of Z coordinate because standard Z-buffers (24/32 bit wide) have very poor resolution on the whole range. It can be partially solved by use of linear or logarithmic scale of Z-buffer but if you need defined accuracy/resolution on the full range you need to use some kind of combination with Z-sorting and combine more frustrums together or use custom Z-Buffer with high dynamic range which is not supported by current HW
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With