Problem Set 2

CMSC 427

Distributed Thursday, February 24, 2005

Due: Thursday, March 10, 2005

 

Programming

 

  1. Perlin Noise: Implement an interactive version of the Perlin noise function. You can see Ken Perlin’s talk at http://www.noisemachine.com/talk1/; for pseudo-code and more explanation check out http://freespace.virgin.net/hugo.elias/models/m_perlin.htm. Ken Perlin also provides some code at http://www.noisemachine.com.  You are free to use or adapt any of this code in completing the assignment. Please reference any sources that you use.

 

You will write a program to generate Perlin noise.  The program will allow the user to tune the characteristics of the noise, displaying the result, and saving it to a file when the user is satisfied with its appearance.  To start with, you will be given some skeleton code, including code for reading and writing images to files using a format called bmp.  Executing the skeleton code will display a screen with uniform gray “noise”.  Typing ‘s’ will save this noise image to a file called ‘noise.bmp’. 

    1. 20 points. Modify this program so that it initially displays some Perlin noise instead of a uniformly gray image.  This can be Perlin noise generated at a single octave.
    2. 5 points. Now, modify your program so that you can control the number of octaves used to generate the Perlin noise.  Typing 'o' should increase the number of octaves used, and typing 'O' should decrease the number of octaves.
    3. 5 points. Add a feature that allows you to control the color of the noise, by typing ‘r’, ‘g’, ‘b’, ‘R’, ‘G’, ‘B’.  For example, typing ‘r’ should increase the amount of red in the noise, while typing ‘R’ should decrease the amount of red. 
    4. 5 points. Now add a feature so that typing ‘p’ allows you to zoom in on the texture, while typing ‘P’ zooms you out.
    5. 5 points. Finally, add a toggle so that typing 1 either turns off or turns on turbulence.  This is done by using the absolute values of the intensity, instead of the raw intensity.
    6. Challenge problem:  Add more features to your Perlin noise generator, and experiment with other mappings from noise to color.  Ideas can be found on Ken Perlin’s web pages, on the instructions to Problem Set 1 of Amitabh Varshney’s class last semester, and on the web.  Derek has also implemented an interesting method you can look at by typing ‘2’ on his demo system.  Try to generate the most realistic possible grass to map onto your ground plane (see problem 2), or the most creative textures to map onto your buildings.  Document how you achieved your results.  Prizes will be given for the best results.

 

 

 

  1. Texture Mapping:
    1. 12 points. Modify the 3D program from problem set 1 to texture map images onto the rectanguloids.  You may use Perlin noise that you have generated, and/or you may use your own images. 
    2. 12 points.  Also, create a ground plane and texture it with a grass-like Perlin noise texture generated using code from Problem 1.  Position the retanguloids so that they appear to rest on the plane.  Note that you can still do this problem using Derek’s code even if you do not complete problem 1.

 

 

Pencil and Paper Exercises (9 points each.  For problems with three parts, each part is 3 points.)

 

  1. Suppose we have two triangles of equal area in the z=0 plane.  We rotate them about the y axis and project them orthographically back into the z=0 plane. 
    1. Prove that the projection of the two triangles still have equal area.
    2. What is the relationship between the area of the triangles before and after they are projected, as a function of the angle of rotation?
    3. Show that if we project the two triangles using perspective projection they do not necessarily have the same area after projection.
  2. Suppose we have a perspective camera, with a focal point at the origin, and an image plane at the z=1 plane.  We are looking at lines on the floor, which is the    y = -5 plane.  Give equations that describe the set of lines that have a vanishing point at (3,0,1).
  3. Consider a point that at time t=0 is at the position (6,1,2).  The point travels in the z direction at a speed of one unit of distance per unit of time.  For example, at time t=1, the point is at (6,1,3).  Suppose this point is being imaged using the perspective camera in problem 2.  Write an equation that gives the x coordinate of the image of the point as a function of time.
  4. Suppose that a fan has five identical, equally spaced blades.  The fan is rotating at a speed of 10 revolutions per second.
    1. Suppose at time 0 a blade has an angle of 0 relative to the x axis.  If we take another picture 1/30th of a second later how far will this blade have moved?
    2. What will be the angle to the blade that is nearest to the x axis.
    3. How quickly do we have to take photographs to avoid aliasing?
  5. Challenge Problem: Suppose we have a one-dimensional sine wave, y = sin(kx).  Suppose we average this function, so that the y value of every point is replaced by the average of all points within a distance of  p/8 of that point in the x direction.  What will be the function that results from this averaging?  Explain how this shows that averaging helps remove high-frequency changes in an image.