Quiz 19
Today
- So does Three.js use both the painter's algorithm and the z-buffer
algorithm?
Yes! Anything with a opacity less than 1 is drawn after all the opaque objects (opacity == 1), and sorted by distance from the camera.
- What are the efficiency differences between the two drawing
algorithms? Is one better to use in cases that require a lot of continuous
rendering? What about scenes with a lot of objects in them?
Great question! Sorting is $O(n\log n)$, so sorting N drawable objects takes time. The z-buffer algorithm just draws each thing, in any order, so it's $O(n)$. So, using a lot of transparent objects will slow you down somewhat.