BloomPass constructor
BloomPass(
- num? strength,
- num? kernelSize,
- dynamic sigma,
- dynamic resolution,
)
Implementation
BloomPass(num? strength, num? kernelSize, sigma, resolution) : super() {
strength = (strength != null) ? strength : 1;
kernelSize = (kernelSize != null) ? kernelSize : 25;
sigma = (sigma != null) ? sigma : 4.0;
resolution = (resolution != null) ? resolution : 256;
// render targets
var pars = {
"minFilter": LinearFilter,
"magFilter": LinearFilter,
"format": RGBAFormat
};
this.renderTargetX = new WebGLRenderTarget(
resolution, resolution, WebGLRenderTargetOptions(pars));
this.renderTargetX.texture.name = 'BloomPass.x';
this.renderTargetY = new WebGLRenderTarget(
resolution, resolution, WebGLRenderTargetOptions(pars));
this.renderTargetY.texture.name = 'BloomPass.y';
// copy material
if (CopyShader == null) print('THREE.BloomPass relies on CopyShader');
var copyShader = CopyShader;
this.uniforms = UniformsUtils.clone(copyShader["uniforms"]);
this.uniforms['opacity']["value"] = strength;
this.materialCopy = new ShaderMaterial({
"uniforms": this.uniforms,
"vertexShader": copyShader["vertexShader"],
"fragmentShader": copyShader["fragmentShader"],
"blending": AdditiveBlending,
"transparent": true
});
// convolution material
if (ConvolutionShader == null)
print('THREE.BloomPass relies on ConvolutionShader');
var convolutionShader = ConvolutionShader;
this.convolutionUniforms =
UniformsUtils.clone(convolutionShader["uniforms"]);
this.convolutionUniforms['uImageIncrement']["value"] = BloomPass.blurX;
this.convolutionUniforms['cKernel']["value"] =
ConvolutionShader_buildKernel(sigma);
this.materialConvolution = new ShaderMaterial({
"uniforms": this.convolutionUniforms,
"vertexShader": convolutionShader["vertexShader"],
"fragmentShader": convolutionShader["fragmentShader"],
"defines": {
'KERNEL_SIZE_FLOAT': toFixed(kernelSize, 1),
'KERNEL_SIZE_INT': toFixed(kernelSize, 0)
}
});
this.needsSwap = false;
this.fsQuad = new FullScreenQuad(null);
}