CS 455 Lecture 22 – Applying Noise
- what ?s
- last homework
- compute this
- generating noise
- wood and marble
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?
As a lab exercise:
- Your task is to color the plane in our scene with a moving fog texture.
- Sync with the class repository to get the
- Switch from the
noise.*.glslshaders to the
- Generate a volume of noise instead of a slice. Use the
Field3class, a 3D texture (which needs one further parameter to its
Uploadcall), and a
- 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
timeuniform. As time progresses, we will draw the fog out from different planes of our 3D texture.
OnDraw, upload the time uniform such that it increases as our application executes. What do you notice?
- 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
achannel) to the fog intensity. How does this look?
- 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;
- What can you do to make the fog thicker? More immersive?
- Send me a screenshot of your foggy plane.