Next: 6.21.7 Example: Image Warping
Up: 6.21 Procedural Texture Generation
Previous: 6.21.5 Other Noise Functions
  Contents
To create an illusion of turbulent flow, first-derivative discontinuities are
introduced into the noise
function by taking the absolute value of the function. Although OpenGL
does not include an absolute value operator for framebuffer contents, the
same effect can be achieved by the following:
- glAccumGL_ LOAD,1.0(GL_ LOAD,1.0);
- glAccumGL_ ADD,-0.5(GL_ ADD,-0.5);
- glAccumGL_ MULT,2.0(GL_ MULT,2.0);
- glAccumGL_ RETURN,1.0(GL_ RETURN,1.0);
- Save the image in the color buffer to a texture, main memory, or other
color buffer.
- glAccumGL_ RETURN,-1.0(GL_ RETURN,-1.0);
- Draw the saved image from Step 5 using GL_ ONE as both the source
blend factor and the destination blend factor.
The calls with GL_ ADD and GL_ MULT map the values in the
accumulation buffer from the range
[0,1] to [-1,1]; this is needed because values retrieved from the color
buffer into the accumulation buffer are positive.
Since values from the accumulation buffer are clamped to [0,1] when returned,
the first GL_ RETURN clamps all negative values to 0 and returns
the positive values intact. The second GL_ RETURN clamps the positive
values to 0, and negates and returns the negative values. The
color buffer needs to be saved after the first GL_ RETURN because the
second GL_ RETURN overwrites the color buffer; OpenGL does not define
blending for accumulation buffer operations.
Next: 6.21.7 Example: Image Warping
Up: 6.21 Procedural Texture Generation
Previous: 6.21.5 Other Noise Functions
  Contents
2001-01-10