Created
January 7, 2022 15:29
-
-
Save kurtroberts/27fc95315fbd8137956c5a2406816651 to your computer and use it in GitHub Desktop.
Shaders Notes
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
#ifdef GL_ES | |
precision lowp float; | |
#endif | |
uniform vec2 u_resolution; | |
float draw_circle(vec2 coord, vec2 center, float radius) { | |
return step(distance(center, coord), radius); | |
} | |
void main() { | |
vec2 coord = gl_FragCoord.xy / u_resolution; | |
float circle = draw_circle(coord, vec2(.5, .2), 0.1); | |
vec3 color = vec3(circle); | |
gl_FragColor = vec4(color, 1.0); | |
} |
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
#ifdef GL_ES | |
precision lowp float; | |
#endif | |
uniform vec2 u_resolution; | |
float draw_rectangle(vec2 coord, vec2 dimensions) { | |
vec2 shaper = vec2(step(coord.x, dimensions.x), step(coord.y, dimensions.y)); | |
return shaper.x * shaper.y; | |
} | |
float draw_rectangle(vec2 coord, vec2 dimensions, vec2 offset) { | |
vec2 shaper = step(offset, coord); | |
shaper *= step(coord, offset + dimensions); | |
return shaper.x * shaper.y; | |
} | |
void main() { | |
vec2 coord = gl_FragCoord.xy / u_resolution; | |
vec2 offset = vec2(0.3); | |
float rectangle = draw_rectangle(coord, vec2(0.5, 0.25), offset); | |
vec3 color = vec3(rectangle); | |
gl_FragColor = vec4(color, 1.0); | |
} |
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
#ifdef GL_ES | |
precision mediump float; | |
#endif | |
uniform vec2 u_resolution; | |
uniform vec2 u_mouse; | |
uniform float u_time; | |
vec3 white = vec3(1.0); | |
float parabola (float x, float k) { | |
return pow(4.0 * x * (1.0 - x), k); | |
} | |
vec3 splotch (vec2 st, vec3 colorA, vec2 posA, vec2 mouse) { | |
vec2 posB = posA + 0.1; | |
float pct = smoothstep(0.1, 0.4, distance(st, posA) + distance(st, posB)); | |
vec3 color = mix(mix(colorA, white, parabola(distance(st.y, mouse.y), 9.0)), white, pct); | |
return color; | |
} | |
void main () { | |
vec2 st = gl_FragCoord.xy / u_resolution.xy; | |
vec2 mouse = u_mouse.xy / u_resolution.xy; | |
vec3 color2 = vec3(0.29, 0.345, 0.98); | |
vec3 color3 = vec3(0.98, 0.58, 0.29); | |
vec3 color4 = vec3(0.69, 0.98, 0.29); | |
vec3 canvas = splotch(st, color2, vec2(0.6, 0.3), mouse); | |
canvas *= splotch(st, color3, vec2(0.8, 0.1), mouse); | |
canvas *= splotch(st, color4, vec2(0.1, 0.7), mouse); | |
gl_FragColor = vec4(canvas, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ISF version (madmapper)