- Home /
Can i disable shader pass based on #define symbols?
I am writing a complex shader and i want a simple option how to turn the surface effect on and off, done by defining material shader keywords. I would also like to disable a pass that renders cull:front - the interior of the mesh - when the effect is off, and I'd like to avoid having to sync two or more properties. Is it possible to skip a pass entirely based on these symbols?
Answer by tatoforever · Oct 20, 2016 at 08:39 PM
@Pangamini, No you can't (by design). What you can do is to have a lightweight version of your vertex/fragment programs in that pass based on some Keywords define but still the pass needs to happen (you can't avoid the pass). Would be awesome if we can enable/disable passes with the Material.SetPass() function. -__-
You actually can enable/disable passes per-material: https://docs.unity3d.com/ScriptReference/$$anonymous$$aterial.SetShaderPassEnabled.html
Back in that time we were unable to set $$anonymous$$aterial passes from script. But now we can (I think since Unity 2017 or 2018), can't remember exactly when.
Answer by tanoshimi · Oct 20, 2016 at 10:07 PM
No you can't but, from memory I was able to simulate the same result by defining passes with different LOD and then setting Shader.maximumLOD: https://docs.unity3d.com/Manual/SL-ShaderLOD.html
Your answer
Follow this Question
Related Questions
Disabling a Pass or Subshader Programmatically 0 Answers
Surface Shader, run vertex multiple times 0 Answers
Use Shader Motion Vectors pass in Surface Shader 2 Answers
Shaders: Using Property for Offset 3 Answers
Parsing values in multipass cg shader 0 Answers