Initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
vec4 applyBrightness(vec4 color, float factor) {
|
||||
return vec4(mix(vec3(0.5), color.rgb, 1.0 + factor), color.a);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
vec2 applyBulge(vec2 uv, float strength) {
|
||||
if (strength == 0.0) return uv;
|
||||
vec2 center = vec2(0.5, 0.5);
|
||||
vec2 dir = uv - center;
|
||||
float dist = length(dir);
|
||||
float factor = pow(dist, 1.0 + strength * 0.5);
|
||||
return center + dir * (factor / dist);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Requires rgb2hsv and hsv2rgb
|
||||
vec4 applyHueShift(vec4 color, float degrees) {
|
||||
if (degrees == 0.0) return color;
|
||||
vec3 hsv = rgb2hsv(color.rgb);
|
||||
hsv.x = fract(hsv.x + degrees / 360.0);
|
||||
return vec4(hsv2rgb(hsv), color.a);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
vec2 applyMosaic(vec2 uv, float strength) {
|
||||
float absStrength = abs(strength);
|
||||
if (absStrength < 5.0) return uv;
|
||||
|
||||
// Map strength to grid size: 5-14 → 2, 15-24 → 3, etc.
|
||||
int level = int((absStrength - 5.0) / 10.0) + 2; // Start at 2×2
|
||||
int scale = clamp(level, 2, 32); // Safety cap
|
||||
|
||||
// Compute which cell we're in
|
||||
vec2 cellCoord = floor(uv * scale);
|
||||
|
||||
// Sample from center of that cell in low-res space
|
||||
vec2 samplePoint = (cellCoord + 0.5) / scale;
|
||||
|
||||
return samplePoint;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
vec4 applyOpacity(vec4 color, float opacity) {
|
||||
color.a *= opacity;
|
||||
return color;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
vec2 applyPixelation(vec2 uv, float strength) {
|
||||
if (strength <= 0.0) return uv;
|
||||
ivec2 size = textureSize(u_Texture, 0);
|
||||
vec2 invRes = 1.0 / vec2(size);
|
||||
vec2 cell = floor(uv / invRes / (strength + 1.0));
|
||||
return cell * invRes * (strength + 1.0) + invRes * 0.5;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
vec2 applyWhirl(vec2 uv, float strength) {
|
||||
if (strength == 0.0) return uv;
|
||||
vec2 center = vec2(0.5, 0.5);
|
||||
vec2 dir = uv - center;
|
||||
float dist = length(dir);
|
||||
float maxDist = length(vec2(0.5));
|
||||
float angle = strength * (dist / maxDist) * 3.14159265;
|
||||
mat2 rot = mat2(cos(angle), -sin(angle), sin(angle), cos(angle));
|
||||
return center + rot * dir;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
vec3 rgb2hsv(vec3 c) {
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 1.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + 1e-10)), d / (q.x + 1e-10), q.x);
|
||||
}
|
||||
Reference in New Issue
Block a user