|
Ray Tracing Projects |
|
Assignment 5: Marble Image (with Phong
Shading) |
Return to Ray Tracing
Assignment Overview
|
|
Here, a marble-like effect is created using a
solid texture generated by a noise function from Ken Perlin (see Perlin's
web page
here). Different marble effects are possible by varying
the parameters: scale, period, distortion, and octaves in the
following GenMarble function:
Sin(period * point[X] + distortion * fractal(point, octaves));
Where fractal() returns a summation (based on
the number of octaves) of the result of the Perlin noise function
at a given point in 3-space. The color at a particular point
becomes the object base color multiplied by some weighting of the
absolute value of the equation above. Different "marbles" can be used
in the input file--each which generate their own random Perlin
noise--so one can render more than one type of marble in a given
scene. On the other hand if a new marble is not specified,
the same one is used for evey object below it in the input file,
so triangle meshes would appear as one object (see discussion of
input file below).
When I got my first images I was impressed, but
they seemed to lack a certain marble shine. I hadn't
implemented Phong shading yet, so I figured this would be the best
time to do that so I could have some specular highlights on my
marble.
|
|

400x400 JPG converted from PPM output
scale = 1.6; period = 3.0; distortion = 6.0;
octaves = 8
|
|

400x400 JPG converted from PPM output
scale = 0.4; period = 1.0; distortion = 5.0;
octaves = 64
|
|

400x400 JPG converted from PPM output
scale = 2.5; period = 1.0; distortion = 2.0;
octaves = 2
|
|

50 Floating Marbles
400x400 JPG converted from 500x500 PPM output
scale = 2.6; period = 4.0; distortion = 6.0;
octaves = 8
|
|
Redesigned Input File
There are now two types of "materials": marble
and regular. Regular materials will be Phong shaded based on
a diffuse color, a specular color, and a Phong constant (highlight
size). Lambertian objects can be rendered simply by omitting
the specular color and phong constant. The keyword "regular"
in the input file means that all objects that follow will be
shaded with a soild color until the next material keyword is seen.
The "marble" material keyword has four values
that follow it, one each for the aforementioned parameters: scale,
period, distortion, and octaves. The same Perlin noise
function will be used for each object following the marble keyword
(this is good for objects made of triangle meshes--where it should
visibly look like the same texture. To get different marbles
in a scene, simply add more marble material keywords and values
before each object that is to be different. See example file
and image below:
|
|

Scene from Previous Assignments: Marbleized
400x400 JPG converted from 500x500 PPM output
Input File:
light -1.0 0.25 0.0 1 1 1
ambient 0.2 0.2 0.2
marble 1.7 5.2 1.5 8
triangle -2.25 0.50 -6.00 0.00 -1.00 -4.00 0.00 2.00 -4.50
0.48 0.30 0.16 0.6 0.6 0.6 32
marble 1.0 4.2 2.5 8
triangle 0.00 -2.00 -5.00 1.50 -1.00 -3.00 1.00 0.00 -10.00
0.78 0.63 0.35 0.6 0.6 0.6 32
marble 1.6 3.0 6 8
sphere -0.5 -0.9 -2.0 0.8 0.53 0.68 0.48 0.6 0.6 0.6 32
marble 0.65 1.75 9 16
sphere -1.0 0.0 -5.0 1.0 0.06 0.21 0.23 0.6 0.6 0.6 32
sphere 0.0 0.0 -6.0 1.0 0.41 0.14 0.00 0.6 0.6 0.6 32
sphere 1.0 0.0 -7.0 1.0 0.15 0.30 0.37 0.6 0.6 0.6 32
sphere 2.0 0.0 -8.0 1.0 0.70 0.69 0.55 0.6 0.6 0.6 32
marble 0.1 2.2 4.0 8 16
sphere 6.0 10.0 -50.0 20.0 0.99 0.85 0.031 0.6 0.6 0.6 32
|
Object Format Reference:
light x y z r g b
ambient r g b
triangle x1 y1 z1 x2 y2 z2 x3 y3 z3
dR dG dB sR sG sB phong
sphere x y z radius dR dG dB
sR sG sB phong
marble scale period distortion octaves
|
 |
 |
 |
|
email
at jasonwaltman
dot com |
 |
|
(c) 2000-2007 jason waltman |
|
|