axmol/tests/cpp-tests/Resources/Shaders/example_Twist.fsh

35 lines
704 B
Plaintext
Raw Normal View History

// Shader from here: http://www.iquilezles.org/
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 resolution;
uniform sampler2D tex0;
uniform sampler2D tex1;
2019-09-04 09:58:40 +08:00
uniform vec2 u_screenSize;
2019-03-26 13:45:03 +08:00
uniform vec4 u_Time;
uniform vec4 u_CosTime
void main(void)
{
2019-09-04 09:58:40 +08:00
#ifdef METAL
vec2 fragCoord = vec2(gl_FragCoord.x, u_screenSize.y - gl_FragCoord.y);
#else
vec2 fragCoord = gl_FragCoord.xy;
#endif
2019-03-26 13:45:03 +08:00
float time = u_Time[1];
2019-09-04 09:58:40 +08:00
vec2 p = -1.0 + 2.0 * fragCoord / resolution.xy;
vec2 uv;
float a = atan(p.y,p.x);
float r = sqrt(dot(p,p));
2019-03-26 13:45:03 +08:00
uv.x = r - u_Time[2];
uv.y = sin(a*10.0 + 2.0*u_CosTime[0];
vec3 col = (.5+.5*uv.y)*texture2D(tex0,uv).xyz;
gl_FragColor = vec4(col,1.0);
}