How to do it...

To create a shader program that provides a disintegration effect, perform the following steps:

  1. Create a vertex shader that sends the texture coordinate to the fragment shader via the TexCoord output variable. It should also pass the position and normal to the fragment shader through the Position and Normal variables.
  1. Use the following code for the fragment shader:
// Insert uniforms needed for the Phong shading model layout(binding=0) uniform sampler2D NoiseTex; in vec4 Position; in vec3 Normal; in vec2 TexCoord; uniform float LowThreshold; uniform float HighThreshold; layout ( location = 0 ) out vec4 FragColor; vec3 phongModel() { // Compute Phong shading model... } void main() { // Get the noise value at TexCoord vec4 ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.