The Code Therapy

Manga White Star

A star shining through the lenses of the manga world!

Created by mgshadermaster on Sat, 06 Jul 2024 00:37:36 GMT.


#version 300 es

//By MGShaderMaster!

precision highp float;

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

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

const float PI = 3.14;

void main(void) {
  vec2 uv = gl_FragCoord.xy / resolution.xy;
  uv = uv * 2.0 - 1.0;
  uv.x *= resolution.x / resolution.y;
  uv -= mouselerp / 10.0;
  vec2 circlePos = vec2(0.02, 0.3);
  circlePos = uv - circlePos;

  float dist = length(circlePos);
  const float radius = 0.4;
  const float edgeThickness = 0.2;
  const float glowIntensity = 0.06;

  float circleEdge = smoothstep(radius - edgeThickness, radius + edgeThickness, dist);
  float neonGlow = glowIntensity / pow(circleEdge, 2.0); // Make glow around edge

  float circleFill = smoothstep(radius, radius - edgeThickness, dist); // Make cicle "Middle" fill
  float intensity = max(circleFill, neonGlow); // Mix em' both
  intensity = clamp(intensity, 0.0, 1.0);

  vec2 stripPos = uv * rotate(-PI * 0.28);
  float intensitySub = clamp((sin(stripPos.x * 321.0) - clamp((stripPos.x * 10.0 + 0.05), 0.0, 1.0)) * smoothstep(0.3, 1.0, circleFill * 0.8), 0.0, 1.0); // Decrease Thickness of lines
  intensitySub = (intensitySub - clamp((stripPos.x - 0.06) * 100.0, 0.0, 1.0)) * step(0.3, circleFill); // Decrease Opacity of lines
  intensity -= intensitySub;
  intensity = clamp(intensity, 0.0, 1.0);

  circlePos *= rotate(time / 5.0);

  float moon = length(circlePos * 2.0) - 1.2;
  moon = 0.134 / moon;
  moon = abs(moon);
  moon = clamp(moon, 0.0, 1.0);

  float moonShadow = length((circlePos - vec2(0.03, 0.03)) * 2.0) - 1.2;
  moonShadow = 0.19 / moonShadow;
  moonShadow = abs(moonShadow);
  moonShadow = clamp(moonShadow, 0.0, 1.0);
  vec3 color = vec3(max(moon - moonShadow, intensity));

  fragColor = vec4(color, 1.0);
}