CS 184: COMPUTER GRAPHICS

Warm-up Exercise:

Last time we tried to gain a qualitative understanding of illumination and brightness.
Today we want to gain experience in doing a quantitative calculation:

Given a directional white light source (sun) sending 3 trillion photons per second per mm2

shining at an angle of 60 degrees (measured against the normal vector) on to a cyan-colored lacquered surface

with those specifications:    color = (0.2  1.0  0.7),  ka = kd = 0.2,      ks = 0.8,      ksp = 75,      ksm = 0.6;

the surface is in an environment of yellow ambient light:    color = (1.0  1.0  0.0),    I =  0.4*1012 photons / s / mm2.

Calculate the intensities of the (r,g,b) components sent towards an eye located in direction of the ideally reflected rays.

Ieye, r = _____ ;      Ieye, g = _____ ;      Ieye, b = _____ .



PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT

Lecture #11 -- Mon 3/2/2009.

A practical raytracer system has many different aspects:

We will take a look at all three of them today (and also in assignments A#5 and A#6).

Physical Aspect: Working with the Lighting/Shading equations.

SOLUTIONS TO THE ABOVE PROBLEM:

Calculate the diffusely reflected components:

I'd   = (  Ia + Id*cos(inc.angle) ) * kd * (r,g,b):
I'dR = (  0.2   +  1 * 0.5   )    *   0.2    *  (0.2)  = 0.028 
*1012 photons / s / mm2.
I'dG = (  0.2
   +  1 * 0.5   )    *   0.2    *  (1.0)  = 0.14    *1012 photons / s / mm2.
I'dB = (  0.0   +  1 * 0.5   )    *   0.2    *  (0.7)  = 0.07    *1012 photons / s / mm2.

Calculate the speculalrly reflected component:

I's   = Id  * ks * (Phong.Factor) * (adjusted color):
I'sR = 1  * 0.8  *       (1.0)          * (0.6*0.2 + 0.4*1.0)  = 0.416  *1012 photons / s / mm2.
I'sG = 1  * 0.8  *       (1.0)          * (0.6*1.0 + 0.4*1.0)  = 0.8      *1012 photons / s / mm2.
I'sB = 1  * 0.8  *       (1.0)          * (0.6*0.7 + 0.4*1.0)  = 0.656  *1012 photons / s / mm2.

Sum up the components:

I'totalR  = 0.444  *1012 photons / s / mm2.
I'totalG  = 0.94    *1012 photons / s / mm2.
I'totalB  = 0.663  *1012 photons / s / mm2.

This kind of computation has to be done by your raytracer every time it hits a surface !


Statistical Aspect: Distribution Ray-tracing -- improving resolution quality, reducing aliasing

Shooting only a single ray per pixel can result in objectionable aliasing effects; these can be reduced by shooting multiple rays per pixels and averaging the returned (r,g,b) intensities.
In the simplest case, each pixel is sampled according to a regular grid (i.e. 2, 3, or 4 samples per pixel edge). This is equivalent of assuming that you have screen in which the number of pixels in the horizontal and vertical directions are increased by an interger multiple.
In a more sophisticated program the individual super-sampling rays would be randomized in their positions within a pixel.

This one basic trick: shooting several distributed rays and then averaging the result, can simulate several useful effects:
Anti-aliasing of high spatial frequencies
Smooth reflections and refractions
Soft Shadows
Fuzzy Reflections on brushed aluminium, brushed table top;   (more brushed metal)
Caustics from reflections, from refractions, in swimming pool
Depth of Field   - distribution sampling over aperture of lens
Motion Blur  - distribution sampling over inter-frame time interval

Geometrical Aspect: Ray - Triangle Intersections [10.3.2]

Ray equation:  R(t) = A+tD
Triangle in barycentric coordinates:  X(β, γ) = V1+β(V2−V1)+γ(V3−V1)
Combine:  V1+β(V2−V1)+γ(V3−V1) = A+tD
Solve for β, γ, and t:  -- 3 equations with 3 unknowns; -- danger: divide by near-zero; -- check ranges.

Eficiency Aspects: Exploiting Locality and Coherence  [10.9]

Ray - Bbox Intersections [10.9.1]

Parameterize ray;  determine parameter values for when ray crosses xmin, ymin, zmin, xmax, ymax, zmax.
Ray passes through box, if the union of all three inside-intervals [ (xmin,xmax), (ymin,ymax), (zmin,zmax) ] is non-zero.

Hierarchical Bounding Boxes [10.9.2]

There are many variant for this ...
We recommend the following approach for your Assignment#6:
Instantiate all objects in your logical scene hierarchy (these could be spheres sprinkled by a generator program, or triangle meshes read in as OBJ files).
Now you have hierarchically flat, fully instantiated "sea of spheres and triangles"; determine the centroid sor each primitive, and the overall bounding box around the whole scene.
Pick the longest axis of this bounding box, and sort all centroids along this axis; then split the whole population at the median into two halves of equal magnitude.
Recursively continue this splitting process for the two halves.
When you have created the complete binary tree, recursively from the leaves to the root, create a nested bounding box hierarchy starting with the bounding boxes of the leaf-primitives.

After having built this additonal data-access structure you can now do the queries as to what each ray intersects much more efficiently.
Compare the rendering times in your ray-tracer with and without using this data structure.

And there are other methods to create efficient testing of Ray-Scene intersections . . .

Uniform Spatial Subdivision [10.9.3]

Binary Space Partitioning [10.9.4]


Reading Assignments:

Study: ( i.e., try to understand fully, so that you can answer questions on an exam): 
Shirley, 2nd Ed:
Ch  9; Ch10.


Programming Assignment 5: To be done individually; due (electronically submitted) before Thursday 3/5, 11:00pm.


PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT
Page Editor: Carlo H. Séquin