After Tube2020, I decided to make a more complete 3d engine.
It is still a very simple engine and lacks many features.
It displays only flat shaded triangles and does rotations only around Y axis.
So what to say about it?
It's not very fast despite the fact that it uses the GPU and blitter.
On my PAL machine, it runs in 3 frames (16.6 fps) while computing about 254 triangles.
Possible optimisations are:
improve depth sorting: if I remove depth sorting, it runs in 2 frames (25 fps). To do depth sorting I uses comb sort, which is an optimized bubble sort. Shell sort would probably be better. Another optimisation would be to do depth sorting only on the objects and use convex objects.
backface culling: I didn't implement backface culling (because lazyness). This would likely speed things up quite bit.
use the DSP for transformation and clipping, the GPU for rasterisation.
reduces the amount of transformations: there are duplicate vertices that are transformed multiple times. This could be improved.
Doing this would take time and also run into the 4K limit of the GPU (except using DSP, this would help a lot with the 4K limit but good-bye U235 sound engine).
The routine could easily be split into 2 chunks for the GPU (transformation/clipping and rasterisation).
Anyway, doing fast 3D on the Jag is not easy (who knew?). Now I understand Checkered Flag (which probably uses a faster engine than this one).
But I don't understand No Second Prize on the Atari ST.
Edit: I implemented backface culling and things are indeed quite a bit faster. It now runs in 2 frames (25fps).
The effects of backface culling are two-fold: there are fewer triangles the rasterize will attempt to draw and fewer triangles to depth sort.
By the way I'll explain the meaning of the numbers on screen:
the first is the size of the routine in bytes. I can check that I stay within the 4096 bytes limitation of the GPU.
the second one is the number of triangles rendered.
the third one is a bit hard to grasp: it's the number of ticks (1/50th ou 1/60th of a second depending on your region) used to render 50 frames. So if the number is 50, one frame takes one tick. You are at full framerate (50fps or 60fps). If the number is 100, one frame takes two ticks you're at half framerate (25fps or 30fps).