My Octopress Blog

A blogging framework for hackers.

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]