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