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.


Timings (MM:SS.S) are for 500x500 pixel images on a PentiumIII 733Mhz with 384MB SDRAM
(unless otherwise noted).



scale-0.5 scale-1
scale-2 scale-4
(click on each image for a larger view).

Four images showing marble solid texture at different scales.

scaleperioddistortionoctavesrender
10.51.01.082.0
21.01.01.082.0
32.01.01.082.0
44.01.01.082.0


period-0.5 period-1
period-2 period-4
(click on each image for a larger view).

Four images showing marble solid texture at different periods.

scaleperioddistortionoctavesrender
11.00.51.082.0
21.01.01.082.0
31.02.01.082.0
41.04.01.082.0


distortion-0.5 distortion-1
distortion-2 distortion-4
(click on each image for a larger view).

Four images showing marble solid texture at different4 distortions.

scaleperioddistortionoctavesrender
11.01.00.582.0
21.01.01.082.0
31.01.02.082.0
41.01.04.082.0


octave-1 octave-2
octave-4 octave-8
(click on each image for a larger view).

Four images showing marble solid texture at different octaves.

scaleperioddistortionoctavesrender
11.01.01.010.8
21.01.01.021.0
31.01.01.041.4
41.01.01.082.0


Eight images showing different color maps.

noise-1 noise-2 noise-3 noise-4
noise-5 noise-6 noise-7 noise-8
(click on each image for a larger view).


marble-1 marble-2
marble-3 marble-4
(click on each image for a larger view).

My best attempts at making a realistic looking marble sphere.

scaleperioddistortionoctavesrender
11.01.33.0122.8
21.01.51.7326.3
30.31.23.082.1
42.71.60.682.1


marble-teapot marble-al
marble-dolphins marble-flake
(click on each image for a larger view).

And of course, how could we do without a marble teapot? We all know that Capone favored pinstripes! Also shown are some marble dolphins and a marble sphereflake.



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