From c17d0cd7944e974dfad2331abd3d775d282a5439 Mon Sep 17 00:00:00 2001 From: Bruce LANE Date: Tue, 16 Oct 2018 04:09:52 +0200 Subject: [PATCH] more uniforms --- AcidAtTheDisco.fs | 2 +- AnyArrayIndex.fs | 33 +++--- BinarySerpents.fs | 84 +++++++++++++++ ComplexColorPlots.fs | 172 +++++++++++++++++++++++++++++ NovaFractal.fs | 55 ++++++++++ PlasmaGlobe.fs | 251 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 580 insertions(+), 17 deletions(-) create mode 100644 BinarySerpents.fs create mode 100644 ComplexColorPlots.fs create mode 100644 NovaFractal.fs create mode 100644 PlasmaGlobe.fs diff --git a/AcidAtTheDisco.fs b/AcidAtTheDisco.fs index 45eac01..5366b22 100644 --- a/AcidAtTheDisco.fs +++ b/AcidAtTheDisco.fs @@ -1,9 +1,9 @@ /*{ - "DESCRIPTION": "https://www.shadertoy.com/view/4sfXRB", "CREDIT" : "AcidAtTheDisco by Author", "CATEGORIES" : [ "ci" ], + "DESCRIPTION": "https://www.shadertoy.com/view/4sfXRB", "INPUTS": [ { "NAME" :"iMouse", diff --git a/AnyArrayIndex.fs b/AnyArrayIndex.fs index ad78ee0..81d12aa 100644 --- a/AnyArrayIndex.fs +++ b/AnyArrayIndex.fs @@ -1,8 +1,9 @@ -/*{"DESCRIPTION": "https://www.shadertoy.com/view/ldj3Rd", +/*{ "CREDIT" : "AnyArrayIndex by Author", "CATEGORIES" : [ "ci" ], +"DESCRIPTION": "https://www.shadertoy.com/view/ldj3Rd", "INPUTS": [ { "NAME": "iZoom", @@ -66,24 +67,24 @@ vec3 AAIGetSMColor(float c, float s) // https://www.shadertoy.com/view/ldj3Rd void mainImage(out vec4 fragColor, in vec2 fragCoord) { - vec2 uv = fragCoord.xy/RENDERSIZE.xy; + vec2 uv = iZoom * fragCoord.xy/RENDERSIZE.xy; vec3 col=vec3(0.); // define the colors - // AAIPalette[6]=vec3(iColor.r*255,000,000)/255.; - // AAIPalette[5]=vec3(iColor.r*255,iColor.g*127,000)/255.; - // AAIPalette[4]=vec3(iColor.r*255,iColor.g*255,000)/255.; - // AAIPalette[3]=vec3(000,iColor.g*255,000)/255.; - // AAIPalette[2]=vec3(000,000,iColor.b*255)/255.; - // AAIPalette[1]=vec3(iColor.r*075,000,iColor.b*130)/255.; - // AAIPalette[0]=vec3(iColor.r*143,000,iColor.b*255)/255.; + AAIPalette[6]=vec3(iColor.r*255,000,000)/255.; + AAIPalette[5]=vec3(iColor.r*255,iColor.g*127,000)/255.; + AAIPalette[4]=vec3(iColor.r*255,iColor.g*255,000)/255.; + AAIPalette[3]=vec3(000,iColor.g*255,000)/255.; + AAIPalette[2]=vec3(000,000,iColor.b*255)/255.; + AAIPalette[1]=vec3(iColor.r*075,000,iColor.b*130)/255.; + AAIPalette[0]=vec3(iColor.r*143,000,iColor.b*255)/255.; // rainbow - AAIPalette[6]=vec3(255,000,000)/255.; - AAIPalette[5]=vec3(255,127,000)/255.; - AAIPalette[4]=vec3(255,255,000)/255.; - AAIPalette[3]=vec3(000,255,000)/255.; - AAIPalette[2]=vec3(000,000,255)/255.; - AAIPalette[1]=vec3(075,000,130)/255.; - AAIPalette[0]=vec3(143,000,255)/255.; + // AAIPalette[6]=vec3(255,000,000)/255.; + // AAIPalette[5]=vec3(255,127,000)/255.; + // AAIPalette[4]=vec3(255,255,000)/255.; + // AAIPalette[3]=vec3(000,255,000)/255.; + // AAIPalette[2]=vec3(000,000,255)/255.; + // AAIPalette[1]=vec3(075,000,130)/255.; + // AAIPalette[0]=vec3(143,000,255)/255.; vec2 p=(uv-.5); p.x*=RENDERSIZE.x/RENDERSIZE.y; diff --git a/BinarySerpents.fs b/BinarySerpents.fs new file mode 100644 index 0000000..2f566a4 --- /dev/null +++ b/BinarySerpents.fs @@ -0,0 +1,84 @@ +/*{ +"CREDIT" : "BinarySerpents by Trisomie21", +"CATEGORIES" : [ +"ci" +], +"DESCRIPTION": "https://www.shadertoy.com/view/MslGRH", + "INPUTS": [ + { + "NAME": "iChannel0", + "TYPE": "image" + }, +{ +"NAME": "iZoom", +"TYPE" : "float", +"MIN" : 0.0, +"MAX" : 1.0, +"DEFAULT" : 1.0}, + {"NAME" :"iMouse", +"TYPE" : "point2D", +"DEFAULT" : [0.0, 0.0], +"MAX" : [640.0, 480.0], +"MIN" : [0.0, 0.0]}, +{ +"NAME": "iColor", +"TYPE" : "color", +"DEFAULT" : [ +0.0, +1.0, +0.0, +1.0 +]} +], +} +*/ +// https://www.shadertoy.com/view/MslGRH + +// With tweaks by PauloFalcao + +float BinarySerpentsTexture3D(vec3 n, float res){ + n = floor(n*res+.5); + return fract(sin((n.x+n.y*1e5+n.z*1e7)*1e-4)*1e5); +} + +float BinarySerpentsmap( vec3 p ){ + p.x+=sin(p.z*4.0+TIME*4.0)*0.1*cos(TIME*0.1); + p = mod(p,vec3(1.0, 1.0, 1.0))-0.5; + return length(p.xy)-.1; +} +void mainImage(out vec4 fragColor, in vec2 fragCoord) +{ + vec2 uv = iZoom * fragCoord.xy/RENDERSIZE.xy * 2.0 - 0.5; + vec3 camPos = vec3(cos(TIME*0.3), sin(TIME*0.3), 1.5); + vec3 camTarget = vec3(0.0, 0.0, 0.0); + + vec3 camDir = normalize(camTarget-camPos); + vec3 camUp = normalize(vec3(0.0, 1.0, 0.0)); + vec3 camSide = cross(camDir, camUp); + float focus = 2.0; + + vec3 rayDir = normalize(camSide*uv.x + camUp*uv.y + camDir*focus); + vec3 ray = camPos; + float d = 0.0, total_d = 0.0; + const int MAX_MARCH = 100; + const float MAX_DISTANCE = 5.0; + float c = 1.0; + for(int i=0; iMAX_DISTANCE) { c = 0.; total_d=MAX_DISTANCE; break; } + } + + float fog = 3.1; + vec3 result = vec3( vec3(iColor.r, iColor.g, iColor.b) * (fog - total_d) / fog ); + + ray.z -= 5.+TIME*.5; + float r = BinarySerpentsTexture3D(ray, 33.); + + fragColor = vec4(result*(step(r,.3)+r*.2+.1),1.0); +} + + +void main(void) { mainImage(gl_FragColor, gl_FragCoord.xy); } \ No newline at end of file diff --git a/ComplexColorPlots.fs b/ComplexColorPlots.fs new file mode 100644 index 0000000..1c8097f --- /dev/null +++ b/ComplexColorPlots.fs @@ -0,0 +1,172 @@ +/*{ +"CREDIT" : "ComplexColorPlots by allemangD", +"CATEGORIES" : [ +"ci" +], +"DESCRIPTION": "https://www.shadertoy.com/view/lsycRW", + "INPUTS": [ +{ +"NAME": "iChannel0", +"TYPE" : "image" +}, +{ +"NAME": "iZoom", +"TYPE" : "float", +"MIN" : 0.0, +"MAX" : 1.0, +"DEFAULT" : 1.0}, + {"NAME" :"iMouse", +"TYPE" : "point2D", +"DEFAULT" : [0.0, 0.0], +"MAX" : [640.0, 480.0], +"MIN" : [0.0, 0.0]}, +{ +"NAME": "iColor", +"TYPE" : "color", +"DEFAULT" : [ +0.7, +0.5, +0.0, +1.0 +]} +], +} +*/ + +vec3 hsv2rgb(vec3 c) +{ + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); +} + +vec2 comp(in float x) { return vec2(x, 0.); } +vec2 comp(in int x) { return vec2(float(x), 0.); } +vec2 comp(in vec2 x) { return x; } + +vec2 cMul(in vec2 a, in vec2 b) +{ + return vec2(a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x); +} +vec2 cMul(in float a, in vec2 b) { return cMul(comp(a), comp(b)); } +vec2 cMul(in int a, in vec2 b) { return cMul(comp(a), comp(b)); } +vec2 cMul(in vec2 a, in float b) { return cMul(comp(a), comp(b)); } +vec2 cMul(in vec2 a, in int b) { return cMul(comp(a), comp(b)); } +vec2 cMul(in float a, in float b) { return cMul(comp(a), comp(b)); } + +vec2 cInv(in vec2 b) +{ + return vec2(b.x, -b.y)/length(b)/length(b); +} +vec2 cInv(in float a) { return cInv(comp(a)); } +vec2 cInv(in int a) { return cInv(comp(a)); } + +vec2 cDiv(in vec2 a, in vec2 b) +{ + return cMul(a, cInv(b)); +} +vec2 cDiv(in float a, in vec2 b) { return cDiv(comp(a), comp(b)); } +vec2 cDiv(in int a, in vec2 b) { return cDiv(comp(a), comp(b)); } +vec2 cDiv(in vec2 a, in float b) { return cDiv(comp(a), comp(b)); } +vec2 cDiv(in vec2 a, in int b) { return cDiv(comp(a), comp(b)); } +vec2 cDiv(in float a, in float b) { return cDiv(comp(a), comp(b)); } + +vec2 cPow(in vec2 b1, in vec2 c2) +{ + float l, a, r, t, x, y; + + l = log(length(b1)); + a = atan(b1.y, b1.x); + + r = exp(c2.x * l - c2.y * a); + t = c2.x * a + c2.y * l; + + x = r * cos(t); + y = r * sin(t); + + return vec2(x, y); +} +vec2 cPow(in float a, in vec2 b) { return cPow(comp(a), comp(b)); } +vec2 cPow(in int a, in vec2 b) { return cPow(comp(a), comp(b)); } +vec2 cPow(in vec2 a, in float b) { return cPow(comp(a), comp(b)); } +vec2 cPow(in vec2 a, in int b) { return cPow(comp(a), comp(b)); } +vec2 cPow(in float a, in float b) { return cPow(comp(a), comp(b)); } + +vec2 cExp(in vec2 a) { + return exp(a.x) * vec2(cos(a.y), sin(a.y)); +} +vec2 cExp(in float a) { return cExp(comp(a)); } +vec2 cExp(in int a) { return cExp(comp(a)); } + +vec2 cExpi(in vec2 a) { + return exp(-a.y) * vec2(cos(a.x), sin(a.x)); +} +vec2 cExpi(in float a) { return cExpi(comp(a)); } +vec2 cExpi(in int a) { return cExpi(comp(a)); } + +vec2 cLog(in vec2 a) { + return vec2(log(length(a)), atan(a.y, a.x)); +} +vec2 cLog(in float a) { return cLog(comp(a)); } +vec2 cLog(in int a) { return cLog(comp(a)); } + +vec2 cSin(in vec2 a) { + return cDiv(cExpi(a)-cExpi(-a), vec2(0.,2.)); +} +vec2 cSin(in float a) { return cSin(comp(a)); } +vec2 cSin(in int a) { return cSin(comp(a)); } + +vec2 cCos(in vec2 a) { + return (cExpi(a)+cExpi(-a))/2.; +} +vec2 cCos(in float a) { return cCos(comp(a)); } +vec2 cCos(in int a) { return cCos(comp(a)); } + +vec2 cCon(in vec2 a) { + return a * vec2(1, -1); +} +vec2 cCon(in float a) { return comp(a); } +vec2 cCon(in int a) { return comp(a); } + +vec2 f(in vec2 z) { + vec2 u = cMul(vec2(3, 0), cExpi(TIME/4.)); + vec2 v = cMul(vec2(1, 0), cExpi(TIME/2.)); + vec2 w = cMul(vec2(8, 0), cExpi(-TIME)); + + vec2 a = cPow(z, 1) + u; + vec2 b = cInv(cPow(z, 2) + v); + vec2 c = cPow(z, 3) + w; + + return cMul(cMul(a, b), c); +} +void mainImage(out vec4 fragColor, in vec2 fragCoord) +{ + float SCALE = 8.0; + + // Normalized pixel coordinates (from 0 to 1) + vec2 uv = fragCoord.xy/RENDERSIZE.xy - vec2(.5); + uv.x *= RENDERSIZE.x/RENDERSIZE.y; + uv *= SCALE; + + vec2 o = f(uv); + float h = atan(o.y, o.x); + vec3 col = hsv2rgb(vec3(h / 6.28, 1., 1.)); + + float sa, sb; + float w = 0.05; + + sa = log(length(o)); + sa = abs(sa - floor(sa)); + col *= mix(.8, 1.0, sa); + + sb = atan(o.y, o.x); + sb = (sb + 3.1415)/6.2832 * 8.0; + sb = abs(sb - floor(sb)); + + if (sb < w || sb > 1. - w) + col = mix(col, vec3(1), smoothstep(.025, .0, abs(fract(sb + .5 + w) - .5 - w))); + + // Output to screen + fragColor = vec4(col,1.0); +} + void main(void) { mainImage(gl_FragColor, gl_FragCoord.xy); } \ No newline at end of file diff --git a/NovaFractal.fs b/NovaFractal.fs new file mode 100644 index 0000000..ce494a8 --- /dev/null +++ b/NovaFractal.fs @@ -0,0 +1,55 @@ +/*{ +"CREDIT" : "NovaFractal by gleurop", +"CATEGORIES" : [ +"ci" +], +"DESCRIPTION": "https://www.shadertoy.com/view/Xsl3DM", + "INPUTS": [ +{ +"NAME": "iChannel0", +"TYPE" : "image" +}, +{ +"NAME": "iZoom", +"TYPE" : "float", +"MIN" : 0.0, +"MAX" : 1.0, +"DEFAULT" : 1.0}, + {"NAME" :"iMouse", +"TYPE" : "point2D", +"DEFAULT" : [0.0, 0.0], +"MAX" : [640.0, 480.0], +"MIN" : [0.0, 0.0]}, +{ +"NAME": "iColor", +"TYPE" : "color", +"DEFAULT" : [ +0.7, +0.5, +0.0, +1.0 +]} +], +} +*/ + +void mainImage( out vec4 fragColor, in vec2 fragCoord ) { + vec2 p = fragCoord.xy / RENDERSIZE.xy * 2.0 - 1.0; + p.x *= RENDERSIZE.x / RENDERSIZE.y; + vec2 c = p; + float iter = 0.0; + vec4 color = vec4(0.0); + for (int i = 0; i < 40; i++) { + //vec4 g = texture2D(iChannel0, c); + //color += g; + float phi = atan(c.y, c.x) + TIME*0.01*iter; + float r = dot(c,c); + if (r < 16.0) { + c.x = ((cos(2.0*phi))/r) + p.x; + c.y = (-sin(2.0*phi)/r) + p.y; + + iter++; + } + } + fragColor = vec4(color / 40.0 + max(0.75 - iter / 40.0, 0.0)); +}void main(void) { mainImage(gl_FragColor, gl_FragCoord.xy); } \ No newline at end of file diff --git a/PlasmaGlobe.fs b/PlasmaGlobe.fs new file mode 100644 index 0000000..ecc6356 --- /dev/null +++ b/PlasmaGlobe.fs @@ -0,0 +1,251 @@ +/*{ + "CREDIT" : "PlasmaGlobe by nimitz", + "CATEGORIES" : [ + "ci" + ], + "DESCRIPTION": "https://www.shadertoy.com/view/XsjXRm", + "INPUTS": [ + { + "NAME": "iChannel0", + "TYPE" : "image" + }, + { + "NAME": "iZoom", + "TYPE" : "float", + "MIN" : 0.0, + "MAX" : 1.0, + "DEFAULT" : 1.0}, + { + "NAME": "iSteps", + "TYPE" : "float", + "MIN" : 2.0, + "MAX" : 75.0, + "DEFAULT" : 35.0}, + { + "NAME" :"iMouse", + "TYPE" : "point2D", + "DEFAULT" : [0.0, 0.0], + "MAX" : [640.0, 480.0], + "MIN" : [0.0, 0.0]}, + { + "NAME": "iColor", + "TYPE" : "color", + "DEFAULT" : [ + 0.9, + 0.6, + 0.0, + 1.0 + ]} + ], +} +*/ +// https://www.shadertoy.com/view/XsjXRm +//Plasma Globe by nimitz (twitter: @stormoid) + +//looks best with around 20 rays +#define NUM_RAYS 13. + +#define VOLUMETRIC_STEPS 19 + +#define MAX_ITER 35 +#define FAR 6. + +#define time TIME*1.1 + + +mat2 mm2(in float a){float c = cos(a), s = sin(a);return mat2(c,-s,s,c);} +float fnoise( in float x ){return fract(sin(x)*43758.5453);} + +float hash( float n ){return fract(sin(n)*43758.5453);} + +float vnoise( in vec3 x ) +{ + vec3 p = floor(x); return p.x; + /* BL TODO vec3 f = fract(x); + f = f*f*(3.0-2.0*f); + + return mix(mix(mix( hash(p+vec3(0,0,0)), + hash(p+vec3(1,0,0)),f.x), + mix( hash(p+vec3(0,1,0)), + hash(p+vec3(1,1,0)),f.x),f.y), + mix(mix( hash(p+vec3(0,0,1)), + hash(p+vec3(1,0,1)),f.x), + mix( hash(p+vec3(0,1,1)), + hash(p+vec3(1,1,1)),f.x),f.y),f.z); */ +} + +mat3 m3 = mat3( 0.00, 0.80, 0.60, + -0.80, 0.36, -0.48, + -0.60, -0.48, 0.64 ); + + +//See: https://www.shadertoy.com/view/XdfXRj +float flow(in vec3 p, in float t) +{ + float z=2.; + float rz = 0.; + vec3 bp = p; + for (float i= 1.;i < 5.;i++ ) + { + p += time*.1; + rz+= (sin(vnoise(p+t*0.8)*6.)*0.5+0.5) /z; + p = mix(bp,p,0.6); + z *= 2.; + p *= 2.01; + p*= m3; + } + return rz; +} + +//could be improved +float sins(in float x) +{ + float rz = 0.; + float z = 2.; + for (float i= 0.;i < 3.;i++ ) + { + rz += abs(fract(x*1.4)-0.5)/z; + x *= 1.3; + z *= 1.15; + x -= time*.65*z; + } + return rz; +} + +float segm( vec3 p, vec3 a, vec3 b) +{ + vec3 pa = p - a; + vec3 ba = b - a; + float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1. ); + return length( pa - ba*h )*.5; +} + +vec3 path(in float i, in float d) +{ + vec3 en = vec3(0.,0.,1.); + float sns2 = sins(d+i*0.5)*0.22; + float sns = sins(d+i*.6)*0.21; + en.xz *= mm2((hash(i*10.569)-.5)*6.2+sns2); + en.xy *= mm2((hash(i*4.732)-.5)*6.2+sns); + return en; +} + +vec2 map(vec3 p, float i) +{ + float lp = length(p); + vec3 bg = vec3(0.); + vec3 en = path(i,lp); + + float ins = smoothstep(0.11,.46,lp); + float outs = .15+smoothstep(.0,.15,abs(lp-1.)); + p *= ins*outs; + float id = ins*outs; + + float rz = segm(p, bg, en)-0.011; + return vec2(rz,id); +} + +float march(in vec3 ro, in vec3 rd, in float startf, in float maxd, in float j) +{ + float precis = 0.001; + float h=0.5; + float d = startf; + for( int i=0; imaxd ) break; + d += h*1.2; + float res = map(ro+rd*d, j).x; + h = res; + } + return d; +} + +//volumetric marching +vec3 vmarch(in vec3 ro, in vec3 rd, in float j, in vec3 orig) +{ + vec3 p = ro; + vec2 r = vec2(0.); + vec3 sum = vec3(0); + float w = 0.; + for( int i=0; i= FAR)continue; + vec3 pos = ro+rz*rd; + col = max(col,vmarch(pos,rd,j, bro)); + } + #endif + + ro = bro; + rd = brd; + vec2 sph = iSphere2(ro,rd); + + if (sph.x > 0.) + { + vec3 pos = ro+rd*sph.x; + vec3 pos2 = ro+rd*sph.y; + vec3 rf = reflect( rd, pos ); + vec3 rf2 = reflect( rd, pos2 ); + float nz = (-log(abs(flow(rf*1.2,time)-.01))); + float nz2 = (-log(abs(flow(rf2*1.2,-time)-.01))); + col += (0.1*nz*nz* vec3(0.12,0.12,.5) + 0.05*nz2*nz2*vec3(0.55,0.2,.55))*0.8; + } + + fragColor = vec4(col*1.3, 1.0); +} + +void main(void) { mainImage(gl_FragColor, gl_FragCoord.xy); } \ No newline at end of file