CS 184: COMPUTER GRAPHICS

Heads-up!!  -- Midterm-Exam: in class on Wednesday 3/16 -- be prepared; show up on time!

How to prepare for the Midterm-Exam

What to do during the Midterm-Exam


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

A)  Use a minimum number of cubic Bezier
segments to make a G1- and C1-continuous,
planar curve with turning-number zero.
B)  How can you place a minimal number of
control points for a cubic B-spline curve, so that
you obtain a rollercoaster track with a knot in it ?
HINTS: 
Draw a simple curve with turning-number zero.
Try to split this conveniently into segments that
   can be realized with cubic Bezier curves.
Properly glue these segments together to obtain
   the desired continuity.

HINTS:
Try to make a knot with a minimum number
   of straight, connected sticks.
Solve the problem in a top-down view first;
   then adjust the heights later.
Check whether the B-spline forms the same knot.

Lecture #15 -- Mon 3/14/2011.

Discuss Mini-Quiz #2:  Review:  "Winding-Number"  and  "Turning-Number"

Finishing up from last time:

Complicated Interpolating Splines made from Bezier Segments

How to put two Bezier segments together with G1 or with C1 continuity.

How to generate a G1-continuous compound Bezier curve through many interpolation points.

[ How to do this with G2-continuity ...  (take CS 284). ]


Two Outstanding extra-credit submissions from Assignment#6:
Chris Tandiono
Brandon Wang


And a truely awesome "bubble" scene:
Andrew Lee (cs184-ei): "Cherry-Blossom Island" produced by the Sakura Scene Generator



Smooth Shading

Many models in computer graphics are not really smooth, but are more or less finely tessellated polyhedral surfaces.
When rendered with flat shading (each triangle shaded based on its face normal), they will look facetted.
We can make their appearance much smoother, by smoothly varying the shading over the whole surface.
This can be done in two basic ways:

1.  Gouraud Shading Technique:  Linear interpolation of (scalar) brightness values

Good for: handling small nonuniformities in illumination intensity, or for polyhedral approximations to round objects.
Principle: Use barycentric or bilinear (using sweep-line) intensity interpolation.
GOURAUD SHADING TECHNIQUE:


1. Compute Brightness, B, at visual vertices, A, B, C, D ...
2. Compute Brightness along edges by linear interpolation between vertices.
3. Compute Brightness along spans by linear interpolation between edges.

The result is fake: edges remain straight (visible at the silhouette edges!) and highlights look unnatural -- but the method is efficient.
Limitations of Gouraud Shading: 
Some flat spots;  extrema may be "short-circuited";   discontinuities at concave corners;   missing highlights...

2nd Technique:  Phong Shading:  Interpolate normal vector directions

We can fix some of the above problems with a more sophisticated interpolation scheme.
We first calculate averaged vertex normals at all the vertices.
The best way to calculate these averages is by weighting the normal of every facet that touches this vertex with the inside angle of that contributing facet. -- In this way, if we were to split one of these facets, the net contribution to the averaged vertex normal would not change. (For well-behaved meshes just giving every facet normal an equal weight is also acceptable).
Once we have all the vertex normals, we then calculate the surface normal at an arbitrary point inside a facet, by bi-linear interpolation between the surrounding vertex normals. For triangles this just means weighting the three vertex normals with the barycentric coordinates of the ray intersection point.
In a classical rendering environment, we compute the normals for every pixel in an efficient incremental manner, scanline by scanline.
PHONG SHADING


1. Compute normals, N, at visual vertices, A, B, C, D ...
2. Compute normals along edges by vector interpolation.
3. Compute normals along spans by vector interpolation.
4.For every pixel compute brightness from interpolated normal direction and local light intensities.

Phong can interpolate over flat spots. -- But it is not perfect either !
Limitations of Phong Shading:
“Corrugated” structures with too few vertices (just a zig-zag) may have all parallel normal directions and cannot represent periodic shading variations.
(Geometry that is not "seen" at vertices cannot be inferred!  Illumination changes that are not seen at vertices cannot be inferred!)

In Assignment#8 we ask you to compare the flat-shaded rendering style with a smooth-shading style.

Surface Decoration

Motivation: It would be too tedious to describe all the rich details that we observe in natural scenes with individual polygons and polyhedrons!
In Assignment#8  you will make worms/snakes/ribbons/sculptures with a focus on surface decoration.

Slides covering the techniques below in more detail:
(Thanks to James O'Brien for many many of the pictures!)

A terse summary of the key techniques:

Texture mapping:

A simple way to make a surface more interesting is by texture mapping.
The texture map provides a look-up table for the local color on a piece of surface.
Two additional scalar values nare stored at each vertex: the "texture coordinates" (s,t).
Rendering textures is based on bilinear interpolation of these texture coordinates s,t.
If the geometric coordinates and the texture coordinates of a facet are not matched, serious distortion can result.
Designing and defining seamless textures on complex objects is a more challenging task:
How do you design and place textures, so that they smoothly wrap around the various arms and holes of objects of higher genus?

Bump mapping:
Jiggle the vertex normals to produce changes in shading that simulate the existence of height variations on the surface.
However, at the silhouette edges one can still see clearly that the underlying shape may have been smooth.

Displacement mapping:
In this technique a varying incremental height-offset is specified over the surface,
and a more complictaed computation is applied to determine how this changes the intersection point with the imaging rays
and how it affects the surface normals at all the ray intersection points.

Environment mapping:
This is a cheap way to simulate highly reflective objects in complex environments.
Rather than actually tracing rays from the shiny surface into the environment to see what gets hit,
we use a single, global surrounding picture of the environment which gets accessed with the direction of the reflected ray.
Any local intersections with real objects in the scene are ignored.
Example, the surroundings of a bar in Palo Alto reflected in a shiny sculpture.


Implementation of all these techniques:
This typically occurs through special graphics hardware: GPU's (Graphics Processing Units),
using special Shader programs that work on a  per-vertex
per-fragment or per-pixel  basis.
Example of a typical processing pipeline.
We encourage you to explore several of these techniques over the next two weeks;
this work gives you extra credit for As#8, and also serves to put some techniques in place for your final projects.

Remarks about your Final Course Projects


Reading Assignments:

Read about cubic curves, texture mapping, shaders;  compare to lecture notes and assignment write-ups.
Shirley: [ 2nd Ed: Ch 15;  11.2-11.7;  Ch 17
Shirley: { 3rd Ed: Ch 15 11.2-11.6;  Ch 18 }



Programming Assignment #8:
May be done in pairs;
due (electronically submitted) before <NEW DATE!> Wednesday 3/30, 11:00pm == after Spring Break!
( You may use this time to do some cool extra-credit work. )



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