Notes for Tuesday April 14 class -- Bicubic surface patches

I will be filling in more info in these notes, but I wanted to post this now to get you started with the material as soon as possible.

Crossing one Bezier cubic curve with another to create a bicubic patch

As we discussed in class, we can evaluate a Bezier bicubic surface patch over (u,v), which has a cross section for any fixed u and for any fixed v, by doing the following math:
spline value at (u,v) u3 u2 u  1 -1   3  -3   1 
 3  -6   3   0 
-3   3   0   0 
 1   0   0   0 
P0,0 P0,1 P0,2 P0,3
P1,0 P1,1 P1,2 P1,3
P2,0 P2,1 P2,2 P2,3
P3,0 P3,1 P3,2 P3,3
-1   3  -3   1 
 3  -6   3   0 
-3   3   0   0 
 1   0   0   0 
v3
v2

1
Note that our key points matrix contains 16 key values for each of the x, y and z coordinates.

Therefore, a total of 48 floating point numbers is required to create a single Bezier bicubic surface patch.

Catmull Rom splines
A Catmull Rom spline is purely interpolating: The spline goes through all of the key points.

In a Catmull Rom spline with n cubic segments, consider segment i, which goes between key point Pi and key point Pi+1. We can then use the previous key point Pi-1 to control the slope at the beginning of the cubic segment, and the following key point Pi+2 to control the slope at the end of the cubic segment.

To convert those four key points into an interpolating spline between Pi and Pi+1, we use the Catmull Rom spline basis matrix:

a
b
c
d
-1/2
 1
-1/2
 0
 3/2
-5/2
 0
 1
-3/2
 2
1/2
 0
 1/2
-1/2
 0
 0
Pi-1
Pi
Pi+1
Pi+2
Adding noise to lighting
In class we modified the fragment shader by adding the line shown in blue to create more interesting specular reflection lighting by using the noise function.
    // DO PHONG SHADING

    vec3 color = ambient;
    for (int i = 0 ; i < nl ; i++) {
       vec3 R = 2. * dot(uLDir[i], N) * N - uLDir[i];
       float d = max(0., dot(uLDir[i], N));
       float s = pow(max(0., dot(E, R)), p);
       color += uLCol[i] * (diffuse * d + specular * s);
    }
    color += specular * .02 * (.1 + noise(2. * N) * N.z);
    if (ta != 0.)
       color *= 1. + ta * noise(vec3(tf * vUV, 0.));
    gl_FragColor = vec4(sqrt(color), 1.0);