COMP870: Homework 4

Huai-Ping Lee

Procedural Shading with RenderMan

The Utah teapot scene (RIB) file used in this homework is downloaded from RenderMan Repository. I changed the image size and shaders used.

Modified Surface Shader

I tried out some built-in shaders in PRMan (in /usr/local/prman/lib/shaders) such as "glass," which uses

    (comp(Ci,0) + comp(Ci,1) + comp(Ci,2))/3 + (1-Cs)

as the output opacity, which depends on the colors. I changed it to depend on the angle between the viewing direction and the normal:

    ...
    Nf = faceforward( normalize(N), I);
    V = -normalize(I);
    ...
    P_tr = transform("shader", P);
    C_tmp = 2 * color noise(P_tr);
    Kl = (comp(C_tmp,0) + comp(C_tmp,1) + comp(C_tmp,2))/3;
    Oi = Kl * (0.75 - 0.5 * abs(V.Nf));
    ...
  

Here are the resulting pictures:
built-in glass shader modified glass shader
built-in glass teapot modified glass teapot

Displacement Shader

I tried out a procedural displacement shader from RenderMan Repository:

    ...
    PP = transform ("shader", P);
    size = frequency;
    for (i = 0;  i < maxoctaves;  i += 1) {
        magnitude += abs (.5 - noise (PP*size)) / size;
        size *= 2;
      }
    P = P - (Km * pow (magnitude, power)) * normalize (N);
    N = calculatenormal (P);
    ...
  

which is basically moving each fragment along its normal direction according to some turbulence (sum of multiple noise functions with varying amplitude and frequency). Here are some results:
Km = 1 Km = 5
dented, Km = 1 dented, Km = 5

Code

Modified .rib and .sl code.

Reference

RenderMan Repository, http://www.renderman.org/.