Adding post-process effects
Another one of benefits of using a renderer is that you can easily add post-processing effects to your game, which is what we are going to cover in this tutorial.
Contents
Adding a post-processor
Before we can start adding post-processing effects, we first need to create a new BBMOD_PostProcessor and assign it to our renderer's PostProcessor property:
/// @desc Create event
postProcessor = new BBMOD_PostProcessor();
renderer.PostProcessor = postProcessor;
Do not forget to destroy the post-processor when it's no longer needed to avoid memory leaks:
/// @desc Clean Up event
postProcessor = postProcessor.destroy();
Adding effects
Since version 3.21.0, BBMOD comes with a large variety of post-processing effects. You can quickly find all of them by searching BBMOD_PostProcessingEffect in the online documentation and scrolling down to "Child structs", where they are all listed.
When you find the desired post-processing effect, e.g. vignette, simply create a new instance of it and add it to the post-processor using its method add_effect:
vignette = new BBMOD_VignetteEffect();
vignette.Color = c_black;
vignette.Strength = 1.5;
postProcessor.add_effect(vignette);
Note: Effects are executed in the order they are added to a post-processor, meaning you can get different results with different order of effects! You can also add multiple effects of the same kind, just do not forget to make a new instance every time with the
new
operator.
Individual effects can be temporarily disabled by setting their Enabled
property to false
, or removed entirely using the remove_effect
method:
// Disable temporarily:
vignette.Enabled = false;
// Or completely remove the effect:
postProcessor.remove_effect(vignette);
Tip: If you ever wish to temporarily disable all post-processing effects, you can do so by setting the post-processor's Enabled property to
false
.
Please note that BBMOD_PostProcessEffect
has a method destroy
, which must be
called before an effect goes out of scope to avoid memory leaks! When a
post-processor is destroyed, it also destroys all effects added to it, but if
you use remove_effect
, you will need to destroy the effect yourself!