build/postprocessing.esm.js
/**
	 * Updates the compound shader material.
	 *
	 * @private
	 */
Updates the compound shader material.
@private
Updates the compound shader material . @private
updateMaterial() {
		const blendRegExp = /\bblend\b/g;
		const shaderParts = new Map([
			[Section.FRAGMENT_HEAD, ""],
			[Section.FRAGMENT_MAIN_UV, ""],
			[Section.FRAGMENT_MAIN_IMAGE, ""],
			[Section.VERTEX_HEAD, ""],
			[Section.VERTEX_MAIN_SUPPORT, ""]
		]);
		const blendModes = new Map();
		const defines = new Map();
		const uniforms = new Map();
		const extensions = new Set();
		let id = 0, varyings = 0, attributes = 0;
		let transformedUv = false;
		let readDepth = false;
		let result;
		for(const effect of this.effects) {
			if(effect.blendMode.getBlendFunction() === BlendFunction.SKIP) {
				attributes |= (effect.getAttributes() & EffectAttribute.DEPTH);
			} else if((attributes & EffectAttribute.CONVOLUTION) !== 0 &&
				(effect.getAttributes() & EffectAttribute.CONVOLUTION) !== 0) {
				console.error("Convolution effects cannot be merged", effect);
			} else {
				attributes |= effect.getAttributes();
				result = integrateEffect(("e" + id++), effect, shaderParts, blendModes, defines, uniforms, attributes);
				varyings += result.varyings.length;
				transformedUv = transformedUv || result.transformedUv;
				readDepth = readDepth || result.readDepth;
				if(effect.extensions !== null) {
					for(const extension of effect.extensions) {
						extensions.add(extension);
					}
				}
			}
		}
		for(const blendMode of blendModes.values()) {
			shaderParts.set(Section.FRAGMENT_HEAD, shaderParts.get(Section.FRAGMENT_HEAD) +
				blendMode.getShaderCode().replace(blendRegExp, "blend" + blendMode.getBlendFunction()) + "\n");
		}
		if((attributes & EffectAttribute.DEPTH) !== 0) {
			if(readDepth) {
				shaderParts.set(Section.FRAGMENT_MAIN_IMAGE, "float depth = readDepth(UV);\n\n\t" +
					shaderParts.get(Section.FRAGMENT_MAIN_IMAGE));
			}
			this.needsDepthTexture = (this.getDepthTexture() === null);
		} else {
			this.needsDepthTexture = false;
		}
		if(transformedUv) {
			shaderParts.set(Section.FRAGMENT_MAIN_UV, "vec2 transformedUv = vUv;\n" +
				shaderParts.get(Section.FRAGMENT_MAIN_UV));
			defines.set("UV", "transformedUv");
		} else {
			defines.set("UV", "vUv");
		}
		shaderParts.forEach((value, key, map) => map.set(key, value.trim().replace(/^#/, "\n#")));
		this.uniforms = uniforms.size;
		this.varyings = varyings;
		this.skipRendering = (id === 0);
		this.needsSwap = !this.skipRendering;
		const material = this.getFullscreenMaterial();
		material.setShaderParts(shaderParts).setDefines(defines).setUniforms(uniforms);
		material.extensions = {};
		if(extensions.size > 0) {
			for(const extension of extensions) {
				material.extensions[extension] = true;
			}
		}
		this.needsUpdate = false;
	}
updateMaterial ( ) { const blendRegExp = / \bblend\b / g ; const shaderParts = new Map ( [ [ Section . FRAGMENT_HEAD , "" ] , [ Section . FRAGMENT_MAIN_UV , "" ] , [ Section . FRAGMENT_MAIN_IMAGE , "" ] , [ Section . VERTEX_HEAD , "" ] , [ Section . VERTEX_MAIN_SUPPORT , "" ] ] ) ; const blendModes = new Map ( ) ; const defines = new Map ( ) ; const uniforms = new Map ( ) ; const extensions = new Set ( ) ; let id = 0 , varyings = 0 , attributes = 0 ; let transformedUv = false ; let readDepth = false ; let result ; for ( const effect of this . effects ) { if ( effect . blendMode . getBlendFunction ( ) === BlendFunction . SKIP ) { attributes |= ( effect . getAttributes ( ) & EffectAttribute . DEPTH ) ; } else if ( ( attributes & EffectAttribute . CONVOLUTION ) !== 0 && ( effect . getAttributes ( ) & EffectAttribute . CONVOLUTION ) !== 0 ) { console . error ( "Convolution effects cannot be merged" , effect ) ; } else { attributes |= effect . getAttributes ( ) ; result = integrateEffect ( ( "e" + id ++ ) , effect , shaderParts , blendModes , defines , uniforms , attributes ) ; varyings += result . varyings . length ; transformedUv = transformedUv || result . transformedUv ; readDepth = readDepth || result . readDepth ; if ( effect . extensions !== null ) { for ( const extension of effect . extensions ) { extensions . add ( extension ) ; } } } } for ( const blendMode of blendModes . values ( ) ) { shaderParts . set ( Section . FRAGMENT_HEAD , shaderParts . get ( Section . FRAGMENT_HEAD ) + blendMode . getShaderCode ( ) . replace ( blendRegExp , "blend" + blendMode . getBlendFunction ( ) ) + "\n" ) ; } if ( ( attributes & EffectAttribute . DEPTH ) !== 0 ) { if ( readDepth ) { shaderParts . set ( Section . FRAGMENT_MAIN_IMAGE , "float depth = readDepth(UV);\n\n\t" + shaderParts . get ( Section . FRAGMENT_MAIN_IMAGE ) ) ; } this . needsDepthTexture = ( this . getDepthTexture ( ) === null ) ; } else { this . needsDepthTexture = false ; } if ( transformedUv ) { shaderParts . set ( Section . FRAGMENT_MAIN_UV , "vec2 transformedUv = vUv;\n" + shaderParts . get ( Section . FRAGMENT_MAIN_UV ) ) ; defines . set ( "UV" , "transformedUv" ) ; } else { defines . set ( "UV" , "vUv" ) ; } shaderParts . forEach ( ( value , key , map ) => map . set ( key , value . trim ( ) . replace ( / ^# / , "\n#" ) ) ) ; this . uniforms = uniforms . size ; this . varyings = varyings ; this . skipRendering = ( id === 0 ) ; this . needsSwap = ! this . skipRendering ; const material = this . getFullscreenMaterial ( ) ; material . setShaderParts ( shaderParts ) . setDefines ( defines ) . setUniforms ( uniforms ) ; material . extensions = { } ; if ( extensions . size > 0 ) { for ( const extension of extensions ) { material . extensions [ extension ] = true ; } } this . needsUpdate = false ; }
Updates the compound shader material.
Updates the compound shader material .
// Check if this effect relies on depth and then continue. // Collect the WebGL extensions that are required by this effect. // Integrate the relevant blend functions. // Check if any effect relies on depth. // Only read depth if any effect actually uses this information. // Only request a depth texture if none has been provided yet. // Check if any effect transforms UVs in the fragment shader. // Ensure that leading preprocessor directives start at a new line. // Enable required WebGL extensions.