فهرست منبع

test and extend: shader's

micha 2 سال پیش
والد
کامیت
b7530f8776
1فایلهای تغییر یافته به همراه802 افزوده شده و 44 حذف شده
  1. 802 44
      vpu/shader2_live.py

+ 802 - 44
vpu/shader2_live.py

@@ -17,20 +17,711 @@ vertex_shader = """
 in vec3 in_position;
 
 void main(){
-    gl_Position = vec4(in_position, 0.9);
+    gl_Position = vec4(in_position, 1);
 }
 """
 
+fragment_shaderX = """
+#version 400
+
+precision highp float;
+
+uniform float time = 0;
+uniform vec2 mouse = vec2(0,0); 
+uniform vec2 resolution;
+
+
+out vec4 fragColor;
+
+
+float random(float seed)
+{
+	return fract(sin(seed)*1e4);
+}
+
+
+float row(float x, float y, float row_idx)
+{
+	float rand_factor = 0.25+random(row_idx)*0.75;
+	return step(0.2, y) * step(y, 0.8) * step(0.5, random(floor(x*rand_factor*2. + 15.*time*random(rand_factor))));
+}
+
+void main()
+{
+	vec2 uv = gl_FragCoord.xy / resolution.y;
+	uv.x *= 10.0;
+	uv.y *= 35.0;
+	
+	float c = row(uv.x, fract(uv.y), floor(uv.y));
+	
+	fragColor = vec4(c);
+}
+"""
+
+#matrix like
+fragment_shaderX = """
+#version 400
+#extension GL_OES_standard_derivatives : enable
+
+precision highp float;
+out vec4 fragColor;
+
+uniform float time;
+uniform vec2 mouse;
+uniform vec2 resolution;
+
+float random(float seed)
+{
+	return fract(sin(seed)*40002 );//*200e2);
+}
+
+
+float row(float x, float y, float row_idx)
+{
+	float rand_factor1 = 0.15+random(row_idx)*0.75;
+	float rand_factor2 = 0.15+random(row_idx/2.1)*0.75;
+	return step(0.3, y) * step(y, 0.7) * step(0.4, random(floor(x*rand_factor1*-3.0 + 30.100*time*random(rand_factor2))));
+}
+
+void main()
+{
+	vec2 uv = gl_FragCoord.yx / resolution.y;
+	uv.x *= 20.5;
+	uv.y *= 120.0;
+	
+	float c = row(uv.x, fract(uv.y), floor(uv.y));
+	
+	fragColor = vec4(c);
+}
+
+"""
+
+# shadow bar
+fragment_shaderX = """
+#version 400
+//https://glslsandbox.com/e#97695.0
+
+#extension GL_OES_standard_derivatives : enable
+out vec4 fragColor;
+
+precision highp float;
+
+uniform float time;
+uniform vec2 mouse;
+uniform vec2 resolution;
+
+void main( void ) {
+
+	vec2 pos = ( gl_FragCoord.xy / resolution.xy );
+
+        float color = 0.0;//sin(6.28*0.5*(time-pos.x))*0.5+sin(6.28*1.0*(time+pos.x/0.5))*0.5;
+
+	for(float i=0.0;i<10.0;i+=1.0){
+	  color += sin(6.28*0.3*i*(time*i*0.05-pos.x/1.0))*0.03+sin(6.28*1.0*i*(time*i*0.01-pos.x/0.7)+i*2.0)*0.03;
+	  color += sin(6.28*0.3*i*(time*i*0.05+pos.x/1.2))*0.03+sin(6.28*1.0*i*(time*i*0.01+pos.x/0.5)+i*0.7)*0.03;
+	}
+
+
+	color *= sin(3.14*pos.x);
+
+
+	fragColor = vec4( vec3( color*2, color*2,color*2 ), 1.0 );
+
+}
+"""
+
+
+#waves
+fragment_shaderX = """
+#version 400
+//#extension GL_OES_standard_derivatives : enable
+//https://glslsandbox.com/e#97629.0
+out vec4 fragColor;
+
+#ifdef GL_ES
+precision highp float;
+#endif
+
+//#extension GL_OES_standard_derivatives : enable
+
+uniform float time;
+uniform vec2 resolution;
+
+
+void main( void ) {
+	vec2 uv = (gl_FragCoord.xy - resolution * 0.7) / max(resolution.x, resolution.y) * 3.0;
+	uv *= 3.0;
+
+	float e = 0.0;
+	for (float i=3.0;i<=5.0;i+=1.0) {
+		e += 0.007/abs( (i/15.) +sin((time/9.0) + 0.15*i*(uv.x) *( cos(i/4.9 + (time / 9.0) + uv.x*1.2) ) ) + 3.5*uv.y);
+        fragColor = vec4( vec3(e/39.1, e/0.6, e/3.6), 9.0);
+
+	}
+
+}
+"""
+
+# sea 
+fragment_shaderX = """
+#version 400
+//#extension GL_OES_standard_derivatives : enable
+out vec4 fragColor;
+
+precision highp float;
+
+uniform float time;
+uniform vec2 mouse;
+uniform vec2 resolution;
+
+float spike(float x) {
+	x = mod(x, 2.0);
+	
+	if (x < 1.0)
+		return x * x;
+	
+	x = 2.0 - x;
+	
+	return x * x;
+}
+
+
+float noise(float x, float amplitude) {
+	float n = spike(x*3.0 + time) * 0.03 +
+		sin(x*30.5 + time*26.5) * 0.005 + 
+		sin(time) * 0.1;
+	return n * amplitude;
+}
+
+const vec3 sky_high = vec3(92, 176, 255) / 255.0;
+const vec3 sky_low = vec3(219, 238, 255) / 255.0;
+const vec3 water = vec3(62, 153, 180) / 255.0;
+
+float fog = 6.0;
+
+void main() {
+
+	vec2 uv = (gl_FragCoord.xy / resolution.xy);
+
+	float v = 0.0;
+
+	float n0 = noise(uv.x * 3.18, 0.3);
+	float n1 = noise(uv.x * 2.34, 0.4);
+	float n2 = noise(uv.x * 2.14, 0.6);
+	float n3 = noise(uv.x * 1.4, 0.8);
+	float n4 = noise(uv.x * 1.23, 1.0);
+	
+	if (uv.y < 0.2 + n4) {
+		v = 1.2;
+	} else if (uv.y < 0.3 + n3) {
+		v = 1.4;
+	} else if (uv.y < 0.35 + n2) {
+		v = 1.6;
+	} else if (uv.y < 0.385 + n1) {
+		v = 1.8;
+	} else if (uv.y < 0.4 + n0) {
+		v = 2.6;
+	}
+
+	   
+	vec3 color = mix(sky_low, sky_high, uv.y);
+
+	if (v > 0.0) {
+		vec3 water_color = water * v;
+		//color = water_color;
+		color = mix(mix(sky_high, sky_low, 0.5), water_color, clamp(2.0-(uv.y*uv.y*uv.y)*fog, 3.3, 2.6));
+		
+	}
+	
+	fragColor = vec4(color, 5.0);
+}
+"""
+
+
+#flow
+fragment_shaderX = """
+#version 400
+out vec4 fragColor;
+//#extension GL_OES_standard_derivatives : enable
+//https://glslsandbox.com/e#97672.0
+
+precision highp float;
+
+uniform float time;
+const float ZOOM = 80.0;
+const float SPEED = 0.20;
+
+void main( void ) {
+	
+	vec2 pos = gl_FragCoord.xy / ZOOM;
+	float dist;
+	float dist1;
+	
+	for(int i = 0; i < 20; i++) {
+		dist = distance(pos.x, pos.y);
+        dist = 0.5;
+        //dist = rand(vec2(0.1,0.4));
+        //dist = hash(1);
+        //dist = rand2(vec2(1,10));
+        //dist = nois(0.456);
+        //dist1 = hash(10);
+		
+		pos.x = pos.x + sin(time / SPEED) + cos(pos.y + sin(dist));
+		pos.y = pos.y - cos(time / SPEED) + sin(pos.x - sin(dist));	
+	}
+
+	fragColor = vec4( 0,0,sin(pos.x /10),  1.0);
+
+}
+"""
+
+
+# dimming grid 
+fragment_shaderX = """
+#version 400
+out vec4 fragColor;
+
+//#extension GL_OES_standard_derivatives : enable
+
+precision highp float;
+
+uniform float time;
+uniform vec2 mouse;
+uniform vec2 resolution;
+
+#define step 100.0
+#define width 2.0
+
+#define bigval 0.8
+#define smallval 0.4
+#define bgval 0.2
+
+float h21(vec2 p)
+{
+	p = fract(p * vec2(123.34, 456.21));
+	p += dot(p, p+45.32);
+	return fract(p.x*p.y);
+}
+
+void main(void)
+{
+	vec2 pos = gl_FragCoord.xy - mouse.xy * resolution.xy;
+	vec2 lpos = mod(pos, step);
+	vec2 id = floor(pos / step);
+
+	float lbg = mod(h21(id), bgval);
+	float val = (sin((lbg + 1.0) * time) * bgval + bgval) * 0.5;
+	if (lpos.x < width)
+	{
+		if (abs(mod(id.x, 5.0)) < 0.5)
+			val = bigval;
+		else
+			val = smallval;
+	}
+	if (val < bigval)
+	{
+		if (lpos.y < width)
+		{
+			if (abs(mod(id.y, 5.0)) < 0.5)
+				val = bigval;
+			else
+				val = smallval;
+		}
+	}
+	gl_FragColor = vec4(0,0,val, 1.0);
+
+}
+"""
 
 
 fragment_shader = """
 #version 400
+out vec4 fragColor;
+
+// https://glslsandbox.com/e#97668.0
+
+
+#ifdef GL_ES
+precision highp float;
+#endif
+
+// ↙
+//  ↙
+//   ↙
+// http://66.media.tumblr.com/2a2f183dc4a6a040ff65355418b9403/tumblr_ncbj5rJvLI1tmxmpzo1_500.jpg
+
+vec2 uv;
+
+uniform float time;
+uniform vec2 resolution;
+
+const vec2 ch_size  = vec2(1.0, 2.0) * 0.6;              // character size (Y,X)
+const vec2 ch_space = ch_size + vec2(1.0, 1.0);    // character distance Vector(X,Y)
+const vec2 ch_start = vec2 (ch_space.x * -1.75, 3.25); // start position
+      vec2 ch_pos   = vec2 (0.0, 0.0);             // character position(X,Y)
+//      vec3 ch_color = vec3 (1.5, 0.75, 0.5);        // character color (R,G,B)
+//const vec3 bg_color = vec3 (0.2, 0.2, 0.2);        // background color (R,G,B)
+
+#define REPEAT_SIGN false // True/False; True=Multiple, False=Single
+
+/* 16 segment display...Akin to LED Display.
+
+Segment bit positions:
+  __2__ __14__
+ |\    |    /|
+ | \   |   / |
+ 5  11 40 9  0
+ |   \ | /   |
+ |    \|/    |
+  _12__ __8__
+ |           |
+ |    /|\    |
+ 4   / | \   7
+ | 13 1  15 |
+ | /   |   \ |
+  __3__|__6__
+
+15 12 11 8 7  4 3  0
+ |  | |  | |  | |  |
+ 0000 0000 0000 0000
+10101010101010101011
+
+example: letter A
+
+   12    8 7  4 3210
+    |    | |  | ||||
+ 0001 0001 1001 1111
+
+ binary to hex -> 0x119F
+*/
+
+#define n0 ddigit(0x22FF);
+#define n1 ddigit(0x0281);
+#define n2 ddigit(0x1177);
+#define n3 ddigit(0x11E7);
+#define n4 ddigit(0x5508);
+#define n5 ddigit(0x11EE);
+#define n6 ddigit(0x11FE);
+#define n7 ddigit(0x2206);
+#define n8 ddigit(0x11FF);
+#define n9 ddigit(0x11EF);
+
+#define A ddigit(0x119F);
+#define B ddigit(0x927E);
+#define C ddigit(0x007E);
+#define D ddigit(0x44E7);
+#define E ddigit(0x107E);
+#define F ddigit(0x101E);
+#define G ddigit(0x807E);
+#define H ddigit(0x1199);
+#define I ddigit(0x4466);
+#define J ddigit(0x4436);
+#define K ddigit(0x9218);
+#define L ddigit(0x0078);
+#define M ddigit(0x0A99);
+#define N ddigit(0x8899);
+#define O ddigit(0x00FF);
+#define P ddigit(0x111F);
+#define Q ddigit(0x80FF);
+#define R ddigit(0x911F);
+#define S ddigit(0x8866);
+#define T ddigit(0x4406);
+#define U ddigit(0x00F9);
+#define V ddigit(0x2218);
+#define W ddigit(0xA099);
+#define X ddigit(0xAA00);
+#define Y ddigit(0x4A00);
+#define Z ddigit(0x2266);
+#define _ ch_pos.x += ch_space.x;
+#define s_dot     ddigit(0);
+#define s_minus   ddigit(0x1100);
+#define s_plus    ddigit(0x5500);
+#define s_greater ddigit(0x2800);
+#define s_less    ddigit(0x8200);
+#define s_sqrt    ddigit(0x0C02);
+#define nl1 ch_pos = ch_start;  ch_pos.y -= 3.0;
+#define nl2 ch_pos = ch_start;  ch_pos.y -= 6.0;
+#define nl3 ch_pos = ch_start;	ch_pos.y -= 9.0;
+#define nl4 ch_pos = ch_start;	ch_pos.y -= 12.0;
+
+float dseg(vec2 p0, vec2 p1)
+{
+	vec2 dir = normalize(p1 - p0);
+	vec2 cp = (uv - ch_pos - p0) * mat2(dir.x, dir.y,-dir.y, dir.x);
+	return distance(cp, clamp(cp, vec2(0), vec2(distance(p0, p1), 0)));
+}
+
+bool bit(int n, int b)
+{
+	return mod(floor(float(n) / exp2(floor(float(b)))), 2.0) != 0.0;
+}
+
+float d = 1e6;
+
+void ddigit(int n)
+{
+	float v = 1e6;
+	vec2 cp = uv - ch_pos;
+	if (n == 0)     v = min(v, dseg(vec2(-0.405, -1.000), vec2(-0.500, -1.000)));
+	if (bit(n,  0)) v = min(v, dseg(vec2( 0.500,  0.063), vec2( 0.500,  0.937)));
+	if (bit(n,  1)) v = min(v, dseg(vec2( 0.438,  1.000), vec2( 0.063,  1.000)));
+	if (bit(n,  2)) v = min(v, dseg(vec2(-0.063,  1.000), vec2(-0.438,  1.000)));
+	if (bit(n,  3)) v = min(v, dseg(vec2(-0.500,  0.937), vec2(-0.500,  0.062)));
+	if (bit(n,  4)) v = min(v, dseg(vec2(-0.500, -0.063), vec2(-0.500, -0.938)));
+	if (bit(n,  5)) v = min(v, dseg(vec2(-0.438, -1.000), vec2(-0.063, -1.000)));
+	if (bit(n,  6)) v = min(v, dseg(vec2( 0.063, -1.000), vec2( 0.438, -1.000)));
+	if (bit(n,  7)) v = min(v, dseg(vec2( 0.500, -0.938), vec2( 0.500, -0.063)));
+	if (bit(n,  8)) v = min(v, dseg(vec2( 0.063,  0.000), vec2( 0.438, -0.000)));
+	if (bit(n,  9)) v = min(v, dseg(vec2( 0.063,  0.063), vec2( 0.438,  0.938)));
+	if (bit(n, 10)) v = min(v, dseg(vec2( 0.000,  0.063), vec2( 0.000,  0.937)));
+	if (bit(n, 11)) v = min(v, dseg(vec2(-0.063,  0.063), vec2(-0.438,  0.938)));
+	if (bit(n, 12)) v = min(v, dseg(vec2(-0.438,  0.000), vec2(-0.063, -0.000)));
+	if (bit(n, 13)) v = min(v, dseg(vec2(-0.063, -0.063), vec2(-0.438, -0.938)));
+	if (bit(n, 14)) v = min(v, dseg(vec2( 0.000, -0.938), vec2( 0.000, -0.063)));
+	if (bit(n, 15)) v = min(v, dseg(vec2( 0.063, -0.063), vec2( 0.438, -0.938)));
+	ch_pos.x += ch_space.x;
+	d = min(d, v);
+}
+mat2 rotate(float a)
+{
+	float c = cos(a);
+	float s = sin(a);
+	return mat2(c, s, -s, c);
+}
+vec3 hsv2rgb_smooth( in vec3 c )
+{
+    vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
+
+	rgb = rgb*rgb*(3.0-2.0*rgb); // cubic smoothing
+
+	return c.z * mix( vec3(1.0), rgb, c.y);
+}
+void main( void )
+{
+
+	vec2 aspect = resolution.xy / resolution.y;
+	uv = ( gl_FragCoord.xy / resolution.y ) - aspect / 2.0;
+	float _d =  1.0-length(uv);
+	uv *= 18.0 ;
+	uv -= vec2(-7., 1.);
+	//uv *= rotate(time+uv.x*0.05);
+
+	vec3 ch_color = hsv2rgb_smooth(vec3(time*0.4+uv.y*0.1,0.5,1.0));
+
+	vec3 bg_color = vec3(_d*0.4, _d*0.2, _d*0.1);
+	uv.x += 0.5+sin(time+uv.y*0.7)*0.5;
+	ch_pos = ch_start;
+
+
+_ _ _ _ _ W O W _ nl1;
+_ _ _ _  S O M E nl2;
+_ _ _ _ T R O L L A G E nl3;
+
+
+
+	vec3 color = mix(ch_color, bg_color, 1.0- (0.08 / d*2.0));  // shading
+	fragColor = vec4(color, 1.0);
+}
+"""
+
+fragment_shader = """
+#version 400
+//--- hatsuyuki ---
+// by Catzpaw 2016
+#ifdef GL_ES
+precision mediump float;
+#endif
+
+//#extension GL_OES_standard_derivatives : enable
+out vec4 fragColor;
+
+uniform float time;
+uniform vec2 mouse;
+uniform vec2 resolution;
+
+float snow(vec2 uv,float scale)
+{
+    float time1 = time / 10;
+	float w=smoothstep(1.,0.,-uv.y*(scale/10.));
+    if(w<.1){
+        return 0.;
+    }
+	uv+=time1/scale;
+    uv.y+=time1*2./scale;
+    uv.x+=sin(uv.y+time1*.5)/scale;
+	//uv*=scale;
+    vec2 s=floor(uv),f=fract(uv),p;
+    float k=3.,d;
+	p=.5+.35*sin(11.*fract(sin((s+p+scale)*mat2(7,3,6,5))*5.))-f;
+    d=length(p);
+    k=min(d,k);
+	k=smoothstep(0.,k,sin(f.x+f.y)*0.01);
+    
+    return k*w;
+}
+
+void main(void){
+	vec2 uv=(gl_FragCoord.xy*2.-resolution.xy)/min(resolution.x,resolution.y); 
+	vec3 finalColor=vec3(0);
+	float c=smoothstep(1.,0.3,clamp(uv.y*.3+.8,0.,.75));
+	//c+=snow(uv,30.)*.3;
+	//c+=snow(uv,20.)*.5;
+	//c+=snow(uv,15.)*.8;
+	//c+=snow(uv,10.);
+	//c+=snow(uv,8.);
+	//c+=snow(uv,6.);
+	c+=snow(uv,5.);
+	finalColor=(vec3(c));
+	fragColor = vec4(finalColor,1);
+}
+
+"""
+
+fragment_shader = """
+#version 400
+//#extension GL_OES_standard_derivatives : enable
+
+precision highp float;
+
+uniform float time;
+uniform vec2 mouse;
+uniform vec2 resolution;
+
+float random(float seed)
+{
+	return fract(sin(seed));//*200e2);
+}
+
+
+float row(float x, float y, float row_idx)
+{
+    float time1 = time*2;
+	float rand_factor = 0.35+random(row_idx)*.175;
+	return  step(0.3, y) * step(y, 0.37) * step(0.99, random(floor(x*rand_factor*-31.0 + 10.100*time1*random(rand_factor))));
+}
+
+void main()
+{
+	vec2 uv = gl_FragCoord.xy / resolution.y;
+	uv.x *= 20.5;
+	uv.y *= 20.0;
+	
+	float c = row(uv.y, fract(uv.x), floor(uv.x));
+	
+	gl_FragColor = vec4(c);
+}
+"""
+
+
+fragment_shader = """
+#version 400
+
+
+out vec4 fragColor;
+
+//uniform vec3      iResolution;           // viewport resolution (in pixels)
+//uniform float     iTime;                 // shader playback time (in seconds)
+//uniform float     iTimeDelta;            // render time (in seconds)
+//uniform float     iFrameRate;            // shader frame rate
+//uniform int       iFrame;                // shader playback frame
+//uniform float     iChannelTime[4];       // channel playback time (in seconds)
+//uniform vec3      iChannelResolution[4]; // channel resolution (in pixels)
+//uniform vec4      iMouse;                // mouse pixel coords. xy: current (if MLB down), zw: click
+//uniform samplerXX iChannel0..3;          // input channel. XX = 2D/Cube
+//uniform vec4      iDate;                 // (year, month, day, time in seconds)
+//uniform float     iSampleRate;           // sound sample rate (i.e., 44100)
+
+ vec3      iResolution;           // viewport resolution (in pixels)
+ float     iTime = 0;                 // shader playback time (in seconds)
+ float     iTimeDelta = 1;            // render time (in seconds)
+ float     iFrameRate = 1;            // shader frame rate
+ int       iFrame;                // shader playback frame
+ float     iChannelTime[4];       // channel playback time (in seconds)
+ vec3      iChannelResolution[4]; // channel resolution (in pixels)
+ vec4      iMouse;                // mouse pixel coords. xy: current (if MLB down), zw: click
+ samplerXX iChannel0..3;          // input channel. XX = 2D/Cube
+ vec4      iDate;                 // (year, month, day, time in seconds)
+ float     iSampleRate = 1.;           // sound sample rate (i.e., 44100)
+                
+
+
+//Based on https://thebookofshaders.com/edit.php#11/wood.frag
+float random (in vec2 st) {
+    return fract(sin(dot(st.xy,
+                         vec2(12.9898,78.233)))
+                 * 43758.5453123);
+}
+
+// 2D Noise based on Morgan McGuire @morgan3d
+// https://www.shadertoy.com/view/4dS3Wd
+float noise (in vec2 st) {
+    vec2 i = floor(st);
+    vec2 f = fract(st);
+
+    // Four corners in 2D of a tile
+    float a = random(i);
+    float b = random(i + vec2(1.0, 0.0));
+    float c = random(i + vec2(0.0, 1.0));
+    float d = random(i + vec2(1.0, 1.0));
+    // Smooth Interpolation
+    // Cubic Hermine Curve.  Same as SmoothStep()
+    vec2 u = f*f*(3.0-2.0*f);
+    // u = smoothstep(0.,1.,f);
+    // Mix 4 coorners percentages
+    return mix(a, b, u.x) +
+            (c - a)* u.y * (1.0 - u.x) +
+            (d - b) * u.x * u.y;
+}
+
+mat2 rotate2d(float angle){
+    return mat2(cos(angle),-sin(angle),
+                sin(angle),cos(angle));
+}
+
+float lines(in vec2 pos, float b){
+    float scale = 10.0;
+    pos *= scale;
+    return smoothstep(0.0,.5+b*.5,
+                    abs((sin(pos.x*1.)+b*2.0))*0.95);
+}
+
+void main( out vec4 fragColor, in vec2 fragCoord )
+{
+    // Normalized pixel coordinates <-0.5, 0.5>
+    vec2 uv = (fragCoord - .5 * iResolution.xy) / iResolution.y;
+    uv -= 1.;
+    vec4 mouse = iMouse / iResolution.x;
+    vec2 pos = vec2(uv*5.0) + mouse.xy*100.;
+    float n = noise(pos)+iTime/100.;
+    pos = rotate2d(n)*pos;
+    float pattern = lines(pos,0.5);
+    // Output to screen
+    fragColor = vec4(vec3(pattern), 1.0) * vec4(0.55, 1.5,1.0,1.0);
+}
+
+"""
+
+fragment_shader= """
+#version 400
 
 #define PI 3.1415926538
 out vec4 fragColor;
 uniform vec4 col2 = vec4(1);
 uniform vec4 col3 = vec4(1,0,0,0);
 uniform vec4 fix_bg = vec4(0,1,0,0);
+
+uniform float fix1_size = 1 ;
+uniform float fix1_speed = 0 ;
+uniform float fix1_width = 1 ;
+
+uniform float fix2_size = 1 ;
+uniform float fix2_speed = 0 ;
+uniform float fix2_width = 0.1 ;
+
+uniform float fix3_size = 1 ;
+uniform float fix3_speed = 0 ;
+uniform float fix3_width = 0.1 ;
+
 uniform float master_dim = 1;
 uniform vec4 fix_block_pos = vec4(0,1,0,0);
 uniform vec4 fix_circle_pos = vec4(0,1,0,0);
@@ -71,12 +762,23 @@ vec4 ring(vec4 col,vec2 uv,vec2 aa, int z,float ang, float speed,float scaleX, f
 
 
 vec4 circle(vec2 uv,vec4 col,vec2 a, float r, vec4 col2){
+    //float t = 1.0 - smoothstep(0.0, 10, abs(r-1));
     if( distance( uv-a, vec2(0.5,0.5)) < r/2.0){
             col = col2;
     }
     return col;
 }
 
+vec4 circleS(vec2 uv,vec4 col,vec2 a, float r, vec4 col2){
+    float borderThickness = 2;
+    float d = 1;
+    vec3 color = vec3(1,1,0);
+    vec3 baseColor = vec3(1,1,0);
+    float t1 = 1.0 - smoothstep(r-borderThickness, r, d);
+    float t2 = 1.0 - smoothstep(r, r+borderThickness, d);
+    return vec4(mix(color.rgb, baseColor.rgb, t1), t2);
+}
+
 vec4 block(vec2 uv,vec4 col, vec2 a, vec2 b, vec4 col2){
     float r1 = 0;
     float boarder = 5;
@@ -112,6 +814,7 @@ vec4 block(vec2 uv,vec4 col, vec2 a, vec2 b, vec4 col2){
     }
     return col;
 }
+
 vec4 block1(vec2 uv,vec4 col, vec2 a, vec2 b){
     if( uv.x > a.x && uv.x < a.x+b.x ){
         if( uv.y > a.y && uv.y < a.y+b.y ){
@@ -124,6 +827,7 @@ vec4 block1(vec2 uv,vec4 col, vec2 a, vec2 b){
     }
     return col;
 }
+
 vec4 pulse(vec2 uv,vec4 col, vec2 a,vec4 col4){
     float tt = sin(time*10)*1000;
     col = circle(uv,col,a,tt,col4);
@@ -137,12 +841,34 @@ vec4 pulse(vec2 uv,vec4 col, vec2 a,vec4 col4){
     col = circle(uv,col,a,tt-310,col4);
     return col;
 }
-float grid(vec2 st, float res)
-{
+
+float grid(vec2 st, float res){
   vec2 grid = fract(st*res);
   return (step(res,grid.x) * step(res,grid.y));
 }
 
+float random(float seed){
+	return fract(sin(seed)*1e4);
+}
+
+
+uniform float direction;
+uniform float velocity = 1.0;
+uniform float intensity;
+    
+    //vec3 COLOR = vec3(1);
+    //vec3 finalColor = vec3(1);
+
+float snow(vec2 uv, float scale, float time)
+{
+    float w=smoothstep(1.0,0.0,-uv.y*(scale/10.0));if(w<.1)return 0.0;
+    uv+=time/scale;uv.y+=time*2.0/scale;uv.x+=sin(uv.y+time*.5)/scale;
+    uv*=scale;vec2 s=floor(uv),f=fract(uv),p;float k=3.0,d;
+    p=.5+.35*sin(11.0*fract(sin((s+scale)*mat2(vec2(7,3),vec2(6,5)))*5.0))-f;d=length(p);k=min(d,k);
+    k=smoothstep(0.0,k,sin(f.x+f.y)*0.01);
+    return k*w;
+}
+
 void main1(){;
     vec2 uv = gl_FragCoord.xy ; //vUV.st ;
     //vec2 uv = (gl_FragCoord.xy - resolution.xy/2) / resolution.y;
@@ -163,41 +889,57 @@ void main1(){;
     vec4 col = vec4(0,0,0,1);
     vec4 col4 = vec4(0,1,0,1);
     
+
     col = fix_bg ; //col44; 
+    
+    //float c=smoothstep(1.0,0.3,clamp(uv.y*0.3+0.8,0.0,0.75));
+    //c  += snow(uv,30,time);
+    //col += vec4(vec3(c),0.5);
+    
+    if(0==1){
+    float TIME = fix1_speed/20;
+    //float c=smoothstep(1.0,0.3,clamp(uv.y*.3+.8,0.0,.75));
+    float c=smoothstep(1.0,0.3,clamp(uv.y+.8,0.0,.75));
+    c+=snow(uv,30.0,TIME)*.3;
+    //c+=snow(uv,20.0,TIME)*.5;
+    //c+=snow(uv,15.0,TIME)*.8;
+    //c+=snow(uv,10.0,TIME);
+    //c+=snow(uv,8.0,TIME);
+    c+=snow(uv,6.0,TIME);
+    //c+=snow(uv,5.0,TIME);
+    vec3 finalColor=vec3(c);
+    col = vec4(finalColor,1.0);
+    }
+    //# background animation
+    float mysin1 = sin(uv.y/3.14/10+fix1_speed*4+sin(fix1_width))*fix1_size;
+    float mysin2 = sin(uv.x/3.14/10+fix2_speed*4+sin(fix2_width))*fix2_size;
+    //float mysin2 = clamp(uv.x/3.14/10+fix2_speed*4+sin(fix2_width/10))*fix2_size;
+    //float mysin2 = smoothstep(uv.x/3.14/10+fix2_speed*4+sin(fix2_width/10))*fix2_size;
+    //float mysin2 = fract(uv.x/3.14/10+fix2_speed*4+sin(fix2_width/10))*fix2_size;
+    //float mysin2 = length(uv/3.14/10+fix2_speed*4+sin(fix2_width/10))*fix2_size;
 
-    vec2 grid_uv = vec2(uv.xy*0.5);
-    float x = grid( grid_uv, 1/15.) ;
-    col.rgb += vec3(x,x,x) ;//*x;
+    col -= vec4(mysin1*fix_bg.r ,mysin1*fix_bg.g ,mysin1*fix_bg.b , 1 ) ;
+    col -= vec4(mysin2*fix_bg.r ,mysin2*fix_bg.g ,mysin2*fix_bg.b , 1 ) ;
+    
+    //col -= vec4(sin(uv.x*time),0,0,0);
+    //col -= vec4(fract(uv.x*time/1000),0,0,0);
+    //col -= vec4(length(uv.xy*time/1000),0,0,0);
+    //float mysin3 = sin(uv.x/3.14/10+fix3_speed*4+sin(fix3_width))*fix3_size;
+    //col -= vec4(mysin3*fix_bg.r ,mysin3*1 ,mysin3*fix_bg.b , 1 ) ;
 
-    //# background animation
-    //float mysin = sin(uv.x/3.14/20*time);
-    float mysin = sin(uv.y/3.14/10+time*4);
-    float mysin2 = cos(uv.y/3.14/20+time*4);
-    //float mysin2 = sin(uv.y/3.14/20*time*4);
-    float mycos = cos(uv.x/3.14/10*time);
-    //col += vec4(mysin2,0, 0,1);
-    //col += vec4(mysin-mysin2 ,0 ,0, 1);
-    //col += vec4((mysin-mysin2)*col44.r ,col44.g , col44.b, 1);
-    //col += vec4((mysin-mysin2)*fix_bg.r ,(mysin-mysin2)*fix_bg.g , (mysin-mysin2)*fix_bg.b, 1);
-    col -= vec4(mysin*fix_bg.r ,mysin*fix_bg.g ,mysin*fix_bg.b , 1 ) ;
-    //col += vec4(mysin2*fix_bg.r ,mysin2*fix_bg.g ,mysin2*fix_bg.b , 1 ) ;
+    col = circle(uv,col,vec2(20,20),40,vec4(0,1,1,0));
+    col = circle(uv,col,vec2(0,0),20,vec4(0,1,0,0));
+    //vec4 circle(vec2 uv,vec4 col,vec2 a, float r, vec4 col2){
 
+    vec2 grid_uv = vec2(uv.xy*0.5);
+    float x = grid( grid_uv, 1/15.) ;
+    //col.rgb -= vec3(x,x,x) ;//*x;
 
     a = vec2(0,0);
-    //col = pulse(uv,col,a,col4);
 
     col4 = vec4(1,0,0,1);
     a = vec2(600,0);
-    //col = pulse(uv,col,a,col4);
 
-    //if( uv.x > -100 && uv.x < 100 ){
-    //    col.r = 0;
-    //    col.b = 1 ;//length(uv+vec2(2.9,0.9) )/200;
-    //    col.g = 0;
-    //}
-    
-    
-    
     col += 0.1 / length(uv+vec2(.6,.8) ); //sun
 
 
@@ -205,9 +947,7 @@ void main1(){;
     //# BOX
     a.x += sin(time*2)*100*3;
     a.y += cos(time*2)*100*3;
-    //b.y += 150+time*100;
     b = vec2(100,200);
-    //col = block(uv,col,a,b,col2);
     vec2 aa = vec2(0,0);
     aa.x = fix_block_pos.x -255*2;
     aa.y = fix_block_pos.y -255*2;
@@ -218,9 +958,6 @@ void main1(){;
     
     a.x += cos(time*2)*100*3;
     a.y += sin(-1*time*2)*100*3;
-    //b.y += 150+time*100;
-    //col = block(uv,col,a,b,col2);
-    //col = circle(uv,col,a,100,col3);
     aa.x = fix_circle_pos.x -255*2;
     aa.y = fix_circle_pos.y -255*2;
     col = circle(uv,col,aa,100,col3);
@@ -229,14 +966,11 @@ void main1(){;
     a.y += sin(-1*time*2+.1)*100*3;
     col4 = vec4(1,0,1,0);
     col4 = vec4(1,0,1,0);
-    //col = circle(uv,col,a,100,col4);
-    //col.r -= 0.1; 
 
     a.x = cos(time*2-.3)*100*4;
     a.y = sin(-1*time*2-.3)*100*2;
     a.y *=-1;
     col4 = vec4(1,1,0,0);
-    //col = circle(uv,col,a,100,col4);
     
     //float dist = distance(uv , vec2(10,10));
     //float circle = smoothstep((10-0.01),(10+0.01),1.0-dist );
@@ -249,7 +983,6 @@ void main1(){;
     a = vec2(500,100);
     //col = ring(col,uv,a, z, ang, speed, 180, 180)*4;
 
-    z = 80; //count of star's
     ang = 360;
     speed = 50;
     //col = ring(col,uv,a, z, ang, -speed, 280, 280/2)*2;
@@ -340,6 +1073,9 @@ class Screen(mglw.WindowConfig):
         self.ANG_DIR = 1
         self.time = 0
 
+        self.fix1_speed = 0
+        self.fix2_speed = 0
+
     def set_uniform(self,u_name, u_value):
         try:
             self.prog[u_name] = u_value
@@ -379,16 +1115,38 @@ class Screen(mglw.WindowConfig):
         bb=0
         if x:
             #a = 1+x[141-1]/255.*10
-            r = x[141-1]/255
-            g = x[142-1]/255
-            b = x[143-1]/255
-            aa = x[144-1] *4 #* a
-            bb = x[145-1] *4 #* a
-            self.time += (x[147-1]/255.-0.5) # *4 #* a
+            r = x[142-1]/255
+            g = x[143-1]/255
+            b = x[144-1]/255
+            aa = x[145-1] *4 #* a
+            bb = x[146-1] *4 #* a
+            self.time += (x[148-1]/255.-0.5)/10 # *4 #* a
+
         self.set_uniform('time',self.time)
+
         self.set_uniform('fix_block_pos',[aa,bb,0,0])
         self.set_uniform('fix_circle_pos',[bb,aa,0,0])
-        self.set_uniform('master_dim',x[146-1]/255.)
+
+        dmx=141-1
+        print(x[dmx],x[dmx+1],x[dmx+2])
+        self.set_uniform('master_dim',x[dmx]/255.)
+
+        dmx=161-1
+        print(x[dmx],x[dmx+1],x[dmx+2])
+        self.set_uniform('fix1_size',x[dmx]/255.)
+        self.fix1_speed += (x[dmx+1]/255.-0.5)/10
+        #self.fix1_speed += (x[201-1+2]/255.-0.5)/10
+        self.set_uniform('fix1_speed',self.fix1_speed) 
+        self.set_uniform('fix1_width',x[dmx+2])
+
+        dmx=181-1
+        dmx=201-1
+        print(x[dmx],x[dmx+1],x[dmx+2])
+        self.set_uniform('fix2_size',x[dmx]/255.)
+        self.fix2_speed += (x[dmx+1]/255.-0.5)/10
+        self.set_uniform('fix2_speed',self.fix2_speed)
+        #self.set_uniform('fix2_width',x[dmx+2]/255)
+
         x = time.time()/10%1
         #self.set_uniform('col2',[r,g,b,1])
         self.set_uniform('fix_bg',[r,g,b,1])