diff --git a/shaders/redaphid/1.frag b/shaders/redaphid/1.frag deleted file mode 100644 index 5493a20..0000000 --- a/shaders/redaphid/1.frag +++ /dev/null @@ -1,66 +0,0 @@ -// Noise animation - Electric -// by nimitz (stormoid.com) (twitter: @stormoid) -// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License -// Contact the author for other licensing options - -//The domain is displaced by two fbm calls one for each axis. -//Turbulent fbm (aka ridged) is used for better effect. - -#define time iTime*0.15 -#define tau 6.2831853 - -mat2 makem2(in float theta){float c = cos(theta);float s = sin(theta);return mat2(c,-s,s,c);} -float noise( in vec2 x ){return texture(prevFrame, x*.01).y;} - -float fbm(in vec2 p) -{ - float z=2.; - float rz = 0.; - vec2 bp = p; - for (float i= 1.;i < 6.;i++) - { - rz+= abs((noise(p)-0.5)*2.)/z; - z = z*2.; - p = p*2.; - } - return rz; -} - -float dualfbm(in vec2 p) -{ - //get two rotated fbm calls and displace the domain - vec2 p2 = p*.7; - vec2 basis = vec2(fbm(p2-time*1.6),fbm(p2+time*1.7)); - basis = (basis-.5)*.2; - p += basis; - - //coloring - return fbm(p*makem2(time*0.2)); -} - -float circ(vec2 p) -{ - float r = length(p); - r = log(sqrt(r)); - return abs(mod(r*4.,tau)-3.14)*3.+.2; - -} - -void mainImage( out vec4 fragColor, in vec2 fragCoord ) -{ - //setup system - vec2 p = fragCoord.xy / iResolution.xy-0.5; - p.x *= iResolution.x/iResolution.y; - p*=4.; - - float rz = dualfbm(p); - - //rings - p /= exp(mod(time*10.,3.14159)); - rz *= pow(abs((0.1-circ(p))),.9); - - //final color - vec3 col = vec3(.2,0.1,0.4)/rz; - col=pow(abs(col),vec3(.99)); - fragColor = vec4(col,1.); -} diff --git a/shaders/redaphid/cube-rose.frag b/shaders/redaphid/cube-rose.frag deleted file mode 100644 index 83ef1a3..0000000 --- a/shaders/redaphid/cube-rose.frag +++ /dev/null @@ -1,757 +0,0 @@ - -// Created by Danil (2021+) https://cohost.org/arugl -// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. -// self https://www.shadertoy.com/view/NslGRN - - -// --defines for "DESKTOP WALLPAPERS" that use this shader-- -// comment or uncomment every define to make it work (add or remove "//" before #define) - - -// this shadertoy use ALPHA, NO_ALPHA set alpha to 1, BG_ALPHA set background as alpha -// iChannel0 used as background if alpha ignored by wallpaper-app -//#define NO_ALPHA -//#define BG_ALPHA -//#define SHADOW_ALPHA -//#define ONLY_BOX - - -// save PERFORMANCE by disabling shadow -//#define NO_SHADOW - - -// static CAMERA position, 0.49 on top, 0.001 horizontal -//#define CAMERA_POS 0.049 - - -// speed of ROTATION -#define ROTATION_SPEED 0.8999 - - -// static SHAPE form, default 0.5 -//#define STATIC_SHAPE 0.15 - - -// static SCALE far/close to camera, 2.0 is default, exampe 0.5 or 10.0 -//#define CAMERA_FAR 0.1 - - -// ANIMATION shape change -//#define ANIM_SHAPE - - -// ANIMATION color change -//#define ANIM_COLOR - - -// custom COLOR, and change those const values -//#define USE_COLOR -const vec3 color_blue=vec3(0.5,0.65,0.8); -const vec3 color_red=vec3(0.99,0.2,0.1); - - -// use 4xAA for cube only (set 2-4-etc level of AA) -//#define AA_CUBE 4 - -// use 4xAA for everything - derivative filtering will not be used, look fcos2 -// this is very slow - DO NOT USE -//#define AA_ALL 4 - - - -// --shader code-- - -// Layers sorted and support transparency and self-intersection-transparency -// Antialiasing is only dFd. (with some dFd fixes around edges) - -// using iq's intersectors: https://iquilezles.org/articles/intersectors -// using https://www.shadertoy.com/view/ltKBzG -// using https://www.shadertoy.com/view/tsVXzh -// using https://www.shadertoy.com/view/WlffDn -// using https://www.shadertoy.com/view/WslGz4 - -#define tshift 53. - -// reflect back side -//#define backside_refl - -// Camera with mouse -// #define MOUSE_control - -// min(iFrame,0) does not speedup compilation in ANGLE -#define ANGLE_loops 0 - - -// this shader discover Nvidia bug with arrays https://www.shadertoy.com/view/NslGR4 -// use DEBUG with BUG, BUG trigger that bug and one layer will be white on Nvidia in OpenGL -//#define DEBUG -//#define BUG - -#define FDIST 0.7 -#define GROUNDSPACING 0.5 -#define GROUNDGRID 0.05 -#define BOXDIMS vec3(0.75, 0.75, 1.25) - -#define IOR 1.33 - -mat3 rotx(float a){float s = sin(a);float c = cos(a);return mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, c, s), vec3(0.0, -s, c)); } -mat3 roty(float a){float s = sin(a);float c = cos(a);return mat3(vec3(c, 0.0, s), vec3(0.0, 1.0, 0.0), vec3(-s, 0.0, c));} -mat3 rotz(float a){float s = sin(a);float c = cos(a);return mat3(vec3(c, s, 0.0), vec3(-s, c, 0.0), vec3(0.0, 0.0, 1.0 ));} - -vec3 fcos1(vec3 x) { - vec3 w = fwidth(x); - //if((length(w)==0.))return vec3(0.); // dFd fix2 - //w*=0.; //test - float lw=length(w); - if((lw==0.)||isnan(lw)||isinf(lw)){vec3 tc=vec3(0.); for(int i=0;i<8;i++)tc+=cos(x+x*float(i-4)*(0.01*400./iResolution.y));return tc/8.;} - - return cos(x) * smoothstep(3.14 * 2.0, 0.0, w); -} - -vec3 fcos2( vec3 x){return cos(x);} -vec3 fcos( vec3 x){ -#ifdef AA_ALL - return fcos2(x); -#else - return fcos1(x); -#endif -} - -vec3 getColor(vec3 p) -{ - // dFd fix, dFd broken on borders, but it fix only top level dFd, self intersection has border - //if (length(p) > 0.99)return vec3(0.); - p = abs(p); - - p *= 01.25; - p = 0.5 * p / dot(p, p); -#ifdef ANIM_COLOR - p+=0.072*spectralSkewNormalized; -#endif - - float t = (spectralSpreadMedian) * length(p); - vec3 col = vec3(0.3, 0.4, 0.5); - col += 0.12 * fcos(spectralCentroid * t * 1.0+ spectralCentroidMedian + vec3(0.0, 0.8, 1.1)); - col += 0.11 * fcos(spectralCentroid * t * 3.1+ spectralCentroidMedian + vec3(0.3, 0.4, 0.1)); - col += 0.10 * fcos(spectralCentroid * t * 5.1+ spectralCentroidMedian + vec3(0.1, 0.7, 1.1)); - col += 0.10 * fcos(spectralCentroid * t * 17.1+ spectralCentroidMedian + vec3(0.2, 0.6, 0.7)); - col += 0.10 * fcos(spectralCentroid * t * 31.1+ spectralCentroidMedian + vec3(0.1, 0.6, 0.7)); - col += 0.10 * fcos(spectralCentroid * t * 65.1+ spectralCentroidMedian + vec3(0.0, 0.5, 0.8)); - col += 0.10 * fcos(spectralCentroid * t * 115.1+ spectralCentroidMedian + vec3(0.1, 0.4, 0.7)); - col += 0.10 * fcos(spectralCentroid * t * 265.1+ spectralCentroidMedian + vec3(1.1, 1.4, 2.7)); - col = clamp(col, 0., 1.); - - return col; -} - -void calcColor(vec3 ro, vec3 rd, vec3 nor, float d, float len, int idx, bool si, float td, out vec4 colx, - out vec4 colsi) -{ - - vec3 pos = (ro + rd * d); -#ifdef DEBUG - float a = 1. - smoothstep(len - 0.15, len + 0.00001, length(pos)); - if (idx == 0)colx = vec4(1., 0., 0., a); - if (idx == 1)colx = vec4(0., 1., 0., a); - if (idx == 2)colx = vec4(0., 0., 1., a); - if (si) - { - pos = (ro + rd * td); - float ta = 1. - smoothstep(len - 0.15, len + 0.00001, length(pos)); - if (idx == 0)colsi = vec4(1., 0., 0., ta); - if (idx == 1)colsi = vec4(0., 1., 0., ta); - if (idx == 2)colsi = vec4(0., 0., 1., ta); - } -#else - float a = 1. - smoothstep(len - 0.15*0.5, len + 0.00001, length(pos)); - //a=1.; - vec3 col = getColor(pos); - colx = vec4(col, a); - if (si) - { - pos = (ro + rd * td); - float ta = 1. - smoothstep(len - 0.15*0.5, len + 0.00001, length(pos)); - //ta=1.; - col = getColor(pos); - colsi = vec4(col, ta); - } -#endif -} - -// xSI is self intersect data, fade to fix dFd on edges -bool iBilinearPatch(in vec3 ro, in vec3 rd, in vec4 ps, in vec4 ph, in float sz, out float t, out vec3 norm, - out bool si, out float tsi, out vec3 normsi, out float fade, out float fadesi) -{ - vec3 va = vec3(0.0, 0.0, ph.x + ph.w - ph.y - ph.z); - vec3 vb = vec3(0.0, ps.w - ps.y, ph.z - ph.x); - vec3 vc = vec3(ps.z - ps.x, 0.0, ph.y - ph.x); - vec3 vd = vec3(ps.xy, ph.x); - t = -1.; - tsi = -1.; - si = false; - fade = 1.; - fadesi = 1.; - norm=vec3(0.,1.,0.);normsi=vec3(0.,1.,0.); - - float tmp = 1.0 / (vb.y * vc.x); - float a = 0.0; - float b = 0.0; - float c = 0.0; - float d = va.z * tmp; - float e = 0.0; - float f = 0.0; - float g = (vc.z * vb.y - vd.y * va.z) * tmp; - float h = (vb.z * vc.x - va.z * vd.x) * tmp; - float i = -1.0; - float j = (vd.x * vd.y * va.z + vd.z * vb.y * vc.x) * tmp - (vd.y * vb.z * vc.x + vd.x * vc.z * vb.y) * tmp; - - float p = dot(vec3(a, b, c), rd.xzy * rd.xzy) + dot(vec3(d, e, f), rd.xzy * rd.zyx); - float q = dot(vec3(2.0, 2.0, 2.0) * ro.xzy * rd.xyz, vec3(a, b, c)) + dot(ro.xzz * rd.zxy, vec3(d, d, e)) + - dot(ro.yyx * rd.zxy, vec3(e, f, f)) + dot(vec3(g, h, i), rd.xzy); - float r = - dot(vec3(a, b, c), ro.xzy * ro.xzy) + dot(vec3(d, e, f), ro.xzy * ro.zyx) + dot(vec3(g, h, i), ro.xzy) + j; - - if (abs(p) < 0.000001) - { - float tt = -r / q; - if (tt <= 0.) - return false; - t = tt; - // normal - - vec3 pos = ro + t * rd; - if(length(pos)>sz)return false; - vec3 grad = - vec3(2.0) * pos.xzy * vec3(a, b, c) + pos.zxz * vec3(d, d, e) + pos.yyx * vec3(f, e, f) + vec3(g, h, i); - norm = -normalize(grad); - return true; - } - else - { - float sq = q * q - 4.0 * p * r; - if (sq < 0.0) - { - return false; - } - else - { - float s = sqrt(sq); - float t0 = (-q + s) / (2.0 * p); - float t1 = (-q - s) / (2.0 * p); - float tt1 = min(t0 < 0.0 ? t1 : t0, t1 < 0.0 ? t0 : t1); - float tt2 = max(t0 > 0.0 ? t1 : t0, t1 > 0.0 ? t0 : t1); - float tt0 = tt1; - if (tt0 <= 0.) - return false; - vec3 pos = ro + tt0 * rd; - // black border on end of circle and self intersection with alpha come because dFd - // uncomment this to see or rename fcos2 to fcos - //sz+=0.3; - bool ru = step(sz, length(pos)) > 0.5; - if (ru) - { - tt0 = tt2; - pos = ro + tt0 * rd; - } - if (tt0 <= 0.) - return false; - bool ru2 = step(sz, length(pos)) > 0.5; - if (ru2) - return false; - - // self intersect - if ((tt2 > 0.) && ((!ru)) && !(step(sz, length(ro + tt2 * rd)) > 0.5)) - { - si = true; - fadesi=s; - tsi = tt2; - vec3 tpos = ro + tsi * rd; - // normal - vec3 tgrad = vec3(2.0) * tpos.xzy * vec3(a, b, c) + tpos.zxz * vec3(d, d, e) + - tpos.yyx * vec3(f, e, f) + vec3(g, h, i); - normsi = -normalize(tgrad); - } - - fade=s; - t = tt0; - // normal - vec3 grad = - vec3(2.0) * pos.xzy * vec3(a, b, c) + pos.zxz * vec3(d, d, e) + pos.yyx * vec3(f, e, f) + vec3(g, h, i); - norm = -normalize(grad); - - return true; - } - } -} - -float dot2( in vec3 v ) { return dot(v,v); } - -float segShadow( in vec3 ro, in vec3 rd, in vec3 pa, float sh ) -{ - float dm = dot(rd.yz,rd.yz); - float k1 = (ro.x-pa.x)*dm; - float k2 = (ro.x+pa.x)*dm; - vec2 k5 = (ro.yz+pa.yz)*dm; - float k3 = dot(ro.yz+pa.yz,rd.yz); - vec2 k4 = (pa.yz+pa.yz)*rd.yz; - vec2 k6 = (pa.yz+pa.yz)*dm; - - for( int i=0; i<4 + ANGLE_loops; i++ ) - { - vec2 s = vec2(i&1,i>>1); - float t = dot(s,k4) - k3; - - if( t>0.0 ) - sh = min(sh,dot2(vec3(clamp(-rd.x*t,k1,k2),k5-k6*s)+rd*t)/(t*t)); - } - return sh; -} - -float boxSoftShadow( in vec3 ro, in vec3 rd, in vec3 rad, in float sk ) -{ - rd += 0.0001 * (1.0 - abs(sign(rd))); - vec3 rdd = rd; - vec3 roo = ro; - - vec3 m = 1.0/rdd; - vec3 n = m*roo; - vec3 k = abs(m)*rad; - - vec3 t1 = -n - k; - vec3 t2 = -n + k; - - float tN = max( max( t1.x, t1.y ), t1.z ); - float tF = min( min( t2.x, t2.y ), t2.z ); - - if( tN0.0) return 0.0; - - float sh = 1.0; - sh = segShadow( roo.xyz, rdd.xyz, rad.xyz, sh ); - sh = segShadow( roo.yzx, rdd.yzx, rad.yzx, sh ); - sh = segShadow( roo.zxy, rdd.zxy, rad.zxy, sh ); - sh = clamp(sk*sqrt(sh),0.0,1.0); - return sh*sh*(3.0-2.0*sh); -} - -float box(in vec3 ro, in vec3 rd, in vec3 r, out vec3 nn, bool entering) -{ - rd += 0.0001 * (1.0 - abs(sign(rd))); - vec3 dr = 1.0 / rd; - vec3 n = ro * dr; - vec3 k = r * abs(dr); - - vec3 pin = -k - n; - vec3 pout = k - n; - float tin = max(pin.x, max(pin.y, pin.z)); - float tout = min(pout.x, min(pout.y, pout.z)); - if (tin > tout) - return -1.; - if (entering) - { - nn = -sign(rd) * step(pin.zxy, pin.xyz) * step(pin.yzx, pin.xyz); - } - else - { - nn = sign(rd) * step(pout.xyz, pout.zxy) * step(pout.xyz, pout.yzx); - } - return entering ? tin : tout; -} - -vec3 bgcol(in vec3 rd) -{ - return mix(vec3(0.01), vec3(0.336, 0.458, .668), 1. - pow(abs(rd.z+0.25), 1.3)); -} - -vec3 background(in vec3 ro, in vec3 rd , vec3 l_dir, out float alpha) -{ -#ifdef ONLY_BOX -alpha=0.; -return vec3(0.01); -#endif - float t = (-BOXDIMS.z - ro.z) / rd.z; - alpha=0.; - vec3 bgc = bgcol(rd); - if (t < 0.) - return bgc; - vec2 uv = ro.xy + t * rd.xy; -#ifdef NO_SHADOW - float shad=1.; -#else - float shad = boxSoftShadow((ro + t * rd), normalize(l_dir+vec3(0.,0.,1.))*rotz(PI*0.65) , BOXDIMS, 1.5); -#endif - float aofac = smoothstep(-0.95, .75, length(abs(uv) - min(abs(uv), vec2(0.45)))); - aofac = min(aofac,smoothstep(-0.65, 1., shad)); - float lght=max(dot(normalize(ro + t * rd+vec3(0.,-0.,-5.)), normalize(l_dir-vec3(0.,0.,1.))*rotz(PI*0.65)), 0.0); - vec3 col = mix(vec3(0.4), vec3(.71,.772,0.895), lght*lght* aofac+ 0.05) * aofac; - alpha=1.-smoothstep(7.,10.,length(uv)); -#ifdef SHADOW_ALPHA - //alpha=clamp(alpha*max(lght*lght*0.95,(1.-aofac)*1.25),0.,1.); - alpha=clamp(alpha*(1.-aofac)*1.25,0.,1.); -#endif - return mix(col*length(col)*0.8,bgc,smoothstep(7.,10.,length(uv))); -} - -#define swap(a,b) tv=a;a=b;b=tv - -vec4 insides(vec3 ro, vec3 rd, vec3 nor_c, vec3 l_dir, out float tout) -{ - tout = -1.; - vec3 trd=rd; - - vec3 col = vec3(0.); - - float pi = 3.1415926; - - if (abs(nor_c.x) > 0.5) - { - rd = rd.xzy * nor_c.x; - ro = ro.xzy * nor_c.x; - } - else if (abs(nor_c.z) > 0.5) - { - l_dir *= roty(pi); - rd = rd.yxz * nor_c.z; - ro = ro.yxz * nor_c.z; - } - else if (abs(nor_c.y) > 0.5) - { - l_dir *= rotz(-pi * 0.5); - rd = rd * nor_c.y; - ro = ro * nor_c.y; - } - -#ifdef ANIM_SHAPE - float curvature = (0.001+1.5-1.5*smoothstep(0.,8.5,mod((spectralSkewNormalized+tshift)*0.44,20.))*(1.-smoothstep(10.,18.5,mod((spectralSkewNormalized+tshift)*0.44,20.)))); - // curvature(to not const above) make compilation on Angle 15+ sec -#else -#ifdef STATIC_SHAPE - const float curvature = STATIC_SHAPE; -#else - const float curvature = .5; -#endif -#endif - float bil_size = 1.; - vec4 ps = vec4(-bil_size, -bil_size, bil_size, bil_size) * curvature; - vec4 ph = vec4(-bil_size, bil_size, bil_size, -bil_size) * curvature; - - vec4 [3]colx=vec4[3](vec4(0.),vec4(0.),vec4(0.)); - vec3 [3]dx=vec3[3](vec3(-1.),vec3(-1.),vec3(-1.)); - vec4 [3]colxsi=vec4[3](vec4(0.),vec4(0.),vec4(0.)); - int [3]order=int[3](0,1,2); - - for (int i = 0; i < 3 + ANGLE_loops; i++) - { - if (abs(nor_c.x) > 0.5) - { - ro *= rotz(-pi * (1. / float(3))); - rd *= rotz(-pi * (1. / float(3))); - } - else if (abs(nor_c.z) > 0.5) - { - ro *= rotz(pi * (1. / float(3))); - rd *= rotz(pi * (1. / float(3))); - } - else if (abs(nor_c.y) > 0.5) - { - ro *= rotx(pi * (1. / float(3))); - rd *= rotx(pi * (1. / float(3))); - } - vec3 normnew; - float tnew; - bool si; - float tsi; - vec3 normsi; - float fade; - float fadesi; - - if (iBilinearPatch(ro, rd, ps, ph, bil_size, tnew, normnew, si, tsi, normsi, fade, fadesi)) - { - if (tnew > 0.) - { - vec4 tcol, tcolsi; - calcColor(ro, rd, normnew, tnew, bil_size, i, si, tsi, tcol, tcolsi); - if (tcol.a > 0.0) - { - { - vec3 tvalx = vec3(tnew, float(si), tsi); - dx[i]=tvalx; - } -#ifdef DEBUG - colx[i]=tcol; - if (si)colxsi[i]=tcolsi; -#else - - float dif = clamp(dot(normnew, l_dir), 0.0, 1.0); - float amb = clamp(0.5 + 0.5 * dot(normnew, l_dir), 0.0, 1.0); - - { -#ifdef USE_COLOR - vec3 shad = 0.57 * color_blue * amb + 1.5*color_blue.bgr * dif; - const vec3 tcr = color_red; -#else - vec3 shad = vec3(0.32, 0.43, 0.54) * amb + vec3(1.0, 0.9, 0.7) * dif; - const vec3 tcr = vec3(1.,0.21,0.11); -#endif - float ta = clamp(length(tcol.rgb),0.,1.); - tcol=clamp(tcol*tcol*2.,0.,1.); - vec4 tvalx = - vec4((tcol.rgb*shad*1.4 + 3.*(tcr*tcol.rgb)*clamp(1.-(amb+dif),0.,1.)), min(tcol.a,ta)); - tvalx.rgb=clamp(2.*tvalx.rgb*tvalx.rgb,0.,1.); - tvalx*=(min(fade*5.,1.)); - colx[i]=tvalx; - } - if (si) - { - dif = clamp(dot(normsi, l_dir), 0.0, 1.0); - amb = clamp(0.5 + 0.5 * dot(normsi, l_dir), 0.0, 1.0); - { -#ifdef USE_COLOR - vec3 shad = 0.57 * color_blue * amb + 1.5*color_blue.bgr * dif; - const vec3 tcr = color_red; -#else - vec3 shad = vec3(0.32, 0.43, 0.54) * amb + vec3(1.0, 0.9, 0.7) * dif; - const vec3 tcr = vec3(1.,0.21,0.11); -#endif - float ta = clamp(length(tcolsi.rgb),0.,1.); - tcolsi=clamp(tcolsi*tcolsi*2.,0.,1.); - vec4 tvalx = - vec4(tcolsi.rgb * shad + 3.*(tcr*tcolsi.rgb)*clamp(1.-(amb+dif),0.,1.), min(tcolsi.a,ta)); - tvalx.rgb=clamp(2.*tvalx.rgb*tvalx.rgb,0.,1.); - tvalx.rgb*=(min(fadesi*5.,1.)); - colxsi[i]=tvalx; - } - } -#endif - } - } - } - } - // transparency logic and layers sorting - float a = 1.; - if (dx[0].x < dx[1].x){{vec3 swap(dx[0], dx[1]);}{int swap(order[0], order[1]);}} - if (dx[1].x < dx[2].x){{vec3 swap(dx[1], dx[2]);}{int swap(order[1], order[2]);}} - if (dx[0].x < dx[1].x){{vec3 swap(dx[0], dx[1]);}{int swap(order[0], order[1]);}} - - tout = max(max(dx[0].x, dx[1].x), dx[2].x); - - if (dx[0].y < 0.5) - { - a=colx[order[0]].a; - } - -#if !(defined(DEBUG)&&defined(BUG)) - - // self intersection - bool [3] rul= bool[3]( - ((dx[0].y > 0.5) && (dx[1].x <= 0.)), - ((dx[1].y > 0.5) && (dx[0].x > dx[1].z)), - ((dx[2].y > 0.5) && (dx[1].x > dx[2].z)) - ); - for(int k=0;k<3;k++){ - if(rul[k]){ - vec4 tcolxsi = vec4(0.); - tcolxsi=colxsi[order[k]]; - vec4 tcolx = vec4(0.); - tcolx=colx[order[k]]; - - vec4 tvalx = mix(tcolxsi, tcolx, tcolx.a); - colx[order[k]]=tvalx; - - vec4 tvalx2 = mix(vec4(0.), tvalx, max(tcolx.a, tcolxsi.a)); - colx[order[k]]=tvalx2; - } - } - -#endif - - float a1 = (dx[1].y < 0.5) ? colx[order[1]].a : ((dx[1].z > dx[0].x) ? colx[order[1]].a : 1.); - float a2 = (dx[2].y < 0.5) ? colx[order[2]].a : ((dx[2].z > dx[1].x) ? colx[order[2]].a : 1.); - col = mix(mix(colx[order[0]].rgb, colx[order[1]].rgb, a1), colx[order[2]].rgb, a2); - a = max(max(a, a1), a2); - return vec4(col, a); -} - -void mainImage(out vec4 fragColor, in vec2 fragCoord) -{ - float osc = 0.5; - vec3 l_dir = normalize(vec3(0., 1., 0.)); - l_dir *= rotz(0.5); - float mouseY = 1.0 * 0.5 * PI; -#ifdef MOUSE_control - mouseY = (1.0 - 1.15 * iMouse.y / iResolution.y) * 0.5 * PI; - if(iMouse.y < 1.) -#endif -#ifdef CAMERA_POS - mouseY = PI*CAMERA_POS; -#else - mouseY = PI*0.49 - smoothstep(0.,8.5,mod((spectralSkewNormalized+tshift)*0.33,25.))*(1.-smoothstep(14.,24.0,mod((spectralSkewNormalized+tshift)*0.33,25.))) * 0.55 * PI; -#endif -#ifdef ROTATION_SPEED - float mouseX = -2.*PI-0.25*(spectralSkewNormalized*ROTATION_SPEED+tshift); -#else - float mouseX = -2.*PI-0.25*(spectralSkewNormalized+tshift); -#endif -#ifdef MOUSE_control - mouseX+=-(iMouse.x / iResolution.x) * 2. * PI; -#endif - -#ifdef CAMERA_FAR - vec3 eye = (2. + CAMERA_FAR) * vec3(cos(mouseX) * cos(mouseY), sin(mouseX) * cos(mouseY), sin(mouseY)); -#else - vec3 eye = 4. * vec3(cos(mouseX) * cos(mouseY), sin(mouseX) * cos(mouseY), sin(mouseY)); -#endif - vec3 w = normalize(-eye); - vec3 up = vec3(0., 0., 1.); - vec3 u = normalize(cross(w, up)); - vec3 v = cross(u, w); - - vec4 tot=vec4(0.); -#if defined(AA_CUBE)||defined(AA_ALL) -#ifdef AA_CUBE - const int AA = AA_CUBE; -#else - const int AA = AA_ALL; -#endif - vec3 incol_once=vec3(0.); - bool in_once=false; - vec4 incolbg_once=vec4(0.); - bool bg_in_once=false; - vec4 outcolbg_once=vec4(0.); - bool bg_out_once=false; - for( int mx=0; mx 0.) - { - float ang = -spectralSkewNormalized * 0.33; - vec3 col = vec3(0.); -#ifdef AA_CUBE - if(in_once)col=incol_once; - else{ - in_once=true; -#endif - float R0 = (IOR - 1.) / (IOR + 1.); - R0 *= R0; - - vec2 theta = vec2(0.); - vec3 n = vec3(cos(theta.x) * sin(theta.y), sin(theta.x) * sin(theta.y), cos(theta.y)); - - vec3 nr = n.zxy * ni.x + n.yzx * ni.y + n.xyz * ni.z; - vec3 rdr = reflect(rd, nr); - float talpha; - vec3 reflcol = background(ro, rdr, l_dir,talpha); - - vec3 rd2 = refract(rd, nr, 1. / IOR); - - float accum = 1.; - vec3 no2 = ni; - vec3 ro_refr = ro; - - vec4 [2] colo = vec4[2](vec4(0.),vec4(0.)); - - for (int j = 0; j < 2 + ANGLE_loops; j++) - { - float tb; - vec2 coords2 = ro_refr.xy * no2.z + ro_refr.yz * no2.x + ro_refr.zx * no2.y; - vec3 eye2 = vec3(coords2, -1.); - vec3 rd2trans = rd2.yzx * no2.x + rd2.zxy * no2.y + rd2.xyz * no2.z; - - rd2trans.z = -rd2trans.z; - vec4 internalcol = insides(eye2, rd2trans, no2, l_dir, tb); - if (tb > 0.) - { - internalcol.rgb *= accum; - colo[j]=internalcol; - } - - if ((tb <= 0.) || (internalcol.a < 1.)) - { - float tout = box(ro_refr, rd2, BOXDIMS, no2, false); - no2 = n.zyx * no2.x + n.xzy * no2.y + n.yxz * no2.z; - vec3 rout = ro_refr + tout * rd2; - vec3 rdout = refract(rd2, -no2, IOR); - float fresnel2 = R0 + (1. - R0) * pow(1. - dot(rdout, no2), 1.3); - rd2 = reflect(rd2, -no2); - -#ifdef backside_refl - if((dot(rdout, no2))>0.5){fresnel2=1.;} -#endif - ro_refr = rout; - ro_refr.z = max(ro_refr.z, -0.999); - - accum *= fresnel2; - } - } - float fresnel = R0 + (1. - R0) * pow(1. - dot(-rd, nr), 5.); - col = mix(mix(colo[1].rgb * colo[1].a, colo[0].rgb, colo[0].a)*fadeborders, reflcol, pow(fresnel, 1.5)); - col=clamp(col,0.,1.); -#ifdef AA_CUBE - } - incol_once=col; - if(!bg_in_once){ - bg_in_once=true; - float alpha; - incolbg_once = vec4(background(eye, rd, l_dir, alpha), 0.15); -#if defined(BG_ALPHA)||defined(ONLY_BOX)||defined(SHADOW_ALPHA) - incolbg_once.w = alpha; -#endif - } -#endif - - float cineshader_alpha = 0.; - cineshader_alpha = clamp(0.15*dot(eye,ro),0.,1.); - vec4 tcolx = vec4(col, cineshader_alpha); -#if defined(BG_ALPHA)||defined(ONLY_BOX)||defined(SHADOW_ALPHA) - tcolx.w = 1.; -#endif - tot += tcolx; - } - else - { - vec4 tcolx = vec4(0.); -#ifdef AA_CUBE - if(!bg_out_once){ - bg_out_once=true; -#endif - float alpha; - tcolx = vec4(background(eye, rd, l_dir, alpha), 0.15); -#if defined(BG_ALPHA)||defined(ONLY_BOX)||defined(SHADOW_ALPHA) - tcolx.w = alpha; -#endif -#ifdef AA_CUBE - outcolbg_once=tcolx; - }else tcolx=max(outcolbg_once,incolbg_once); -#endif - tot += tcolx; - } -#if defined(AA_CUBE)||defined(AA_ALL) - } - tot /= float(AA*AA); -#endif - fragColor = tot; -#ifdef NO_ALPHA - fragColor.w = 1.; -#endif - fragColor.rgb=clamp(fragColor.rgb,0.,1.); -#if defined(BG_ALPHA)||defined(ONLY_BOX)||defined(SHADOW_ALPHA) - fragColor.rgb=fragColor.rgb*fragColor.w+texture(iChannel0, fragCoord/iResolution.xy).rgb*(1.-fragColor.w); -#endif - if(fragColor.r < 0.1 && fragColor.g < 0.1 && fragColor.b < 0.1){ - fragColor = vec4(spectralRolloffMedian/spectralRolloffMax*uv.x, spectralKurtosisMedian/spectralKurtosisMax*uv.y, spectralSkewMedian/spectralSkewMax*sin(time), 1.0); - } - //fragColor=vec4(fragColor.w); -} - diff --git a/shaders/redaphid/dandelion.frag b/shaders/redaphid/dandelion.frag deleted file mode 100644 index 9935d2f..0000000 --- a/shaders/redaphid/dandelion.frag +++ /dev/null @@ -1,19 +0,0 @@ -#define t iTime/4. - -void mainImage(out vec4 fragColor,in vec2 fragCoord){ - vec2 translate=vec2(spectralCentroid,energy*10.)*100.; - vec2 p=(2.*fragCoord.xy-iResolution.xy)/iResolution.y; - vec2 mp=translate/iResolution.xy*.5+.5; - - float s=1.; - if(beat)s=.5; - for(int i=0;i<7;i++){ - s=max(s,abs(p.x)-.375); - p=abs(p*2.25)-mp*1.25; - p*=mat2(cos(t+mp.x),-sin(t+mp.y),sin(t+mp.y),cos(t+mp.x)); - } - - vec3 col=vec3(4.,2.,1.)/abs(atan(p.y,p.x))/s; - - fragColor=vec4(col,1.); -} diff --git a/shaders/redaphid/distortion.frag b/shaders/redaphid/distortion.frag deleted file mode 100644 index 7f7c896..0000000 --- a/shaders/redaphid/distortion.frag +++ /dev/null @@ -1,49 +0,0 @@ - -uniform float knob_1; -uniform float knob_2; -uniform float knob_3; - -#define amplitude energyZScore*3. -#define CENTER vec2(0.5,0.5) -#define FREQUENCY knob_1 -bool isInDrip(vec2 uv) { - vec2 center = vec2(0.5, 0.5); // Center of the "drip" - float radius = 0.1 + amplitude * 0.05; // Dynamic radius based on amplitude - - // Calculate distance from the center - float dist = length(uv - center); - - // Return true if the distance is less than the dynamic radius - return dist < radius; -} - -// Function to distort UVs based on a "drip" effect -vec2 drip(vec2 uv, vec2 center) { - vec2 toCenter = center - uv; - // Ensure wrapping effect by considering the shortest path in a toroidal topology - toCenter = toCenter - round(toCenter); - - float distance = length(toCenter); // Distance to the center, considering wrapping - float wave = sin(distance * 10.0 - time * FREQUENCY) * amplitude; // Sinusoidal wave based on distance and time, scaled by amplitude - wave *= exp(-distance * 15.); // Exponential falloff based on distance, sharper to make the effect more localized - - return toCenter * wave * 0.05; // Scale the distortion vector by a factor for visual effect -} - -// Main function -void mainImage(out vec4 fragColor, in vec2 fragCoord) { - vec2 uv = fragCoord.xy / iResolution.xy; // Normalize UV coordinates - - // Calculate time-based parameters for animation - float time = iTime; - - // Center of the drip effect, animated to move across the screen - vec2 center = CENTER; - - // Apply the drip effect to distort UV coordinates - vec2 distortedUv = uv + drip(uv, center); - - // Fetch the color from the previous frame, using distorted UVs - vec4 color = getLastFrameColor(distortedUv); - fragColor = color; -} diff --git a/shaders/redaphid/generators.frag b/shaders/redaphid/generators.frag deleted file mode 100644 index 853ce24..0000000 --- a/shaders/redaphid/generators.frag +++ /dev/null @@ -1,288 +0,0 @@ -// "GENERATORS REDUX" by Kali - -// Same fractal as "Ancient Temple" + rotations, improved shading -// (better coloring, AO and shadows), some lighting effects, and a path for the camera -// following a liquid metal ball. - - -#define ENABLE_HARD_SHADOWS // turn off to enable faster AO soft shadows -//#define ENABLE_VIBRATION -#define ENABLE_POSTPROCESS // Works better on window view rather than full screen - - -#define RAY_STEPS 70 -#define SHADOW_STEPS 50 -#define LIGHT_COLOR vec3(.85,.9,1.) -#define AMBIENT_COLOR vec3(.8,.83,1.) -#define FLOOR_COLOR vec3(1.,.7,.9) -#define ENERGY_COLOR vec3(1.,.7,.4) -#define BRIGHTNESS .9 -#define GAMMA 1.3 -#define SATURATION .85 - - -#define detail .00005 -#define t (iTime *.25 + abs(energyMean/10.)) - - - -vec3 lightdir=normalize(vec3(0.5,-0.3,-1.)); -vec3 ambdir=normalize(vec3(0.,0.,1.)); -const vec3 origin=vec3(0.,3.11,0.); -vec3 power=vec3(0.01); -#ifdef ENABLE_VIBRATION -float vibration=sin(iTime*60.)*.0013; -#else -float vibration=0.; -#endif -float det=0.0; -vec3 pth1; - - -mat2 rot(float a) { - return mat2(cos(a),sin(a),-sin(a),cos(a)); -} - - -vec3 path(float ti) { -return vec3(sin(ti),.3-sin(ti*.632)*.3,cos(ti*.5))*.5; -} - -float Sphere(vec3 p, vec3 rd, float r){//A RAY TRACED SPHERE - float b = dot( -p, rd ); - float inner = b * b - dot( p, p ) + r * r; - if( inner < 0.0 ) return -1.0; - return b - sqrt( inner ); -} - -vec2 de(vec3 pos) { - float hid=0.; - vec3 tpos=pos; - tpos.xz=abs(.5-mod(tpos.xz,1.)); - vec4 p=vec4(tpos,1.); - float y=max(0.,.35-abs(pos.y-3.35))/.35; - for (int i=0; i<7; i++) {//LOWERED THE ITERS - p.xyz = abs(p.xyz)-vec3(-0.02,1.98,-0.02); - p=p*(2.0+vibration*y)/clamp(dot(p.xyz,p.xyz),.4,1.)-vec4(0.5,1.,0.4,0.); - p.xz*=mat2(-0.416,-0.91,0.91,-0.416); - } - float fl=pos.y-3.013; - float fr=(length(max(abs(p.xyz)-vec3(0.1,5.0,0.1),vec3(0.0)))-0.05)/p.w;//RETURN A RRECT - //float fr=length(p.xyz)/p.w; - float d=min(fl,fr); - d=min(d,-pos.y+3.95); - if (abs(d-fl)<.001) hid=1.; - return vec2(d,hid); -} - - -vec3 normal(vec3 p) { - vec3 e = vec3(0.0,det,0.0); - - return normalize(vec3( - de(p+e.yxx).x-de(p-e.yxx).x, - de(p+e.xyx).x-de(p-e.xyx).x, - de(p+e.xxy).x-de(p-e.xxy).x - ) - ); -} - -float shadow(vec3 pos, vec3 sdir) {//THIS ONLY RUNS WHEN WITH HARD SHADOWS - float sh=1.0; - float totdist =2.0*det; - float dist=10.; - float t1=Sphere((pos-spectralCentroid*sdir)-pth1,-sdir,spectralCentroid); - if (t1>0. && t1<.5) { - vec3 sphglowNorm=normalize(pos-t1*sdir-pth1 + spectralCentroid); - sh=1.-pow(max(.0,dot(sphglowNorm,sdir))*energyZScore,3.); - } - for (int steps=0; stepsdetail) { - vec3 p = pos - totdist * sdir; - dist = de(p).x; - sh = min( sh, max(spectralFlux*dist/totdist,0.0) ); - totdist += max(.01,dist); - } - } - - return clamp(sh,0.1,1.0); -} - - -float calcAO( const vec3 pos, const vec3 nor ) { - float aodet=detail*40.; - float totao = 0.0; - float sca = 14.0; - for( int aoi=0; aoi<5; aoi++ ) { - float hr = aodet*float(aoi*aoi); - vec3 aopos = nor * hr + pos; - float dd = de( aopos ).x; - totao += -(dd-hr)*sca; - sca *= 0.7; - } - return clamp( 1.0 - 5.0*totao, 0., 1.0 ); -} - -float _texture(vec3 p) { - p=abs(energy-fract(p*10.)); - vec3 c=vec3(spectralFluxNormalized); - float es, l=es=0.; - for (int i = 0; i < int(spectralRolloff); i++) { - p = abs(p + c) - abs(p - c) - p; - p/= clamp(dot(p, p), .0, 1.); - p = p* -1.5 + c; - if ( mod(float(i), 2.) < 1. ) { - float pl = l; - l = length(p); - es+= exp(-1. / abs(l - pl)); - } - } - return es; -} - -vec3 light(in vec3 p, in vec3 dir, in vec3 n, in float hid) {//PASSING IN THE NORMAL - #ifdef ENABLE_HARD_SHADOWS - float sh=shadow(p, lightdir); - #else - float sh=calcAO(p,-2.5*lightdir);//USING AO TO MAKE VERY SOFT SHADOWS - #endif - float ao=calcAO(p,n); - float diff=max(0.,dot(lightdir,-n))*sh; - float y=3.35-p.y; - vec3 amb=max(.5,dot(dir,-n))*.5*AMBIENT_COLOR; - if (hid<.5) { - amb+=max(0.2,dot(vec3(0.,1.,0.),-n))*FLOOR_COLOR*pow(max(0.,.2-abs(3.-p.y))/.2,1.5)*2.; - amb+=power*pow(max(0.,.4-abs(y))/.4,2.)*max(0.2,dot(vec3(0.,-sign(y),0.),-n))*2.; - } - vec3 r = reflect(lightdir,n); - float spec=pow(max(0.,dot(dir,-r))*sh,10.); - vec3 col; - float energysource=pow(max(0.,spectralCentroid/10.-abs(y))/spectralCentroid/10.,4.)*2.; - if (hid>1.5) {col=vec3(1.); spec=spec*spec;} - else{ - float k=_texture(p)*.23+.2; - k=min(k,1.5-energysource); - col=mix(vec3(k,k*k,k*k*k),vec3(k),.3); - if (abs(hid-1.)<.001) col*=FLOOR_COLOR*1.3; - } - col=col*(amb+diff*LIGHT_COLOR)+spec*LIGHT_COLOR; - if (hid<.5) { - col=max(col,power*2.*energysource); - } - col*=min(1.,ao+length(power)*.5*max(0.,.1-abs(y))/.1); - return col; -} - -vec3 raymarch(in vec3 from, in vec3 dir) - -{ - float ey=mod(t*.5,1.); - float glow,eglow,ref,sphdist,totdist=glow=eglow=ref=sphdist=0.; - vec2 d=vec2(1.,0.); - vec3 p, col=vec3(0.); - vec3 origdir=dir,origfrom=from,sphNorm; - - //FAKING THE SQUISHY BALL BY MOVING A RAY TRACED BALL - vec3 wob=cos(dir*500.0*length(from-pth1)+(from-pth1)*250.+iTime*10.)*0.0005; - float t1=Sphere(from-pth1+wob,dir,0.015); - float tg=Sphere(from-pth1+wob,dir,0.02); - if(t1>0.){ - ref=1.0;from+=t1*dir;sphdist=t1; - sphNorm=normalize(from-pth1+wob); - dir=reflect(dir,sphNorm); - } - else if (tg>0.) { - vec3 sphglowNorm=normalize(from+tg*dir-pth1+wob); - glow+=pow(max(0.,dot(sphglowNorm,-dir)),5.); - }; - - for (int i=0; idet && totdist<3.0) { - p=from+totdist*dir; - d=de(p); - det=detail*(1.+totdist*60.)*(1.+ref*5.); - totdist+=d.x; - power=ENERGY_COLOR*(1.5+sin(iTime*20.+p.z*10.))*.25; - if(d.x<0.015)glow+=max(0.,.015-d.x)*exp(-totdist); - if (d.y<.5 && d.x<0.03){//ONLY DOING THE GLOW WHEN IT IS CLOSE ENOUGH - float glw=min(abs(3.35-p.y-ey),abs(3.35-p.y+ey));//2 glows at once - eglow+=max(0.,.03-d.x)/.03* - (pow(max(0.,.05-glw)/.05,5.) - +pow(max(0.,.15-abs(3.35-p.y))/.15,8.))*1.5; - } - } - } - float l=pow(max(0.,dot(normalize(-dir.xz),normalize(lightdir.xz))),2.); - l*=max(0.2,dot(-dir,lightdir)); - vec3 backg=.5*(1.2-l)+LIGHT_COLOR*l*.7; - backg*=AMBIENT_COLOR; - if (d.x<=det) { - vec3 norm=normal(p-abs(d.x-det)*dir);//DO THE NORMAL CALC OUTSIDE OF LIGHTING (since we already have the sphere normal) - col=light(p-abs(d.x-det)*dir, dir, norm, d.y)*exp(-.2*totdist*totdist); - col = mix(col, backg, 1.0-exp(-1.*pow(totdist,1.5))); - } else { - col=backg; - } - vec3 lglow=LIGHT_COLOR*pow(l,30.)*.5; - col+=glow*(backg+lglow)*1.3; - col+=pow(eglow,2.)*power*.015; - col+=lglow*min(1.,totdist*totdist*.3); - if (ref>0.5) { - vec3 sphlight=light(origfrom+sphdist*origdir,origdir,sphNorm,2.); - col=mix(col*.3+sphlight*.7,backg,1.0-exp(-1.*pow(sphdist,1.5))); - } - return col; -} - -vec3 move(inout mat2 rotview1,inout mat2 rotview2) { - vec3 go=path(t); - vec3 adv=path(t+.7); - vec3 advec=normalize(adv-go); - float an=atan(advec.x,advec.z); - rotview1=mat2(cos(an),sin(an),-sin(an),cos(an)); - an=advec.y*1.7; - rotview2=mat2(cos(an),sin(an),-sin(an),cos(an)); - return go; -} - - -void mainImage( out vec4 fragColor, in vec2 fragCoord ) -{ - pth1 = path(t+.3)+origin+vec3(0.,.01,0.); - vec2 uv = fragCoord.xy / iResolution.xy*2.-1.; - vec2 uv2=uv; -#ifdef ENABLE_POSTPROCESS - uv*=1.+pow(length(uv2*uv2*uv2*uv2),4.)*.07; -#endif - uv.y*=iResolution.y/iResolution.x; - vec2 mouse=(iMouse.xy/iResolution.xy-.5)*3.; - if (iMouse.z<1.) mouse=vec2(0.); - mat2 rotview1, rotview2; - vec3 from=origin+move(rotview1,rotview2); - vec3 dir=normalize(vec3(uv*.8,1.)); - dir.yz*=rot(0.); - dir.xz*=rot(0.); - dir.yz*=rotview2; - dir.xz*=rotview1; - vec3 color=raymarch(from,dir); - color=clamp(color,vec3(.0),vec3(1.)); - color=pow(color,vec3(GAMMA))*BRIGHTNESS; - color=mix(vec3(length(color)),color,SATURATION); -#ifdef ENABLE_POSTPROCESS - vec3 rain=pow(texture(iChannel0,uv2+iTime*7.25468).rgb,vec3(1.5)); - color=mix(rain,color,clamp(iTime*.5-.5,0.,1.)); - color*=1.-pow(length(uv2*uv2*uv2*uv2)*1.1,6.); - uv2.y *= iResolution.y / 360.0; - color.r*=(.5+abs(.5-mod(uv2.y ,0.17)/0.17)*.5); - color.g*=(.5+abs(.5-mod(uv2.y+.007,0.17)/0.17)*.5)*1.5; - color.b*=(.5+abs(.5-mod(uv2.y+.014,0.17)/0.17)*.5)*1.5; - color*=.9+rain*.35; -#endif - vec3 hsl = rgb2hsl(color); - if(hsl.z > 0.8) { - hsl.x = spectralCentroid; - hsl.z = fract(energyMean * 100.); - } - color = hsl2rgb(hsl); - fragColor = vec4(color,1.); -}