hello world
Posted by Andy on May 29, 2009
In my journey as a 3D graphics programmer, it seems I am continually learning, forgetting, and relearning a lot of the millions of fine details, particularly the finer points of the math. I thought I should make a place where I can capture my moments of clarity, so that I can refer back to them later. And why not put it on the web while I’m at it, so that others who are learning can have a look?
I’ve been doing 3D graphics programming for about 17 years, ever since the day in 10th grade algebra when we covered rectangular and polar coordinates. Daydreaming during the lesson, I realized that you could use that math to rotate stuff. On the way home, I imagined using the formulas to rotate a cloud of points in 3D space. I went straight to my Tandy 1000 and fired up BASIC.
My first 3D program had a random cloud of pixels spinning in 3D space, projected head-on, orthographically. In other words, it looked like a bunch of pixels swaying from side to side on the screen – but I knew what it represented. Then two things happened. First, I realized that if I drew lines connecting the points instead, I could make something more like a geometric shape. I got some graph paper, plotted a triangular prism, and typed in the coordinates. Second, almost as an afterthought, I started thinking about how to make it look “more 3D” – i.e. how to add perspective.
As I remember it, it only took me a few minutes to work out that if I wanted far away things to be smaller, that meant I should divide everything by z. I tried this, and it sort of almost worked, but the result looked distorted. Without understanding what I was doing, I experimented with adding an extra term to the formula until it looked right. And just like that, I had a rotating 3D wireframe model, with perspective.
I didn’t fully appreciate at the time that I had just independently rediscovered the Perspective Projection, following in the footsteps of Florentine painters, mathematicians, and early computer graphics practitioners. Nor did I fully understand the details, such as the fact that my extra term was actually the distance from the eye to the view plane.
I find it a little funny that the concept that spurred me to write a 3D program was rotation, and that I tacked on perspective almost as an afterthought. It’s like I thought rotation was the main thing that would make an object seem real and solid.
Still, figuring out perspective was a pretty big deal. I have a much deeper understanding of it now than I did back then. And yet, when I went to reimplement a projection matrix today, I found that I’d forgotten (again) what a lot of the terms did, and how it all worked with the homogeneous coordinates and what not. So, my first little series will be a breakdown of perspective projection matrices and why they are the way they are.
David said
Hello.
I too love 3D. I first saw 3d renderings in the movie the last starfighter back in the 1980’s.
I later got re-introduced when I found out about Active World (activeworlds.com). There, you can create 3d spaces where visitors can interact with the 3d objects and chat with other visitors.
I saw the future potencial of creating entire web pages in 3d, but no one else seems to be interested in such a project.
On my website I have an interface that I created to help people view 3d websites. It can be downloaded for free. http://www.webelementsplus.com/index/Slipstream3D/slipstream3d.html
Anyhow, I just wanted to make contact and introduce myself. Perhaps we could do some 3d work together.