Assignment 4 Frequently Asked Questions (FAQ)

Q. I'm getting this error when I try to build the viewer--what's up?
ld32: FATAL 12: Expecting n32 objects: /usr/class/cs248/support/lib/libppm.a(libppm1.o) is o32.
make: *** [viewer] Error 2

 A. This is due to a bug in the Makefile that causes trouble on the raptors. Please copy the updated makefile from the assignments directory to your work directory, remove your old object files, and try compiling again.

Q. How come the texture coordinates are stored in an array of three floats? What's the third one for?

 A. Don't worry about the third one, it's always zero. The first two are the u and v texture coordinates, respectively.

Q. How many parameters should I use on my config files?

 A. Make any variable you could ever possibly want to change when experimenting a parameter. For example, you can implement several ways of doing something as separate shaders - or introduce an integer or string valued variable to make a choice between implementations inside a shader. Document everything. We'll need to know what variables you used so we can see what they do.

Q. How do I load textures into memory for use in my shader?

 A. See the file image.h in the framework; the function ReadImage() is what you want to use. You'll probably want to load the texture in the shaderSetup() function.

Q. How do I get the surface's partial derivatives for bump mapping?

 A. Check out the variables float surfaceDDs[3], surfaceDDt[3]; in info.h

Q. For the marble and wood textures, do I need to write my own noise function, modify the one in mnoise.c, or do something like that?

 A. Nope! You'll want to use noise and call the FBm() function, but you don't need to implement your own noise function or change the implementation of the supplied one. Instead, the trick is figuring out how to call the function and how to use the result in the process of getting an accurate-looking result.

Q. Any hints for how to do bump mapping?

 A. Sure! Use a paint program to design bump images. Start with a black canvas and paint white shapes on it. Then, view it with xv and blur it (a lot... use a blur size of at least 7). Or, write a function that given parameter values (u,v) returns a height value or a gradiant value. Think about including a bumpScale parameter that will allow you to increase or decrease the effect the bumps have on your normal to make them easier to see.

Q. Wow! How incredibly useful! How about some hints for the wood and marble shaders?

 A. You bet, campers! Our silly noise example used the noise function to modulate a color between black and white - i.e. color = noise*otherColor. Use linear interpolation to modulate between two colors. Even better - figure out a way to modulate between three colors.

When I run the viewer, I just get a window filled with black. What's up?

 A. Is the shader that is being executed setting a color?

I'm getting compile errors when I try to use the FBm() function.

 A. Bug in our Makefile--sorry! Please copy the new Makefile from /usr/class/cs248/assignments/assignment4.

Which graphics package can we use on the SGI machines to draw/create our bump map pattern?

 A. display is a possibility. Run it and hit the left mouse button over the window to get a menu. There are some options for drawing basic shapes, etc.

I'm getting strange errors when I try to parse the config file, even though everything looks ok.

 A. Make sure the config file ends with a newline. Unfortunately, our parser doesn't handle this robustly.

Q. I don't understand the FBm() function or how to use it to make marble/wood.

 A. First, a brief review of Perlin's noise function. The noise function is defined throughout 3D space, and returns a value between -1 and 1 (roughly). It has two important properties:

One way to think of it is as a sine wave defined in 3 space, except it is a little more irregular. See our example noise shader to get an idea of what noise looks like on its own. If you consider wood or marble, each has higher frequency variation than the noise function, and each has sharp transitions, which noise doesn't naturally have.

The function we supply you, FBm(), packages Perlin's function in a convenient manner. To wit:

FBm(float x, float y, float z, float omega, float lambda, float octaves)
  double ret = 0;
  double o = omega;

  for (int i = 0; i < (int)octaves; ++i) {
     ret += o * Noise(x, y, z);

     o *= omega;
     x *= lambda;
     y *= lambda;
     z *= lambda;

  ret += (octaves - (int)octaves) * o * Noise(x, y, z);
  return ret;
FBm() can be used to compute a series of scales of noise, in order to add higher frequencies. The octaves parameter defines how many scales to add together. Lambda gives the change in frequency between scales: for almost all situations, a lambda value of 2 is right. Finally, the omega parameter is a muliplicitive change in amplitude from scale to scale. It should usually be less than one, since higher frequencies should have less impact. Experiment with it to see how it changes the 'roughness' of the texture. Given a value of omega and the knowledge of the fact that Noise() returns values (roughly) between -1 and 1, it's possible to bound the value of FBm().

Given all that, there are a few things to figure out:

Q. I'm having trouble getting the mask I created with xv (or xpaint) to work.

 A. When you make a *.ppm image in xpaint or xv, make sure you save it in full color mode. Otherwise, it uses a range of 0-1 rather than 0-255.

Copyright © 1998 Pat Hanrahan