Creating a disintegration effect
It is straightforward to use the GLSL discard
keyword in combination with noise to simulate erosion or decay. We can simply discard fragments that correspond to a noise value that is above or below a certain threshold. The following image shows a teapot with this effect. Fragments are discarded when the noise value corresponding to the texture coordinate is outside a certain threshold range.
Getting ready
Set up your OpenGL program to provide position, normal, and texture coordinates to the shader. Be sure to pass the texture coordinate along to the fragment shader. Set up any uniforms needed to implement the shading model of your choice.
Create a seamless noise texture (see Creating a seamless noise texture), and place it in the appropriate texture channel.
The following uniforms are defined in the fragment shader, and should be set via the OpenGL program:
NoiseTex
: The noise textureLowThreshold
: Fragments are discarded if the noise value is below this value...