Skip to content

Enabling and Disabling Effects

Raoul v. R edited this page Sep 24, 2021 · 8 revisions

The EffectPass bakes effects into a single shader. This means that enabling or disabling one effect at runtime would require a recompilation of the shader program which blocks the render thread and causes a noticeable freeze. An Effect should not be disabled by setting its blend function to BlendFunction.SKIP because this only prevents it from being integrated into the final shader. Many effects perform additional render operations that will still be executed even if they are excluded from the shader.

The recommended way to enable or disable effects on the fly is to prepare multiple EffectPass instances with the desired Effect combinations ahead of time and to enable or disable these passes as needed using Pass.setEnabled(). This approach requires some planning ahead and uses a little bit more memory but is the most efficient solution. Note that Effect instances can be reused in other EffectPass instances to reduce memory usage.

Clone this wiki locally