Pages

miercuri, 9 august 2023

Shader Editor - example 004.

Another example with the Shader Editor android application, this time simpler:
This shader displays some concentric circles that change their colors according to a sine and cosine formula.
This is the source code for the shader:
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif

uniform vec2 resolution;
uniform float time;

void main(void) {
 float mx = max(resolution.x, resolution.y);
 vec2 uv = gl_FragCoord.xy / mx;
 vec2 center = resolution / mx * 0.5;
 float t = time * 10.0;

 gl_FragColor = vec4(cos(t+distance(uv, center) / 222.0)+1.0,
  vec2(sin(t - distance(uv, center) * 76.0)) * 10.5,
  1.0);
}