7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
13 vec4 custom_uniforms[16];
17#define amp_high ext.audio_bands.z
18#define amp_low ext.audio_bands.x
19#define amp_mid ext.audio_bands.y
20#define amp_peak ext.u2.w
21#define amp_smooth ext.u3.w
22#define iResolution ext.u0.zw
23#define time_f ext.u2.y
26layout(location = 0) out vec4 color;
27layout(set = 0, binding = 0) uniform sampler2D samp;
36const
float PI = 3.14159265359;
37const
float TAU = 6.28318530718;
45 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
56 f = f * f * (3.0 - 2.0 * f);
57 return mix(mix(
hash21(i),
hash21(i + vec2(1.0, 0.0)), f.x),
58 mix(
hash21(i + vec2(0.0, 1.0)),
hash21(i + vec2(1.0)), f.x), f.y);
68 float amplitude = 0.52;
69 mat2 basis = mat2(0.707, -0.707, 0.707, 0.707);
70 for (
int i = 0; i < 6; ++i) {
71 float ridge = 1.0 - abs(
valueNoise(p) * 2.0 - 1.0);
72 sum += ridge * ridge * amplitude;
73 p = basis * p * 2.08 + vec2(-3.7, 1.9);
88 return mat2(c, -s, s, c) * p;
97 return 1.0 - abs(mod(uv, 2.0) - 1.0);
106 vec3
wave = vec3(1.0, 0.79, 0.58);
107 return 0.5 + 0.5 * cos(
TAU * (phase *
wave + vec3(0.00, 0.17, 0.39)));
117 float r = max(length(p), 0.018);
118 float a = atan(p.y, p.x);
119 float logarithmic = log(r + 0.045);
120 float chamberPhase = a * 7.0 - logarithmic * 15.0 - t * 1.75;
121 chamberPhase += sin(a * 2.0 + t * 0.35) *
amp_mid * 0.85;
122 float ribs = cos(chamberPhase) * exp(-r * 0.34);
125 float angularCurl = sin(a * 3.0 - t * 0.18) * 0.22;
126 vec2 curled =
rotate2(p, angularCurl - logarithmic * 0.7 + t * 0.07);
127 float liquid =
ridgedFbm(curled * 4.8 + vec2(t * 0.11, -t * 0.08));
128 float rings = sin(r * 69.0 - a * 2.0 - t * 4.4 + liquid * 3.0);
129 float membrane = cos(a * 2.0 + r * 18.0 + sin(a * 5.0 - t) * 1.4);
130 float centralPool = exp(-r * 8.0) * sin(a * 4.0 - t * 3.0);
131 return ribs * 0.32 + rings * 0.08 + membrane * 0.11 + liquid * 0.58 + centralPool * 0.32;
144 vec2 gradient = vec2(right - center, up - center) / e;
145 return normalize(vec3(-gradient * 0.12, 1.0));
157 vec2 axis = normalize(
curl + normalFlow * 0.5 + vec2(0.0001));
158 vec2 across = vec2(-axis.y, axis.x);
160 vec3 axialBlur = texture(samp, center).rgb * 0.42;
161 axialBlur += texture(samp,
mirrorUV(uv + axis * 0.0045)).rgb * 0.2;
162 axialBlur += texture(samp,
mirrorUV(uv - axis * 0.0045)).rgb * 0.2;
163 axialBlur += texture(samp,
mirrorUV(uv + across * 0.003)).rgb * 0.09;
164 axialBlur += texture(samp,
mirrorUV(uv - across * 0.003)).rgb * 0.09;
165 return vec3(texture(samp,
mirrorUV(uv + across * dispersion)).r,
167 texture(samp,
mirrorUV(uv - across * dispersion)).b);
176float ggx(
float nh,
float roughness) {
177 float a = roughness * roughness;
179 float denominator = nh * nh * (a2 - 1.0) + 1.0;
180 return a2 / max(
PI * denominator * denominator, 0.0001);
193 vec3 view = normalize(vec3(-p * 0.12, 1.45));
194 vec3 light0 = normalize(vec3(-0.72, 0.38, 0.68));
195 vec3 light1 = normalize(vec3(0.56, 0.66, 0.51));
196 vec3 light2 = normalize(vec3(0.25, -0.72, 0.65));
197 vec3 lights[3] = vec3[3](light0, light1, light2);
198 vec3 colors[3] = vec3[3](vec3(1.0, 0.58, 0.28),
199 vec3(0.30, 0.62, 1.0),
200 vec3(0.72, 0.25, 1.0));
201 vec3 f0 = mix(vec3(0.68), base, 0.52);
202 vec3 result = base * 0.04;
204 for (
int i = 0; i < 3; ++i) {
205 vec3 halfVector = normalize(view + lights[i]);
206 float nl = max(dot(
n, lights[i]), 0.0);
207 float nh = max(dot(
n, halfVector), 0.0);
208 float vh = max(dot(view, halfVector), 0.0);
209 vec3 fresnel = f0 + (1.0 - f0) * pow(1.0 - vh, 5.0);
210 result += colors[i] * nl *
211 (base * 0.065 + fresnel *
ggx(nh, roughness) * 0.2);
214 float nv = max(dot(
n, view), 0.0);
215 vec3 reflection = reflect(-view,
n);
216 vec3 environment = mix(vec3(0.025, 0.035, 0.065),
217 thinFilm(sin(phase) * 0.18 + reflection.y * 0.14 +
time_f * 0.013),
218 smoothstep(-0.65, 0.75, reflection.z));
219 vec3 fresnel = f0 + (1.0 - f0) * pow(1.0 - nv, 5.0);
220 return result + environment * fresnel * 1.5;
229 value = max(value, 0.0);
230 return value / (1.0 + value * 0.72);
238 vec2 p = (tc - 0.5) * vec2(aspect, 1.0);
240 float radius = max(length(p), 0.018);
241 float angle = atan(p.y, p.x);
242 float phase = angle * 7.0 - log(radius + 0.045) * 15.0 -
time_f * 1.75;
246 vec2 radial = p / radius;
247 vec2 tangent = vec2(-radial.y, radial.x);
248 float curlStrength = 0.018 + 0.045 * exp(-radius * 2.2) +
amp_low * 0.022;
249 vec2
curl = tangent * curlStrength;
250 curl += radial * sin(phase + height * 2.0) * 0.009;
251 vec2 normalFlow =
n.xy * (0.018 +
amp_smooth * 0.014);
252 vec2 uv =
mirrorUV(tc + (
curl + normalFlow) / vec2(aspect, 1.0));
254 float dispersion = 0.0015 +
amp_high * 0.006 + abs(sin(phase)) * 0.0015;
256 float luminance = dot(source, vec3(0.299, 0.587, 0.114));
257 vec3
chrome = mix(vec3(
luminance) * vec3(0.83, 0.89, 1.0), source, 0.38);
261 float ribHighlight = pow(0.5 + 0.5 * cos(phase), 18.0);
262 result +=
thinFilm(sin(phase) * 0.15 + height * 0.09) * ribHighlight *
264 result = mix(result, result * (0.55 + source * 1.1), 0.2);
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
vec3 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
vec3 chrome(float t)
Evaluates chrome for this shader effect.
vec2 mirrorUV(vec2 uv)
Evaluates mirrorUV for this shader effect.
float valueNoise(vec2 p)
Evaluates valueNoise for this shader effect.
float hash21(vec2 p)
Evaluates hash21 for this shader effect.
float n(vec2 p)
Evaluates n for this shader effect.
float luminance(vec3 c)
Evaluates luminance for this shader effect.
vec2 curl(vec2 p, float t)
Evaluates curl for this shader effect.
vec2 rotate2(vec2 p, float angle)
Evaluates rotate2 for this shader effect.
vec3 toneMap(vec3 value)
Evaluates toneMap for this shader effect.
vec3 chromeLighting(vec3 base, vec3 n, vec2 p, float phase, float roughness)
Evaluates chromeLighting for this shader effect.
float ridgedFbm(vec2 p)
Evaluates ridgedFbm for this shader effect.
vec3 shellNormal(vec2 p, float e)
Evaluates shellNormal for this shader effect.
float shellHeight(vec2 p)
Evaluates shellHeight for this shader effect.
vec3 thinFilm(float phase)
Evaluates thinFilm for this shader effect.
float ggx(float nh, float roughness)
Evaluates ggx for this shader effect.
vec3 textureAlongShell(vec2 uv, vec2 curl, vec2 normalFlow, float dispersion)
Evaluates textureAlongShell for this shader effect.