@@ -145,7 +145,9 @@ class UnrealBloomPass extends Pass {
145145 // gaussian blur materials
146146
147147 this . separableBlurMaterials = [ ] ;
148- const kernelSizeArray = [ 3 , 5 , 7 , 9 , 11 ] ;
148+ // These sizes have been changed to account for the altered coefficients-calculation to avoid blockiness,
149+ // while retaining the same blur-strength. For details see https://github.com/mrdoob/three.js/pull/31528
150+ const kernelSizeArray = [ 6 , 10 , 14 , 18 , 22 ] ;
149151 resx = Math . round ( this . resolution . x / 2 ) ;
150152 resy = Math . round ( this . resolution . y / 2 ) ;
151153
@@ -376,10 +378,11 @@ class UnrealBloomPass extends Pass {
376378 _getSeparableBlurMaterial ( kernelRadius ) {
377379
378380 const coefficients = [ ] ;
381+ const sigma = kernelRadius / 3 ;
379382
380383 for ( let i = 0 ; i < kernelRadius ; i ++ ) {
381384
382- coefficients . push ( 0.39894 * Math . exp ( - 0.5 * i * i / ( kernelRadius * kernelRadius ) ) / kernelRadius ) ;
385+ coefficients . push ( 0.39894 * Math . exp ( - 0.5 * i * i / ( sigma * sigma ) ) / sigma ) ;
383386
384387 }
385388
@@ -420,10 +423,9 @@ class UnrealBloomPass extends Pass {
420423 vec2 uvOffset = direction * invSize * x;
421424 vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
422425 vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
423- diffuseSum += (sample1 + sample2) * w;
424- weightSum += 2.0 * w;
426+ diffuseSum += ( sample1 + sample2 ) * w;
425427 }
426- gl_FragColor = vec4(diffuseSum/weightSum , 1.0);
428+ gl_FragColor = vec4( diffuseSum, 1.0 );
427429 }`
428430 } ) ;
429431
0 commit comments