mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-02 17:50:19 +08:00
more fixes
This commit is contained in:
parent
7c1f02d1fa
commit
bb048d4aaa
@ -2,6 +2,7 @@
|
|||||||
precision highp float;
|
precision highp float;
|
||||||
|
|
||||||
uniform sampler2D u_image0;
|
uniform sampler2D u_image0;
|
||||||
|
uniform vec2 u_resolution;
|
||||||
uniform int u_int0; // Mode
|
uniform int u_int0; // Mode
|
||||||
uniform float u_float0; // Amount (0 to 100)
|
uniform float u_float0; // Amount (0 to 100)
|
||||||
|
|
||||||
@ -30,30 +31,36 @@ void main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Aspect-corrected coordinates for circular effects
|
||||||
|
float aspect = u_resolution.x / u_resolution.y;
|
||||||
vec2 centered = uv - 0.5;
|
vec2 centered = uv - 0.5;
|
||||||
float r = length(centered);
|
vec2 corrected = vec2(centered.x * aspect, centered.y);
|
||||||
vec2 dir = r > 0.0001 ? centered / r : vec2(0.0);
|
float r = length(corrected);
|
||||||
|
vec2 dir = r > 0.0001 ? corrected / r : vec2(0.0);
|
||||||
vec2 offset = vec2(0.0);
|
vec2 offset = vec2(0.0);
|
||||||
|
|
||||||
if (u_int0 == MODE_LINEAR) {
|
if (u_int0 == MODE_LINEAR) {
|
||||||
// Horizontal shift
|
// Horizontal shift (no aspect correction needed)
|
||||||
offset = vec2(amount, 0.0);
|
offset = vec2(amount, 0.0);
|
||||||
}
|
}
|
||||||
else if (u_int0 == MODE_RADIAL) {
|
else if (u_int0 == MODE_RADIAL) {
|
||||||
// Outward from center, stronger at edges
|
// Outward from center, stronger at edges
|
||||||
offset = dir * r * amount * RADIAL_MULT;
|
offset = dir * r * amount * RADIAL_MULT;
|
||||||
|
offset.x /= aspect; // Convert back to UV space
|
||||||
}
|
}
|
||||||
else if (u_int0 == MODE_BARREL) {
|
else if (u_int0 == MODE_BARREL) {
|
||||||
// Lens distortion simulation (r² falloff)
|
// Lens distortion simulation (r² falloff)
|
||||||
offset = dir * r * r * amount * BARREL_MULT;
|
offset = dir * r * r * amount * BARREL_MULT;
|
||||||
|
offset.x /= aspect; // Convert back to UV space
|
||||||
}
|
}
|
||||||
else if (u_int0 == MODE_SWIRL) {
|
else if (u_int0 == MODE_SWIRL) {
|
||||||
// Perpendicular to radial (rotational aberration)
|
// Perpendicular to radial (rotational aberration)
|
||||||
vec2 perp = vec2(-dir.y, dir.x);
|
vec2 perp = vec2(-dir.y, dir.x);
|
||||||
offset = perp * r * amount * RADIAL_MULT;
|
offset = perp * r * amount * RADIAL_MULT;
|
||||||
|
offset.x /= aspect; // Convert back to UV space
|
||||||
}
|
}
|
||||||
else if (u_int0 == MODE_DIAGONAL) {
|
else if (u_int0 == MODE_DIAGONAL) {
|
||||||
// 45° offset
|
// 45° offset (no aspect correction needed)
|
||||||
offset = vec2(amount, amount) * INV_SQRT2;
|
offset = vec2(amount, amount) * INV_SQRT2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,6 @@ void main() {
|
|||||||
float t1 = threshold + 0.15;
|
float t1 = threshold + 0.15;
|
||||||
|
|
||||||
vec2 texelSize = 1.0 / u_resolution;
|
vec2 texelSize = 1.0 / u_resolution;
|
||||||
float aspect = u_resolution.x / u_resolution.y;
|
|
||||||
float radius2 = radius * radius;
|
float radius2 = radius * radius;
|
||||||
|
|
||||||
float sampleScale = clamp(radius * 0.75, 0.35, 1.0);
|
float sampleScale = clamp(radius * 0.75, 0.35, 1.0);
|
||||||
@ -104,7 +103,7 @@ void main() {
|
|||||||
float fi = float(i);
|
float fi = float(i);
|
||||||
float dist = sqrt(fi / float(samples)) * radius * radiusJitter;
|
float dist = sqrt(fi / float(samples)) * radius * radiusJitter;
|
||||||
|
|
||||||
vec2 offset = dir * dist * texelSize * vec2(1.0, aspect);
|
vec2 offset = dir * dist * texelSize;
|
||||||
vec3 c = texture(u_image0, v_texCoord + offset).rgb;
|
vec3 c = texture(u_image0, v_texCoord + offset).rgb;
|
||||||
float mask = smoothstep(t0, t1, dot(c, LUMA));
|
float mask = smoothstep(t0, t1, dot(c, LUMA));
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
precision highp float;
|
precision highp float;
|
||||||
|
|
||||||
uniform sampler2D u_image0;
|
uniform sampler2D u_image0;
|
||||||
uniform vec2 u_resolution;
|
|
||||||
|
|
||||||
in vec2 v_texCoord;
|
in vec2 v_texCoord;
|
||||||
layout(location = 0) out vec4 fragColor0;
|
layout(location = 0) out vec4 fragColor0;
|
||||||
|
|||||||
@ -36,11 +36,11 @@ void main() {
|
|||||||
for (int x = -samples; x <= samples; x++) {
|
for (int x = -samples; x <= samples; x++) {
|
||||||
for (int y = -samples; y <= samples; y++) {
|
for (int y = -samples; y <= samples; y++) {
|
||||||
vec2 offset = vec2(float(x), float(y)) * texel;
|
vec2 offset = vec2(float(x), float(y)) * texel;
|
||||||
vec2 sampleCoord = v_texCoord + offset;
|
vec4 sample_color = texture(u_image0, v_texCoord + offset);
|
||||||
|
|
||||||
float dist = length(vec2(float(x), float(y)));
|
float dist = length(vec2(float(x), float(y)));
|
||||||
float weight = gaussian(dist, sigma);
|
float weight = gaussian(dist, sigma);
|
||||||
blurred += texture(u_image0, sampleCoord) * weight;
|
blurred += sample_color * weight;
|
||||||
totalWeight += weight;
|
totalWeight += weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user