Updated pack sources

This commit is contained in:
Digital Artifex
2025-11-04 11:29:25 -05:00
parent 2bbd4f806d
commit adebc672ad
49 changed files with 3251 additions and 552 deletions

View File

@@ -1,32 +0,0 @@
{
"author": "s23b",
"name": "Blueprint of the Arkiteckt",
"version": "1.0.0",
"description": "",
"license": "CC BY-NC-SA 3.0",
"engine": "shadertoys",
"id": "4tySDW",
"tags": [
"reactive",
"raymarching",
"fractal",
"edge detect",
"mouse"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"channel0":
{
"type": 2,
"source": "./shaders/Buffer A.frag.qsb",
"frame_buffer_channel": 1,
"channel0":
{
"type": 4,
"invert": true
}
}
}

View File

@@ -1,8 +0,0 @@
// the purpose of this buffer is too smooth out the sudden changes in the fft
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
float old = texture(iChannel1, uv).x;
float new = texture(iChannel0, uv).x;
fragColor = vec4(mix(old, new, new > old ? .4 : .04));
}

View File

@@ -1,356 +0,0 @@
#define SPEED .1
#define FOV 3.
#define MAX_STEPS 80
#define EPS .001
#define RENDER_DIST 5.
#define AO_SAMPLES 4.
#define AO_RANGE 100.
#define PI 3.14159265359
#define saturate(x) clamp(x, 0., 1.)
// precomputed globals
float _house = 0.;
float _boat = 0.;
float _spaceship = 0.;
float _atmosphere = 0.;
mat3 _kifsRot = mat3(1, 0, 0, 0, 1, 0, 0, 0, 1);
float _kifsOffset = 0.;
// rotate 2d space with given angle
void tRotate(inout vec2 p, float angel) {
float s = sin(angel), c = cos(angel);
p *= mat2(c, -s, s, c);
}
// divide 2d space into s chunks around the center
void tFan(inout vec2 p, float s) {
float k = s / PI / 2.;
tRotate(p, -floor((atan(p.y, p.x)) * k + .5) / k);
}
// rectangle distance
float sdRect(vec2 p, vec2 r) {
p = abs(p) - r;
return min(max(p.x, p.y), 0.) + length(max(p, 0.));
}
// box distance
float sdBox(vec3 p, vec3 r) {
p = abs(p) - r;
return min(max(p.x, max(p.y, p.z)), 0.) + length(max(p, 0.));
}
// sphere distance
float sdSphere(vec3 p, float r) {
return length(p) - r;
}
// 3d cross distance
float sdCross(vec3 p, vec3 r) {
p =abs(p) - r;
p.xy = p.x < p.y ? p.xy : p.yx;
p.yz = p.y < p.z ? p.yz : p.zy;
p.xy = p.x < p.y ? p.xy : p.yx;
return length(min(p.yz, 0.)) - max(p.y, 0.);
}
// union
float opU(float a, float b) {
return min(a, b);
}
// intersection
float opI(float a, float b) {
return max(a, b);
}
// substraction
float opS(float a, float b) {
return max(a, -b);
}
// smooth union
float opSU(float a, float b, float k)
{
float h = clamp(.5 + .5 * (b - a) / k, 0., 1.);
return mix(b, a, h) - k * h * (1. - h);
}
// house distance
float sdHouse(vec3 p) {
p.y += .075;
vec3 boxDim = vec3(.2, .15, .2);
// add the walls
float d = sdBox(p, boxDim);
// add the windows
vec3 q = abs(p);
vec3 windSize = vec3(.04, .04, .06);
q -= windSize + vec3(.005);
d = opI(d, opU(sdCross(q, windSize), .11 - abs(p.y)));
// add the roof
q = p;
q.y -= .38;
tFan(q.xz, 4.);
tRotate(q.xy, PI/4.);
d = opU(d, sdBox(q, vec3(.35, .01, .35)));
// make it hollow
d = opS(d, sdBox(p, boxDim - vec3(.02)));
return d;
}
// boat distance
float sdBoat(vec3 p) {
// add the mast (a word I learned today :P)
float d = sdBox(p + vec3(0, .05, 0), vec3(.01, .2, .01));
// add the sail
vec3 q = p + vec3(0, -.05, .12);
float a = sdSphere(q, .2);
a = opS(a, sdSphere(q, .195));
q.x = abs(q.x);
tRotate(q.yx, .1);
a = opI(a, sdBox(q - vec3(0, 0, .1), vec3(.1)));
d = opU(d, a);
// add the body of the boat
p.x = abs(p.x);
p.x += .1;
a = sdSphere(p, .3);
a = opS(a, sdSphere(p, .29));
a = opI(a, p.y + .15);
d = opU(d,a);
return d;
}
// spaceship distance
float sdSpaceship(vec3 p) {
tFan(p.xz, 6.);
p.x += .3;
// add the cap
float d = sdSphere(p, .4);
d = opS(d, p.y - .12);
// add the body
d = opU(d, sdSphere(p, .39));
// add the fins (another word I learned, thanks google :P)
d = opU(d, opI(sdSphere(p + vec3(0, .24, 0), .41), sdRect(p.zx, vec2(.005, .5))));
d = opS(d, sdSphere(p + vec3(0, .3, 0), .37));
d = opS(d, p.y + .25);
return d;
}
// atmosphere distance
float sdAtmosphere(vec3 p) {
float time = iTime;
tRotate(p.yz, time);
vec3 q = p;
tFan(q.xz, 12.);
float d = sdBox(q - vec3(.3, 0, 0), vec3(.01));
tRotate(p.yx, time);
q = p;
tFan(q.yz, 12.);
d = opU(d, sdBox(q - vec3(0, .23, 0), vec3(.01)));
tRotate(p.xz, time);
q = p;
tFan(q.yx, 12.);
d = opU(d, sdBox(q - vec3(0, .16, 0), vec3(.01)));
return d;
}
// distance estimation of everything together
float map(vec3 p) {
float d = _house <= 0. ? 5. : sdHouse(p) + .1 - _house * .1;
if (_boat > 0.) d = opU(d, sdBoat(p) + .1 - _boat * .1);
if (_spaceship > 0.) d = opU(d, sdSpaceship(p) + .1 - _spaceship * .1);
if (_atmosphere > 0.) d = opU(d, sdAtmosphere(p) + .1 - _atmosphere * .1);
//return d;
float s = 1.;
for (int i = 0; i < 4; ++i) {
tFan(p.xz, 10.);
p = abs(p);
p -= _kifsOffset;
p *= _kifsRot;
s *= 2.;
}
return opSU(d, sdBox(p * s, vec3(s / 17.)) / s, .1);
}
// trace the scene from ro (origin) to rd (direction, normalized)
// until hit or reached maxDist, outputs distance traveled, the number of steps
// and the closest distance achieved during marching (used of cheap edge detection)
float trace(vec3 ro, vec3 rd, float maxDist, out float steps, out float nt) {
float total = 0.;
steps = 0.;
nt = 100.;
for (int i = 0; i < MAX_STEPS; ++i) {
++steps;
float d = map(ro + rd * total);
nt = min(d, nt);
total += d;
if (d < EPS || maxDist < total) break;
}
return total;
}
// calculate the normal vector
vec3 getNormal(vec3 p) {
vec2 e = vec2(.0001, 0);
return normalize(vec3(
map(p + e.xyy) - map(p - e.xyy),
map(p + e.yxy) - map(p - e.yxy),
map(p + e.yyx) - map(p - e.yyx)
));
}
// ambient occlusion
float calculateAO(vec3 p, vec3 n) {
float r = 0., w = 1., d;
for (float i = 1.; i <= AO_SAMPLES; i++){
d = i / AO_SAMPLES / AO_RANGE;
r += w * (d - map(p + n * d));
w *= .5;
}
return 1.-saturate(r * AO_RANGE);
}
// a lovely function that goes up and down periodically between 0 and 1, pausing at the extremes
float pausingWave(float x, float a, float b) {
x = abs(fract(x) - .5) * 1. - .5 + a;
return smoothstep(0., a - b, x);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
// transform screen coordinates
vec2 uv = fragCoord.xy / iResolution.xy;
uv = uv * 2. - 1.;
uv.x *= iResolution.x / iResolution.y;
// transform mouse coordinates
vec2 mouse = iMouse.xy / iResolution.xy * 2. - 1.;
mouse.x *= iResolution.x / iResolution.y;
mouse *= 2.;
// set time dependent constants
float speed = .25 / 10.5;
float time = mod(iTime, 290.);
time -= 10.5;
if (time > 167.) time -= 167.; else
if (time > 63.) time -= 63.;
time -= 5.25;
time *= speed;
// these determine which object to show
_house = pausingWave(time, .15, .125);
_boat = pausingWave(time - .125 / .1, .15, .125);
_spaceship = pausingWave(time - .25 / .1, .15, .125);
_atmosphere = pausingWave(time - .375 / .1, .15, .125) * step(10., iTime);
// set up kifs rotation matrix
float a = -texture(iChannel0, vec2(.5, .25)).x + sin(iTime) * .2 + .9;
float s = sin(a), c = cos(a);
_kifsRot *= mat3(c, -s, 0, s, c, 0, 0, 0, 1);
_kifsRot *= mat3(1, 0, 0, 0, c, -s, 0, s, c);
_kifsRot *= mat3(c, 0, s, 0, 1, 0, -s, 0, c);
// set up kifs offset
_kifsOffset = .07 + texture(iChannel0, vec2(.1, .25)).x * .06;
// set up camera position
vec3 rd = normalize(vec3(uv, FOV));
vec3 ro = vec3(0, 0, -2);
// light is relative to the camera
vec3 light = vec3(-1., .5, 0);
vec2 rot = vec2(0);
if (iMouse.z > 0. && iMouse.x > 0. && iMouse.y > 0.) {
// rotate the scene using the mouse
rot = -mouse;
} else {
// otherwise rotate constantly as time passes
rot = vec2(
iTime * SPEED * PI,//had to slightly modify \/ this value due to an issue reported by Fabrice
mix(sin(iTime * SPEED) * PI / 8., PI / 2. - 1e-5, saturate(exp(-iTime + 10.5))));
}
tRotate(rd.yz, rot.y);
tRotate(rd.xz, rot.x);
tRotate(light.xz, rot.x);
tRotate(ro.yz, rot.y);
tRotate(ro.xz, rot.x);
// march
float steps, outline, dist = trace(ro, rd, RENDER_DIST, steps, outline);
// calculate hit point coordinates
vec3 p = ro + rd * dist;
// calculate normal
vec3 normal = getNormal(p);
// light direction
vec3 l = normalize(light - p);
// ambient light
float ambient = .1;
// diffuse light
float diffuse = max(0., dot(l, normal));
// specular light
float specular = pow(max(0., dot(reflect(-l, normal), -rd)), 4.);
// "ambient occlusion"
float ao = calculateAO(p, normal);
// create the background grid
vec2 gridUv = fragCoord.xy - iResolution.xy / 2.;
float grid = dot(step(mod(gridUv.xyxy, vec4(20, 20, 100, 100)), vec4(1)), vec4(.1, .1, .2, .2));
// create blue background
vec3 bg = vec3(0, .1, .3) * saturate(1.5 - length(uv) * .5);
// find the edges in the geometry
float edgeWidth = .0015;
float edge = smoothstep(1., .0, dot(normal, getNormal(p - normal * edgeWidth))) * step(length(p), 1.);
// get the outline of the shapes
outline = smoothstep(.005, .0, outline) * step(1., length(p));
// diagonal strokes used for shading
vec2 strokes = sin(vec2(uv.x + uv.y, uv.x - uv.y) * iResolution.y * PI / 4.) * .5 - .5;
// first part of the shading: ao + marching steps
float highlights = (steps / float(MAX_STEPS) + sqrt(1. - ao)) * step(length(p), 1.) * .5;
highlights = floor(highlights * 5.) / 10.;
// second part of the shading: ambient + diffuse + specular light
float fog = saturate(length(ro) - dist * dist * .25);
float lightValue = (ambient + diffuse + specular) * fog;
lightValue = floor(lightValue * 5.) / 10.;
fragColor.rgb = mix(bg, vec3(1., .9, .7),
max(max(max(saturate(highlights + strokes.x), saturate(lightValue + strokes.y)) * fog,
(edge + outline) * 2. + strokes.y), grid));
// gamma correction
fragColor = pow(saturate(fragColor), vec4(1. / 2.2)) * step(abs(uv.y), 1.);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

View File

@@ -0,0 +1,52 @@
{
"author": "nimitz",
"name": "Homecomputer",
"version": "1.0.0",
"description": "An audio reactive shader",
"license": "CC-BY-NC-SA",
"engine": "shadertoy",
"id": "XdVGWt",
"tags": [
"reactive",
"galaxy",
"fractal"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"bufferA":
{
"source": "./shaders/Buffer A.frag.qsb",
"frame_buffer_channel": 0,
"channel1":
{
"type": 0,
"source":"./images/iChannel1.png"
},
"channel2": "{bufferC}"
},
"bufferB":
{
"source": "./shaders/Buffer B.frag.qsb",
"frame_buffer_channel": 1,
"channel0": "{bufferA}",
"channel2": "{bufferC}"
},
"bufferC":
{
"source": "./shaders/Buffer C.frag.qsb",
"frame_buffer_channel": 0,
"channel1":
{
"type": 4
}
},
"channel0":"{bufferB}"
}

View File

@@ -0,0 +1,83 @@
// Homecomputer by nimitz 2016 (twitter: @stormoid)
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// Contact the author for other licensing options
//Velocity handling
#define time iTime
vec3 hash3(vec3 p)
{
p = fract(p * vec3(443.8975,397.2973, 491.1871));
p += dot(p.zxy, p.yxz+19.1);
return fract(vec3(p.x * p.y, p.z*p.x, p.y*p.z))-0.5;
}
vec3 update(in vec3 vel, vec3 pos, in float id)
{
vec4 sndNFO = texture(iChannel2, vec2(0.75, 0.25));
float R = 1.5;
const float r = .5;
float t= time*2.+id*8.;
float d= 5.;
float x = ((R-r)*cos(t-time*0.1) + d*cos((R-r)/r*t));
float y = ((R-r)*sin(t) - d*sin((R-r)/r*t));
vel = mix(vel, vec3(x*1.2,y,sin(time*12.6+id*50. + sndNFO.z*10.)*7.)*5. +hash3(vel*10.+time*0.2)*7., 1.);
//vel.z += sin(time*sndNFO.z)*50.;
//vel.z += sin(time + sndNFO.z*70.)*10.;
//vel.z += sin(time)*30.*sndNFO.x;
return vel;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 q = fragCoord.xy / iResolution.xy;
vec2 p = q-0.5;
p.x *= iResolution.x/iResolution.y;
vec2 mo = iMouse.xy/iResolution.xy-0.5;
float dt = iTimeDelta;
vec4 col= vec4(0);
vec2 w = 1./iResolution.xy;
vec3 pos = texture(iChannel0, vec2(q.x,100.*w)).xyz;
vec3 velo = texture(iChannel0, vec2(q.x,0.0)).xyz;
velo = update(velo, pos, q.x);
if (fragCoord.y < 30.)
{
col.rgb = velo;
}
else
{
pos += velo*0.002;
col.rgb = pos;
}
if (iFrame < 5)
{
if (fragCoord.y < 30.)
col = ((texture(iChannel1, q*1.9))-.5)*vec4(0.,0.,0.,0.);
else
{
col = vec4(.0,-.7,0,0);
}
}
if (mod(float(iFrame), 300.) == 0. && fragCoord.y > 30.)
{
col = vec4(.0,-.2, -0.,0);
}
col.a = q.x;
fragColor = col;
}

View File

@@ -0,0 +1,73 @@
// Homecomputer by nimitz 2016 (twitter: @stormoid)
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// Contact the author for other licensing options
//Rendering
/*
This buffer renders each particles
multiple times per frame to allow particles
to move more than one pixel per frame while still
leaving a solid trail.
*/
#define time iTime
const int numParticles = 100;
const int stepsPerFrame = 9;
mat2 mm2(in float a){float c = cos(a), s = sin(a);return mat2(c,s,-s,c);}
float mag(vec3 p){return dot(p,p);}
vec4 drawParticles(in vec3 ro, in vec3 rd, in float ints)
{
vec4 rez = vec4(0);
vec2 w = 1./iResolution.xy;
for (int i = 0; i < numParticles; i++)
{
vec3 pos = texture(iChannel0, vec2(i,100.0)*w).rgb;
vec3 vel = texture(iChannel0, vec2(i,0.0)*w).rgb;
float st = sin(time*0.6);
for(int j = 0; j < stepsPerFrame; j++)
{
float d = mag((ro + rd*dot(pos.xyz - ro, rd)) - pos.xyz);
d *= 1000.;
d = 2./(pow(d,1.+ sin(time*0.6)*0.15)+1.5);
d *= (st+4.)*.8;
rez.rgb += d*(sin(vec3(.7,2.0,2.5)+float(i)*.015 + time*0.3 + vec3(5,1,6))*0.45+0.55)*0.005;
pos.xyz += vel*0.002*1.5;
}
}
return rez;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 q = fragCoord.xy/iResolution.xy;
vec2 p = fragCoord.xy/iResolution.xy-0.5;
p.x*=iResolution.x/iResolution.y;
vec3 ro = vec3(0.,0.,2.7);
vec3 rd = normalize(vec3(p,-.5));
vec3 sndNFO = texture(iChannel2, vec2(0.65, 0.1)).zwx + vec3(-.5, -0.1, -0.0);
vec4 cola = drawParticles(ro, rd, sndNFO.y)*10.;
//if (mod(time+q.x*.15+q.y*0.15,28.) < 14.)cola = vec4(.9,.95,1.,1.)-cola*.9; //Invert colors
vec2 mv = vec2(pow(sndNFO.z,2.)*0.05,sndNFO.x*.95);
mv *= mm2(time*1.);
vec4 colb = texture(iChannel1, q+mv);
//vec4 colb = texture(iChannel1, q);
vec4 col = mix(cola, colb, 0.91);
if (iFrame < 5) col = vec4(0);
fragColor = col;
}

View File

@@ -0,0 +1,51 @@
// Homecomputer by nimitz 2016 (twitter: @stormoid)
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// Contact the author for other licensing options
/*
The goal of this Buffer is to prepare
the sound data so that it can be used
by the other buffers
Data output:
x = fft
y = waveform
z = filtered waveform
w = filtered fft summed over many bands
*/
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 q = fragCoord.xy/iResolution.xy;
float fft = texture( iChannel1, vec2(q.x,0.25) ).x;
float nwave = texture( iChannel1, vec2(q.x,0.75) ).x;
float owave = texture( iChannel0, vec2(q.x,0.25) ).z;
float offt = texture( iChannel0, vec2(q.x,0.25) ).w;
float fwave = mix(nwave,owave, 0.85);
/*
get fft sum over many bands, this will allow
to ge tthe current "intensity" of a track
*/
float nfft = 0.;
for (float i = 0.; i < 1.; i += 0.05)
{
nfft += texture( iChannel1, vec2(i,0.25) ).x;
}
nfft = clamp(nfft/30.,0.,1.);
float ffts = mix(nfft, offt, 0.8);
if (iFrame < 5)
{
fft = 0.;
fwave= .5;
ffts = 0.;
}
fragColor = vec4(fft, nwave, fwave, ffts);
}

View File

@@ -0,0 +1,20 @@
// Homecomputer by nimitz 2016 (twitter: @stormoid)
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// Contact the author for other licensing options
//Code is in the other tabs:
//Buf A = Velocity and position handling
//Buf B = Rendering
//Buf C = Soundcloud filtering and propagation
#define time iTime
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 q = fragCoord.xy / iResolution.xy;
vec3 col = texture(iChannel0, q).rgb;
col *= sin(gl_FragCoord.y*350.+time)*0.04+1.;//Scanlines
col *= sin(gl_FragCoord.x*350.+time)*0.04+1.;
col *= pow( 16.0*q.x*q.y*(1.0-q.x)*(1.0-q.y), 0.1)*0.35+0.65; //Vign
fragColor = vec4(col,1.0);
}

