Created
February 19, 2014 17:22
-
-
Save earino/9096814 to your computer and use it in GitHub Desktop.
Why is there C in my javascript?!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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