axmol/tests/cpp-tests/Content/Shaders/example_Plasma.fsh

30 lines
883 B
Plaintext
Raw Normal View History

// Shader from http://www.iquilezles.org/apps/shadertoy/
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 center;
uniform vec2 resolution;
2019-09-04 09:58:40 +08:00
uniform vec2 u_screenSize;
2019-03-26 13:45:03 +08:00
uniform vec4 u_Time;
void main(void)
{
2019-09-04 09:58:40 +08:00
#ifdef METAL
float fragCoordY = u_screenSize.y - gl_FragCoord.y;
#else
float fragCoordY = gl_FragCoord.y;
#endif
2019-03-26 13:45:03 +08:00
float time = u_Time[1];
2019-09-04 09:58:40 +08:00
float x = gl_FragCoord.x - (center.x - resolution.x / 2.0);
float y = fragCoordY - (center.y - resolution.y / 2.0);
float mov0 = x+y+cos(sin(time)*2.)*100.+sin(x/100.)*1000.;
float mov1 = y / resolution.y / 0.2 + time;
float mov2 = x / resolution.x / 0.2;
float c1 = abs(sin(mov1+time)/2.+mov2/2.-mov1-mov2+time);
float c2 = abs(sin(c1+sin(mov0/1000.+time)+sin(y/40.+time)+sin((x+y)/100.)*3.));
float c3 = abs(sin(c2+cos(mov1+mov2+c2)+cos(mov2)+sin(x/1000.)));
gl_FragColor = vec4( c1,c2,c3,1.0);
}