View File

@@ -0,0 +1,17 @@
{
"author": "lsdlive",
"name": "Mist by Ohno! - part2",
"version": "1.0.0",
"description": "This is my part for 'Mist' by Ohno, a 4 kilobytes demo released at the Cookie 2018.",
"license": "CC-BY-NC-SA",
"engine": "shadertoy",
"id": "wdBGWD",
"tags": [
"reactive",
"pixel",
"neon"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1
}

View File

@@ -0,0 +1,274 @@
/*
@lsdlive
CC-BY-NC-SA
This is my part for "Mist" by Ohno, a 4 kilobytes demo released at the Cookie 2018.
pouet: http://www.pouet.net/prod.php?which=79350
youtube: https://www.youtube.com/watch?v=UUtU3WVB144
Code/Graphics: Flopine
Code/Graphics: Lsdlive
Music: Triace from Desire
Part1 from Flopine here: https://www.shadertoy.com/view/tdBGWD
Information about my process for making this demo here:
https://twitter.com/lsdlive/status/1090627411379716096
*/
float time = 0.;
float random(vec2 uv) {
return fract(sin(dot(uv, vec2(12.2544, 35.1571))) * 5418.548416);
}
mat2 r2d(float a) {
float c = cos(a), s = sin(a);
// Explained here why you still get an anti-clockwise rotation with this matrix:
// https://www.shadertoy.com/view/wdB3DW
return mat2(c, s, -s, c);
}
vec3 re(vec3 p, float d) {
return mod(p - d * .5, d) - d * .5;
}
void amod2(inout vec2 p, float d) {
// should be atan(p.y, p.x) but I had this function for a while
// and putting parameters like this add a PI/6 rotation.
float a = re(vec3(atan(p.x, p.y)), d).x;
p = vec2(cos(a), sin(a)) * length(p);
}
void mo(inout vec2 p, vec2 d) {
p = abs(p) - d;
if (p.y > p.x)p = p.yx;
}
vec3 get_cam(vec3 ro, vec3 ta, vec2 uv) {
vec3 fwd = normalize(ta - ro);
vec3 right = normalize(cross(fwd, vec3(0, 1, 0)));
//vec3 right = normalize(vec3(-fwd.z, 0, fwd.x));
return normalize(fwd + right * uv.x + cross(right, fwd) * uv.y);
}
// signed cube
// https://iquilezles.org/articles/distfunctions
float cube(vec3 p, vec3 b) {
b = abs(p) - b;
return min(max(b.x, max(b.y, b.z)), 0.) + length(max(b, 0.));
}
// iq's signed cross sc() - https://iquilezles.org/articles/menger
float sc(vec3 p, float d) {
p = abs(p);
p = max(p, p.yzx);
return min(p.x, min(p.y, p.z)) - d;
}
////////////////////////// SHADER LSDLIVE //////////////////////////
float prim(vec3 p) {
p.xy *= r2d(3.14 * .5 + p.z * .1); // .1
amod2(p.xy, 6.28 / 3.); // 3.
p.x = abs(p.x) - 9.; // 9.
p.xy *= r2d(p.z * .2); // .2
amod2(p.xy, 6.28 /
mix(
mix(10., 5., smoothstep(59.5, 61.5, time)), // T4
3.,
smoothstep(77.5, 77.75, time)) // T8
); // 3.
mo(p.xy, vec2(2.)); // 2.
p.x = abs(p.x) - .6; // .6
return length(p.xy) - .2;//- smoothstep(80., 87., time)*(.5+.5*sin(time)); // .2
}
float g = 0.; // glow
float de(vec3 p) {
if (time > 109.2) {
mo(p.xy, vec2(.2));
p.x -= 10.;
}
if (time > 101.4) {
p.xy *= r2d(time*.2);
}
if (time > 106.5) {
mo(p.xy, vec2(5. + sin(time)*3.*cos(time*.5), 0.));
}
if (time > 104.) {
amod2(p.xy, 6.28 / 3.);
p.x += 5.;
}
if (time > 101.4) {
mo(p.xy, vec2(2. + sin(time)*3.*cos(time*.5), 0.));
}
p.xy *= r2d(time * .05); // .05
p.xy *= r2d(p.z *
mix(.05, .002, step(89.5, time)) // P2 - T11
); // .05 & .002
p.x += sin(time) * smoothstep(77., 82., time);
amod2(p.xy, 6.28 /
mix(
mix(1., 2., smoothstep(63.5, 68.5, time)), // T6
5.,
smoothstep(72., 73.5, time)) // T7
); // 5.
p.x -= 21.; // 21.
vec3 q = p;
p.xy *= r2d(p.z * .1); // .1
amod2(p.xy, 6.28 / 3.); // 3.
p.x = abs(p.x) -
mix(20., 5., smoothstep(49.5, 55., time)) // T2
; // 5.
p.xy *= r2d(p.z *
mix(1., .2, smoothstep(77.5, 77.75, time)) // T8b
); // .2
p.z = re(p.zzz, 3.).x; // 3.
p.x = abs(p.x);
amod2(p.xy, 6.28 /
mix(6., 3., smoothstep(77.75, 78.5, time)) // T10
); // 3.
float sc1 = sc(p,
mix(8., 1., smoothstep(45.5, 51., time)) // T1
); // 1.
amod2(p.xz, 6.28 /
mix(3., 8., smoothstep(61.5, 65.5, time)) // T5
); // 8.
mo(p.xz, vec2(.1)); // .1
p.x = abs(p.x) - 1.;// 1.
float d = cube(p, vec3(.2, 10, 1)); // fractal primitive: cube substracted by a signed cross
d = max(d, -sc1) -
mix(.01, 2., smoothstep(56., 58.5, time)) // T3
; // 2.
g += .006 / (.01 + d * d); // first layer of glow
d = min(d, prim(q)); // add twisted cylinders
g += .004 / (.013 + d * d); // second layer of glow (after the union of two geometries)
return d;
}
////////////////////////// RAYMARCHING FUNCTIONS //////////////////////////
vec3 raymarch_lsdlive(vec3 ro, vec3 rd, vec2 uv) {
vec3 p;
float t = 0., ri;
float dither = random(uv);
for (float i = 0.; i < 1.; i += .02) {// 50 iterations to keep it "fast"
ri = i;
p = ro + rd * t;
float d = de(p);
d *= 1. + dither * .05; // avoid banding & add a nice "artistic" little noise to the rendering (leon gave us this trick)
d = max(abs(d), .002); // phantom mode trick from aiekick https://www.shadertoy.com/view/MtScWW
t += d * .5;
}
// Shading: uv, iteration & glow:
vec3 c = mix(vec3(.9, .8, .6), vec3(.1, .1, .2), length(uv) + ri);
c.r += sin(p.z * .1) * .2;
c += g * .035; // glow trick from balkhan https://www.shadertoy.com/view/4t2yW1
return c;
}
// borrowed from (mmerchante) : https://www.shadertoy.com/view/MltcWs
void glitch(inout vec2 uv, float start_time_stamp, float end_time_stamp)
{
int offset = int(floor(time)*2.) + int((uv.x + uv.y) * 8.0);
float res = mix(10., 100.0, random(vec2(offset)));
// glitch pixellate
if (time > start_time_stamp && time <= end_time_stamp) uv = floor(uv * res) / res;
int seedX = int(gl_FragCoord.x + time) / 32;
int seedY = int(gl_FragCoord.y + time) / 32;
int seed = mod(time, 2.) > 1. ? seedX : seedY;
// glitch splitter
uv.x += (random(vec2(seed)) * 2.0 - 1.0)
* step(random(vec2(seed)), pow(sin(time * 4.), 7.0))
* random(vec2(seed))
* step(start_time_stamp, time)
* (1. - step(end_time_stamp, time));
}
////////////////////////// MAIN FUNCTION //////////////////////////
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 q = fragCoord.xy / iResolution.xy;
vec2 uv = (q - .5) * iResolution.xx / iResolution.yx;
/* just code for the shadertoy port */
time = mod(iTime, 43. + 10.4);
time = time + 45.;
if (time > 88. && time <= 98.6) // 98.
time += 10.6;
// added glitch
glitch(uv, 0., 2.);
glitch(uv, 98., 99.);
// lsdlive 2nd part
glitch(uv, 100.5, 101.5);
glitch(uv, 103., 104.);
glitch(uv, 105.5, 106.5);
vec3 lsd_ro = vec3(0, 0, -4. + time * 8.);
vec3 lsd_target = vec3(0., 0., time * 8.);
vec3 lsd_cam = get_cam(lsd_ro, lsd_target, uv);
vec3 col = vec3(0.);
if (time > 45. && time <= 88.) // 43 seconds
col = raymarch_lsdlive(lsd_ro, lsd_cam, uv);
if (time > 98.6 && time <= 109.) // 10.4 seconds
col = raymarch_lsdlive(lsd_ro, lsd_cam, uv);
// vignetting (iq)
col *= 0.5 + 0.5*pow(16.0*q.x*q.y*(1.0 - q.x)*(1.0 - q.y), 0.25);
// fading out - end of the demo
//col *= 1. - smoothstep(120., 125., time);
fragColor = vec4(col, 1.);
}

View File

