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};
renderTargetX = WebGLRenderTarget(resolution, resolution, WebGLRenderTargetOptions(pars));
renderTargetX.texture.name = 'BloomPass.x';
renderTargetY = WebGLRenderTarget(resolution, resolution, WebGLRenderTargetOptions(pars));
renderTargetY.texture.name = 'BloomPass.y';
// copy material
uniforms = UniformsUtils.clone(copyShader["uniforms"]);
uniforms['opacity']["value"] = strength;
materialCopy = ShaderMaterial({
"uniforms": uniforms,
"vertexShader": copyShader["vertexShader"],
"fragmentShader": copyShader["fragmentShader"],
"blending": AdditiveBlending,
"transparent": true
});
// convolution material
convolutionUniforms = UniformsUtils.clone(convolutionShader["uniforms"]);
convolutionUniforms['uImageIncrement']["value"] = BloomPass.blurX;
convolutionUniforms['cKernel']["value"] = convolutionShaderBuildKernel(sigma);
materialConvolution = ShaderMaterial({
"uniforms": convolutionUniforms,
"vertexShader": convolutionShader["vertexShader"],
"fragmentShader": convolutionShader["fragmentShader"],
"defines": {'KERNEL_SIZE_FLOAT': toFixed(kernelSize, 1), 'KERNEL_SIZE_INT': toFixed(kernelSize, 0)}
});
needsSwap = false;
fsQuad = FullScreenQuad(null);
}