Mindustry/core/assets/shaders/water.frag

41 lines
1.1 KiB
GLSL
Raw Normal View History

2019-03-10 10:53:16 +07:00
#ifdef GL_ES
precision highp float;
precision mediump int;
#endif
uniform sampler2D u_texture;
2020-04-10 07:50:11 +07:00
uniform vec2 u_campos;
uniform vec2 u_resolution;
uniform float u_time;
2019-03-10 10:53:16 +07:00
varying vec4 v_color;
varying vec2 v_texCoord;
2020-04-10 07:50:11 +07:00
const float mscl = 40.0;
const float mth = 7.0;
2020-04-04 11:31:29 +07:00
void main(){
2019-03-10 10:53:16 +07:00
vec2 c = v_texCoord.xy;
2020-04-10 07:50:11 +07:00
vec2 v = vec2(1.0/u_resolution.x, 1.0/u_resolution.y);
vec2 coords = vec2(c.x / v.x + u_campos.x, c.y / v.y + u_campos.y);
2019-03-10 10:53:16 +07:00
2020-04-10 07:50:11 +07:00
float stime = u_time / 5.0;
2019-03-10 10:53:16 +07:00
2020-04-04 09:42:46 +07:00
vec3 color = texture2D(u_texture, c + vec2(sin(stime/3.0 + coords.y/0.75) * v.x, 0.0)).rgb * vec3(0.9, 0.9, 1);
2019-03-10 10:53:16 +07:00
2020-04-04 09:42:46 +07:00
float tester = mod((coords.x + coords.y*1.1 + sin(stime / 8.0 + coords.x/5.0 - coords.y/100.0)*2.0) +
sin(stime / 20.0 + coords.y/3.0) * 1.0 +
2020-04-04 09:42:46 +07:00
sin(stime / 10.0 - coords.y/2.0) * 2.0 +
sin(stime / 7.0 + coords.y/1.0) * 0.5 +
2020-04-04 09:42:46 +07:00
sin(coords.x / 3.0 + coords.y / 2.0) +
2020-04-10 07:50:11 +07:00
sin(stime / 20.0 + coords.x/4.0) * 1.0, mscl);
if(tester < mth){
2019-03-10 10:53:16 +07:00
color *= 1.2;
}
2020-04-04 09:42:46 +07:00
gl_FragColor = vec4(color.rgb, 1.0);
2019-03-10 10:53:16 +07:00
}