I recently finished up school, and part of that was finishing up my ray tracing project. At the last minute, I implemented Gouraud shading which is a technique to try to smooth out a triangulated surface. What it really does is just linearly interpolate the normal vectors, where the normal of a vertex is calculated as a weighted average of the normals of the triangles using that vertex.

Long story short:

A render of the Stanford bunny with my raytracer without Gouraud shading.

A render of the Stanford bunny with my raytracer without Gouraud shading.

A render of the Stanford bunny with smooth Gouraud shading.

A render of the Stanford bunny with smooth Gouraud shading.

Also, thanks to an improvement in my parallelization of the problem and a speedup in octtree traversal, I was able to render the Stanford dragon model (~1 million triangles):

The Stanford dragon model.

The Stanford dragon model.

Tagged with:
 

Stanford Bunny

The Stanford Bunny is a graphics benchmark of sorts. It was a high-resolution scan that the imaging lab there did of a ceramic bunny, and the triangulation is a popular model to test systems on.

It contains a little under 70,000 triangles which makes brute-force ray tracing intractable. I mentioned octtrees earlier, and so having built octtrees into my ray tracer, I was able to render the Stanford Bunny in about 40 minutes on one core. Granted, that’s with only 1-pass anti-aliasing, but I feel pretty good about this. I don’t think I’ll have a chance to implement Gouraud shading (or normal interpolation for that matter), but as soon as I do, it will look a lot less blocky.

The Stanford Bunny rendered with my ray tracer.

The Stanford Bunny rendered with my ray tracer.

Tagged with:
 

Raytracing is slow. Incredibly slow. Painfully slow. That’s because you’ve got to check a lot of things to accurately determine what you’re seeing, if it’s in shadow, if it reflects off of something, etc., so it helps quite a bit to be able to get an idea beforehand of where everything is. Enter octtrees.

We’ve got a picture of a model (in this case, the Stanford bunny model). It consists of thousands of tiny triangles that make a surface. Then, imagine a cube surrounding the entire model. If there are two many triangles in that cube, you cut the cube in to eight smaller cubes, and repeat. What this build is a tree where “busy” portions of the space get divided more.

And now for pretty pictures:

The bunny on its own.  There are tricks to smooth it out, but I left it highly triangulated to better represent the idea.

The bunny on its own. There are tricks to smooth it out, but I left it highly triangulated to better represent the idea.


Bunny with balanced wireframe octtree around it.

Bunny with balanced wireframe octtree around it.


Profile of the bunny with a very deep octtree.

Profile of the bunny with a very deep octtree.

I’m finishing up the implementation, and then I’ll be using it as part of my octtree as a intersection speedup.

Tagged with:
 

Orbits

Orbiting planets. The days are about twice as along as they normally are relative to each planet’s year, but that’s an aesthetic preference. Enjoy.

Tagged with:
 

New Render

I got a new render up from my ray tracer that applies planetary textures to spheres and makes them spin on their respective axes (none of the planets in our solar system spin on a “vertical” axis). I hope to do one with their orbits, but I haven’t had a chance to get to it; though, the nice thing is, I just have to define their paths and rotations as a function of time, and where I want the viewpoint to be. It took about 15 minutes to render in full HD 1080×1920 on 18 processors:

Tagged with:
 

This afternoon I was able to successfully parallelize the ray tracer I wrote for Graphics II to run on the Alamode cluster at Mines. Using 17 machines, I was able to render a 4,096 x 4,096 pixel image with 25 passes and up to 5 reflections. It took only 1 minute and 20 seconds.

Reflective spheres rendered at high resolution on a small cluster.

Reflective spheres rendered at high resolution on a small cluster.


Another image rendered on the same cluster

Another image rendered on the same cluster

For the benefit of those who are not computer scientists, this is what the input file looks like:

8192 8192
0 0 20
-1 -1 1
2 0 0
0 2 0
3 10 10 0.8
0.2
9
# These next few lines will define a triangle
T
# With one of the points at (1, 1, 1)
1 1 1
# and the next point here:
0.12321 0.12321 -1
# and the last point here:
-1 1 1
# and with this color setting
1 1 1 1 1 1 0 1 0.7
T
-1 1 1
-0.12321 0.12321 -1
0.12321 0.12321 -1
1 1 1 1 1 1 0 1 0
T
1 -1 1
0.12321 -0.12321 -1
-1 -1 1
1 1 1 1 1 1 0 1 0
T
-1 -1 1
-0.12321 -0.12321 -1
0.12321 -0.12321 -1
1 1 1 1 1 1 0 1 0
T
1 1 1
0.12321 0.12321 -1
1 -1 1
1 0 0 1 0 0 0 1 0
T
1 -1 1
0.12321 -0.12321 -1
0.12321 0.12321 -1
1 0 0 1 0 0 0 1 0
T
-1 1 1
-0.12321 0.12321 -1
-1 -1 1
1 1 0 1 1 0 0 1 0
T
-1 -1 1
-0.12321 -0.12321 -1
-0.12321 0.12321 -1
1 1 0 1 1 0 0 1 0
S
0 0 0 0.5
1 0 1 1 0 1 0 1 0.3

Tagged with: