-
-
Notifications
You must be signed in to change notification settings - Fork 215
Enabling and Disabling Effects
Since the EffectPass
bakes effects into a single shader, enabling or disabling one effect at runtime would require a slow recompilation of the shader program. The EffectPass
actually provides a recompile method that allows you to do that, but it blocks the render thread and causes a noticeable hiccup when performed at runtime. This method is not intended for toggling effects and should only be used in a situation where a user changes special effect parameters that require a shader recompilation.
Instead, you should prepare multiple EffectPass
instances with the desired Effect
combinations ahead of time and enable or disable these passes as needed using the Pass.enabled
flag. This 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 so you won't have to worry about redundant frame buffers.