|
Notes for Thursday February 13 class -- Ray tracing to a sphere, part 2
We implemented a simple version of ray tracing to a sphere
You can see what we did in hw2.zip.
I've added some comments to make things easier to read.
I also mentioned the alternate open-source
Tor Web Browser,
which uses a search engine that doesn't track you
or sell your information to advertisers.
Just in case you sometimes want a less intrusive
alternative to you-know-who. :-)
Then I went over Phong Shading on the whiteboard
The first really interesting model for surface reflection was developed by Bui-Tong Phong in 1973.
Before that, computer graphics surfaces were rendered using only diffuse lambert reflection.
Phong's was the first model that accounted for specular highlights.
The Phong model begins by defining a reflection vector R, which is a reflection of the
direction to the light source L about the surface normal N.
As we showed in class, and as you can see from the diagram on the right,
it is given by:
R = 2 (N • L) N - L
|
|
Computing the R vector
|
|
Once R has been defined, then the Phong model
approximates the specular component of surface reflectance
as:
Srgb max(0, E • R)p )
where Srgb is the color of specular reflection, p is a specular power,
and E is the direction to the eye. In our case, E = -W, the
reverse of the ray direction.
The larger the specular power p, the "shinier" the surface will appear.
We can have more than one light.
To get the complete Phong reflectance, we sum over the lights in the scene:
Argb +
∑i
lightColori
(
Drgb max(0, N • Li) +
Srgb max(0, E • R) p
)
where
Argb,
Drgb and
Srgb
are the ambient, diffuse and specular color,
respectively, and p is the specular power.
|
|
Vectors used for Phong specular reflection
|
Homework, due before start of class on Thursday Feb 20
Extend what I implemented in class by adding the
specular component of the Phong reflectance model.
When you have done that, you should see a
specular highlight on the sphere.
For the image on the right,
I used a Phong specular power of 20.0.
Some things you might try for extra credit:
- Try putting two or more spheres into the scene
- Try more than one light source
- Animate things creatively
- Put some noise texture on your sphere
- Add noise into the sphere computation itself
You can also use your imagination, and
do something for extra credit that will
surprise me. I would like that. :-)
|
|
Sphere with specular component
|
| |
|