_steps.clear();
// step 1: downsample previous rendering in chain
{
_steps.add(new EffectStep_SetRenderTarget(RT_DOWNSAMPLED));
final EffectStep_RenderScreenOverlay downsample = new EffectStep_RenderScreenOverlay();
downsample.getTargetMap().put("*Previous", 0);
_steps.add(downsample);
}
// step 2: extract our average luminance value
{
_steps.add(new EffectStep_SetRenderTarget(RT_LUM64x64));
final EffectStep_RenderScreenOverlay extract64 = new EffectStep_RenderScreenOverlay();
extract64.getEnforcedStates().put(StateType.GLSLShader, getLuminanceExtractionShader());
extract64.getTargetMap().put(RT_DOWNSAMPLED, 0);
_steps.add(extract64);
_steps.add(new EffectStep_SetRenderTarget(RT_LUM16x16));
final EffectStep_RenderScreenOverlay extract4 = new EffectStep_RenderScreenOverlay();
extract4.getTargetMap().put(RT_LUM64x64, 0);
_steps.add(extract4);
_steps.add(new EffectStep_SetRenderTarget(RT_LUM1x1));
final EffectStep_RenderScreenOverlay extract1 = new EffectStep_RenderScreenOverlay();
extract1.getTargetMap().put(RT_LUM16x16, 0);
_steps.add(extract1);
}
// step 3: apply bright pass, extracting the brighter than normal portions of the scene
{
_steps.add(new EffectStep_SetRenderTarget(RT_BRIGHTMAP));
final EffectStep_RenderScreenOverlay bright = new EffectStep_RenderScreenOverlay();
bright.getEnforcedStates().put(StateType.GLSLShader, getBrightMapShader());
bright.getTargetMap().put(RT_DOWNSAMPLED, 0);
bright.getTargetMap().put(RT_LUM1x1, 1);
_steps.add(bright);
}
// finally: draw bloom texture and previous texture on fsq, blended.
_steps.add(new EffectStep_SetRenderTarget("*Next"));
final EffectStep_RenderScreenOverlay blendOverlay = new EffectStep_RenderScreenOverlay();
blendOverlay.getTargetMap().put(RT_BRIGHTMAP, 0);
_steps.add(blendOverlay);
super.prepare(manager);
}