Last active
July 7, 2018 13:25
-
-
Save takeokunn/c39a2578860f69b0fcef071fff10e966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precision mediump float; | |
uniform float t; // time | |
uniform vec2 r; // resolution | |
const float PI = 3.1415926; | |
const vec3 red = vec3(1.0, 0.0, 0.0); | |
const vec3 yellow = vec3(1.0, 1.0, 0.2); | |
const vec3 white = vec3(1.0); | |
const vec3 black = vec3(0.15, 0.15, 0.15); | |
const vec3 gray = vec3(0.4, 0.4, 0.4); | |
void circle(vec2 p, vec2 offset, float size, vec3 color, inout vec3 i) { | |
float l = length(p - offset); | |
if(l < size) { | |
i = color; | |
} | |
} | |
void ellipse(vec2 p, vec2 offset, vec2 prop, float size, vec3 color, inout vec3 i) { | |
vec2 q = (p - offset) / prop; | |
if(length(q) < size) { | |
i = color; | |
} | |
} | |
void circleLine(vec2 p, vec2 offset, float iSize, float oSize, vec3 color, inout vec3 i) { | |
float l = length(p - offset); | |
if(l > iSize && l < oSize) { | |
i = color; | |
} | |
} | |
void arcLine(vec2 p, vec2 offset, float iSize, float oSize, float rad, float height, vec3 color, inout vec3 i) { | |
float s = sin(rad); | |
float c = cos(rad); | |
vec2 q = (p - offset) * mat2(c, -s, s, c); | |
float l = length(q); | |
if(l > iSize && l < oSize && q.y > height) { | |
i = color; | |
} | |
} | |
void main(void) { | |
vec2 p = (gl_FragCoord.xy * 2.0 - r) / min(r.x, r.y); | |
vec3 destColor = vec3(1.0); | |
circle(p, vec2(-0.4, 0.35), 0.15, yellow, destColor); | |
circleLine(p, vec2(-0.4, 0.35), 0.15, 0.16, gray, destColor); | |
circle(p, vec2(-0.4, 0.35), 0.08, white, destColor); | |
circle(p, vec2(0.4, 0.35), 0.15, yellow, destColor); | |
circleLine(p, vec2(0.4, 0.35), 0.15, 0.16, gray, destColor); | |
circle(p, vec2(0.4, 0.35), 0.08, white, destColor); | |
circle(p, vec2(0.0), 0.5, yellow, destColor); | |
circleLine(p, vec2(0.0), 0.5, 0.51, gray, destColor); | |
ellipse(p, vec2(0.15, 0.05), vec2(0.65, 1.0), 0.075, black, destColor); | |
ellipse(p, vec2(-0.15, 0.05), vec2(0.75, 1.0), 0.075, black, destColor); | |
ellipse(p, vec2(0, -0.25), vec2(1.75, 1.0), 0.150, white, destColor); | |
ellipse(p, vec2(0, -0.20), vec2(1.75, 1.0), 0.025, black, destColor); | |
arcLine(p * vec2(0.9, 0.95), vec2(0.0, -0.15), 0.19, 0.20, PI, 0.19, black, destColor); | |
gl_FragColor = vec4(destColor, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment