Initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#version 330 core
|
||||
|
||||
in vec4 v_Color;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform float u_HueShift;
|
||||
uniform float u_Brightness;
|
||||
uniform float u_Opacity;
|
||||
|
||||
{{rgb2hsv}}
|
||||
{{hsv2rgb}}
|
||||
{{apply_hue_shift}}
|
||||
{{apply_brightness}}
|
||||
{{apply_opacity}}
|
||||
|
||||
void main() {
|
||||
vec4 color = v_Color;
|
||||
|
||||
color = applyOpacity(color, u_Opacity);
|
||||
color = applyHueShift(color, u_HueShift);
|
||||
color = applyBrightness(color, u_Brightness);
|
||||
|
||||
FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec2 a_Position;
|
||||
|
||||
uniform mat4 u_ModelViewProj;
|
||||
uniform vec4 u_Color;
|
||||
|
||||
out vec4 v_Color;
|
||||
|
||||
void main() {
|
||||
v_Color = u_Color;
|
||||
gl_Position = u_ModelViewProj * vec4(a_Position, 0.0, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#version 330 core
|
||||
|
||||
in vec2 v_TexCoord;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D u_Texture;
|
||||
uniform float u_Alpha;
|
||||
uniform float u_HueShift;
|
||||
uniform float u_Bulge; // Radial distortion strength
|
||||
uniform float u_Whirl; // Rotation angle based on distance from center
|
||||
uniform float u_Pixelation;
|
||||
uniform float u_Mosaic;
|
||||
uniform float u_Brightness;
|
||||
uniform float u_Opacity;
|
||||
|
||||
{{rgb2hsv}}
|
||||
{{hsv2rgb}}
|
||||
{{apply_hue_shift}}
|
||||
{{apply_bulge}}
|
||||
{{apply_whirl}}
|
||||
{{apply_pixelation}}
|
||||
{{apply_mosaic}}
|
||||
{{apply_brightness}}
|
||||
{{apply_opacity}}
|
||||
|
||||
void main() {
|
||||
vec2 uv = v_TexCoord;
|
||||
|
||||
// Apply geometric distortions in order
|
||||
uv = applyBulge(uv, u_Bulge);
|
||||
uv = applyWhirl(uv, u_Whirl);
|
||||
// skew done in vertex shader
|
||||
uv = applyMosaic(uv, u_Mosaic);
|
||||
if (u_Pixelation > 0.0) {
|
||||
uv = applyPixelation(uv, u_Pixelation);
|
||||
}
|
||||
|
||||
vec4 color = texture(u_Texture, uv);
|
||||
|
||||
// Apply color effects
|
||||
color = applyHueShift(color, u_HueShift);
|
||||
color = applyBrightness(color, u_Brightness);
|
||||
color = applyOpacity(color, u_Opacity);
|
||||
|
||||
// Final alpha
|
||||
color.a *= u_Alpha;
|
||||
|
||||
FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec2 a_Position;
|
||||
layout (location = 1) in vec2 a_TexCoord;
|
||||
|
||||
out vec2 v_TexCoord;
|
||||
|
||||
uniform mat4 u_ModelViewProj;
|
||||
uniform float u_SkewX;
|
||||
uniform float u_SkewY;
|
||||
|
||||
void main() {
|
||||
// Apply skew
|
||||
vec2 skewedPos = a_Position;
|
||||
skewedPos.x += a_Position.y * u_SkewX * 0.01; // Shear X based on Y
|
||||
skewedPos.y += a_Position.x * u_SkewY * 0.01; // Shear Y based on X
|
||||
|
||||
gl_Position = u_ModelViewProj * vec4(skewedPos, 0.0, 1.0);
|
||||
v_TexCoord = a_TexCoord;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#version 330 core
|
||||
|
||||
in vec4 v_Color;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform float u_HueShift;
|
||||
uniform float u_Brightness;
|
||||
uniform float u_Opacity;
|
||||
|
||||
{{rgb2hsv}}
|
||||
{{hsv2rgb}}
|
||||
{{apply_hue_shift}}
|
||||
{{apply_brightness}}
|
||||
{{apply_opacity}}
|
||||
|
||||
void main() {
|
||||
vec4 color = v_Color;
|
||||
|
||||
color = applyOpacity(color, u_Opacity);
|
||||
color = applyHueShift(color, u_HueShift);
|
||||
color = applyBrightness(color, u_Brightness);
|
||||
|
||||
FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec2 a_Position;
|
||||
|
||||
uniform mat4 u_ModelViewProj;
|
||||
uniform vec4 u_Color;
|
||||
|
||||
out vec4 v_Color;
|
||||
|
||||
void main() {
|
||||
v_Color = u_Color;
|
||||
gl_Position = u_ModelViewProj * vec4(a_Position, 0.0, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user