* Constructs a new bloom effect. * * @param {Object} [options] - The options. * @param {BlendFunction} [options.blendFunction=BlendFunction.SCREEN] - The blend function of this effect. * @param {Number} [options.luminanceThreshold=1.0] - The luminance threshold. Raise this value to mask out
({
blendFunction = BlendFunction.SCREEN,
luminanceThreshold = 1.0,
luminanceSmoothing = 0.03,
mipmapBlur = true,
intensity = 1.0,
radius = 0.85,
levels = 8,
kernelSize = KernelSize.LARGE,
resolutionScale = 0.5,
width = Resolution.AUTO_SIZE,
height = Resolution.AUTO_SIZE,
resolutionX = width,
resolutionY = height
} = {})
| 38 | */ |
| 39 | |
| 40 | constructor({ |
| 41 | blendFunction = BlendFunction.SCREEN, |
| 42 | luminanceThreshold = 1.0, |
| 43 | luminanceSmoothing = 0.03, |
| 44 | mipmapBlur = true, |
| 45 | intensity = 1.0, |
| 46 | radius = 0.85, |
| 47 | levels = 8, |
| 48 | kernelSize = KernelSize.LARGE, |
| 49 | resolutionScale = 0.5, |
| 50 | width = Resolution.AUTO_SIZE, |
| 51 | height = Resolution.AUTO_SIZE, |
| 52 | resolutionX = width, |
| 53 | resolutionY = height |
| 54 | } = {}) { |
| 55 | |
| 56 | super("BloomEffect", fragmentShader, { |
| 57 | blendFunction, |
| 58 | uniforms: new Map([ |
| 59 | ["map", new Uniform(null)], |
| 60 | ["intensity", new Uniform(intensity)] |
| 61 | ]) |
| 62 | }); |
| 63 | |
| 64 | /** |
| 65 | * A render target. |
| 66 | * |
| 67 | * @type {WebGLRenderTarget} |
| 68 | * @private |
| 69 | */ |
| 70 | |
| 71 | this.renderTarget = new WebGLRenderTarget(1, 1, { depthBuffer: false }); |
| 72 | this.renderTarget.texture.name = "Bloom.Target"; |
| 73 | |
| 74 | /** |
| 75 | * A blur pass. |
| 76 | * |
| 77 | * @type {KawaseBlurPass} |
| 78 | * @readonly |
| 79 | * @deprecated Use mipmapBlurPass instead. |
| 80 | */ |
| 81 | |
| 82 | this.blurPass = new KawaseBlurPass({ kernelSize }); |
| 83 | |
| 84 | /** |
| 85 | * A luminance pass. |
| 86 | * |
| 87 | * Disable to skip luminance filtering. |
| 88 | * |
| 89 | * @type {LuminancePass} |
| 90 | * @readonly |
| 91 | */ |
| 92 | |
| 93 | this.luminancePass = new LuminancePass({ colorOutput: true }); |
| 94 | this.luminanceMaterial.threshold = luminanceThreshold; |
| 95 | this.luminanceMaterial.smoothing = luminanceSmoothing; |
| 96 | |
| 97 | /** |