3D Perspective Transformation Project


When I was studying computer graphics at University (well over a decade ago) I remember sitting in my 3D graphics lectures thinking "Why should I bother memorising all this? 3D graphics cards will do it all for me, surely?". To ignore those lectures was a BIG mistake!

Now, after over a decade in the games industry I've certainly picked up a lot, and can normally "get by" when it comes to 3D tasks. But it's not really the same as having a proper grounding in it. I've always had a weakness for 3D worlds and 3D landscape generation and always wanted to do it for myself.

And if I was just messing with DirectX or OpenGL, it would be trivial. I wouldn't really learn all that much about the maths behind it all.

I'm also aware that I don't really have a "showcase" project to show at job interviews (when you work in the software industry, potential employers like to see examples of your coding style before they interview you).

So this project is a marrying of both these problems. My objectives for this project can be summarised thusly:

This webpage exists just to show some screengrabs of how I'm getting on (and for potential employers who will want to see the results but are unlikely to want to compile the code). I suspect these images won't be considered jaw-dropping for anyone else ... but to me they represent a do-my-own-3D-project itch that I'm only scratching now, after over a decade of trying to find the time.

(All but the first-few images can be clicked for higher-res versions.)

Added 14th May 2010.
"Bitmap" class in place. Supports 2D pixel and line-drawing, debug-text plotting, and export to BMP, TGA and PPM.
(Some may notice that I've nicked the font data from RISC OS.)
Added 14th May 2010.
Vector, Matrix and Mesh classes in place. Camera code done. First iteration of 3D-to-2D pipeline done. Woohoo!
It may not look much, but seeing this cube is a big deal for me!
Added 17th May 2010.
Back-face culling working! And the cube is now made of triangles.
Added 17th May 2010.
Rendering in different world-positions working. Also generating face-normal data (though you can't see that).
Added 17th May 2010.
As you can see - no depth buffering or sort order stuff done yet. That's gonna be a stinker.
Added 19th May 2010.
Added ability to generate cylinders with an arbitrary number of sides. Should make it easier to test my directional-lighting code.
Added 20th May 2010.
Directional lighting (and an "ambient" light setting) is working! Thought it would take a couple of evenings, but I seem to have got it working after about half an hour. Woot!
It'll look much better when I implement filled-triangles, though.
Added 23rd May 2010.
Wrote OBJ importer and exporter code, because I wanted objects that were more complicated than what I could build up in code.
To test it, I found some OBJ files off T'Internet with a decent number of vertexes and faces. Daisy, here, will be my model for the session.
This is her with every face rendered ...
Added 23rd May 2010.
And this is Daisy with backface culling applied ...
Added 23rd May 2010.
And this is Daisy with both backface culling and a directional light. You might note that her tail looks wrong - that's because I'm not doing any z-buffering yet. That'll be soon.
Added 26th May 2010.
My first attempt at stereoscopic/anaglyph images! Done by rendering two 3D images (with viewpoints adjusted for the gap between the viewer's eyes) and then merged into one image with a colour filter. Quite pleased with it, as a first go.
This one is for people with red/blue glasses ...
Added 26th May 2010.
... and this one for people with red/green glasses.
Added 27th May 2010.
Supposed to be a line of trees. Or could equally be a rubbish Sentinel remake. Red/blue version.
Added 27th May 2010.
Red/green version again.
26th June 2011:
Rather a long break! Work has been very busy (deadlines for two projects, before my contract came to an end and I moved back to Derby) and the next stage for this renderer has been the most challenging so far.
I have finally got around to attempting the triangle rasteriser and depth-buffer. I probably spent about a week of evenings just reading-up on the subject before I attempted any code. It's only a first go, but I'm quite happy with the results.
Added 26th June 2011.
This shows the triangle rasteriser and depth-buffer working. I've turned off backface culling, so all the triangles for the cubes are being rendered. The fact that it still looks correct means I'm happy that the depth-buffer is working. :)
Added 26th June 2011.
... And because I was pleased with myself (that code was quite difficult to get my head around) I decided I wanted to see Daisy looking a bit more solid.


E-mail me!
This page was last updated June 2011.