Time for action – testing some post-process effects
Open the file
ch10_PostProcess.html
in an HTML5 browser.The buttons at the bottom allow you to switch between several sample effects. Try each of them to get a feel for the effect they have on the scene. We've already looked at grayscale, so let's examine the rest of filters individually.
The invert effect is similar to grayscale, in that it only modifies the color output; this time inverting each color channel.
uniform sampler2D uSampler; varying vec2 vTextureCoord; void main(void) { vec4 frameColor = texture2D(uSampler, vTextureCoord); gl_FragColor = vec4(1.0-frameColor.r, 1.0-frameColor.g, 1.0-frameColor.b, frameColor.a); }
The wavy effect manipulates the texture coordinates to make the scene swirl and sway. In this effect, we also provide the current time to allow the distortion to change as time progresses.
uniform sampler2D uSampler; uniform float uTime; varying vec2 vTextureCoord; const float speed = 15.0; const float magnitude...