Note that there are some explanatory texts on larger screens.

plurals
  1. POLinear sampled Gaussian blur quality issue
    text
    copied!<p>I recently implemented a linear sampled gaussian blur based on this article:</p> <p><a href="http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/" rel="nofollow noreferrer">Linear Sampled Gaussian Blur</a></p> <p>It generally came out well, however it appears there is slight alisasing on text and thinner collections of pixels. I'm pretty stumped as to what is causing this, is it an issue with my shader or weight calculations or is it an inherit draw back of using this method? </p> <p>I'd like to add that I don't run into this issue when I sample each pixel regularly instead of using bilinear filtering.</p> <p>Any insights are much appreciated. Here's a code sample of how I work out my weights:</p> <pre><code>int support = int(sigma * 3.0f); float total = 0.0f; weights.push_back(exp(-(0*0)/(2*sigma*sigma))/(sqrt(2*constants::pi)*sigma)); total += weights.back(); offsets.push_back(0); for (int i = 1; i &lt;= support; i++) { float w1 = exp(-(i*i)/(2*sigma*sigma))/(sqrt(2*constants::pi)*sigma); float w2 = exp(-((i+1)*(i+1))/(2*sigma*sigma))/(sqrt(2*constants::pi)*sigma); weights.push_back(w1 + w2); total += 2.0f * weights[i]; offsets.push_back((i * w1 + (i + 1) * w2) / weights[i]); } for (int i = 0; i &lt; support; i++) { weights[i] /= total; } </code></pre> <p>And here is the fragment shader (there is another vertical version of this shader too):</p> <pre><code> void main() { vec3 acc = texture2D(tex_object, v_tex_coord.st).rgb*weights[0]; for (int i = 1; i &lt; NUM_SAMPLES; i++) { acc += texture2D(tex_object, (v_tex_coord.st+(vec2(offsets[i], 0.0)/tex_size))).rgb*weights[i]; acc += texture2D(tex_object, (v_tex_coord.st-(vec2(offsets[i], 0.0)/tex_size))).rgb*weights[i]; } gl_FragColor = vec4(acc, 1.0); </code></pre> <p>Here is a screenshot depicting the issue:</p> <p><img src="https://i.stack.imgur.com/afDDi.png" alt="Linear Sample Gaussian Blur Issue"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload