Next: 6.21.7 Example: Image Warping
Up: 6.21 Procedural Texture Generation
Previous: 6.21.5 Other Noise Functions
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:
- 1.
- glAccumGL_LOAD,1.0(GL_LOAD,1.0);
- 2.
- glAccumGL_ADD,-0.5(GL_ADD,-0.5);
- 3.
- glAccumGL_MULT,2.0(GL_MULT,2.0);
- 4.
- glAccumGL_RETURN,1.0(GL_RETURN,1.0);
- 5.
- Save the image in the color buffer to a texture, main memory, or other
color buffer.
- 6.
- glAccumGL_RETURN,-1.0(GL_RETURN,-1.0);
- 7.
- 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
David Blythe
1999-08-06