Skip to content

Instantly share code, notes, and snippets.

@earino
Created February 19, 2014 17:22
Show Gist options
  • Select an option

  • Save earino/9096814 to your computer and use it in GitHub Desktop.

Select an option

Save earino/9096814 to your computer and use it in GitHub Desktop.
Why is there C in my javascript?!
/* from http://madebyevan.com/webgl-water/water.js
used in the awesome WebGL water demo
http://madebyevan.com/webgl-water/*/
this.dropShader = new GL.Shader(vertexShader, '\
const float PI = 3.141592653589793;\
uniform sampler2D texture;\
uniform vec2 center;\
uniform float radius;\
uniform float strength;\
varying vec2 coord;\
void main() {\
/* get vertex info */\
vec4 info = texture2D(texture, coord);\
\
/* add the drop to the height */\
float drop = max(0.0, 1.0 - length(center * 0.5 + 0.5 - coord) / radius);\
drop = 0.5 - cos(drop * PI) * 0.5;\
info.r += drop * strength;\
\
gl_FragColor = info;\
}\
');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment