Back to shaders

Shader test bench

Ocean Caustic Mesh

stronghold-curated material glsl runnable fragment MIT
Source
runnable fragment

Complete GLSL fragment shader. Stronghold runs it directly when the browser can compile it.

Code

precision mediump float;
uniform vec2 resolution;
uniform float time;
void main(){
  vec2 uv=gl_FragCoord.xy/resolution.xy; uv.x*=resolution.x/resolution.y;
  float c=0.0;
  for(int i=0;i<5;i++){
    float fi=float(i)+1.0;
    vec2 p=uv*fi*2.4 + vec2(sin(time*0.25*fi), cos(time*0.18*fi));
    c += abs(sin(p.x*3.14159 + sin(p.y*2.2+time))) / fi;
    c += abs(sin(p.y*3.14159 + cos(p.x*2.0-time*0.7))) / fi;
  }
  c=pow(1.0-smoothstep(0.8,1.45,c/2.4),3.0);
  vec3 water=vec3(0.0,0.18,0.28)+vec3(0.02,0.28,0.38)*uv.y;
  gl_FragColor=vec4(water + c*vec3(0.65,0.95,1.0),1.0);
}