Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork239
Enabling and Disabling Effects
TheEffectPass 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. AnEffect should not be disabled by setting its blend function toBlendFunction.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 multipleEffectPass instances with the desiredEffect combinations ahead of time and to enable or disable these passes as needed usingPass.setEnabled(). This approach requires some planning ahead and uses a little bit more memory but is the most efficient solution. Note thatEffect instances can be reused in otherEffectPass instances to reduce memory usage.