How disable effect
Hi! I was trying your beautiful library, really awesome! Apologies this is more a question then an issue. I would like to know if is it possible to selectively disable/enable an effect inside EffectPass. I see that each effect has several passes inside, I've tried to set enabled = false for each of the inner passes to disable the effect but it didn't work.
Thanks!
Hi,
that's a nice question 👍 I should probably add some information about this topic to the wiki.
You may have noticed that the Effect class doesn't have an enabled flag. That's a deliberate design decision. 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.
Now, to answer your question, 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.
I hope this helps!
Hi,
that's a nice question 👍 I should probably add some information about this topic to the wiki.
You may have noticed that the
Effectclass doesn't have anenabledflag. That's a deliberate design decision. Since theEffectPassbakes effects into a single shader, enabling or disabling one effect at runtime would require a slow recompilation of the shader program. TheEffectPassactually provides arecompilemethod 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.Now, to answer your question, you should prepare multiple
EffectPassinstances with the desired effect combinations ahead of time and enable or disable these passes as needed using thePass.enabledflag. This requires some planning ahead and uses a little bit more memory but is the most efficient solution. Note thatEffectinstances can be reused in otherEffectPassinstances so you won't have to worry about redundant frame buffers.I hope this helps!
Ehi thank you very much for the great explanation! I will do as you suggested, using different EffectPass merging effects that should be enable/disable together