|
|
@@ -25,8 +25,11 @@ class GaussianBlurNode extends TempNode {
|
|
|
* @param {TextureNode} textureNode - The texture node that represents the input of the effect.
|
|
|
* @param {Node<vec2|float>} directionNode - Defines the direction and radius of the blur.
|
|
|
* @param {number} sigma - Controls the kernel of the blur filter. Higher values mean a wider blur radius.
|
|
|
+ * @param {Object} [options={}] - Additional options for the gaussian blur effect.
|
|
|
+ * @param {boolean} [options.premultipliedAlpha=false] - Whether to use premultiplied alpha for the blur effect.
|
|
|
+ * @param {Vector2} [options.resolution=new Vector2(1, 1)] - The resolution of the effect. 0.5 means half the resolution of the texture node.
|
|
|
*/
|
|
|
- constructor( textureNode, directionNode = null, sigma = 4 ) {
|
|
|
+ constructor( textureNode, directionNode = null, sigma = 4, options = {} ) {
|
|
|
|
|
|
super( 'vec4' );
|
|
|
|
|
|
@@ -110,7 +113,7 @@ class GaussianBlurNode extends TempNode {
|
|
|
* @type {Vector2}
|
|
|
* @default (1,1)
|
|
|
*/
|
|
|
- this.resolution = new Vector2( 1, 1 );
|
|
|
+ this.resolution = options.resolution || new Vector2( 1, 1 );
|
|
|
|
|
|
/**
|
|
|
* Whether the effect should use premultiplied alpha or not. Set this to `true`
|
|
|
@@ -119,32 +122,7 @@ class GaussianBlurNode extends TempNode {
|
|
|
* @type {boolean}
|
|
|
* @default false
|
|
|
*/
|
|
|
- this.premultipliedAlpha = false;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets the given premultiplied alpha value.
|
|
|
- *
|
|
|
- * @param {boolean} value - Whether the effect should use premultiplied alpha or not.
|
|
|
- * @return {GaussianBlurNode} height - A reference to this node.
|
|
|
- */
|
|
|
- setPremultipliedAlpha( value ) {
|
|
|
-
|
|
|
- this.premultipliedAlpha = value;
|
|
|
-
|
|
|
- return this;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns the premultiplied alpha value.
|
|
|
- *
|
|
|
- * @return {boolean} Whether the effect should use premultiplied alpha or not.
|
|
|
- */
|
|
|
- getPremultipliedAlpha() {
|
|
|
-
|
|
|
- return this.premultipliedAlpha;
|
|
|
+ this.premultipliedAlpha = options.premultipliedAlpha || false;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -280,6 +258,7 @@ class GaussianBlurNode extends TempNode {
|
|
|
const sample2 = sampleTexture( uvNode.sub( uvOffset ) );
|
|
|
|
|
|
diffuseSum.addAssign( sample1.add( sample2 ).mul( w ) );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return output( diffuseSum );
|
|
|
@@ -349,18 +328,28 @@ export default GaussianBlurNode;
|
|
|
* @param {Node<vec4>} node - The node that represents the input of the effect.
|
|
|
* @param {Node<vec2|float>} directionNode - Defines the direction and radius of the blur.
|
|
|
* @param {number} sigma - Controls the kernel of the blur filter. Higher values mean a wider blur radius.
|
|
|
+ * @param {Object} [options={}] - Additional options for the gaussian blur effect.
|
|
|
+ * @param {boolean} [options.premultipliedAlpha=false] - Whether to use premultiplied alpha for the blur effect.
|
|
|
+ * @param {Vector2} [options.resolution=new Vector2(1, 1)] - The resolution of the effect. 0.5 means half the resolution of the texture node.
|
|
|
* @returns {GaussianBlurNode}
|
|
|
*/
|
|
|
-export const gaussianBlur = ( node, directionNode, sigma ) => nodeObject( new GaussianBlurNode( convertToTexture( node ), directionNode, sigma ) );
|
|
|
+export const gaussianBlur = ( node, directionNode, sigma, options = {} ) => nodeObject( new GaussianBlurNode( convertToTexture( node ), directionNode, sigma, options ) );
|
|
|
|
|
|
/**
|
|
|
* TSL function for creating a gaussian blur node for post processing with enabled premultiplied alpha.
|
|
|
*
|
|
|
* @tsl
|
|
|
* @function
|
|
|
+ * @deprecated since r180. Use `gaussianBlur()` with `premultipliedAlpha: true` option instead.
|
|
|
* @param {Node<vec4>} node - The node that represents the input of the effect.
|
|
|
* @param {Node<vec2|float>} directionNode - Defines the direction and radius of the blur.
|
|
|
* @param {number} sigma - Controls the kernel of the blur filter. Higher values mean a wider blur radius.
|
|
|
* @returns {GaussianBlurNode}
|
|
|
*/
|
|
|
-export const premultipliedGaussianBlur = ( node, directionNode, sigma ) => nodeObject( new GaussianBlurNode( convertToTexture( node ), directionNode, sigma ).setPremultipliedAlpha( true ) );
|
|
|
+export function premultipliedGaussianBlur( node, directionNode, sigma ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.TSL: "premultipliedGaussianBlur()" is deprecated. Use "gaussianBlur()" with "premultipliedAlpha: true" option instead.' ); // deprecated, r180
|
|
|
+
|
|
|
+ return gaussianBlur( node, directionNode, sigma, { premultipliedAlpha: true } );
|
|
|
+
|
|
|
+}
|