teaching machines

CS 455 Lecture 22 – Applying Noise

Agenda

  • what ?s
  • last homework
  • compute this
  • generating noise
  • wood and marble
  • fog

Compute This

Suppose you’ve got three numbers. You want to weight and sum them. The 0th should be weighted half as much as the 1st. The 1st should be weighted half as much as the 2nd. What are the weights?

Suppose you’ve got n numbers. You want to weight and sum them. The 0th should be weighted half as much as the 1st. The 1st should be weighted half as much as the 2nd. And so on. What are the weights?

TODO

As a lab exercise:

  1. Your task is to color the plane in our scene with a moving fog texture.
  2. Sync with the class repository to get the noise project.
  3. Switch from the noise.*.glsl shaders to the fog.*.glsl shaders.
  4. Generate a volume of noise instead of a slice. Use the Field3 class, a 3D texture (which needs one further parameter to its Upload call), and a sampler3D.
  5. Retrieve the grayscale intensity from the fog volume in the fragment shader. You’ll need 3D texture coordinates to sample a 3D texture. Where do you get them? The plane’s 2D texture coordinates provide two. For the third, let’s use a time uniform. As time progresses, we will draw the fog out from different planes of our 3D texture.
  6. In OnDraw, upload the time uniform such that it increases as our application executes. What do you notice?
  7. When you are satisfied with the advancement of the texture, let’s make the fog transparent. Hug your drawing of the plane with these commands:
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    ...
    glDisable(GL_BLEND);

    In your fragment shader, set the fragment’s color opacity (it’s a channel) to the fog intensity. How does this look?

  8. You might find it helpful to push the fog to the background like we did with the skybox. In the vertex shader, add:
    gl_Position.z = gl_Position.w;
  9. What can you do to make the fog thicker? More immersive?
  10. Send me a screenshot of your foggy plane.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *