shaders

assortment of fragment shaders.
Log | Files | Refs | README | LICENSE

commit 41fdd8440b27b463b27f2afda901ede873c1f0bd
parent bb966bebb323a2ad4a879789ff1f3c2a0ddf20d9
Author: mpizzzle <m@michaelpercival.xyz>
Date:   Mon,  7 Sep 2020 15:12:32 +0100

following along with book of shaders tutorial. safety commit

Diffstat:
Amiyagi.frag | 28++++++++++++++++++++++++++++
Amiyagi2.frag | 26++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/miyagi.frag b/miyagi.frag @@ -0,0 +1,28 @@ +#ifdef GL_ES +precision mediump float; +#endif + +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +// Plot a line on Y using a value between 0.0-1.0 + +float plot(vec2 st) { + return smoothstep(0.02, 0.0, abs(st.y - st.x)); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution; + + float y = st.x; + + vec3 color = vec3(y); + + // Plot a line + float pct = plot(st); + color = (1.0-pct)*color+pct*vec3(0.0,1.0,0.0); + + gl_FragColor = vec4(color,1.0); +} + diff --git a/miyagi2.frag b/miyagi2.frag @@ -0,0 +1,26 @@ +#ifdef GL_ES +precision mediump float; +#endif + +#define PI 3.14159265359 + +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +void main() { + vec2 st = gl_FragCoord.xy / u_resolution; + + //float y = (sin(st.x * PI / 2.0 + (u_time * 1.5)) / 2.0) + 0.5; + //float y = abs(sin(st.x * PI / 2.0 + (u_time * 1.5))); + //float y = fract(sin(st.x * PI / 2.0 + (u_time * 1.5))); + float y = (sin(st.x * PI / 2.0 + (u_time * 1.5)) / 2.0) + 0.5; + + vec3 color = vec3(y); + float pct = smoothstep(y - 0.02, y, st.y) - smoothstep(y, y + 0.02, st.y); + + color = (1.0 - pct) * color + pct * vec3(1.0, 0.0, 1.0); + + gl_FragColor = vec4(color, 1.0); +} +