#version 410 core uniform float fGlobalTime; // in seconds uniform vec2 v2Resolution; // viewport resolution (in pixels) uniform float fFrameTime; // duration of the last frame, in seconds uniform sampler1D texFFT; // towards 0.0 is bass / lower freq, towards 1.0 is higher / treble freq uniform sampler1D texFFTSmoothed; // this one has longer falloff and less harsh transients uniform sampler1D texFFTIntegrated; // this is continually increasing uniform sampler2D texPreviousFrame; // screenshot of the previous frame uniform sampler2D texChecker; uniform sampler2D texNoise; uniform sampler2D texTex1; uniform sampler2D texTex2; uniform sampler2D texTex3; uniform sampler2D texTex4; uniform float md1; layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything #define STEPS 128.0 #define MDIST 128.0 #define pi 3.1415926535 #define rot(a) mat2(cos(a),sin(a),-sin(a),cos(a)) #define sat(a) clamp(a,0.,1.) #define pmod(p,x) (mod(p,x)-0.5*(x)) float psin(float x, float b){ float xx = floor(b*x)/b; return sin(xx)+(sin(floor(b*x+1.0)/b)-sin(xx))*mod(b*x,1.0); } vec2 vor(vec2 m, vec3 p, vec3 s){ float scl = 0.2; vec3 c = round(scl*p+s); c+=sin(fract(72985*sin(dot(c,c.yzx+33.3)))*6.+fGlobalTime*3)*0.3; c*=(1./scl); float v = length(c - p); return vMDIST){ dO = MDIST; break; } } vec3 bg = mix(vec3(0.5,0.4,0.85),vec3(0.45,0.45,0.9),clamp(rd.y*5,-1,1)); if(hit){ vec3 n = norm(p); vec3 ld = normalize(vec3(20,45,0)-p); vec3 rr = reflect(rd,n); float diff = max(0,dot(n,ld)); float amb = dot(n,ld)*0.5+0.5; float spec = pow(max(0.,dot(rr,ld)),40); float fres = pow(max(0.7+dot(rd,n),0),2.0); vec3 al = vec3(0.2,0.25,0.75); #define AO(a,n,p) smoothstep(-a,a,map(p+n*a).x) float ao = AO(0.3,n,p)*AO(0.5,n,p)*AO(0.9,n,p); float sss = 0.; for(float i = 0.; i<20.; i++){ float dist = i*0.09; sss+=smoothstep(0.,1.,map(p+ld*dist).x/dist)*0.033; } if(d.y==2.0) al*=2; col = vec3(1.0-shad); col = al*mix(vec3(0.3,0,0.3),vec3(1),mix(diff,amb,0.25)); col+=spec*0.3*bg; col+=sss*0.3; col*=mix(ao,1.0,0.3); col = pow(col,vec3(0.7)); //WAVEY COLOR sss = 0.; float ssmag = 1.; ld = normalize(vec3(0,100,0)-p); if(d.y==3.0){ld = normalize(vec3(p.x,0,p.z)); ssmag = 1.5; } spec = pow(max(.0,dot(rr,ld)),20.0); vec3 wcol = vec3(0); al = vec3(0.2,0.6,1); for(float i = 0.; i<20.; i++){ float dist = i*0.3; sss+=smoothstep(0.,1.,map(p+ld*dist).x/dist)*0.06*ssmag; } wcol = mix((1.0-shad),1.,0.5)*vec3(sss)*al; wcol+=spec*0.3; col = mix(col,wcol,wavey); } col = mix(col,bg,pow(dO/MDIST,2.5)); out_color = vec4(col,1); }