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