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(269.5, 183.3))) * 43758.5453);
56 vec2 u = f * f * (3.0 - 2.0 * f);
57 return mix(mix(
hash21(i),
hash21(i + vec2(1.0, 0.0)), u.x),
58 mix(
hash21(i + vec2(0.0, 1.0)),
hash21(i + vec2(1.0)), u.x), u.y);
68 float amplitude = 0.52;
69 mat2
rotation = mat2(0.58, -0.82, 0.82, 0.58);
70 for (
int i = 0; i < 6; ++i) {
71 value += abs(
noise21(p) * 2.0 - 1.0) * amplitude;
72 p =
rotation * p * 2.07 + vec2(3.13, -2.41);
87 return mat2(c, -s, s, c) * p;
96 return 1.0 - abs(mod(uv, 2.0) - 1.0);
106 vec3 wavelengths = vec3(1.0, 0.78, 0.58);
107 vec3 bands = 0.5 + 0.5 * cos(
TAU * (phase + thickness * wavelengths) +
108 vec3(0.0, 0.9, 1.7));
109 return pow(bands, vec3(1.15));
119 float radius = max(length(p), 0.018);
120 float angle = atan(p.y, p.x);
121 float tightening = log(radius + 0.035) * (7.8 +
amp_mid * 0.9);
122 float phase = angle * 6.0 + tightening - t * 1.8;
124 vec2 q =
rotate2(p, -log(radius + 0.05) * 0.55 + t * 0.08);
127 q += (
warp - 0.48) * 0.19;
128 float filaments =
turbulentFbm(q * 7.3 + vec2(t * 0.14, -t * 0.09));
129 float arms = sin(phase + filaments * 5.5) * 0.31;
130 float wake = sin(radius * 58.0 - angle * 3.0 - t * 5.1 +
warp.x * 4.0) * 0.1;
131 float cross = cos(q.x * 36.0 + q.y * 19.0 + t * 3.8) * 0.055;
132 float funnel = -exp(-radius * 6.5) * 0.62;
133 return arms + wake + cross + filaments * 0.56 + funnel;
147 vec2 gradient = vec2(right - left, up - down) / (2.0 * e);
148 return normalize(vec3(-gradient * 0.105, 1.0));
160 vec2 direction = normalize(tangent + normalFlow * 0.7 + vec2(0.0001));
161 vec2 across = vec2(-direction.y, direction.x);
162 vec3 source = texture(samp,
mirrorUV(uv)).rgb * 0.38;
163 source += texture(samp,
mirrorUV(uv + direction * 0.003)).rgb * 0.2;
164 source += texture(samp,
mirrorUV(uv - direction * 0.003)).rgb * 0.2;
165 source += texture(samp,
mirrorUV(uv + across * 0.0045)).rgb * 0.11;
166 source += texture(samp,
mirrorUV(uv - across * 0.0045)).rgb * 0.11;
167 return vec3(texture(samp,
mirrorUV(uv + normalFlow * split + across * split)).r,
169 texture(samp,
mirrorUV(uv - normalFlow * split - across * split)).b);
182 vec3 halfVector = normalize(v + l);
183 vec3 bitangent = normalize(cross(
n, tangent));
184 float th = dot(tangent, halfVector) / max(roughness, 0.04);
185 float bh = dot(bitangent, halfVector) / max(roughness * 2.4, 0.04);
186 float nh = max(dot(
n, halfVector), 0.0);
187 return exp(-(th * th + bh * bh) / max(nh * nh, 0.015)) /
188 max(4.0 *
PI * roughness * roughness, 0.01);
201 vec3 view = normalize(vec3(-p * 0.13, 1.45));
202 vec3 light0 = normalize(vec3(-0.63, 0.51, 0.69));
203 vec3 light1 = normalize(vec3(0.72, 0.24, 0.65));
204 vec3 light2 = normalize(vec3(0.04, -0.76, 0.65));
205 vec3 tangent = normalize(vec3(-
n.y,
n.x, 0.08));
206 float nv = max(dot(
n, view), 0.0);
207 vec3 f0 = mix(vec3(0.67), base, 0.5);
208 vec3 fresnel = f0 + (1.0 - f0) * pow(1.0 - nv, 5.0);
211 vec3 result = base * 0.04;
212 result += base * max(dot(
n, light0), 0.0) * 0.07;
214 vec3(1.0, 0.74, 0.5) * 0.72;
216 vec3(0.28, 0.58, 1.0) * 0.62;
218 vec3(0.74, 0.24, 1.0) * 0.38;
220 vec3 reflected = reflect(-view,
n);
221 vec3 environment = mix(vec3(0.02, 0.03, 0.062),
film,
222 smoothstep(-0.6, 0.82, reflected.z));
223 return result + environment * fresnel * 1.45;
232 value = max(value, 0.0);
233 return 1.0 - exp(-value * (1.06 + value * 0.11));
241 vec2 p = (tc - 0.5) * vec2(aspect, 1.0);
243 float radius = max(length(p), 0.018);
244 float angle = atan(p.y, p.x);
245 float phase = angle * 6.0 + log(radius + 0.035) * 7.8 -
time_f * 1.8;
249 vec2 radial = p / radius;
250 vec2 tangent = vec2(-radial.y, radial.x);
251 float core = exp(-radius * 3.2);
252 vec2 spiralFlow = tangent * (0.022 + core * 0.058 +
amp_low * 0.024);
253 spiralFlow -= radial * (0.006 + core * 0.018);
255 vec2 uv =
mirrorUV(tc + spiralFlow / vec2(aspect, 1.0));
257 float split = 0.0018 +
amp_high * 0.0065 + core * 0.0015;
259 float luminance = dot(source, vec3(0.299, 0.587, 0.114));
260 vec3
alloy = mix(vec3(
luminance) * vec3(0.78, 0.86, 0.98), source, 0.4);
265 float filament = pow(0.5 + 0.5 * sin(phase + height * 8.0), 15.0);
268 result = mix(result, result * (0.58 + source * 1.08), 0.22);
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
vec2 mirrorUV(vec2 uv)
Evaluates mirrorUV for this shader effect.
float hash21(vec2 p)
Evaluates hash21 for this shader effect.
float n(vec2 p)
Evaluates n for this shader effect.
vec2 warp(vec2 p, vec2 o, float k)
Evaluates warp for this shader effect.
float luminance(vec3 c)
Evaluates luminance for this shader effect.
float noise21(vec2 p)
Evaluates noise21 for this shader effect.
vec3 film(float x, float v)
Evaluates film 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 refractedTexture(vec2 uv, vec2 direction, float amount)
Evaluates refractedTexture for this shader effect.
float whirlpoolHeight(vec2 p)
Evaluates whirlpoolHeight for this shader effect.
float anisotropicSpecular(vec3 n, vec3 v, vec3 l, vec3 tangent, float roughness)
Evaluates anisotropicSpecular for this shader effect.
vec3 whirlpoolNormal(vec2 p, float e)
Evaluates whirlpoolNormal for this shader effect.
float turbulentFbm(vec2 p)
Evaluates turbulentFbm for this shader effect.
vec3 iridescentMetal(vec3 base, vec3 n, vec2 p, float thickness, float roughness)
Evaluates iridescentMetal for this shader effect.
vec3 interference(float phase, float thickness)
Evaluates interference for this shader effect.
mat2 rotation(float angle)
Evaluates rotation for this shader effect.