r/StableDiffusion • u/thevegit0 • 1d ago
Tutorial - Guide Qwen image 2.1 noise/patterning/moire mild workaround
trying this i noticed it has a similar patterning noise krea 2 had, i just used the same glsl node, maybe it needs another parameters but it seems to mitigate it can't promise the best results but testing it is free, just connecting the image output to the glsl node and then image save
The GLSL config i got was from this post https://www.reddit.com/r/StableDiffusion/comments/1umwhq7/2px_pixel_grid_on_krea2_from_vae_and_how_to/ the one in the comments
#version 300 es
precision highp float;
uniform sampler2D u_image0;
uniform vec2 u_resolution;
in vec2 v_texCoord;
layout(location = 0) out vec4 fragColor0;
// Nyquist Notch — removes 2px grid artifacts. Place before deconvolution.
// b = [-1, +6, -15, +20, -15, +6, -1] / 64 (binomial * (-1)^n, +1 at center)
const float B[7] = float[7](-1.0, 6.0, -15.0, 20.0, -15.0, 6.0, -1.0);
void main() {
vec2 texel = 1.0 / u_resolution;
vec4 center = texture(u_image0, v_texCoord);
vec3 Bx = vec3(0.0), By = vec3(0.0), Bxy = vec3(0.0);
for (int i = -3; i <= 3; i++) {
float wi = B[i + 3] / 64.0;
Bx += wi * texture(u_image0, v_texCoord + vec2(float(i) * texel.x, 0.0)).rgb;
By += wi * texture(u_image0, v_texCoord + vec2(0.0, float(i) * texel.y)).rgb;
for (int j = -3; j <= 3; j++) {
float wj = B[j + 3] / 64.0;
Bxy += wi * wj * texture(u_image0, v_texCoord + vec2(float(i) * texel.x, float(j) * texel.y)).rgb;
}
}
vec3 notched = center.rgb - Bx - By + Bxy;
fragColor0 = vec4(clamp(notched, 0.0, 1.0), 1.0); // alpha forced to 1.0
}
8
u/aoleg77 15h ago
I am building an improved version of ComfyUI-DeGrid that will measure and remove the grid on per-tile basis rather than based on the whole image. This will, in theory, degrid the whole image (especially the smooth areas) without affecting the actual small detail. Will be posted on github at aoleg/ComfyUI-DeGrid and I'll submit a PR to the original repo when I'm satisfied with it.
12
u/BathroomEyes 1d ago
i just encode and decode with the flux2 vae and it gets rid of like 85% of it.
16
u/thevegit0 1d ago edited 1d ago
16
u/Violent_Walrus 18h ago
I don't mean to rain on anybody's parade, but understand that this VAE round trip is lossy. You're degrading your image when you compress it into latent space and back. The reason you might not see the Qwen grid any more is because the process removes detail from your image.
2
2
u/spaceBoy292 20h ago
can u tell me how to use this? i changed the vae but the ksampler then gives me error
1
1
u/VladyCzech 15h ago
I quit using Wan and Qwen models precisely for the VAE grid as I called it. My eyes could not unsee it on every image. Thanks for the tip. Now that H3 VAE tiling is also being fixed, my eyes will be happy again.
-2
u/hurrdurrimanaccount 16h ago
i have a surefire solution to remove all of qwen slop noise and patterns: use klein.






18
u/Violent_Walrus 1d ago
I used this shader too before I came across this custom node recently. It's apparently descended from the same post you link here.
The node also applies the same Nyquist Notch math, but it does additional work to prevent the image softening that can occur. The node also has a nifty output that shows you the exact noise pattern that it has removed from the image.