CS 455 Lecture 22 – Applying Noise
April 30, 2015 by Chris Johnson. Filed under
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 378
Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 379
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 380
Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 381
Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 382
Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/twodee/blog/wp-includes/category.php on line 383
cs455, lectures, spring 2015.
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:
- Your task is to color the plane in our scene with a moving fog texture.
- Sync with the class repository to get the
noise project.
- Switch from the
noise.*.glsl shaders to the fog.*.glsl shaders.
- 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.
- 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.
- In
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 a channel) 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.