The Code Therapy

Very un-efficient Colors

Wow this shader is really like that art piece from that one famous guy - proving that art is rubish as this shader took a total of 5 minutes to make

Created by mgshadermaster on Tue, 05 Mar 2024 09:51:42 GMT.


#version 300 es
precision highp float;

uniform vec2 resolution;
uniform float time;
out vec4 fragColor;

mat2 rotate(float angle){
  return mat2(
  cos(angle), -sin(angle),
  sin(angle), cos(angle)
  );
}

float paring(float x, float y){
  return 0.5 * (x + y) * (x + y + 1.0) + y;
}

float randInt(float seed, float range){
  float rand = floor((sin(seed * 12345.0) * 0.5 + 0.5) * 64.0);
  return rand;
}

void main(void) {
  vec2 uv = gl_FragCoord.xy / resolution.xy;
  uv.x *= resolution.x/resolution.y;
  uv *= rotate(time/5.0);
  vec2 rUv = fract(uv * 4.5);
  float id = paring(uv.x * 4.5 - rUv.x, uv.y * 4.5- rUv.y);
  float originId = id;
  id = randInt(id + floor(time / 3.0), 1.0) / 64.0;
  fragColor = vec4(
    randInt(id, 1.0) / 64.0,
    randInt(id + 1.0, 1.0) / 64.0,
    randInt(id + 2.0, 1.0) / 64.0,
    1.0);

  if(mod(id, 3.0) == 0.0){
    if(mod(originId, 2.0) != 0.0){
      if(rUv.x + rUv.y < 1.0){
        fragColor = vec4(
        randInt(originId, 1.0) / 64.0,
        randInt(originId + 5.0, 1.0) / 64.0,
        randInt(originId+ 2.0, 1.0) / 64.0,
        1.0);
      } else {
        fragColor = vec4(
        randInt(originId  + 9.0, 1.0) / 64.0,
        randInt(originId + 1.0, 1.0) / 64.0,
        randInt(originId, 1.0) / 64.0,
        1.0);
      }
    } else {
      if(rUv.y < rUv.x){
        fragColor = vec4(
        randInt(originId, 1.0) / 64.0,
        randInt(originId + 1.0, 1.0) / 64.0,
        randInt(originId + 2.0, 1.0) / 64.0,
        1.0);
      } else {
        fragColor = vec4(
        randInt(originId  + 2.0, 1.0) / 64.0,
        randInt(originId + 1.0, 1.0) / 64.0,
        randInt(originId, 1.0) / 64.0,
        1.0);
      }
    }
  }

}