core 0.1-beta
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
vec4 applyBrightness(vec4 color, float factor) {
|
||||
return vec4(mix(vec3(0.5), color.rgb, 1.0 + factor), color.a);
|
||||
return vec4(color.rgb + vec3(factor), color.a);
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
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);
|
||||
float normalized = max(0.0, (strength + 100.0) / 100.0);
|
||||
if (normalized == 0.0) return uv;
|
||||
|
||||
const vec2 center = vec2(0.5, 0.5);
|
||||
|
||||
vec2 dir = (uv - center) / center;
|
||||
float dirLength = length(dir);
|
||||
float r = pow(min(dirLength, 1.0), normalized) * max(1.0, dirLength);
|
||||
vec2 unit = dir / dirLength;
|
||||
|
||||
return center + r * unit * center;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Requires rgb2hsv and hsv2rgb
|
||||
vec4 applyHueShift(vec4 color, float degrees) {
|
||||
if (degrees == 0.0) return color;
|
||||
vec4 applyHueShift(vec4 color, float deg) {
|
||||
if (deg == 0.0) return color;
|
||||
vec3 hsv = rgb2hsv(color.rgb);
|
||||
hsv.x = fract(hsv.x + degrees / 360.0);
|
||||
hsv.x = fract(hsv.x + deg / 360.0);
|
||||
return vec4(hsv2rgb(hsv), color.a);
|
||||
}
|
||||
@@ -1,16 +1,8 @@
|
||||
vec2 applyMosaic(vec2 uv, float strength) {
|
||||
float absStrength = abs(strength);
|
||||
if (absStrength < 5.0) return uv;
|
||||
float normalized = round(abs(strength));
|
||||
if (normalized < 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;
|
||||
float level = (normalized + 10.0) / 10.0;
|
||||
return fract(uv * level);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
vec4 applyOpacity(vec4 color, float opacity) {
|
||||
color.a *= opacity;
|
||||
return color;
|
||||
return vec4(color.rgb, color.a * opacity);
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
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;
|
||||
vec2 applyPixelation(vec2 uv, float strength, sampler2D tex) {
|
||||
float normalized = abs(strength) / 10.0;
|
||||
if (normalized <= 0.0) return uv;
|
||||
const vec2 center = vec2(0.5, 0.5);
|
||||
|
||||
vec2 pixelTexelSize = vec2(textureSize(tex, 0)) / normalized;
|
||||
return (floor(uv * pixelTexelSize) + center) / pixelTexelSize;
|
||||
}
|
||||
@@ -1,10 +1,19 @@
|
||||
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;
|
||||
float normalized = radians(-strength);
|
||||
if (normalized == 0.0) return uv;
|
||||
const vec2 center = vec2(0.5, 0.5);
|
||||
|
||||
vec2 off = uv - center;
|
||||
float offLength = length(off);
|
||||
float factor = normalized * pow(max(1.0 - (offLength / 0.5), 0.0), 2.0);
|
||||
|
||||
// Rotate UV by `factor` radians
|
||||
float fsin = sin(factor);
|
||||
float fcos = cos(factor);
|
||||
mat2 rotation = mat2(
|
||||
fcos, -fsin,
|
||||
fsin, fcos
|
||||
);
|
||||
|
||||
return rotation * off + center;
|
||||
}
|
||||
Reference in New Issue
Block a user