Warp Color
Warp Color
#ifdef GL_ES
precision mediump float;
#define GLSLIFY 1
#endif
uniform vec2 u_resolution;
uniform float u_time;
uniform vec2 u_mouse;
#define GLSLIFY 1
vec4 warpcolor(in vec2 uv, float t){ //Normalized uv[0~1]
float strength = 0.4;
vec3 col = vec3(0);
//pos coordinates (from -1 to 1)
vec2 pos = uv*2.0-1.0;
//請小心!QC迴圈最好使用int index,float index有可能錯誤!
for(int i = 1; i < 7; i++){//疊幾層
pos.x += strength * sin(2.0*t+float(i)*1.5 * pos.y)+t*0.5;
pos.y += strength * cos(2.0*t+float(i)*1.5 * pos.x);}
//Time varying pixel colour
col += 0.5 + 0.5*cos(t+pos.xyx+vec3(0,2,4));
//Gamma
col = pow(col, vec3(0.4545));
return vec4(col,1.0) ;
}
void main()
{
vec2 uv = gl_FragCoord.xy/u_resolution.xy;
uv.x*= u_resolution.x/u_resolution.y;
vec4 color = warpcolor(uv, u_time/10.);
gl_FragColor = vec4(color);
}