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

37 lines
834 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-03-26 13:45:03 +08:00
float time = u_Time[1];
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
vec2 p = 2.0 * (fragCoord - center.xy) / resolution.xy;
vec2 cc = vec2( cos(.25*time), sin(.25*time*1.423) );
float dmin = 1000.0;
vec2 z = p*vec2(1.33,1.0);
for( int i=0; i<64; i++ )
{
z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
float m2 = dot(z,z);
if( m2>100.0 ) break;
dmin=min(dmin,m2);
}
float color = sqrt(sqrt(dmin))*0.7;
gl_FragColor = vec4(color,color,color,1.0);
}