2-D PSRDnoise tutorial

Page 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21

Frame rate: FPS

14: Gradients can push things

We can use the noise gradient to displace the texture coordinates of other patterns. This works differently from simply displacing with a vector built from noise values, because it performs the displacement in a manner very similar to bump mapping, and can create very cheap but plausible-looking imitations of refractions and reflections.

This rather weird shader warps the regular grid texture on the "tiled surface" by adding the gradient of a noise pattern to its texture coordinates. The amount of warping is varied with the y coordinate, creating an illusion of refraction in the water of a swimming pool, with more "refraction" (texure coordinate distortion) to the pattern where the "water surface is farther from the tiled wall". Of course, the refraction isn't computed in any real sense -- we don't even compute the 3-D position of the water surface or the pool wall. This is "visually plausible", but there is absolutely no physics modelling involved, just some carefully scaled texture warping with noise, created for a specific visual effect. We could easily add plausibly faked specular highlights to the "water surface", but let's not go overboard with this particular example.

Note that this is all done by a single evaluation of the noise function. Displacing the texture coordinates in a less nice-looking fashion with a vector of two uncorrelated noise values would require more work for a less satisfactory result.

Of course, the gradient can be used for proper bump mapping to simulate reflections and refractions with a lot more accuracy, and we will get to that. However, this example shows the utility of simply using the gradient from one noise texture evaluation to push around the texture coordinates for a second texture evaluation. We will use this in the next example.

	// Text in this pane will be dynamically replaced.