@@ -0,0 +1,30 @@
{
"author": "cpdt",
"name": "Neon Rings",
"version": "1.0.0",
"description": "An audio-reactive set of smokey neon rings",
"license": "CC-BY-NC-SA",
"engine": "shadertoy",
"id": "XllcR4",
"tags": [
"reactive",
"rings",
"neon"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"bufferA":
{
"source": "./shaders/Buffer A.frag.qsb",
"frame_buffer_channel": 1,
"channel0":
{
"type": 4
}
},
"channel0": "{bufferA}"
}

View File

@@ -0,0 +1,87 @@
/* @kishimisu - 2023
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en)
An audio-reactive scene that maps the frequencies of the input music
and the audio volume to different cells, colors, size and intensity!
I've been struggling to complete this scene as I wanted to repeat
the space with random variations for each cell. There's a wonderful
tutorial by Blackle Mori explaining how to achieve this (https://www.youtube.com/watch?v=I8fmkLK1OKg) ,
however I'm using an accumulation technique for the lighting with a
fixed number of steps (30) which gets broken with this new technique.
I decided to keep a reasonable random variation amount to prevent having
raymarching artifacts that are too visible. I couldn't get totally rid of them,
however with this kind of audio reactive scene it seems to be more acceptable
as there's a lot of rapid movements!
*/
#define light(d, att) 1. / (1.+pow(abs(d*att), 1.3))
#define rot(a) mat2(cos(a + vec4(0,33,11,0)))
/* Audio-related functions */
#define getLevel(x) (texelFetch(iChannel0, ivec2(int(x*512.), 0), 0).r)
#define logX(x,a,c) (1./(exp(-a*(x-c))+1.))
float logisticAmp(float amp){
float c = .88, a = 20.;
return (logX(amp, a, c) - logX(0.0, a, c)) / (logX(1.0, a, c) - logX(0.0, a, c));
}
float getPitch(float freq, float octave){
freq = pow(2., freq) * 261.;
freq = pow(2., octave) * freq / 12000.;
return logisticAmp(getLevel(freq));
}
float getVol(float samples) {
float avg = 0.;
for (float i = 0.; i < samples; i++) avg += getLevel(i/samples);
return avg / samples;
}
/* ----------------------- */
float sdBox( vec3 p, vec3 b ) {
vec3 q = abs(p) - b;
return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
}
float hash13(vec3 p3) {
p3 = fract(p3 * .1031);
p3 += dot(p3, p3.zyx + 31.32);
return fract((p3.x + p3.y) * p3.z);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 uv = (2.*fragCoord-iResolution.xy)/iResolution.y;
vec3 col = vec3(.1,.0,.14);
float vol = getVol(8.);
vec3 ro = vec3(0, 8, 12)*(1. + vol*.3);
ro.zx *= rot(iTime*.4);
vec3 f = normalize(-ro), r = normalize(cross(vec3(0,1,0), f));
vec3 rd = normalize(f + uv.x*r + uv.y*cross(f, r));
float hasSound = 1.; if (iChannelTime[0] <= 0.) hasSound = .4;
for (float i = 0., t = 0.; i < 30.; i++) {
vec3 p = ro + t*rd;
vec2 cen = floor(p.xz) + .5;
vec3 id = abs(vec3(cen.x, 0, cen.y));
float d = length(id);
float freq = smoothstep(0., 20., d)*3.*hasSound + hash13(id)*2.;
float pitch = getPitch(freq, .7);
float v = vol*smoothstep(2., 0., d);
float h = d*.2*(1.+pitch*1.5) + v*2.;
float me = sdBox(p - vec3(cen.x, -50., cen.y), vec3(.3, 50. + h, .3)+pitch) - .05;
col += mix(mix(vec3(.8,.2,.4), vec3(0,1,0), min(v*2.,1.)), vec3(.5,.3,1.2), smoothstep(10., 30., d))
*(cos(id)+1.5)
* (pitch * d*.08 + v)
* light(me, 20.) * (1. + vol*2.);
t += me;
}
fragColor = vec4(col,1.0);
}

View File

@@ -0,0 +1,22 @@
{
"author": "mrange",
"name": "Neonwave Sunset",
"version": "1.0.0",
"description": "Code is hackish but I thought it looked good enough to share",
"license": "CC-BY-NC-SA",
"engine": "shadertoy",
"id": "7dtcRj",
"tags": [
"reactive",
"retro",
"neon"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"channel0":
{
"type": 4
}
}

View File

@@ -0,0 +1,390 @@
// License CC0: Neon Sunset
// Code is hackish but I thought it looked good enough to share
// The music from GTA III - RISE FM, the best radio channel in GTA III IMHO
#define LAYERS 5.0
#define PI 3.141592654
#define TAU (2.0*PI)
#define TIME iTime
#define TTIME (TAU*TIME)
#define RESOLUTION iResolution
#define ROT(a) mat2(cos(a), sin(a), -sin(a), cos(a))
// License: Unknown, author: nmz (twitter: @stormoid), found: https://www.shadertoy.com/view/NdfyRM
float sRGB(float t) { return mix(1.055*pow(t, 1./2.4) - 0.055, 12.92*t, step(t, 0.0031308)); }
// License: Unknown, author: nmz (twitter: @stormoid), found: https://www.shadertoy.com/view/NdfyRM
vec3 sRGB(in vec3 c) { return vec3 (sRGB(c.x), sRGB(c.y), sRGB(c.z)); }
// License: Unknown, author: Matt Taylor (https://github.com/64), found: https://64.github.io/tonemapping/
vec3 aces_approx(vec3 v) {
v = max(v, 0.0);
v *= 0.6f;
float a = 2.51f;
float b = 0.03f;
float c = 2.43f;
float d = 0.59f;
float e = 0.14f;
return clamp((v*(a*v+b))/(v*(c*v+d)+e), 0.0f, 1.0f);
}
// License: Unknown, author: Unknown, found: don't remember
float hash(float co) {
return fract(sin(co*12.9898) * 13758.5453);
}
// License: Unknown, author: Unknown, found: don't remember
vec2 hash2(vec2 p) {
p = vec2(dot (p, vec2 (127.1, 311.7)), dot (p, vec2 (269.5, 183.3)));
return fract(sin(p)*43758.5453123);
}
// License: CC BY-NC-SA 3.0, author: Stephane Cuillerdier - Aiekick/2015 (twitter:@aiekick), found: https://www.shadertoy.com/view/Mt3GW2
vec3 blackbody(float Temp) {
vec3 col = vec3(255.);
col.x = 56100000. * pow(Temp,(-3. / 2.)) + 148.;
col.y = 100.04 * log(Temp) - 623.6;
if (Temp > 6500.) col.y = 35200000. * pow(Temp,(-3. / 2.)) + 184.;
col.z = 194.18 * log(Temp) - 1448.6;
col = clamp(col, 0., 255.)/255.;
if (Temp < 1000.) col *= Temp/1000.;
return col;
}
// License: WTFPL, author: sam hocevar, found: https://stackoverflow.com/a/17897228/418488
const vec4 hsv2rgb_K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 hsv2rgb(vec3 c) {
vec3 p = abs(fract(c.xxx + hsv2rgb_K.xyz) * 6.0 - hsv2rgb_K.www);
return c.z * mix(hsv2rgb_K.xxx, clamp(p - hsv2rgb_K.xxx, 0.0, 1.0), c.y);
}
#define HSV2RGB(c) (c.z * mix(hsv2rgb_K.xxx, clamp(abs(fract(c.xxx + hsv2rgb_K.xyz) * 6.0 - hsv2rgb_K.www) - hsv2rgb_K.xxx, 0.0, 1.0), c.y))
// License: Unknown, author: Unknown, found: don't remember
float tanh_approx(float x) {
// return tanh(x);
float x2 = x*x;
return clamp(x*(27.0 + x2)/(27.0+9.0*x2), -1.0, 1.0);
}
float circle(vec2 p, float r) {
return length(p) - r;
}
// License: MIT, author: Inigo Quilez, found: https://iquilezles.org/articles/smin
float pmin(float a, float b, float k) {
float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 );
return mix( b, a, h ) - k*h*(1.0-h);
}
// License: MIT OR CC-BY-NC-4.0, author: mercury, found: https://mercury.sexy/hg_sdf/
float mod1(inout float p, float size) {
float halfsize = size*0.5;
float c = floor((p + halfsize)/size);
p = mod(p + halfsize, size) - halfsize;
return c;
}
// License: MIT OR CC-BY-NC-4.0, author: mercury, found: https://mercury.sexy/hg_sdf/
vec2 mod2(inout vec2 p, vec2 size) {
vec2 c = floor((p + size*0.5)/size);
p = mod(p + size*0.5,size) - size*0.5;
return c;
}
// License: MIT, author: Inigo Quilez, found: https://iquilezles.org/articles/intersectors
float rayPlane(vec3 ro, vec3 rd, vec4 p) {
return -(dot(ro,p.xyz)+p.w)/dot(rd,p.xyz);
}
vec3 toSpherical(vec3 p) {
float r = length(p);
float t = acos(p.z/r);
float ph = atan(p.y, p.x);
return vec3(r, t, ph);
}
float sun(vec2 p) {
const float ch = 0.0125;
vec2 sp = p;
float d0 = circle(sp, 0.5);
float d = d0;
return d;
}
float segmentx(vec2 p) {
float d0 = abs(p.y);
float d1 = length(p);
return p.x > 0.0 ? d0 : d1;
}
float segmentx(vec2 p, float l) {
float hl = 0.5*l;
p.x = abs(p.x);
float d0 = abs(p.y);
float d1 = length(p-vec2(hl, 0.0));
return p.x > hl ? d1 : d0;
}
float synth(vec2 p, float aa, out float h, out float db) {
const float z = 75.0;
p.y -= -70.0;
const float st = 0.04;
p.x = abs(p.x);
p.x -= 20.0-3.5;
p.x += st*20.0;
p /= z;
float n = mod1(p.x, st);
float dib = 1E6;
const int around = 0;
for (int i = -around; i <=around ;++i) {
float fft = texture(iChannel0, vec2((n+float(i))*st, 0.25)).x;
fft *= fft;
if (i == 0) h = fft;
float dibb = segmentx((p-vec2(st*float(i), 0.0)).yx, fft+0.05)-st*0.4;
dib = min(dib, dibb);
}
float d = dib;
db = abs(p.y)*z;
return smoothstep(aa, -aa, d*z);
}
vec3 road(vec3 ro, vec3 rd, vec3 nrd, float glare, vec4 pl, out float pt) {
const float szoom = 0.5;
const float bsz = 25.0;
const float sm = 1.0;
float off = abs(pl.w);
float t = rayPlane(ro, rd, pl);
pt = t;
vec3 p = ro+rd*t;
vec3 np = ro+nrd*t;
vec2 pp = p.xz;
vec2 npp = np.xz;
vec2 opp = pp;
float aa = length(npp-pp)*sqrt(0.5);
pp.y += -60.0*TIME;
vec3 gcol = vec3(0.0);
float dr = abs(pp.x)-off;
vec2 cp = pp;
mod1(cp.y, 6.0*off);
vec2 sp = pp;
sp.x = abs(sp.x);
mod1(sp.y, off);
float dcl = segmentx(cp.yx, 1.5*off);
float dsl = segmentx((sp-vec2(0.95*off, 0.0)).yx, off*0.5);
vec2 mp = pp;
mod2(mp, vec2(off*0.5));
vec2 dp = abs(mp);
float d = dp.x;
d = pmin(d, dp.y, sm);
d = max(d, -dr);
d = min(d, dcl);
d = min(d, dsl);
vec2 s2 = sin(TIME+2.0*p.xz/off);
float m = mix(0.75, 0.9, tanh_approx(s2.x+s2.y));
m *= m;
m *= m;
m *= m;
vec3 hsv = vec3(0.4+mix(0.5, 0.0, m), tanh_approx(0.15*mix(30.0, 10.0, m)*d), 1.0);
float fo = exp(-0.04*max(abs(t)-off*2., 0.0));
vec3 bcol = hsv2rgb(hsv);
gcol += 2.0*bcol*exp(-0.1*mix(30.0, 10.0, m)*d)*fo;
float sh;
float sdb;
float sd =synth(opp, aa,sh, sdb)*smoothstep(aa, -aa, -dr);
sh = tanh_approx(sh);
sdb *= 0.075;
sdb *= sdb;
sdb += 0.05;
vec3 scol = sd*(sdb)*pow(tanh(vec3(0.1)+bcol), mix(vec3(1.0), vec3(1.5, 0.5, 0.5), smoothstep(0.4, 0.5, sh)));
gcol += scol;
gcol = t > 0.0 ? gcol : vec3(0.0);
return gcol+scol;
}
vec3 stars(vec2 sp, float hh) {
vec3 col = vec3(0.0);
const float m = LAYERS;
hh = tanh_approx(20.0*hh);
for (float i = 0.0; i < m; ++i) {
vec2 pp = sp+0.5*i;
float s = i/(m-1.0);
vec2 dim = vec2(mix(0.05, 0.003, s)*PI);
vec2 np = mod2(pp, dim);
vec2 h = hash2(np+127.0+i);
vec2 o = -1.0+2.0*h;
float y = sin(sp.x);
pp += o*dim*0.5;
pp.y *= y;
float l = length(pp);
float h1 = fract(h.x*1667.0);
float h2 = fract(h.x*1887.0);
float h3 = fract(h.x*2997.0);
vec3 scol = mix(8.0*h2, 0.25*h2*h2, s)*blackbody(mix(3000.0, 22000.0, h1*h1));
vec3 ccol = col + exp(-(mix(6000.0, 2000.0, hh)/mix(2.0, 0.25, s))*max(l-0.001, 0.0))*scol;
ccol *= mix(0.125, 1.0, smoothstep(1.0, 0.99, sin(0.25*TIME+TAU*h.y)));
col = h3 < y ? ccol : col;
}
return col;
}
vec3 meteorite(vec2 sp) {
const float period = 3.0;
float mtime = mod(TIME, period);
float ntime = floor(TIME/period);
float h0 = hash(ntime+123.4);
float h1 = fract(1667.0*h0);
float h2 = fract(9967.0*h0);
vec2 mp = sp;
mp.x += -1.0;
mp.y += -0.5*h1;
mp.y += PI*0.5;
mp *= ROT(PI+mix(-PI/4.0, PI/4.0, h0));
float m = mtime/period;
mp.x += mix(-1.0, 2.0, m);
float d0 = length(mp);
float d1 = segmentx(mp);
vec3 col = vec3(0.0);
col += 0.5*exp(-4.0*max(d0, 0.0))*exp(-1000.0*max(d1, 0.0));
col *= 2.0*HSV2RGB(vec3(0.8, 0.5, 1.0));
float fl = smoothstep(-0.5, 0.5, sin(12.0*TTIME));
col += mix(1.0, 0.5, fl)*exp(-mix(100.0, 150.0, fl)*max(d0, 0.0));
col = h2 > 0.8 ? col: vec3(0.0);
return col;
}
vec3 skyGrid(vec2 sp) {
const float m = 1.0;
const vec2 dim = vec2(1.0/12.0*PI);
float y = sin(sp.x);
vec2 pp = sp;
vec2 np = mod2(pp, dim*vec2(1.0/floor(1.0/y), 1.0));
vec3 col = vec3(0.0);
float d = min(abs(pp.x), abs(pp.y*y));
float aa = 2.0/RESOLUTION.y;
col += 0.25*vec3(0.5, 0.5, 1.0)*exp(-2000.0*max(d-0.00025, 0.0));
return col;
}
vec3 sunset(vec2 sp, vec2 nsp) {
const float szoom = 0.5;
float aa = length(nsp-sp)*sqrt(0.5);
sp -= vec2(vec2(0.5, -0.5)*PI);
sp /= szoom;
sp = sp.yx;
sp.y += 0.22;
sp.y = -sp.y;
float ds = sun(sp)*szoom;
vec3 bscol = hsv2rgb(vec3(fract(0.7-0.25*(sp.y)), 1.0, 1.0));
vec3 gscol = 0.75*sqrt(bscol)*exp(-50.0*max(ds, 0.0));
vec3 scol = mix(gscol, bscol, smoothstep(aa, -aa, ds));
return scol;
}
vec3 glow(vec3 ro, vec3 rd, vec2 sp, vec3 lp) {
float ld = max(dot(normalize(lp-ro), rd),0.0);
float y = -0.5+sp.x/PI;
y = max(abs(y)-0.02, 0.0)+0.1*smoothstep(0.5, PI, abs(sp.y));
float ci = pow(ld, 10.0)*2.0*exp(-25.0*y);
float h = 0.65;
vec3 col = hsv2rgb(vec3(h, 0.75, 0.35*exp(-15.0*y)))+HSV2RGB(vec3(0.8, 0.75, 0.5))*ci;
return col;
}
vec3 neonSky(vec3 ro, vec3 rd, vec3 nrd, out float gl) {
const vec3 lp = 500.0*vec3(0.0, 0.25, -1.0);
const vec3 skyCol = HSV2RGB(vec3(0.8, 0.75, 0.05));
float glare = pow(abs(dot(rd, normalize(lp))), 20.0);
vec2 sp = toSpherical(rd.xzy).yz;
vec2 nsp = toSpherical(nrd.xzy).yz;
vec3 grd = rd;
grd.xy *= ROT(0.025*TIME);
vec2 spp = toSpherical(grd).yz;
float gm = 1.0/abs(rd.y)*mix(0.005, 2.0, glare);
vec3 col = skyCol*gm;
float ig = 1.0-glare;
col += glow(ro, rd, sp, lp);
if (rd.y > 0.0) {
col += sunset(sp, nsp);
col += stars(sp, 0.0)*ig;
col += skyGrid(spp)*ig;
col += meteorite(sp)*ig;
}
gl = glare;
return col;
}
vec3 color(vec3 ro, vec3 rd, vec3 nrd) {
const float off1 = -20.0;
const vec4 pl1 = vec4(normalize(vec3(0.0, 1.0, 0.15)), -off1);
float glare;
vec3 col = neonSky(ro, rd, nrd, glare);
if (rd.y < 0.0) {
float t;
col += road(ro, rd, nrd, glare, pl1, t);
}
return col;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 q = fragCoord/RESOLUTION.xy;
vec2 p = -1.0 + 2.0*q;
p.x *= RESOLUTION.x/RESOLUTION.y;
float aa = 2.0/RESOLUTION.y;
vec3 ro = vec3(0.0, 0.0, 10.0);
vec3 la = vec3(0.0, 2.0, 0.0);
vec3 up = vec3(0.0, 1.0, 0.0);
vec3 ww = normalize(la - ro);
vec3 uu = normalize(cross(up, ww ));
vec3 vv = normalize(cross(ww,uu));
const float fov = tan(TAU/6.0);
vec2 np = p + vec2(aa);
vec3 rd = normalize(-p.x*uu + p.y*vv + fov*ww);
vec3 nrd = normalize(-np.x*uu + np.y*vv + fov*ww);
vec3 col = vec3(0.1);
col = color(ro, rd, nrd);
// col += synth(p, np);
col *= smoothstep(0.0, 4.0, TIME);
col = aces_approx(col);
col = sRGB(col);
fragColor = vec4(col, 1.0);
}

View File

@@ -0,0 +1,22 @@
{
"author": "kishimisu",
"name": "Pixel Room 2",
"version": "1.0.0",
"description": "An audio-reactive scene that maps the frequencies of the input music and the audio volume to different cells, colors, size and intensity!",
"license": "CC-BY-NC-SA",
"engine": "shadertoy",
"id": "Dtj3zW",
"tags": [
"reactive",
"pixel",
"neon"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"channel0":
{
"type": 4
}
}

View File

@@ -0,0 +1,87 @@
/* @kishimisu - 2023
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en)
An audio-reactive scene that maps the frequencies of the input music
and the audio volume to different cells, colors, size and intensity!
I've been struggling to complete this scene as I wanted to repeat
the space with random variations for each cell. There's a wonderful
tutorial by Blackle Mori explaining how to achieve this (https://www.youtube.com/watch?v=I8fmkLK1OKg) ,
however I'm using an accumulation technique for the lighting with a
fixed number of steps (30) which gets broken with this new technique.
I decided to keep a reasonable random variation amount to prevent having
raymarching artifacts that are too visible. I couldn't get totally rid of them,
however with this kind of audio reactive scene it seems to be more acceptable
as there's a lot of rapid movements!
*/
#define light(d, att) 1. / (1.+pow(abs(d*att), 1.3))
#define rot(a) mat2(cos(a + vec4(0,33,11,0)))
/* Audio-related functions */
#define getLevel(x) (texelFetch(iChannel0, ivec2(int(x*512.), 0), 0).r)
#define logX(x,a,c) (1./(exp(-a*(x-c))+1.))
float logisticAmp(float amp){
float c = .88, a = 20.;
return (logX(amp, a, c) - logX(0.0, a, c)) / (logX(1.0, a, c) - logX(0.0, a, c));
}
float getPitch(float freq, float octave){
freq = pow(2., freq) * 261.;
freq = pow(2., octave) * freq / 12000.;
return logisticAmp(getLevel(freq));
}
float getVol(float samples) {
float avg = 0.;
for (float i = 0.; i < samples; i++) avg += getLevel(i/samples);
return avg / samples;
}
/* ----------------------- */
float sdBox( vec3 p, vec3 b ) {
vec3 q = abs(p) - b;
return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
}
float hash13(vec3 p3) {
p3 = fract(p3 * .1031);
p3 += dot(p3, p3.zyx + 31.32);
return fract((p3.x + p3.y) * p3.z);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 uv = (2.*fragCoord-iResolution.xy)/iResolution.y;
vec3 col = vec3(.1,.0,.14);
float vol = getVol(8.);
vec3 ro = vec3(0, 8, 12)*(1. + vol*.3);
ro.zx *= rot(iTime*.4);
vec3 f = normalize(-ro), r = normalize(cross(vec3(0,1,0), f));
vec3 rd = normalize(f + uv.x*r + uv.y*cross(f, r));
float hasSound = 1.; if (iChannelTime[0] <= 0.) hasSound = .4;
for (float i = 0., t = 0.; i < 30.; i++) {
vec3 p = ro + t*rd;
vec2 cen = floor(p.xz) + .5;
vec3 id = abs(vec3(cen.x, 0, cen.y));
float d = length(id);
float freq = smoothstep(0., 20., d)*3.*hasSound + hash13(id)*2.;
float pitch = getPitch(freq, .7);
float v = vol*smoothstep(2., 0., d);
float h = d*.2*(1.+pitch*1.5) + v*2.;
float me = sdBox(p - vec3(cen.x, -50., cen.y), vec3(.3, 50. + h, .3)+pitch) - .05;
col += mix(mix(vec3(.8,.2,.4), vec3(0,1,0), min(v*2.,1.)), vec3(.5,.3,1.2), smoothstep(10., 30., d))
*(cos(id)+1.5)
* (pitch * d*.08 + v)
* light(me, 20.) * (1. + vol*2.);
t += me;
}
fragColor = vec4(col,1.0);
}

View File

@@ -0,0 +1,22 @@
{
"author": "kishimisu",
"name": "Pixel Room",
"version": "1.0.0",
"description": "An audio reactive shader",
"license": "CC-BY-NC-SA",
"engine": "shadertoy",
"id": "dtl3Dr",
"tags": [
"reactive",
"pixel",
"neon"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"channel0":
{
"type": 4
}
}

View File

@@ -0,0 +1,78 @@
/* "3D Audio Visualizer" by @kishimisu - 2022 (https://www.shadertoy.com/view/dtl3Dr)
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en)
Wait for the drop!
The lights of this scene react live to the audio input.
I'm trying to find interesting ways to extract audio
features from the audio's FFT to animate my scenes.
Each light is associated to a random frequency range,
ranging from bass (distant lights) to high (close lights)
Really happy with this result!
*/
#define st(t1, t2, v1, v2) mix(v1, v2, smoothstep(t1, t2, iTime))
#define light(d, att) 1. / (1.+pow(abs(d*att), 1.3))
/* Audio-related functions */
#define getLevel(x) (texelFetch(iChannel0, ivec2(int(x*512.), 0), 0).r)
#define logX(x,a,c) (1./(exp(-a*(x-c))+1.))
float logisticAmp(float amp){
float c = st(0., 10., .8, 1.), a = 20.;
return (logX(amp, a, c) - logX(0.0, a, c)) / (logX(1.0, a, c) - logX(0.0, a, c));
}
float getPitch(float freq, float octave){
freq = pow(2., freq) * 261.;
freq = pow(2., octave) * freq / 12000.;
return logisticAmp(getLevel(freq));
}
float getVol(float samples) {
float avg = 0.;
for (float i = 0.; i < samples; i++) avg += getLevel(i/samples);
return avg / samples;
}
/* ----------------------- */
float sdBox( vec3 p, vec3 b ) {
vec3 q = abs(p) - b;
return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
}
float hash13(vec3 p3) {
p3 = fract(p3 * .1031);
p3 += dot(p3, p3.zyx + 31.32);
return fract((p3.x + p3.y) * p3.z);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 uv = (2.*fragCoord-iResolution.xy)/iResolution.y;
vec3 col = vec3(0.);
float vol = getVol(8.);
float hasSound = 1.; // Used only to avoid a black preview image
if (iChannelTime[0] <= 0.) hasSound = .0;
for (float i = 0., t = 0.; i < 30.; i++) {
vec3 p = t*normalize(vec3(uv, 1.));
vec3 id = floor(abs(p));
vec3 q = fract(p)-.5;
float boxRep = sdBox(q, vec3(.3));
float boxCtn = sdBox(p, vec3(7.5, 6.5, 16.5));
float dst = max(boxRep, abs(boxCtn) - vol*.2);
float freq = smoothstep(16., 0., id.z)*3.*hasSound + hash13(id)*1.5;
col += vec3(.8,.6,1) * (cos(id*.4 + vec3(0,1,2) + iTime) + 2.)
* light(dst, 10. - vol)
* getPitch(freq, 1.);
t += dst;
}
fragColor = vec4(col,1.0);
}

View File

@@ -1,21 +0,0 @@
{
"author": "Lallis",
"name": "PolarVisualizer",
"version": "1.0.0",
"description": "Yet another audio visualizer. Tried to fake some depth with the light and reflection. Try reversing the band order.",
"license": "CC BY-NC-SA 3.0",
"engine": "shadertoy",
"id": "4lySzy",
"tags": [
"reactive",
"2d"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1.0,
"channel0":
{
"type": 4
}
}

View File

@@ -1,133 +0,0 @@
#define time iTime
#define PI 3.14159265359
#define NUM_BANDS 32
//#define REVERSED
float noise3D(vec3 p)
{
return fract(sin(dot(p ,vec3(12.9898,78.233,12.7378))) * 43758.5453)*2.0-1.0;
}
vec3 mixc(vec3 col1, vec3 col2, float v)
{
v = clamp(v,0.0,1.0);
return col1+v*(col2-col1);
}
vec3 drawBands(vec2 uv)
{
uv = 2.0*uv-1.0;
uv.x*=iResolution.x/iResolution.y;
uv = vec2(length(uv), atan(uv.y,uv.x));
//uv.x-=0.25;
//uv.x = max(0.0,uv.x);
uv.y -= PI*0.5;
vec2 uv2 = vec2(uv.x, uv.y*-1.0);
uv.y = mod(uv.y,PI*2.0);
uv2.y = mod(uv2.y,PI*2.0);
vec3 col = vec3(0.0);
vec3 col2 = vec3(0.0);
float nBands = float(NUM_BANDS);
float i = floor(uv.x*nBands);
float f = fract(uv.x*nBands);
float band = i/nBands;
float s;
#ifdef REVERSED
band = 1.0-band;
#endif
//cubic easing
band *= band*band;
band = band*0.99;
band += 0.01;
s = texture( iChannel0, vec2(band,0.25) ).x;
if(band<0.0||band>=1.0){
s = 0.0;
}
/* Gradient colors and amount here */
const int nColors = 4;
vec3 colors[nColors];
colors[0] = vec3(0.05,0.05,1.0);
colors[1] = vec3(0.05,1.00,1.00);
colors[2] = vec3(0.50,1.00,0.25);
colors[3] = vec3(1.00,0.75,0.25);
vec3 gradCol = colors[0];
float n = float(nColors)-1.0;
for(int i = 1; i < nColors; i++)
{
gradCol = mixc(gradCol,colors[i],(s-float(i-1)/n)*n);
}
float h = PI*0.5;
col += vec3(1.0-smoothstep(-0.5,0.0,uv.y-s*h));
col *= gradCol;
col2 += vec3(1.0-smoothstep(-0.5,0.0,uv2.y-s*h));
col2*= gradCol;
col = mix(col,col2,step(0.0,uv.y-PI));
col *= smoothstep(0.125,0.375,f);
col *= smoothstep(0.875,0.625,f);
col = clamp(col,0.0,1.0);
return col;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
vec2 p = vec2(uv.x, uv.y+0.2);
vec3 col = vec3(0.0);
col += drawBands(p);//*smoothstep(1.0,0.5,uv.y);;
vec3 ref = vec3(0.0);
vec2 eps = vec2(0.0025,-0.0025);
ref += drawBands(vec2(p.x,1.0-p.y)+eps.xx);
ref += drawBands(vec2(p.x,1.0-p.y)+eps.xy);
ref += drawBands(vec2(p.x,1.0-p.y)+eps.yy);
ref += drawBands(vec2(p.x,1.0-p.y)+eps.yx);
ref += drawBands(vec2(p.x+eps.x,1.0-p.y));
ref += drawBands(vec2(p.x+eps.y,1.0-p.y));
ref += drawBands(vec2(p.x,1.0-p.y+eps.x));
ref += drawBands(vec2(p.x,1.0-p.y+eps.y));
ref /= 8.0;
float colStep = length(smoothstep(0.0,0.1,col));
vec3 cs1 = drawBands(vec2(0.5,0.51));
vec3 cs2 = drawBands(vec2(0.5,0.93));
vec3 plCol = mix(cs1,cs2,length(p*2.0-1.0))*0.15*smoothstep(0.75,-0.25,length(p*2.0-1.0));
vec3 plColBg = vec3(0.05)*smoothstep(1.0,0.0,length(p*2.0-1.0));
vec3 pl = (plCol+plColBg)*smoothstep(0.5,0.65,1.0-uv.y);
col += clamp(pl*(1.0-colStep),0.0,1.0);
col += ref*smoothstep(0.125,1.6125,p.y);
col = clamp(col, 0.0, 1.0);
float dither = noise3D(vec3(uv,time))*2.0/256.0;
col += dither;
fragColor = vec4(col,1.0);
}

View File

@@ -0,0 +1,24 @@
{
"author": "Virgill",
"name": "Rhodium Liquid Carbon",
"version": "1.0.0",
"description": "Liquid carbon effect from Rhodium 4k Intro",
"license": "",
"engine": "shadertoy",
"id": "llK3Dy",
"tags": [
"fire",
"liquid",
"spheretracing"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"bufferA":
{
"source": "./shaders/Buffer A.frag.qsb"
},
"channel0":"{bufferA}"
}

View File

@@ -0,0 +1,175 @@
// ***********************************************************
// Alcatraz / Rhodium 4k Intro liquid carbon
// by Jochen "Virgill" Feldkötter
//
// 4kb executable: http://www.pouet.net/prod.php?which=68239
// Youtube: https://www.youtube.com/watch?v=YK7fbtQw3ZU
// ***********************************************************
#define time iTime
#define res iResolution
float bounce;
// signed box
float sdBox(vec3 p,vec3 b)
{
vec3 d=abs(p)-b;
return min(max(d.x,max(d.y,d.z)),0.)+length(max(d,0.));
}
// rotation
void pR(inout vec2 p,float a)
{
p=cos(a)*p+sin(a)*vec2(p.y,-p.x);
}
// 3D noise function (IQ)
float noise(vec3 p)
{
vec3 ip=floor(p);
p-=ip;
vec3 s=vec3(7,157,113);
vec4 h=vec4(0.,s.yz,s.y+s.z)+dot(ip,s);
p=p*p*(3.-2.*p);
h=mix(fract(sin(h)*43758.5),fract(sin(h+s.x)*43758.5),p.x);
h.xy=mix(h.xz,h.yw,p.y);
return mix(h.x,h.y,p.z);
}
float map(vec3 p)
{
p.z-=1.0;
p*=0.9;
pR(p.yz,bounce*1.+0.4*p.x);
return sdBox(p+vec3(0,sin(1.6*time),0),vec3(20.0, 0.05, 1.2))-.4*noise(8.*p+3.*bounce);
}
// normal calculation
vec3 calcNormal(vec3 pos)
{
float eps=0.0001;
float d=map(pos);
return normalize(vec3(map(pos+vec3(eps,0,0))-d,map(pos+vec3(0,eps,0))-d,map(pos+vec3(0,0,eps))-d));
}
// standard sphere tracing inside and outside
float castRayx(vec3 ro,vec3 rd)
{
float function_sign=(map(ro)<0.)?-1.:1.;
float precis=.0001;
float h=precis*2.;
float t=0.;
for(int i=0;i<120;i++)
{
if(abs(h)<precis||t>12.)break;
h=function_sign*map(ro+rd*t);
t+=h;
}
return t;
}
// refraction
float refr(vec3 pos,vec3 lig,vec3 dir,vec3 nor,float angle,out float t2, out vec3 nor2)
{
float h=0.;
t2=2.;
vec3 dir2=refract(dir,nor,angle);
for(int i=0;i<50;i++)
{
if(abs(h)>3.) break;
h=map(pos+dir2*t2);
t2-=h;
}
nor2=calcNormal(pos+dir2*t2);
return(.5*clamp(dot(-lig,nor2),0.,1.)+pow(max(dot(reflect(dir2,nor2),lig),0.),8.));
}
// softshadow
float softshadow(vec3 ro,vec3 rd)
{
float sh=1.;
float t=.02;
float h=.0;
for(int i=0;i<22;i++)
{
if(t>20.)continue;
h=map(ro+rd*t);
sh=min(sh,4.*h/t);
t+=h;
}
return sh;
}
// main function
void mainImage(out vec4 fragColor,in vec2 fragCoord)
{
bounce=abs(fract(0.05*time)-.5)*20.; // triangle function
vec2 uv=gl_FragCoord.xy/res.xy;
vec2 p=uv*2.-1.;
// bouncy cam every 10 seconds
float wobble=(fract(.1*(time-1.))>=0.9)?fract(-time)*0.1*sin(30.*time):0.;
// camera
vec3 dir = normalize(vec3(2.*gl_FragCoord.xy -res.xy, res.y));
vec3 org = vec3(0,2.*wobble,-3.);
// standard sphere tracing:
vec3 color = vec3(0.);
vec3 color2 =vec3(0.);
float t=castRayx(org,dir);
vec3 pos=org+dir*t;
vec3 nor=calcNormal(pos);
// lighting:
vec3 lig=normalize(vec3(.2,6.,.5));
// scene depth
float depth=clamp((1.-0.09*t),0.,1.);
vec3 pos2 = vec3(0.);
vec3 nor2 = vec3(0.);
if(t<12.0)
{
color2 = vec3(max(dot(lig,nor),0.) + pow(max(dot(reflect(dir,nor),lig),0.),16.));
color2 *=clamp(softshadow(pos,lig),0.,1.); // shadow
float t2;
color2.rgb +=refr(pos,lig,dir,nor,0.9, t2, nor2)*depth;
color2-=clamp(.1*t2,0.,1.); // inner intensity loss
}
float tmp = 0.;
float T = 1.;
// animation of glow intensity
float intensity = 0.1*-sin(.209*time+1.)+0.05;
for(int i=0; i<128; i++)
{
float density = 0.; float nebula = noise(org+bounce);
density=intensity-map(org+.5*nor2)*nebula;
if(density>0.)
{
tmp = density / 128.;
T *= 1. -tmp * 100.;
if( T <= 0.) break;
}
org += dir*0.078;
}
vec3 basecol=vec3(1./1. , 1./4. , 1./16.);
T=clamp(T,0.,1.5);
color += basecol* exp(4.*(0.5-T) - 0.8);
color2*=depth;
color2+= (1.-depth)*noise(6.*dir+0.3*time)*.1; // subtle mist
// scene depth included in alpha channel
fragColor = vec4(vec3(1.*color+0.8*color2)*1.3,abs(0.67-depth)*2.+4.*wobble);
}

View File

@@ -0,0 +1,36 @@
// ***********************************************************
// Alcatraz / Rhodium 4k Intro liquid carbon
// by Jochen "Virgill" Feldkötter
//
// 4kb executable: http://www.pouet.net/prod.php?which=68239
// Youtube: https://www.youtube.com/watch?v=YK7fbtQw3ZU
// ***********************************************************
#define time iTime
#define res iResolution
const float GA =2.399;
const mat2 rot = mat2(cos(GA),sin(GA),-sin(GA),cos(GA));
// simplyfied version of Dave Hoskins blur
vec3 dof(sampler2D tex,vec2 uv,float rad)
{
vec3 acc=vec3(0);
vec2 pixel=vec2(.002*res.y/res.x,.002),angle=vec2(0,rad);;
rad=1.;
for (int j=0;j<80;j++)
{
rad += 1./rad;
angle*=rot;
vec4 col=texture(tex,uv+pixel*(rad-1.)*angle);
acc+=col.xyz;
}
return acc/80.;
}
//-------------------------------------------------------------------------------------------
void mainImage(out vec4 fragColor,in vec2 fragCoord)
{
vec2 uv = gl_FragCoord.xy / res.xy;
fragColor=vec4(dof(iChannel0,uv,texture(iChannel0,uv).w),1.);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -0,0 +1,23 @@
{
"author": "diatribes",
"name": "Root Sanctum",
"version": "1.0.0",
"description": "Root Sanctum",
"license": "",
"engine": "shadertoy",
"id": "3c2fz1",
"tags": [
"raymarched",
"fractal"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"channel0":
{
"source": "./images/iChannel0.png",
"type": 0,
"can_edit": true
}
}

View File

@@ -0,0 +1,109 @@
#define T (iTime*.5)
#define P(z) (vec3((cos((z) * .2) * .3) * 10., \
(cos((z) * .15) * .3) * 10., (z)))
#define R(a) mat2(cos(a), -sin(a), sin(a), cos(a))
#define N normalize
bool hitRoot = false;
// @Shane
vec3 tex3D( sampler2D tex, in vec3 p, in vec3 n ){
n = max((abs(n) - 0.2)*7., 0.001);
n /= (n.x + n.y + n.z );
return (texture(tex, p.yz)*n.x + texture(tex, p.zx)*n.y + texture(tex, p.xy)*n.z).xyz;
}
// @Shane:
// Commutative smooth minimum function. Provided by Tomkh, and taken
// from Alex Evans's (aka Statix) talk:
// http://media.lolrus.mediamolecule.com/AlexEvans_SIGGRAPH-2015.pdf
// Credited to Dave Smith @media molecule.
float smin(float a, float b, float k){
float f = max(0., 1. - abs(b - a)/k);
return min(a, b) - k*.25*f*f;
}
float fractal(vec3 p) {
float s,w,l;
p.y *= .4;
p += cos(p.yzx*12.)*.07;
p.x -= 1.6;
for (s=0.,w=.7; s++ < 7.; p *= l, w *= l )
p = abs(sin(p))-1.,
l = 1.5/dot(p,p);
return length(p)/w-.0005;
}
float light(vec3 p) {
p.xy -= P(p.z).xy;
float t = iTime*.5;
return length(p-vec3(
tanh(cos(t*1.8)*2.) * .25 ,
tanh(cos(t*1.)*3.) * .3,
4.+T+tanh(cos(t*.4)*4.)*1.
))-.25;
}
float root(vec3 p){
p.xy *= R(sin(p.z*2.)*.1 + sin(p.z*1.)*.3);
p = mod(p, 1.) - .5;
return .6*length(p.xy) - .01;
}
float map(vec3 p) {
float s, r;
r = root(p);
p.xy -= P(p.z).xy;
s = smin(fractal(p), 2. - abs(p.y), .8);
hitRoot = r < s;
s = min(s, r);
return s;
}
// @iq
float AO(in vec3 pos, in vec3 nor) {
float sca = 1.9, occ = 0.0;
for( int i=0; i<5; i++ ){
float hr = 0.01 + float(i)*0.5/4.0;
float dd = map(nor * hr + pos);
occ += (hr - dd)*sca;
sca *= 0.7;
}
return clamp( 1.0 - occ, 0.0, 1.0 );
}
void mainImage(out vec4 o, in vec2 u) {
float s=.1,d=0.,i=0.;
vec3 r = iResolution;
u = (u-r.xy/2.)/r.y;
vec3 e = vec3(.001,0,0),
p = P(T),ro=p,
Z = N( P(T+1.) - p),
X = N(vec3(Z.z,0,-Z)),
D = vec3(R(sin(T*.2)*.4)*u, 1)
* mat3(-X, cross(X, Z), Z);
o = vec4(0);
for(;i++ < 128.;)
p = ro + D * d * .65,
d += s = map(p),
o += 4e1*vec4(6,9,1,0) + 1./max(s, .001);
r = N(map(p) - vec3(map(p-e.xyy),
map(p-e.yxy),
map(p-e.yyx)));
o.rgb *= tex3D(iChannel0, p*.5, r);
o *= o;
o *= hitRoot ? .2*vec4(4,3,2,0) : vec4(1);
o *= AO(p, r);
o = tanh(sqrt(d * o / pow(abs(light(p)), 3.) / 5e9 ));
}

View File

@@ -0,0 +1,22 @@
{
"author": "patu",
"name": "Sailing Beyond - Hyper Tunnel",
"version": "1.0.0",
"description": "Continuation of my attemps to extract audio features from a song",
"license": "",
"engine": "shadertoy",
"id": "4t2cR1",
"tags": [
"reactive",
"tunnel",
"neon"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"channel0":
{
"type": 4
}
}

View File

@@ -0,0 +1,240 @@
/*
Hyper Tunnel from "Sailing Beyond" (demoscene producion)
https://www.youtube.com/watch?v=oITx9xMrAcM&
https://www.pouet.net/prod.php?which=77899
*/
/*
http://bit.ly/shadertoy-plugin
*/
#pragma optimize(off)
#define getNormal getNormalHex
#define FAR 1e3
#define INFINITY 1e32
#define T iTime
#define mt (iChannelTime[0] > 0. ? iChannelTime[0] : iTime)
#define FOV 70.0
#define FOG .06
#define PI 3.14159265
#define TAU (2*PI)
#define PHI (1.618033988749895)
float vol = 0.;
float hash12(vec2 p) {
float h = dot(p,vec2(127.1,311.7));
return fract(sin(h)*43758.5453123);
}
// 3d noise
float noise_3(in vec3 p) {
vec3 i = floor(p);
vec3 f = fract(p);
vec3 u = 1.-(--f)*f*f*f*-f;
vec2 ii = i.xy + i.z * vec2(5.0);
float a = hash12( ii + vec2(0.0,0.0) );
float b = hash12( ii + vec2(1.0,0.0) );
float c = hash12( ii + vec2(0.0,1.0) );
float d = hash12( ii + vec2(1.0,1.0) );
float v1 = mix(mix(a,b,u.x), mix(c,d,u.x), u.y);
ii += vec2(5.0);
a = hash12( ii + vec2(0.0,0.0) );
b = hash12( ii + vec2(1.0,0.0) );
c = hash12( ii + vec2(0.0,1.0) );
d = hash12( ii + vec2(1.0,1.0) );
float v2 = mix(mix(a,b,u.x), mix(c,d,u.x), u.y);
return max(mix(v1,v2,u.z),0.);
}
float fbm(vec3 x)
{
float r = 0.0;
float w = 1.0, s = 1.0;
for (int i=0; i<4; i++)
{
w *= 0.25;
s *= 3.;
r += w * noise_3(s * x);
}
return r;
}
float yC(float x) {
return cos(x * -.134) * 1. * sin(x * .13) * 15.+ fbm(vec3(x * .1, 0., 0.) * 55.4);
}
void pR(inout vec2 p, float a) {
p = cos(a)*p + sin(a)*vec2(p.y, -p.x);
}
struct geometry {
float dist;
vec3 hit;
int iterations;
};
// Cylinder with infinite height
float fCylinderInf(vec3 p, float r) {
return length(p.xz) - r;
}
geometry map(vec3 p) {
p.x -= yC(p.y * .1) * 3.;
p.z += yC(p.y * .01) * 4.;
float n = pow(abs(fbm(p * .06 )) * 12., 1.3);
float s = fbm(p * 0.01 + vec3(0., T * 0.14, 0.)) * 128.;
geometry obj;
obj.dist = max(0., -fCylinderInf(p, s + 18. -n));
p.x -= sin(p.y * .02) * 34. + cos(p.z * 0.01) * 62.;
obj.dist = max(obj.dist, -fCylinderInf(p, s + 28. + n * 2.));
return obj;
}
float t_min = 10.0;
float t_max = FAR;
const int MAX_ITERATIONS = 100;
geometry trace(vec3 o, vec3 d) {
float omega = 1.3;
float t = t_min;
float candidate_error = INFINITY;
float candidate_t = t_min;
float previousRadius = 0.;
float stepLength = 0.;
float pixelRadius = 1./ 1000.;
geometry mp = map(o);
float functionSign = mp.dist < 0. ? -1. : +1.;
float minDist = FAR;
for (int i = 0; i < MAX_ITERATIONS; ++i) {
mp = map(d * t + o);
mp.iterations = i;
float signedRadius = functionSign * mp.dist;
float radius = abs(signedRadius);
bool sorFail = omega > 1. &&
(radius + previousRadius) < stepLength;
if (sorFail) {
stepLength -= omega * stepLength;
omega = 1.;
} else {
stepLength = signedRadius * omega;
}
previousRadius = radius;
float error = radius / t;
if (!sorFail && error < candidate_error) {
candidate_t = t;
candidate_error = error;
}
if (!sorFail && error < pixelRadius || t > t_max) break;
t += stepLength * .5; // ;(
}
mp.dist = candidate_t;
if (
(t > t_max || candidate_error > pixelRadius)
) mp.dist = INFINITY;
return mp;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 ouv = fragCoord.xy / iResolution.xy;
vec2 uv = ouv - .5;
uv *= tan(radians (FOV) / 2.0) * 4.;
vec3
vuv = normalize(vec3(cos(T), sin(T * .11), sin(T * .41))), // up
ro = vec3(0., 30. + iTime * 100., -.1);
ro.x += yC(ro.y * .1) * 3.;
ro.z -= yC(ro.y * .01) * 4.;
vec3 vrp = vec3(0., 50. + iTime * 100., 2.);
vrp.x += yC(vrp.y * .1) * 3.;
vrp.z -= yC(vrp.y * .01) * 4.;
vec3
vpn = normalize(vrp - ro),
u = normalize(cross(vuv, vpn)),
v = cross(vpn, u),
vcv = (ro + vpn),
scrCoord = (vcv + uv.x * u * iResolution.x/iResolution.y + uv.y * v),
rd = normalize(scrCoord - ro),
oro = ro;
vec3 sceneColor = vec3(0.);
geometry tr = trace(ro, rd);
tr.hit = ro + rd * tr.dist;
vec3 col = vec3(1., 0.5, .4) * fbm(tr.hit.xzy * .01) * 20.;
col.b *= fbm(tr.hit * .01) * 10.;
sceneColor += min(.8, float(tr.iterations) / 90.) * col + col * .03;
sceneColor *= 1. + .9 * (abs(fbm(tr.hit * .002 + 3.) * 10.) * (fbm(vec3(0.,0.,iTime * .05) * 2.)) * 1.);
sceneColor = pow(sceneColor, vec3(1.)) * (iChannelTime[0] > 0. ? texelFetch(iChannel0, ivec2(128, 0), 0).r * min(1., mt * .1) : 0.6);
vec3 steamColor1 = vec3(.0, .4, .5);
vec3 rro = oro;
ro = tr.hit;
float distC = tr.dist, f = 0., st = .9;
for (float i = 0.; i < 24.; i++) {
rro = ro - rd * distC;
f += fbm(rro * vec3(.1, .1, .1) * .3) * .1;
distC -= 3.;
if (distC < 3.) break;
}
steamColor1 *= iChannelTime[0] > 0. ? texelFetch(iChannel0, ivec2(32, 0), 0).r : 1.;
sceneColor += steamColor1 * pow(abs(f * 1.5), 3.) * 4.;
fragColor = vec4(clamp(sceneColor * (1. - length(uv) / 2.), 0.0, 1.0), 1.0);
fragColor = pow(abs(fragColor / tr.dist * 130.), vec4(.8));
}

View File

@@ -0,0 +1,17 @@
{
"author": "Kali",
"name": "Mist by Ohno! - part2",
"version": "1.0.0",
"description": "Audio reactive shader",
"license": "CC-BY-NC-SA",
"engine": "shadertoy",
"id": "fd2GD1",
"tags": [
"reactive",
"pixel",
"neon"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1
}

View File

@@ -0,0 +1,126 @@
//#define iTime iChannelTime[0]
float det=.005, maxdist=50., pi=3.1416, gl=0.;
vec2 id;
float hash12(vec2 p)
{
p*=1000.;
vec3 p3 = fract(vec3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
mat2 rot(float a)
{
float s=sin(a), c=cos(a);
return mat2(c,s,-s,c);
}
float box(vec3 p, vec3 c)
{
vec3 pc=abs(p)-c;
return length(max(vec3(0.),pc))-min(0.,max(pc.z,max(pc.x,pc.y)));
}
vec2 amod(vec2 p, float n, float off, out float i)
{
float l=length(p)-off;
float at=atan(p.x,p.y)/pi*n*.5;
i=abs(floor(at));
float a=fract(at)-.5;
return vec2(a,l);
}
float ring(vec3 p,inout vec2 id)
{
p.xy=amod(p.xy*rot(iTime*0.), 20., 2., id.x);
float h=max(0.,texture(iChannel0,vec2(.5+fract(id.x*.2+id.y*.1),0.)*.5).r*3.-.5);
h+=sin(iTime*10.+id.x)*.2;
float d=box(p+vec3(0.,-h*1.5,0.),vec3(.1,h,.1));
return d*.5;
}
float de(vec3 p)
{
float d=100.,ii=0.;
p.xz*=rot(iTime);
p.yz*=rot(sin(iTime));
float r=4.;
vec2 ids;
for (float i=0.; i<r; i++)
{
p.xz*=rot(pi/r);
ids.y=i;
float r=ring(p,ids);
if (r<d)
{
d=r;
id=ids;
}
}
d=min(d,length(p)-1.5);
return d*.7;
}
vec3 normal(vec3 p)
{
vec2 e=vec2(0.,det);
return normalize(vec3(de(p+e.yxx),de(p+e.xyx),de(p+e.xxy))-de(p));
}
vec3 march(vec3 from, vec3 dir)
{
float d, td=0.;
vec3 p, col=vec3(0.);
for (int i=0; i<100; i++)
{
p=from+td*dir;
d=de(p);
if (d<det || td>maxdist) break;
td+=d;
gl+=.1/(10.+d*d*10.)*step(.7,hash12(id+floor(iTime*5.)));
}
if (d<det)
{
//id+=floor(iTime*5.);
vec3 colid=vec3(hash12(id),hash12(id+123.123),1.);
p-=dir*det;
vec3 n=normal(p);
vec2 e=vec2(0.,.05);
col=.1+max(0.,dot(-dir,n))*colid;
col*=.5+step(.7,hash12(id+floor(iTime*5.)));
}
else
{
dir.xz*=rot(iTime*.5);
dir.yz*=rot(iTime*.25);
vec2 p2=abs(.5-fract(dir.yz));
float d2=100.,is=0.;
for(int i=0; i<10; i++)
{
p2=abs(p2*1.3)*rot(radians(45.))-.5;
float sh=length(max(vec2(0.),abs(p2)-.05));
if (sh<d2)
{
d2=sh;
is=float(i);
}
}
col+=smoothstep(.05,.0,d2)*fract(is*.1+iTime)*normalize(p+50.);
}
return col*mod(gl_FragCoord.y,4.)*.5+gl;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = (fragCoord-iResolution.xy*.5)/iResolution.y;
vec3 from = vec3(0.,0.,-8.);
vec3 dir = normalize(vec3(uv,.7));
vec3 col = march(from, dir);
fragColor = vec4(col,1.0);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -0,0 +1,40 @@
{
"author": "z0rg",
"name": "The Grid",
"version": "1.0.0",
"description": "A mix of two of my shaders to create a cyber / tron visual",
"license": "CC-BY-NC-SA",
"engine": "shadertoy",
"id": "7tGfWy",
"tags": [
"tron",
"cyber",
"retrowave"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"bufferA":
{
"source": "./shaders/Buffer A.frag.qsb",
"frame_buffer_channel": 0,
"channel1":
{
"type": 0,
"source":"./images/iChannel1.png"
},
"channel2":
{
"type": 0,
"source":"./images/iChannel2.png"
},
"channel3":
{
"type": 4
}
},
"channel0":"{bufferA}"
}

View File

@@ -0,0 +1,216 @@
// This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0
// Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
// or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
// =========================================================================================================
#define FFT(a) (texture(iChannel3, vec2(a, 0.)).x-.25)
vec3 rdrCirc(vec2 uv, float t)
{
vec3 col = vec3(0.);
vec2 ouv = uv;
float rep = .03;
float id = floor((uv.y+rep*.5)/rep);
uv.y = mod(uv.y+rep*.5,rep)-rep*.5;
uv.x += id;
float cl = .1;
float h = clamp(asin(sin(uv.x*5.)), -cl, cl)/cl;
float line = abs(uv.y-h*0.01)-.001;
vec3 rgb = mix(vec3(.4,.3,.7), vec3(.4,.6,.9).zxy, sat(sin(id)));
rgb *= 1.-sat((abs(ouv.x+(fract(id*.1)-.5)+mod(t*.75+.5*id,4.)-2.)-.2)*4.);
col = mix(col, rgb,1.-sat(line*iResolution.x*.5));
col += .5*rgb*(1.-sat(line*80.));
return col;
}
vec3 rdrCircuit(vec2 uv)
{
vec3 col = rdrCirc(uv, iTime);
col += rdrCirc(uv+vec2(0.,.2), iTime*.7);
col += .5*rdrCirc(2.*uv+vec2(0.,.1), iTime*.5).zxy;
col += .15*rdrCirc(4.*uv+vec2(0.,.1), iTime*.25).yzx;
return col;
}
float seed;
float rand()
{
seed++;
return hash11(seed);
}
vec2 map(vec3 p)
{
vec2 acc = vec2(10000.,-1.);
//acc = _min(acc, vec2(length(p)-2., 0.));
float h = .2;
acc = _min(acc, vec2(-p.y-.2*clamp(asin(sin(p.z*3.)),-h,h), 0.));
return acc;
}
vec3 getEnv(vec3 rd)
{
rd.xy *= r2d(.5);
vec2 uv = vec2(atan(rd.z, rd.x)/PI, (acos(rd.y)/PI-.5)*2.);
float gradf = 3.;
vec3 up = mix(vec3(0.161,0.055,0.239),vec3(0.639,0.059,0.341), sat(uv.y*gradf));
vec3 low = mix(vec3(0.161,0.055,0.239),vec3(0.157,0.345,0.337), sat(-uv.y*gradf));
vec3 back = mix(low, up, float(uv.y > 0. ? low : up));
float stars = pow(texture(iChannel2, uv*4.).x, 10.);
uv.x *= 1.75;
float an = iTime*.1+atan(uv.y+.1, uv.x+.1);
back += .25*((.35*vec3(0.945,0.220,0.310)*sat(sin(an*12.)+.8))*(1.-sat(length(uv*2.)))+
.5*vec3(0.945,0.263,0.216)*sat(sin(-iTime*.05+an*7.+1.)+.7)*(1.-sat(length(uv*1.5)))+
.5*vec3(1.000,0.533,0.502)*sat(sin(an*5.)+.5)*(1.-sat(length(uv*1.)))).zxy;
float rep = 0.05;
vec2 uv2 = uv-vec2(0.,-0.35);
uv2 *= 1.5;
float id = floor((uv2.x+rep*.5)/rep);
uv2.x = mod(uv2.x+rep*.5,rep)-rep*.5;
float height = pow(FFT(abs(id*.01)),1.);
float shape = max(abs(uv2.y)-height, abs(uv2.x)-0.001);
vec3 rgbs = mix(vec3(0.208,0.675,0.431)*0., vec3(0.180+sin(id+iTime)*.5+.5,0.820,0.659+sin(-id+iTime)*.5+.5), sat((abs(uv2.y))*10.));
back += rgbs*(1.-sat(shape*400.))*(1.-sat(abs(uv.x*2.)-.5));
float psz = .25;
uv += vec2(.2,-0.1);
uv *= r2d(2.5);
float planet = length(uv)-psz;
vec3 col = back+stars*vec3(0.580,0.804,0.820)*.5;
vec3 planetrgb = vec3(0.161,0.055,0.239)*.75
+vec3(0.961,0.000,0.192)*pow(texture(iChannel1,vec2(-iTime*.02,0.)+uv*5.*length(uv)).x,3.)*sat(uv.y*5.);
planetrgb += vec3(1.000,0.173,0.078)*(1.-sat((abs(planet)-.001)*50.))*sat(uv.y*5.);
col = mix(col, planetrgb, 1.-sat(planet*400.));
col += .8*vec3(1.000,0.173,0.078)*(1.-sat((abs(planet)-.01)*10.))*sat(uv.y*5.);
col += vec3(1.000,0.314,0.141)*(1.-sat(planet*100.))*.15;
col += .25*rgbs*(1.-sat(shape*10.))*(1.-sat(abs(uv.x*2.)-.5))*sat(planet*10.);
uv.y *= 3.5-2.*uv.y;
float anr = atan(uv.y, uv.x); // ring
float ring = abs(length(uv)-.4)-.1;
col += sat(uv.y+.15)*(1.-sat(ring*100.))*texture(iChannel2, vec2(length(uv), anr*.01)).xxx;
return col;
}
float _cube(vec3 p, vec3 s)
{
vec3 l = abs(p)-s;
return max(l.x, max(l.y, l.z));
}
vec3 getCam(vec3 rd, vec2 uv)
{
vec3 r = normalize(cross(rd, vec3(0.,1.,0.)));
vec3 u = cross(rd, r);
return normalize(rd+(r*uv.x+u*uv.y)*4.);
}
vec3 getNorm(vec3 p, float d)
{
vec2 e = vec2(0.01,0.);
return normalize(vec3(d)-vec3(
map(p-e.xyy).x,
map(p-e.yxy).x,
map(p-e.yyx).x));
}
vec3 trace(vec3 ro, vec3 rd, int steps)
{
vec3 p = ro;
for (int i = 0; i < steps; ++i)
{
vec2 res = map(p);
if (res.x < 0.01)
return vec3(res.x, distance(p, ro), res.y);
p+=rd*res.x;
}
return vec3(-1.);
}
vec3 getMat(vec3 res, vec3 rd, vec3 p, vec3 n)
{
return vec3(.1);
}
vec3 rdr(vec2 uv)
{
vec3 col = vec3(0.);
float t = 4.68;
vec3 ro = vec3(sin(t)*5.,-1.5+sin(iTime*.25)*.2,cos(t)*5.+sin(iTime*.25));
vec3 ta = vec3(sin(iTime)*1.,-2.,0.);
vec3 rd = normalize(ta-ro);
rd = getCam(rd, uv);
float d = 100.;
vec3 res = trace(ro, rd, 64);
if (res.y > 0.)
{
d = res.y;
vec3 p = ro+rd*res.y;
vec3 n = getNorm(p, res.x);
col = getMat(res, rd, p, n);
float move = p.x+iTime;
float river = (abs(p.z-sin(move*1.)*.5-sin(move*.5)*2.)-1.5);
float spec = 1.;//mix(.25,1.,1.-sat(river*400.));
float gloss = .05;//mix(.5,.05, 1.-sat(river*400.));
vec3 refl = normalize(reflect(rd, n)+gloss*(vec3(rand(), rand(), rand())-.5));
vec3 resrefl = trace(p+n*0.01, refl, 32);
vec3 reflec = vec3(0.);
float gridrep = 1.;
vec2 griduv = vec2(move, p.z);
griduv = mod(griduv+gridrep*.5,gridrep)-gridrep*.5;
float gridth = .001;
float grid = min(abs(griduv.x)-gridth, abs(griduv.y)-gridth);
//col += sat(river*400.)*vec3(0.220,0.800,0.412)*(1.-sat(grid*40.))*(1.-sat(res.y/10.));
col += rdrCircuit(vec2(p.x, p.z)*.1);
if (resrefl.y > 0.)
{
vec3 prefl = p+refl*resrefl.y;
vec3 nrefl = getNorm(prefl, resrefl.x);
reflec=getMat(resrefl, refl, prefl, nrefl);
}
else
reflec=getEnv(refl);
col += reflec*spec;
}
else
col = getEnv(rd);
col += vec3(0.816,0.541,1.000)*(1.-sat(exp(-d*0.2+.5)))*sat(rd.y*1.+.5);
col += .5*vec3(1.000,0.314,0.141)*(1.-sat(exp(-d*0.2+1.5)))*sat(rd.y*3.+.5);
col += vec3(0.302,0.698,1.000)*pow(1.-sat(abs((rd.y-.05)*15.)),2.)*(1.-sat(abs(rd.z)));
return col;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = (fragCoord.xy-.5*iResolution.xy)/iResolution.xx;
seed=texture(iChannel2,uv).x;
seed+=fract(iTime);
vec3 col = rdr(uv);
vec2 off = vec2(1., -1.)/(iResolution.x*2.);
#ifdef AA
if (true)// Not so cheap antialiasing
{
vec3 acc = col;
acc += rdr(uv+off.xx);
acc += rdr(uv+off.xy);
acc += rdr(uv+off.yy);
acc += rdr(uv+off.yx);
col = acc/5.;
}
#endif
col *= 1.-sat(length(uv*1.5));
col = pow(col, vec3(1.2));
col *= sat(iTime-1.);
col = mix(col, texture(iChannel0, fragCoord.xy/iResolution.xy).xyz,.5);
col = pow(col, vec3(1.15));
col = sat(col);
fragColor = vec4(col.zxx,1.0);
}

View File

@@ -0,0 +1,23 @@
// This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0
// Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
// or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
// =========================================================================================================
#define AA // Comment to deactivate antialiasing
#define sat(a) clamp(a, 0., 1.)
#define PI 3.141592653
mat2 r2d(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }
vec2 _min(vec2 a, vec2 b)
{
if (a.x < b.x)
return a;
return b;
}
// Stolen from 0b5vr here https://www.shadertoy.com/view/ss3SD8
float hash11(float p)
{
return (fract(sin((p)*114.514)*1919.810));
}

View File

@@ -0,0 +1,30 @@
// This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0
// Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
// or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
// =========================================================================================================
vec3 rdrImg(vec2 uv)
{
vec3 col = pow(texture(iChannel0, uv).xyz,vec3(1.3));
col += pow(texture(iChannel0, uv).xyz,vec3(.9))*.35;
return col;
}
vec3 rdrChroma(vec2 uv)
{
vec3 col = vec3(0.);
vec2 off = vec2(.002);
col.r = rdrImg(uv+off).r;
col.g = rdrImg(uv).g;
col.b = rdrImg(uv-off).b;
return col;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy/iResolution.xy;
vec3 col = rdrChroma(uv);
fragColor = vec4(col,1.0);
}

View File

@@ -0,0 +1,22 @@
{
"author": "Virgill",
"name": "Rhodium Liquid Carbon",
"version": "1.0.0",
"description": "Been reading up on psychedelics and got inspired. Put fullscreen, make sure sure you have sound and stare at it until the end! Use mouse to move.",
"license": "",
"engine": "shadertoy",
"id": "lscczl",
"tags": [
"reactive",
"universe",
"network"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"channel0":
{
"type": 4
}
}

View File

@@ -0,0 +1,157 @@
// The Universe Within - by Martijn Steinrucken aka BigWings 2018
// Email:countfrolic@gmail.com Twitter:@The_ArtOfCode
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// After listening to an interview with Michael Pollan on the Joe Rogan
// podcast I got interested in mystic experiences that people seem to
// have when using certain psycoactive substances.
//
// For best results, watch fullscreen, with music, in a dark room.
//
// I had an unused 'blockchain effect' lying around and used it as
// a base for this effect. Uncomment the SIMPLE define to see where
// this came from.
//
// Use the mouse to get some 3d parallax.
// Music - Terrence McKenna Mashup - Jason Burruss Remixes
// https://soundcloud.com/jason-burruss-remixes/terrence-mckenna-mashup
//
// YouTube video of this effect:
// https://youtu.be/GAhu4ngQa48
//
// YouTube Tutorial for this effect:
// https://youtu.be/3CycKKJiwis
#define S(a, b, t) smoothstep(a, b, t)
#define NUM_LAYERS 4.
//#define SIMPLE
float N21(vec2 p) {
vec3 a = fract(vec3(p.xyx) * vec3(213.897, 653.453, 253.098));
a += dot(a, a.yzx + 79.76);
return fract((a.x + a.y) * a.z);
}
vec2 GetPos(vec2 id, vec2 offs, float t) {
float n = N21(id+offs);
float n1 = fract(n*10.);
float n2 = fract(n*100.);
float a = t+n;
return offs + vec2(sin(a*n1), cos(a*n2))*.4;
}
float GetT(vec2 ro, vec2 rd, vec2 p) {
return dot(p-ro, rd);
}
float LineDist(vec3 a, vec3 b, vec3 p) {
return length(cross(b-a, p-a))/length(p-a);
}
float df_line( in vec2 a, in vec2 b, in vec2 p)
{
vec2 pa = p - a, ba = b - a;
float h = clamp(dot(pa,ba) / dot(ba,ba), 0., 1.);
return length(pa - ba * h);
}
float line(vec2 a, vec2 b, vec2 uv) {
float r1 = .04;
float r2 = .01;
float d = df_line(a, b, uv);
float d2 = length(a-b);
float fade = S(1.5, .5, d2);
fade += S(.05, .02, abs(d2-.75));
return S(r1, r2, d)*fade;
}
float NetLayer(vec2 st, float n, float t) {
vec2 id = floor(st)+n;
st = fract(st)-.5;
vec2 p[9];
int i=0;
for(float y=-1.; y<=1.; y++) {
for(float x=-1.; x<=1.; x++) {
p[i++] = GetPos(id, vec2(x,y), t);
}
}
float m = 0.;
float sparkle = 0.;
for(int i=0; i<9; i++) {
m += line(p[4], p[i], st);
float d = length(st-p[i]);
float s = (.005/(d*d));
s *= S(1., .7, d);
float pulse = sin((fract(p[i].x)+fract(p[i].y)+t)*5.)*.4+.6;
pulse = pow(pulse, 20.);
s *= pulse;
sparkle += s;
}
m += line(p[1], p[3], st);
m += line(p[1], p[5], st);
m += line(p[7], p[5], st);
m += line(p[7], p[3], st);
float sPhase = (sin(t+n)+sin(t*.1))*.25+.5;
sPhase += pow(sin(t*.1)*.5+.5, 50.)*5.;
m += sparkle*sPhase;//(*.5+.5);
return m;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = (fragCoord-iResolution.xy*.5)/iResolution.y;
vec2 M = iMouse.xy/iResolution.xy-.5;
float t = iTime*.1;
float s = sin(t);
float c = cos(t);
mat2 rot = mat2(c, -s, s, c);
vec2 st = uv*rot;
M *= rot*2.;
float m = 0.;
for(float i=0.; i<1.; i+=1./NUM_LAYERS) {
float z = fract(t+i);
float size = mix(15., 1., z);
float fade = S(0., .6, z)*S(1., .8, z);
m += fade * NetLayer(st*size-M*z, i, iTime);
}
float fft = texelFetch( iChannel0, ivec2(.7,0), 0 ).x;
float glow = -uv.y*fft*2.;
vec3 baseCol = vec3(s, cos(t*.4), -sin(t*.24))*.4+.6;
vec3 col = baseCol*m;
col += baseCol*glow;
#ifdef SIMPLE
uv *= 10.;
col = vec3(1)*NetLayer(uv, 0., iTime);
uv = fract(uv);
//if(uv.x>.98 || uv.y>.98) col += 1.;
#else
col *= 1.-dot(uv,uv);
t = mod(iTime, 230.);
col *= S(0., 20., t)*S(224., 200., t);
#endif
fragColor = vec4(col,1);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -0,0 +1,34 @@
{
"author": "stubbe",
"name": "Warp Tunnel",
"version": "1.0.0",
"description": "Warping Through A Wormhole In Space",
"license": "",
"engine": "shadertoy",
"id": "XtdGR7",
"tags": [
"space",
"warp"
],
"source": "./shaders/Image.frag.qsb",
"speed": 1,
"channel0":
{
"source": "./images/iChannel0.png",
"type": 0
},
"channel1":
{
"source": "./images/iChannel1.png",
"type": 0
},
"channel2":
{
"source": "./images/iChannel2.png",
"type": 0
}
}

View File

@@ -0,0 +1,348 @@
const float PI = 3.1415926535;
const float SPEED = 10.0;
const float ARMS = 3.0;
const vec2 EPSILON = vec2(0, .005);
const vec3 sunDir = vec3(-0.363696,0.581914,0.727393);//normalize(vec3(-.5,.8,1));
const vec3 sunColor = vec3(3,2,1);
float time;
float z_offset;
float tunnelShake;
vec2 rotate(vec2 p, float a)
{
return vec2(cos(a)*p.x + sin(a)*p.y, -sin(a)*p.x + cos(a)*p.y);
}
float Noise( in vec3 x )
{
vec3 p = floor(x);
vec3 f = fract(x);
f = f*f*(3.0-2.0*f);
vec2 uv = (p.xy+vec2(37.0,17.0)*p.z) + f.xy;
vec2 rg = textureLod( iChannel0, (uv+ 0.5)/256.0, 0.0 ).yx;
return -1.0+2.0*mix( rg.x, rg.y, f.z );
}
float Map3( in vec3 p )
{
vec3 q = p;
float f;
f = 0.50000*Noise( q ); q = q*2.02;
f += 0.25000*Noise( q ); q = q*2.03;
f += 0.12500*Noise( q ); q = q*2.01;
return f;
}
float Map5( in vec3 p )
{
vec3 q = p;
float f;
f = 0.50000*Noise( q ); q = q*2.02;
f += 0.25000*Noise( q ); q = q*2.03;
f += 0.12500*Noise( q ); q = q*2.01;
f += 0.06250*Noise( q ); q = q*2.02;
f += 0.03125*Noise( q );
return f;
}
mat4 LookAt(vec3 pos, vec3 target, vec3 up)
{
vec3 dir = normalize(target - pos);
vec3 x = normalize(cross(dir, up));
vec3 y = cross(x, dir);
return mat4(vec4(x, 0), vec4(y, 0), vec4(dir, 0), vec4(pos, 1));
}
vec2 TunnelCenter(float z)
{
return vec2(sin(z*.17)*.4,sin(z*.1+4.))*3. * tunnelShake;
}
float GetAngle(vec3 pos)
{
return atan(pos.y,pos.x) - pos.z*.25 + time*3.7 + sin(time)*.2;
}
vec3 Fresnel(vec3 R0, vec3 normal, vec3 viewDir)
{
float NdotV = max(0., dot(normal, viewDir));
return R0 + (vec3(1.0) - R0) * pow(1.0 - NdotV, 5.0);
}
float Map(vec3 pos)
{
pos.z -= z_offset;
pos.xy -= TunnelCenter(pos.z);
float fft = textureLod( iChannel3, vec2(0.5,0.15), 0.0).x;
float angle = GetAngle(pos);
float r = sin(pos.z*.1)*0.5 + 3. + Map5(pos)*.3 + fft * 2.0 + sin(angle*ARMS)*.3;
//r += texture( iChannel3, vec2(fract(pos.z*.1),0.0) ).x;
return length(pos.xy) - r;
}
vec3 Normal(vec3 pos)
{
vec2 e = vec2(0, .05);
return normalize(vec3(Map(pos + e.yxx), Map(pos + e.xyx), Map(pos + e.xxy)) - Map(pos));
}
float IntersectPlanets(vec3 pos, vec3 dir, out vec3 normal, out float max_d, out int type)
{
const float PLANET_CYCLE = 25.0;
const int PLANET_PASSES = 3;
float best_dist = 1e10;
bool hit = false;
max_d = -1e10;
for(int i = 0; i < PLANET_PASSES; i++)
{
int tp = i;
if(tp >= 3) tp-=3;
float time2 = time + 15.5*float(i);
float planetRound = floor(time2 / PLANET_CYCLE);
float planetPos = time2 - planetRound * PLANET_CYCLE;
float planetAngle = planetRound * 23.1;
float planetDistance = (tp==0) ? 20. :
(tp==1) ? 13. :
13.;
vec3 sphereCenter = vec3(cos(planetAngle)*planetDistance,sin(planetAngle)*planetDistance,(PLANET_CYCLE- planetPos)*10.);
vec3 delta = pos - sphereCenter;
float sphereRadius = (tp==0) ? 13. :
(tp==1) ? 7. :
7.;
float B = dot(dir, delta);
float C = dot(delta, delta) - sphereRadius * sphereRadius;
float D = B*B - C;
if(D >= 0.0)
{
float t = -B - sqrt(D);
if(t >= 0. && t < best_dist)
{
vec3 spherePos = pos + t * dir;
normal = normalize(spherePos - sphereCenter);
best_dist = t;
type = tp;
hit = true;
}
}
max_d = max(max_d, D);
}
return hit ? best_dist : -1.;
}
float EarthHeight(vec3 pos)
{
vec2 coord = vec2(acos(pos.y)/(2.0*PI), atan(pos.x, pos.z)/(2.0*PI));
vec3 te = texture( iChannel2, coord ).rgb + texture( iChannel2, coord*3.0 ).rgb * .3;
float landLerp = smoothstep( 0.45, 0.5, te.x);
vec3 albedo = mix( vec3(0.1, 0.2, 0.45), (vec3(0.055, 0.275, 0.0275) + 0.45*te + te*te*0.5*texture( iChannel2, 2.0*coord.xy ).xyz)*0.4, landLerp );
return length(pos) - albedo.x*.015;
}
vec3 BackgroundInner(vec3 pos, vec3 dir, bool enableSun, out bool sphereHit, out vec3 spherePos, out vec3 sphereNormal, out vec3 reflectivity)
{
vec3 nebulaPos = dir.yxz;
float v = Map5(nebulaPos*1.3 + Map5(nebulaPos*0.5)*3.0) + .1;
v = max(v, 0.);
vec3 color = v*mix(vec3(1.,.2,2), vec3(2,.2,10), clamp(Map3(dir*1.3),0.,1.)) + 0.1;
vec2 uv = vec2(acos(dir.x), atan(dir.y,dir.z));
vec3 a = texture( iChannel1, uv*1.5).rgb;
vec3 b = texture( iChannel1, uv*0.4).rgb;
color *= (a * b) * 4.;
color += pow(texture(iChannel1, uv*1.0).rgb, vec3(4.0)) * 0.5;
if(enableSun)
{
float sunDot = max(0., dot(dir, sunDir));
color += (pow(sunDot, 8.0)*.03 + pow(sunDot, 512.0)) * 5. * sunColor;
}
sphereHit = false;
reflectivity = vec3(0);
float max_d;
int type;
float t = IntersectPlanets(pos, dir, sphereNormal, max_d, type);
if(t >= 0.0)
{
spherePos = pos + t * dir;
vec2 coord = vec2(acos(sphereNormal.y)/(2.0*PI), atan(sphereNormal.x, sphereNormal.z)/(2.0*PI));
float time_offset = time*.04;
coord.y += time_offset;
if(type == 0)
{
float offset = texture( iChannel2, coord ).r * .005;
vec3 lookup = sphereNormal;
lookup.xy = rotate(lookup.xy, time_offset*2.0*PI);
float height = Map5(lookup*4.)*.5+.8;//texture( iChannel2, coord + vec2(offset)).r;
height = pow(min(height, 1.),8.);
vec3 fire = (texture( iChannel2, coord*5. + time*.02).rgb +
texture( iChannel2, coord*1. + time*.006).rgb
) * vec3(3,1,1) * .5;
vec3 albedo = texture( iChannel2, coord + vec2(offset)).rgb * .25 -
texture( iChannel2, coord*7.0).rgb * .1;
color = albedo * max(0., dot(sphereNormal, sunDir)) * sunColor + fire * pow(1.0-height,16.);
}
else if(type == 2)
{
vec3 te = texture( iChannel2, coord ).rgb + texture( iChannel2, coord*3.0 ).rgb * .3;
float offset = 0.0 + texture( iChannel2, coord).x*.003;
vec3 albedo = (texture( iChannel2, coord*vec2(.4,0)+vec2(offset,0) ).rgb-.5)*.7 + .4;
albedo += texture( iChannel2, coord*1.0).rgb * .2;
albedo += texture( iChannel2, coord*16.0).rgb * .075;
color = albedo * max(0., dot(sphereNormal, sunDir)) * sunColor;
}
else if(type == 1)
{
vec3 te = texture( iChannel2, coord ).rgb + texture( iChannel2, coord*3.0 ).rgb * .3;
vec3 bumpedNormal = normalize(vec3(EarthHeight(sphereNormal + EPSILON.yxx), EarthHeight(sphereNormal + EPSILON.xyx), EarthHeight(sphereNormal + EPSILON.xxy)) - EarthHeight(sphereNormal));
sphereNormal = bumpedNormal;
float landLerp = smoothstep( 0.45, 0.5, te.x);
vec3 albedo = mix( vec3(0.1, 0.2, 0.45), (vec3(0.055, 0.275, 0.0275) + 0.45*te + te*te*0.5*texture( iChannel2, 2.0*coord.xy ).xyz)*0.4, landLerp );
float specPower = mix(2048., 32., landLerp);
float q = ( texture( iChannel2, coord+vec2(0,time*.02) ).x +
texture( iChannel2, coord*2.0+vec2(0,time*.013) ).x) * .5;
float skyLerp = smoothstep( 0.4, 0.8, q);
reflectivity = mix(vec3(0.1), vec3(0.0), skyLerp);
float NdotL = max(0., dot(sphereNormal, sunDir));
vec3 opaque = albedo * NdotL * sunColor;
color = opaque + pow(max(0., dot(bumpedNormal, normalize(-dir + sunDir))), specPower) * (specPower + 8.0) / (8.0 * PI) * sunColor * reflectivity;
vec3 sky = vec3(0.9) * NdotL * sunColor;
color = mix( color, sky, skyLerp);
}
sphereHit = true;
}
return color;
}
vec3 Background(vec3 pos, vec3 dir)
{
dir = normalize(dir);
bool sphereHit;
vec3 spherePos;
vec3 sphereNormal;
vec3 reflectivity;
vec3 color = BackgroundInner(pos, dir, true, sphereHit, spherePos, sphereNormal, reflectivity);
if(sphereHit)
{
vec3 R = Fresnel(reflectivity, sphereNormal, -dir);
vec3 reflectionDir = reflect(dir,sphereNormal);
bool dummyHit;
vec3 dummyPos;
vec3 dummyNormal;
color += (BackgroundInner(spherePos + sphereNormal*.01, reflectionDir, false, dummyHit, dummyPos, dummyNormal, reflectivity)*(1.0-R)+vec3(1,2,3)*.075)*R*sunColor;
}
return color;
}
vec3 LensFlare(vec2 x)
{
x = abs(x);
float e = 1.5;
float d = pow(pow(x.x*.5, e) + pow(x.y*3., e), 1./e);
vec3 c = vec3(exp(-2.5*d))*sunColor*(.3+sin(x.y*iResolution.y*2.)*.01) * .5;
c += vec3(exp(-dot(d,d)))*sunColor*.05;
return c;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord / iResolution.xy;
time = iTime;
vec3 camPos = vec3(0);
z_offset = time*SPEED;
float introFade = min(time*.05, 1.0);
float camZoom = 3.0 - introFade*2.0;
tunnelShake = introFade;
camPos.xy += TunnelCenter(camPos.z-z_offset)*.5;
vec3 camTarget = vec3(0,0,5);
camTarget.xy += TunnelCenter(camTarget.z-z_offset)*.5;
//camTarget = vec3(3,0,5);
camTarget = mix(vec3(3,0,5), camTarget, introFade);
float camAngle = sin(time*.3) + time*.1;
vec3 camUp = vec3(sin(camAngle),cos(camAngle),0);
mat4 viewToWorld = LookAt(camPos, camTarget, camUp);
vec2 uv2 = (fragCoord - .5*iResolution.xy) / (iResolution.y * camZoom);
vec3 eyeDir = (viewToWorld * normalize(vec4(uv2, 1, 0))).xyz;
float t = 0.0;
vec3 p = camPos;
float iterationCount = 0.0;
for(int i = 0; i < 70; i++)
{
float dist = Map(p);
t += dist;
p += dist*eyeDir;
iterationCount++;
if(abs(dist) < .001) break;
}
vec3 normal = Normal(p);
vec3 refraction = refract(normalize(eyeDir), normal, 1.012);
vec3 reflection = reflect(-normalize(eyeDir), normal);
vec3 halfDir = normalize(sunDir - eyeDir);
vec2 circlePos = p.xy - TunnelCenter(p.z - z_offset);
float angle = atan(circlePos.y,circlePos.x);
float z = p.z - z_offset;
vec3 R = Fresnel(vec3(0.0), normal, -eyeDir);
//vec3 c = mix(vec3(2,1,1),vec3(1,1,2),sin(p.z*.1)*.5+.5);
vec3 c = vec3(1);
vec3 outColor = Background(p, refraction)*(vec3(1.0) - R)*c + Background(p, -reflection)*R;
float fft = texture( iChannel3, vec2(0.2,0.25) ).x;
fft = max(.0, fft - .5);
float tunnelDist = length(p - camPos);
outColor = outColor * exp(-tunnelDist*.05) + (1.0-exp(-tunnelDist*.05))*vec3(2,1,3)*(.1+fft*.6);
outColor += sqrt(iterationCount)*.005;
vec3 sunPos = (vec4(sunDir, 0) * viewToWorld).xyz;
vec2 sunUV = sunPos.xy / sunPos.z;
float vignette = uv.x * (1.0-uv.x) * uv.y * (1.0-uv.y) * 32. * 0.75 + 0.25;
outColor *= vignette;
vec3 sphereNormal;
float max_d;
int type;
float planet_t = IntersectPlanets(camPos, sunDir, sphereNormal, max_d, type);
float lensIntensity = clamp(1.0 - max_d*.02, 0.0, 1.0);
outColor += LensFlare(uv2 - sunUV) * lensIntensity;
outColor += LensFlare(uv2 + sunUV) * .4 * lensIntensity;
outColor = clamp(outColor, 0.0, 1.0);
outColor *= vec3(sqrt(min(time*.2, 1.0)));
fragColor = vec4( outColor, 1.0 );
}

View File

@@ -5,8 +5,6 @@
#define CEL rem(R) #define CEL rem(R)
#define LOWRES 320. #define LOWRES 320.
float rem(vec2 iR) float rem(vec2 iR)
{ {
float slices = floor(iR.y / LOWRES); float slices = floor(iR.y / LOWRES);

View File

@@ -0,0 +1,158 @@
float sun(vec2 uv, float battery)
{
float val = smoothstep(0.3, 0.29, length(uv));
float bloom = smoothstep(0.7, 0.0, length(uv));
float cut = 3.0 * sin((uv.y + iTime * 0.2 * (battery + 0.02)) * 100.0)
+ clamp(uv.y * 14.0 + 1.0, -6.0, 6.0);
cut = clamp(cut, 0.0, 1.0);
return clamp(val * cut, 0.0, 1.0) + bloom * 0.6;
}
float grid(vec2 uv, float battery)
{
vec2 size = vec2(uv.y, uv.y * uv.y * 0.2) * 0.01;
uv += vec2(0.0, iTime * 4.0 * (battery + 0.05));
uv = abs(fract(uv) - 0.5);
vec2 lines = smoothstep(size, vec2(0.0), uv);
lines += smoothstep(size * 5.0, vec2(0.0), uv) * 0.4 * battery;
return clamp(lines.x + lines.y, 0.0, 3.0);
}
float dot2(in vec2 v ) { return dot(v,v); }
float sdTrapezoid( in vec2 p, in float r1, float r2, float he )
{
vec2 k1 = vec2(r2,he);
vec2 k2 = vec2(r2-r1,2.0*he);
p.x = abs(p.x);
vec2 ca = vec2(p.x-min(p.x,(p.y<0.0)?r1:r2), abs(p.y)-he);
vec2 cb = p - k1 + k2*clamp( dot(k1-p,k2)/dot2(k2), 0.0, 1.0 );
float s = (cb.x<0.0 && ca.y<0.0) ? -1.0 : 1.0;
return s*sqrt( min(dot2(ca),dot2(cb)) );
}
float sdLine( in vec2 p, in vec2 a, in vec2 b )
{
vec2 pa = p-a, ba = b-a;
float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
return length( pa - ba*h );
}
float sdBox( in vec2 p, in vec2 b )
{
vec2 d = abs(p)-b;
return length(max(d,vec2(0))) + min(max(d.x,d.y),0.0);
}
float opSmoothUnion(float d1, float d2, float k){
float h = clamp(0.5 + 0.5 * (d2 - d1) /k,0.0,1.0);
return mix(d2, d1 , h) - k * h * ( 1.0 - h);
}
float sdCloud(in vec2 p, in vec2 a1, in vec2 b1, in vec2 a2, in vec2 b2, float w)
{
//float lineVal1 = smoothstep(w - 0.0001, w, sdLine(p, a1, b1));
float lineVal1 = sdLine(p, a1, b1);
float lineVal2 = sdLine(p, a2, b2);
vec2 ww = vec2(w*1.5, 0.0);
vec2 left = max(a1 + ww, a2 + ww);
vec2 right = min(b1 - ww, b2 - ww);
vec2 boxCenter = (left + right) * 0.5;
//float boxW = right.x - left.x;
float boxH = abs(a2.y - a1.y) * 0.5;
//float boxVal = sdBox(p - boxCenter, vec2(boxW, boxH)) + w;
float boxVal = sdBox(p - boxCenter, vec2(0.04, boxH)) + w;
float uniVal1 = opSmoothUnion(lineVal1, boxVal, 0.05);
float uniVal2 = opSmoothUnion(lineVal2, boxVal, 0.05);
return min(uniVal1, uniVal2);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = (2.0 * fragCoord.xy - iResolution.xy)/iResolution.y;
float battery = 1.0;
//if (iMouse.x > 1.0 && iMouse.y > 1.0) battery = iMouse.y / iResolution.y;
//else battery = 0.8;
//if (abs(uv.x) < (9.0 / 16.0))
{
// Grid
float fog = smoothstep(0.1, -0.02, abs(uv.y + 0.2));
vec3 col = vec3(0.0, 0.1, 0.2);
if (uv.y < -0.2)
{
uv.y = 3.0 / (abs(uv.y + 0.2) + 0.05);
uv.x *= uv.y * 1.0;
float gridVal = grid(uv, battery);
col = mix(col, vec3(1.0, 0.5, 1.0), gridVal);
}
else
{
float fujiD = min(uv.y * 4.5 - 0.5, 1.0);
uv.y -= battery * 1.1 - 0.51;
vec2 sunUV = uv;
vec2 fujiUV = uv;
// Sun
sunUV += vec2(0.75, 0.2);
//uv.y -= 1.1 - 0.51;
col = vec3(1.0, 0.2, 1.0);
float sunVal = sun(sunUV, battery);
col = mix(col, vec3(1.0, 0.4, 0.1), sunUV.y * 2.0 + 0.2);
col = mix(vec3(0.0, 0.0, 0.0), col, sunVal);
// fuji
float fujiVal = sdTrapezoid( uv + vec2(-0.75+sunUV.y * 0.0, 0.5), 1.75 + pow(uv.y * uv.y, 2.1), 0.2, 0.5);
float waveVal = uv.y + sin(uv.x * 20.0 + iTime * 2.0) * 0.05 + 0.2;
float wave_width = smoothstep(0.0,0.01,(waveVal));
// fuji color
col = mix( col, mix(vec3(0.0, 0.0, 0.25), vec3(1.0, 0.0, 0.5), fujiD), step(fujiVal, 0.0));
// fuji top snow
col = mix( col, vec3(1.0, 0.5, 1.0), wave_width * step(fujiVal, 0.0));
// fuji outline
col = mix( col, vec3(1.0, 0.5, 1.0), 1.0-smoothstep(0.0,0.01,abs(fujiVal)) );
//col = mix( col, vec3(1.0, 1.0, 1.0), 1.0-smoothstep(0.03,0.04,abs(fujiVal)) );
//col = vec3(1.0, 1.0, 1.0) *(1.0-smoothstep(0.03,0.04,abs(fujiVal)));
// horizon color
col += mix( col, mix(vec3(1.0, 0.12, 0.8), vec3(0.0, 0.0, 0.2), clamp(uv.y * 3.5 + 3.0, 0.0, 1.0)), step(0.0, fujiVal) );
// cloud
vec2 cloudUV = uv;
cloudUV.x = mod(cloudUV.x + iTime * 0.1, 4.0) - 2.0;
float cloudTime = iTime * 0.5;
float cloudY = -0.5;
float cloudVal1 = sdCloud(cloudUV,
vec2(0.1 + sin(cloudTime + 140.5)*0.1,cloudY),
vec2(1.05 + cos(cloudTime * 0.9 - 36.56) * 0.1, cloudY),
vec2(0.2 + cos(cloudTime * 0.867 + 387.165) * 0.1,0.25+cloudY),
vec2(0.5 + cos(cloudTime * 0.9675 - 15.162) * 0.09, 0.25+cloudY), 0.075);
cloudY = -0.6;
float cloudVal2 = sdCloud(cloudUV,
vec2(-0.9 + cos(cloudTime * 1.02 + 541.75) * 0.1,cloudY),
vec2(-0.5 + sin(cloudTime * 0.9 - 316.56) * 0.1, cloudY),
vec2(-1.5 + cos(cloudTime * 0.867 + 37.165) * 0.1,0.25+cloudY),
vec2(-0.6 + sin(cloudTime * 0.9675 + 665.162) * 0.09, 0.25+cloudY), 0.075);
float cloudVal = min(cloudVal1, cloudVal2);
//col = mix(col, vec3(1.0,1.0,0.0), smoothstep(0.0751, 0.075, cloudVal));
col = mix(col, vec3(0.0, 0.0, 0.2), 1.0 - smoothstep(0.075 - 0.0001, 0.075, cloudVal));
col += vec3(1.0, 1.0, 1.0)*(1.0 - smoothstep(0.0,0.01,abs(cloudVal - 0.075)));
}
col += fog * fog * fog;
col = mix(vec3(col.r, col.r, col.r) * 0.5, col, battery * 0.7);
fragColor = vec4(col,1.0);
}
//else fragColor = vec4(0.0);
}

View File

@@ -0,0 +1,102 @@
precision highp float;
float gTime = 0.;
const float REPEAT = 5.0;
// 回転行列
mat2 rot(float a) {
float c = cos(a), s = sin(a);
return mat2(c,s,-s,c);
}
float sdBox( vec3 p, vec3 b )
{
vec3 q = abs(p) - b;
return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
}
float box(vec3 pos, float scale) {
pos *= scale;
float base = sdBox(pos, vec3(.4,.4,.1)) /1.5;
pos.xy *= 5.;
pos.y -= 3.5;
pos.xy *= rot(.75);
float result = -base;
return result;
}
float box_set(vec3 pos, float iTime) {
vec3 pos_origin = pos;
pos = pos_origin;
pos .y += sin(gTime * 0.4) * 2.5;
pos.xy *= rot(.8);
float box1 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);
pos = pos_origin;
pos .y -=sin(gTime * 0.4) * 2.5;
pos.xy *= rot(.8);
float box2 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);
pos = pos_origin;
pos .x +=sin(gTime * 0.4) * 2.5;
pos.xy *= rot(.8);
float box3 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);
pos = pos_origin;
pos .x -=sin(gTime * 0.4) * 2.5;
pos.xy *= rot(.8);
float box4 = box(pos,2. - abs(sin(gTime * 0.4)) * 1.5);
pos = pos_origin;
pos.xy *= rot(.8);
float box5 = box(pos,.5) * 6.;
pos = pos_origin;
float box6 = box(pos,.5) * 6.;
float result = max(max(max(max(max(box1,box2),box3),box4),box5),box6);
return result;
}
float map(vec3 pos, float iTime) {
vec3 pos_origin = pos;
float box_set1 = box_set(pos, iTime);
return box_set1;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 p = (fragCoord.xy * 2. - iResolution.xy) / min(iResolution.x, iResolution.y);
vec3 ro = vec3(0., -0.2 ,iTime * 4.);
vec3 ray = normalize(vec3(p, 1.5));
ray.xy = ray.xy * rot(sin(iTime * .03) * 5.);
ray.yz = ray.yz * rot(sin(iTime * .05) * .2);
float t = 0.1;
vec3 col = vec3(0.);
float ac = 0.0;
for (int i = 0; i < 99; i++){
vec3 pos = ro + ray * t;
pos = mod(pos-2., 4.) -2.;
gTime = iTime -float(i) * 0.01;
float d = map(pos, iTime);
d = max(abs(d), 0.01);
ac += exp(-d*23.);
t += d* 0.55;
}
col = vec3(ac * 0.02);
col +=vec3(0.,0.2 * abs(sin(iTime)),0.5 + sin(iTime) * 0.2);
fragColor = vec4(col ,1.0 - t * (0.02 + 0.02 * sin (iTime)));
}
/** SHADERDATA
{
"title": "Octgrams",
"description": "Lorem ipsum dolor",
"model": "person"
}
*/

View File

@@ -0,0 +1,41 @@
Stone Man
Perlin Noise
EGA
Color Invert
Posterize
Video Wall
Fake Thermal
Mirror (Right)
Mirror (Top)
Mirror (Down)
Mirror (Left)
Mirror (Quad)
ASCII
Aberrating Aberrations
Oil Painting
Old Memory
Italic
Blur (Soft)
Blur (Scatter)
Blur (Chroma)
Blur (Radial)
Circular Pixels
Solarize
Color Reduction
Melting Snow
Video Bubble
Quadtree
Randomized Transitions (x2)
Rainbow Filter
Pixelation
Gameboy
Brannan Filter
Sepia
Water Ripples
Ripple Distortion
Night Vision
Median Filter
Nearest Neighbor
Desaturate
Rain Drops
Gaussian Blur