CS 6620 - Fall 2012 - Ray Tracing for Graphics

Project 6 - Textures

In this project we add textures to objects as well as background and reflection/refraction environment images.

Requirements

XML Scene Format

We have some additions to the XML scene format description to support textures. Textures can be used with color values as shown below. If a color is specified, the value of the texture should be multiplied with the color.

<diffuse r="1" g="0.5" b="0.5" texture="bricks.ppm"/>

<specular value="1" texture="checkerboard"/>

<diffuse texture="bricks.ppm"/>

If the texture attribute value is "checkerboard," we use the checker board procedural texture. Otherwise, we assume that the texture attribute value is the file name of an image and we use that image as the texture. The image file should be located in the same directory as the scene XML file.

The checker board procedural texture has two colors. By default these colors are black and white, but custom color values can be specified as shown below.

<diffuse texture="checkerboard">
   <color1 r="1" g="0" b="0"/>
   <color2 r="0" g="1" b="0"/>
</diffuse>

Each texture has its own texture space, which can be defined using transformations, just like object transformations.

<diffuse texture="checkerboard">
   <scale x="0.25" y="0.5"/>
   <translate x="0.2"/>
</diffuse>

We specify the background image (or color) using the "background" tag, placed inside the "scene" tag. By default the background image is mapped to fit the screen, but transformations can be applied.

<background r="1" g="1" b="1" texture="clouds.ppm">
   <scale y="0.4"/>
   <translate y="-0.1"/>
</background>

The reflection/refraction environment is used when a bounced ray doesn't hit any of the objects. We use environment mapping for the environment texture.

<environment value="0.3" texture="clouds.ppm"/>

You can use this test scene to verify that your implementation is correct. You will also need the bricks.ppm and clouds.ppm files that are referenced in the scene XML file.

Resources

Here is an updated header file that includes classes for keeping the new scene definition in the memory and the updated Blinn Material class that uses textures. Here is an example implementation of the XML parser using TinyXML.

Optional Feature Suggestions

Student Project Pages



_