WebGL Ripple Effect

This is a grid of triangles all programmatically laid out. Each vertex is oscillating on it's Z-coordinate. Using WebGL vertex and fragment shaders, I'm coloring the triangles based on their Z coordinate.
As the value gets more positive, it is colored more red. And as gets more negative, it is colored more blue.

Download the source code here: ripple.js and shapes.js


Your browswer does not support HTML5 Canvas. Try using Chrome!

THE CODE...

initializes all the vertices and triangles on the grid with an X, Y, and Z coordinate. An update loop moves their positions up and down.

THE VERTEX SHADER...

assigns a color to each vertex based on its Z coordinate. The higher up it is, the lighter in color it is.

THE FRAGMENT SHADER...

takes the color information for each vertex, and rounds its value to only one decimal. This loss causes the banding effect on each triangle.



Things that work well:


Things I'd like to impove:


Debug:

Any debug information will be printed out here.