My Octopress Blog

A blogging framework for hackers.

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 1080x1920 on 18 processors:

Ray Tracer - Texturing Support

It’s all well and good to be able to render shapes in space in a photorealistic way, but at some point you’d like to draw something that doesn’t have just one surface color. After all, a billboard isn’t just a bunch of shapes each of which has one color - it’s one object with paint / ink placed on it in an ordered way.

Texturing accomplishes by taking a primitive shape (like a sphere, triangle, surface of revolution, etc.) and wrapping an image onto and over it. Let’s consider a sphere in space: [caption id=”attachment_502” align=”aligncenter” width=”300” caption=”A white sphere in space.”]A white sphere in space.[/caption]

Now let’s say we mean it to be Earth. Then we can take a picture of Earth that’s flat: [caption id=”attachment_503” align=”aligncenter” width=”300” caption=”Flattened map of Earth”]Flattened map of Earth[/caption]

and then map it onto a sphere to get a picture of what we all know Earth to look like: [caption id=”attachment504” align=”aligncenter” width=”300” caption=”Behold!”]Behold![/caption] [caption id=”attachment506” align=”aligncenter” width=”300” caption=”Two Mars globes where the left is what is seen with the eye, and the right is a topographic map.”]Two Mars globes where the left is what is seen with the eye, and the right is a topographic map.[/caption]

IP Geolocation

There are a million services out there where you type in an IP address and get an estimate as to its location. A few months ago I stumbled across a free IP geolocation database because I find myself using online services from time to time - I was sort of surprised how often it’s helpful to know where traffic is coming from (outside of Google Analytics, etc.).

Using the database I found, I threw together a script that takes a list of domain names and / or IP addresses and gives you an idea of where it lives:

dan-lecocqs-macbook:~ dlecocq$ ipquery google.com 209.85.171.100 Mountain View, US 94043 37.4192 -122.0570 dan-lecocqs-macbook:~ dlecocq$ ipquery yahoo.com 68.180.206.184 Sunnyvale, US 94089 37.4249 -122.0070 dan-lecocqs-macbook:~ dlecocq$ ipquery apple.com 17.251.200.70 Cupertino, US 95014 37.3042 -122.0950 dan-lecocqs-macbook:~ dlecocq$ ipquery mines.edu 138.67.1.8 Golden, US 80401 39.7146 -105.2430

Ray Tracer - Now With Animation

It occurred to me today that I could render a scene several times with slight perturbations and then mesh them together into a movie. It took about 15 minutes to render on a cluster at Mines, and then about a minute to stitch together with Mencoder. At 18 frames per second, here is the result. Enjoy!

Ray Tracer Feature: Lathes

Up to this point, my ray tracer had been limited to rendering spheres and triangles, and, while there’s a lot you can do with these primitives, it’s often more efficient and effective to use a lathe or surface or rotation. Imagine you’ve got a curve, and you rotate it around some axis, keeping track of the surface it swept out.

Alternatively, imagine a lump of clay on a clay wheel. As the wheel rotates, if you hold some shape against the clay, it will become a solid that’s symmetrical about the vertical axis. Here’s a sine curve rotated about : [caption id=”attachment_489” align=”aligncenter” width=”300” caption=”A sinusoidal lathe and a sphere.”]A sinusoidal lathe and a sphere.[/caption]

[caption id=”attachment_491” align=”aligncenter” width=”300” caption=”A polynomial curve rotated about x=0.”]A polynomial curve rotated about x=0.[/caption]

Parallel Ray Tracer

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. [caption id=”attachment_481” align=”aligncenter” width=”300” caption=”Reflective spheres rendered at high resolution on a small cluster.”]Reflective spheres rendered at high resolution on a small cluster.[/caption] [caption id=”” align=”aligncenter” width=”300” caption=”Another image rendered on the same cluster”]Another image rendered on the same cluster[/caption]

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

Mandelbrot Set

I take another look at my Mandelbrot code because we recently did a project with antialiasing in a raytracer. I updated my project so that instead of bouncing light, it would instead sample a point on the complex plane, and determine if it was in the Mandelbrot set, and so on and so forth.

I ran the code with 10 passes and 16,384 by 16,384 pixels (~27 megapixels) on my desktop. It took about an hour and a half, but this is the picture that came out of it (it’s a little big):

[caption id=”” align=”aligncenter” width=”300” caption=”A recent rendering of mine of the Mandelbrot set.”]A recent rendering of mine of the Mandelbrot set.[/caption]

I also have a couple of extra pictures that show portions of the set in their detail: [caption id=”attachment475” align=”aligncenter” width=”300” caption=”A region of the Mandelbrot set.”]A region of the Mandelbrot set.[/caption] [caption id=”attachment476” align=”aligncenter” width=”300” caption=”Another zoomed-in portion of the set.”]Another zoomed-in portion of the set.[/caption]

Critical Language Scholarship - Results

I was notified today that I was not accepted into the CLS program for Intermediate Arabic. While I am disappointed and frankly a little surprised, it is a competitive scholarship with acceptance rates under 10%.

To those of you who were accepted, congratulations.

Raytracer With Anti-aliasing and Reflection

For Graphics II, we had to implement a raytracer, and then add anti-aliasing and a feature of our choice. I selected mirrored surfaces.

First, anti-aliasing. Here are a few pictures of the same image rendered with a different number of passes to change the smoothness.

[caption id=”attachment459” align=”aligncenter” width=”300” caption=”Using one pass”]Using one pass[/caption] [caption id=”attachment460” align=”aligncenter” width=”300” caption=”Using 5 passes.”]Using 5 passes.[/caption] [caption id=”attachment_461” align=”aligncenter” width=”300” caption=”Using 50 passes.”]Using 50 passes.[/caption]

And lastly, here’s a scene of several spheres, some of which are reflective. [caption id=”attachment462” align=”aligncenter” width=”300” caption=”A set of spheres, some of which are mirror-like.”]A set of spheres, some of which are mirror-like.[/caption] [caption id=”attachment467” align=”aligncenter” width=”300” caption=”A reflective sphere next to some triangles.”]A reflective sphere next to some triangles.[/caption] [caption id=”attachment469” align=”aligncenter” width=”300” caption=”A mirrored sphere in the center of four other sphere.”]A mirrored sphere in the center of four other sphere.[/caption] [caption id=”attachment470” align=”aligncenter” width=”300” caption=”More spheres!”]More spheres![/caption]

Lamp

I made a lamp this weekend for Rachel as a belated Valentine’s Day gift. Made from balsa wood, vellum, hot glue and the electrical components, I got my inspiration from Instructables. It didn’t look well put-together, and so I made my own interpretation:

[gallery link=”file” orderby=”ID”]