7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
13 vec4 custom_uniforms[16];
18#define history_head int(ext.u3.x)
19#define iFrame int(ext.u2.x)
25layout(local_size_x = 16, local_size_y = 16) in;
26layout(set = 0, binding = 5, rgba8) writeonly uniform image2D outputImage;
27layout(set = 0, binding = 0) uniform sampler2D samp;
41 return clamp(p, ivec2(0), size - ivec2(1));
51 return (vec2(
clampPos(p, size)) + 0.5) / vec2(size);
61 return textureLod(samp,
pixelUv(p, size), 0.0).rgb;
70 int fib[10] =
int[](2, 3, 5, 8, 13, 21, 34, 55, 89, 144);
72 int idx = int(clamp(
alpha, 0.0, 1.0) * 9.0);
81#ifndef USE_HISTORY_TEXTURE_ARRAY
82#define USE_HISTORY_TEXTURE_ARRAY 1
85#if USE_HISTORY_TEXTURE_ARRAY
86layout(set = 0, binding = 2) uniform sampler2DArray history;
89uniform sampler2D textures[
SIZE];
101 index = clamp(index, 0,
SIZE - 1);
102#if USE_HISTORY_TEXTURE_ARRAY
104 return textureLod(history, vec3(uv,
float(layer)), 0.0).rgb;
106 return textureLod(textures[index], uv, 0.0).rgb;
120 vec2 centeredUv = uv - 0.5;
121 float r = length(centeredUv);
122 float angle = atan(centeredUv.y, centeredUv.x);
130 float phi = 1.61803398875;
131 float goldenAngle = 2.0 * 3.14159 / (phi * phi);
135 float targetAngle = (r *
frequency * 20.0) + angle - (time * 0.5);
138 float spiralMask = mod(targetAngle, goldenAngle);
141 float thickness = 0.05 +
alpha * 0.1;
142 spiralMask = smoothstep(thickness, 0.0, abs(spiralMask - thickness * 0.5));
145 spiralMask *= smoothstep(0.5, 0.4, r) * smoothstep(0.0, 0.1, r);
159 float time = float(
iFrame) * 0.01;
166 int blocksPerRow = (size.x + block - 1) / block;
167 int blockIndex = (p.y / block) * blocksPerRow + p.x / block;
168 int maximum =
SIZE - 1;
169 int cycle = max(maximum * 2, 1);
170 int stepIndex = (
iFrame + blockIndex) % cycle;
171 int textureIndex = stepIndex <= maximum ? stepIndex : cycle - stepIndex;
180 vec3 spiralColor1 = vec3(0.0, 0.2, 0.4);
181 vec3 spiralColor2 = vec3(0.7, 0.7, 0.8);
182 vec3 currentSpiralColor = mix(spiralColor1, spiralColor2, sin(time +
frequency * 0.1) * 0.5 + 0.5);
188 vec3 colorEffect = mix(sourceCol, currentSpiralColor * 1.5, spiral);
191 float pulse = sin(time * 2.0 + length(uv - 0.5) *
frequency * 0.5) * 0.5 + 0.5;
192 colorEffect *= (1.0 +
alpha * pulse);
195 return mix(colorEffect, historyCol, 0.5);
202 ivec2 p = ivec2(gl_GlobalInvocationID.xy);
203 ivec2 size = imageSize(outputImage);
204 if (any(greaterThanEqual(p, size)))
211 imageStore(outputImage, p, vec4(clamp(color, 0.0, 1.0), 1.0));
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
ivec2 clampPos(ivec2 p, ivec2 size)
Evaluates clampPos for this shader effect.
int effectBlockSize()
Evaluates effectBlockSize for this shader effect.
vec2 pixelUv(ivec2 p, ivec2 size)
Evaluates pixelUv for this shader effect.
vec3 sampleSource(ivec2 p, ivec2 size)
Evaluates sampleSource for this shader effect.
float sampleHistory(int index, float frequency)
Evaluates sampleHistory for this shader effect.
float getSpiral(vec2 uv, float time, float frequency)
Evaluates getSpiral for this shader effect.
vec3 creativeSpiralHistory(ivec2 p, ivec2 size)
Evaluates creativeSpiralHistory for this shader effect.