io7m | single-page | multi-page | archive (zip, signature)
2. Examples2D GPU displacement mapping4. Ripple
PreviousUpNext

Procedural textures
Modern OpenGL implementations allow for rendering to textures via the use of framebuffers. The programmer allocates space for an RGBA texture, creates a "framebuffer object" and then attaches the allocated texture to the framebuffer object as storage space for the color buffer. The programmer then "binds" the framebuffer object and performs rendering commands as normal. The output produced by the commands is written to the texture as opposed to the screen. This texture can then be used in subsequent rendering commands like any other texture.
The rest of this document consists of examples of combining 2D displacement mapping and render-to-texture techniques to produce a range of computationally inexpensive and deceptively complex-looking effects.
Examples are given in the Java programming language for the sake of keeping code platform independent, but no Java-specific features are used and programs should be easily understood by programmers of other imperative languages (C, C++, Ada, etc). The OpenGL library used is LWJGL. The example code uses OpenGL 3.0 but does not use anything that is not present in OpenGL 2.1 other than framebuffer objects. Porting this code to OpenGL 2.1 is simple: see the ARB_framebuffer_object and/or EXT_framebuffer_object extensions. The shaders used are GLSL 1.1 compatible. For the sake of keeping the code short and simple and to avoid depending on external libraries for what should be short tutorial code, the example programs use the immediate mode glBegin()/glEnd() functions to specify vertices and also the traditional OpenGL matrix stack.

PreviousUpNext
2. Examples2D GPU displacement mapping4. Ripple