Just like PowerVR's gfx chips with tile rendering, which process
the z-buffering for the screen in small blocks and render only
what is visible.
This is common practice across all modern cards. A hierarchical approach is
taken - there
is a full z-buffer for all pixels, then a version with the farthest z for each
group of 4
pixels, a version with the farthest z for each group of 16, and so on, with the
effect that
large portions of triangles can often be thrown away, especially if the
programmer has
followed the modern convention of doing a loose front to back sort before
drawing.
If you
store a table of square roots for the Pythagoras, it speeds up
nicely (big table, but hell, you'll already be storing perspective
correction tables and SINE tables, so you won't be bothered about
memory).
There is an entire web page somewhere dedicated to getting fast sqrts. I've
seen one
which uses only a 256 or 512 byte table but can do a 16bit sqrt in less than
100 cycles.
You could also try doing a view frustum cull beforehand to reduce
the list to just visible objects, or take the easy route and just
make sure the objects are forward of the camera. You count the
T-States and take your choice!
Elite has the very bad habit of culling all objects that even intersect the
front plane. You
don't usually notice, but try flying over the front of a space station.
Right now I'm tinkering with adding 'building block' sector coords
to each object, like a vague grid reference. Then you could easily
apply a 'bitmapped' view frustum to search the main area for
potentially visible objects. I'm not convinced yet, but it may
work
An octree does more or less this. Its a recursive structure, with the parent
being a
rectangle (the root node being the rectangle enclosing 'all' of space) and the
children
being 8 smaller rectangles. The game is that if a particular parent is entirely
outside of
the view frustum then you don't recurse, and if it is entirely inside the view
frustum then
you draw everything immediately. If it intersects the frustum (and the node has
children)
then you recurse.
By the way, with respect to Elite, I once partially reverse engineered the ZX
Spectrum
version, which is visibly identical to the SAM version implying that all that
is running is the
Spectrum code and a mode 1 screen. In which case we are seeing the following
abuses
of the SAM hardware :
- mode 1 display, with obvious effects on running speed
- software double buffering, even though in the SAM (and 128kb Spectrum, I
believe)
this can be achieved in hardware
If someone is planning on writing a new implementation of Elite for the SAM,
then it might
be worth noting that the original BBC Micro 6502 source has been released by
Ian Bell
but is nearly illegible. It has subsequently been converted into C using the
Allegro
graphics library by Christian Pinder, the source for which is available via
http://www.newkind.co.uk (see Elite : The New Kind, rather than the other). I
contributed the anti-aliased drawing routines, and a few other modifications
regarding
subpixel accuracy for that purpose!
-Thomas
When words aren't enough - Vodafone live! A new world of colour, sounds,
picture messages and information on your mobile. a
href=http://ad.doubleclick.net/clk;4909903;7724245;q?http://www.vodafone.co.uk/live;
Click here/a to find out more.