From 6a7e322957c13af9420607974cb5b03d475f96da Mon Sep 17 00:00:00 2001 From: hellerve Date: Thu, 8 Jun 2017 22:00:05 -0400 Subject: [PATCH] basic: added nightsky; utilities: added random --- basic/nightsky.glsl | 30 ++++++++++++++++++++++++++++++ utilities/random.glsl | 5 +++++ 2 files changed, 35 insertions(+) create mode 100644 basic/nightsky.glsl create mode 100644 utilities/random.glsl diff --git a/basic/nightsky.glsl b/basic/nightsky.glsl new file mode 100644 index 0000000..0c22412 --- /dev/null +++ b/basic/nightsky.glsl @@ -0,0 +1,30 @@ +#ifdef GL_ES +precision mediump float; +#endif + +#define PI 3.14159265358979323846 + +uniform vec2 u_resolution; +uniform vec2 u_mouse; +uniform float u_time; + +float random (in vec2 _st) { + return fract(sin(dot(_st.xy, + vec2(12.9898,78.233)))* + 43758.5453123); +} + +float line(vec2 st, float pct) { + return smoothstep( pct-0.02, pct, st.y) - + smoothstep( pct, pct+0.02, st.y); +} + +void main() { + vec2 st = gl_FragCoord.xy/u_resolution.xy; + + float color = 0.; + + color = line(st, random(st)); + + gl_FragColor = vec4(vec3(color),1.0); +} diff --git a/utilities/random.glsl b/utilities/random.glsl new file mode 100644 index 0000000..e1e1b00 --- /dev/null +++ b/utilities/random.glsl @@ -0,0 +1,5 @@ +float random(vec2 st) { + return fract(sin(dot(st.xy, + vec2(12.9898,78.233)))* + 43758.5453123); +}