| CS6620 | Advanced Graphics 2 | University of Utah |
| Prof: Peter Shirley | Ray Tracing | Sem: Spring 2002 |
|
|
| Assignment 05 - Solid Texture (Marble) |
|
On top of the framework I built for Assignment 04 - RGS vs. BVH Bake-Off, I've added the ability to set materials as solid textures. I did this by creating a new class called a Channel whose sole function is to provide a color output. So, for example, there is a class derived from the channel called a ChannelColor, which is simply a constant color. Derived from the Channel class is also a ChannelMarble class which instantiates a Noise class to compute octaves of noise and combines them into marble. In the scene description file, you can now attach any color component of a material (currently only ambient, diffuse and specular) to any of these channels. It looks like this in the scene file:
material "red" {
diffuse { color < 1 0 0 > }
}
}
which will set the diffuse component to a constant red. Here's a more complex example:
material "marble" {
diffuse {
marble {
scale 1
period 1.3
distortion 3
octaves 12
ramp {
< 1.0 0.000 0.0 >
< 1.0 0.125 0.0 >
< 1.0 0.250 0.0 >
< 1.0 0.375 0.0 >
< 1.0 0.500 0.0 >
< 1.0 0.625 0.0 >
< 1.0 0.750 0.0 >
< 1.0 0.875 0.0 >
}
}
}
}
which will set the diffuse channel to the marble function with the given parameters. The hope is that this organization will allow me the flexibility that I want in setting up materials. Further work will include the ability to combine several channels arithmetically, so I can get multi-pass effects, or for things such as a base diffuse color modulated by a marble procedure or an image (texture) map. Here are some quick notes about how I generate the marble texture. The function I use to compute the marble looks something like the following: abs( sin( 180 * ( period * v.x + distortion * Fractal3( v, octaves ) ) ); where v is the (possibly scaled) position at which the noise is to be computed and Fractal3 is a fractal sum of noise computed as follows:
float n = 0.0f;
for ( int i = 0; i < octaves; i++ )
{
float o = ( float )( 1 << i );
n += Noise3( v * o ) / o;
}
return n;
where Noise3 is the standard Perlin Noise function.
(unless otherwise noted). |
All of the images above can be regenerated by specifying the appropriate
scene file on the command line of the rayn program
rayn-05.zip (443 Kb). The source code is included
in the zip file. Here is a description of the command line parameters for
rayn.
usage: rayn [options] <scene_file>
required:
<scene_file> file containing scene description
options:
-o <output_file> output image filename (output.tga)
-w <width> width of output image (256)
-h <height> height of output image (256)
-shadows <true/false> generate shadow rays (true)
-rgs <true/false> generate regular grid subdivision (true)
-bvh <true/false> generate bounding volume hierarchy (false)
-sort <true/false> sort (not split) the surface list (false)
-cull <true/false> cull backfacing triangles (false)
|
| Questions/comments to nate@pobox.com. |
|
|
|
March 2002 © Nate Robins |