COMP 238 Programming Assignment 4

Experiment and exercise your creativity with procedural shading. (assignment)

Algorithm

I used the RenderMan shading language, specifically BMRT.

I wanted to implement shaders for a scene with the three pyramids at the Giza plateau in Egypt. I used Ayam for modeling and slced for editing the shaders. I modeled the pyramid faces as BPatches, the desert and the sky as simple Boxes and the Moon as a Sphere.

The scene, in the Ayam modeler.

At first, I tried combining the brick surface shader and the brickbump displacement shader that come with BMRT. While the result looked reasonable from a distance, it had no new elements (except maybe for the color). Next, I modified the default displacement for the brick surface from zero to some fraction of the texture coordinate. With that, the pyramids looked like pagoda rooftops. Having gained enough experience, I set on to write my own displacement shader. I wanted a "staircase" look for the pyramid sides (although when built they were probably flat).

My displacement shader, in slced's preview mode.

The drawing on the left shows one "step" from the "staircase", projected to 2D.

Side BC coincides with some fraction of the pyramid's side, and has the same slope.

Angles ACD and BAD are equal to the pyramid's slope, passed in as a parameter (arguably not the best choice if the same material is to be used for all the pyramids and their slopes are different, but good enough for our purposes).

In a displacement shader, the current point is displaced along its normal by an amount that's computed by the shader from its input parameters (in this case, texture coordinates). 

Here, we have two cases: points on side BD should be displaced to side BA, and points on side DC should be displaced to side AC.

In each case, the displacement is computed as the length of the side parallel to side AD in triangles similar to triangles ABD and ADC, repspectively.

As seen in the results below, the staircase aspect is different for different heights, because the texture coordinates used as input map to 3D locations further apart.

Also, since the displacements are made in the direction of the surface normal, the pyramid corners becone "holes", and the tip and bases of the pyramids have artifacts.

I also used two shaders from the RenderMan Repository: the craters surface shader for the moon, and the Venus surface shader for the sand surface. For the pyramid surface shader, I used BMRT's brushed metal surface shader. I ended up spending a lot of time tweaking the parameters for these shaders. For example, no matter how hard I tried, my moon did not look quite right: the normals for some of the points in the craters had some problems, yielding results hat looked like holes in the surface.

Results

Below are some screenshots produced by BMRT:

The entire scene.

The smallest pyramid, lateral view (with amplified lights). Note the artifacts at the tip and base.

The smallest pyramid, top view (with amplified lights). Note the hollowed corners.

The largest pyramid, lateral view (with amplified lights). Note the different appearance of the staircase.

The moon up close and personal. Note the "holes" in its surface.

Links

Last modified on November 6, 2002 by .