43mat3
rotX(
float a){
float s=sin(a),c=cos(a);
return mat3(1,0,0, 0,c,-s, 0,s,c);}
49mat3
rotY(
float a){
float s=sin(a),c=cos(a);
return mat3(c,0,s, 0,1,0, -s,0,c);}
55mat3
rotZ(
float a){
float s=sin(a),c=cos(a);
return mat3(c,-s,0, s,c,0, 0,0,1);}
75 vec2 u = f * f * (3.0 - 2.0 * f);
76 return mix(mix(
hash(i + vec2(0.0, 0.0)),
hash(i + vec2(1.0, 0.0)), u.x),
77 mix(
hash(i + vec2(0.0, 1.0)),
hash(i + vec2(1.0, 1.0)), u.x), u.y);
103 vec3 a = vec3(0.5, 0.5, 0.5);
104 vec3 b = vec3(0.5, 0.5, 0.5);
105 vec3 c = vec3(1.0, 1.0, 1.0);
106 vec3 d = vec3(0.00, 0.33, 0.67);
107 return a + b * cos(6.28318 * (c * t + d));
119vec3
renderLayer(vec2 uv,
float t,
float bassStr,
float trebleStr) {
121 vec2 ar = vec2(aspect, 1.0);
122 vec2 center = vec2(0.5);
129 vec2 p = (uv - center) * ar;
133 float len = length(p);
134 float twistBase = 3.0 + (bassStr * 4.0);
135 float angle = atan(p.y, p.x) + twistBase / (len + 0.1) + t * (0.5 + bassStr);
136 vec2 twistedP = vec2(cos(angle), sin(angle)) * len;
140 float rippleWavelength = 8.0;
141 float rippleSpeed = 4.0 + (trebleStr * 10.0);
142 float noiseVal =
fbm(twistedP * 5.0 + t);
144 float rippleX = sin(twistedP.x * rippleWavelength + t * rippleSpeed + noiseVal * 2.0);
145 float rippleY = cos(twistedP.y * rippleWavelength + t * rippleSpeed - noiseVal * 2.0);
148 float rippleAmp = 0.05 + 0.05 * noiseVal * (1.0 + trebleStr * 2.0);
149 vec2 rippledP = twistedP + vec2(rippleX, rippleY) * rippleAmp;
152 vec3 p3 = vec3(rippledP, 1.0);
154 float shake = bassStr * 0.1 * sin(t * 20.0);
155 mat3
R =
rotX(t * 0.2 + shake) *
rotY(t * 0.15) *
rotZ(t * 0.1);
157 float zScale = 1.0 / (1.0 + r.z * 0.5);
158 vec2 projUV = r.xy * zScale;
161 vec2 tiledUV = 1.0 - abs(1.0 - 2.0 * (projUV + 0.5));
162 tiledUV = tiledUV - floor(tiledUV);
166 float aberrationStr = 0.01 + (0.04 + bassStr * 0.05) * (1.0 / (len + 0.5));
167 vec2 offset = vec2(aberrationStr, 0.0);
169 vec3 texR = texture(samp, clamp(tiledUV - offset, 0.0, 1.0)).rgb;
170 vec3 texG = texture(samp, clamp(tiledUV, 0.0, 1.0)).rgb;
171 vec3 texB = texture(samp, clamp(tiledUV + offset, 0.0, 1.0)).rgb;
172 vec3 layerColor = vec3(texR.r, texG.g, texB.b);
175 float glowMask = smoothstep(0.6, 0.95, abs(rippleX * rippleY));
179 return mix(layerColor, layerColor +
palette, glowMask * (0.8 + bassStr * 0.5));
189 float simBass = (
amp <= 0.001) ? abs(sin(
time_f * 4.0)) * 0.5 :
amp;
190 float simTreble = (
uamp <= 0.001) ? abs(cos(
time_f * 8.0)) * 0.5 :
uamp;
201 vec3 finalColor = col0 + (col1 * 0.5) + (col2 * 0.25);
202 finalColor = finalColor / (1.0 + finalColor * 0.4);
204 color = vec4(finalColor, 1.0);
vec3 renderLayer(vec2 uv, float t, float bassStr, float trebleStr)
Evaluates renderLayer for this shader effect.