render method
dynamic
render(})
Implementation
render(renderer, writeBuffer, readBuffer,
{num? deltaTime, bool? maskActive}) {
renderer.getClearColor(this.oldClearColor);
this.oldClearAlpha = renderer.getClearAlpha();
var oldAutoClear = renderer.autoClear;
renderer.autoClear = false;
renderer.setClearColor(this.clearColor, alpha: 1);
if (maskActive == true) renderer.state.buffers.stencil.setTest(false);
// Render input to screen
if (this.renderToScreen) {
this.fsQuad.material = this.basic;
this.basic.map = readBuffer.texture;
renderer.setRenderTarget(null);
renderer.clear(null, null, null);
this.fsQuad.render(renderer);
}
// 1. Extract Bright Areas
this.highPassUniforms['tDiffuse']["value"] = readBuffer.texture;
this.highPassUniforms['luminosityThreshold']["value"] = this.threshold;
this.fsQuad.material = this.materialHighPassFilter;
renderer.setRenderTarget(this.renderTargetBright);
renderer.clear(null, null, null);
this.fsQuad.render(renderer);
// 2. Blur All the mips progressively
var inputRenderTarget = this.renderTargetBright;
for (var i = 0; i < this.nMips; i++) {
this.fsQuad.material = this.separableBlurMaterials[i];
this.separableBlurMaterials[i].uniforms['colorTexture']["value"] =
inputRenderTarget.texture;
this.separableBlurMaterials[i].uniforms['direction']["value"] =
UnrealBloomPass.BlurDirectionX;
renderer.setRenderTarget(this.renderTargetsHorizontal[i]);
renderer.clear(null, null, null);
this.fsQuad.render(renderer);
this.separableBlurMaterials[i].uniforms['colorTexture']["value"] =
this.renderTargetsHorizontal[i].texture;
this.separableBlurMaterials[i].uniforms['direction']["value"] =
UnrealBloomPass.BlurDirectionY;
renderer.setRenderTarget(this.renderTargetsVertical[i]);
renderer.clear(null, null, null);
this.fsQuad.render(renderer);
inputRenderTarget = this.renderTargetsVertical[i];
}
// Composite All the mips
this.fsQuad.material = this.compositeMaterial;
this.compositeMaterial.uniforms['bloomStrength']["value"] = this.strength;
this.compositeMaterial.uniforms['bloomRadius']["value"] = this.radius;
this.compositeMaterial.uniforms['bloomTintColors']["value"] =
this.bloomTintColors;
renderer.setRenderTarget(this.renderTargetsHorizontal[0]);
renderer.clear(null, null, null);
this.fsQuad.render(renderer);
// Blend it additively over the input texture
this.fsQuad.material = this.materialCopy;
this.copyUniforms['tDiffuse']["value"] =
this.renderTargetsHorizontal[0].texture;
if (maskActive == true) renderer.state.buffers.stencil.setTest(true);
if (this.renderToScreen) {
renderer.setRenderTarget(null);
this.fsQuad.render(renderer);
} else {
renderer.setRenderTarget(readBuffer);
this.fsQuad.render(renderer);
}
// Restore renderer settings
renderer.setClearColor(this.oldClearColor, alpha: this.oldClearAlpha);
renderer.autoClear = oldAutoClear;
}