Legacy Documentation: Version 5.6 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Material.SetShaderPassEnabled

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public function SetShaderPassEnabled(passName: string, enabled: bool): void;
public void SetShaderPassEnabled(string passName, bool enabled);

Parameters

passName Shader pass name (case insensitive).
enabled Flag indicating whether this Shader pass should be enabled.

Description

Enables or disables a Shader pass on a per-Material level.

By default, all Shader passes are enabled. This function allows a Material to treat a specific Shader pass (as indicated by LightMode pass tag) as if it does not exist in the Shader. For example, if the Shader has a "refraction" pass but you only want to enable it on Materials that have a refraction Texture assigned, pass "refraction" as passName and false for enabled for Materials without a refraction Texture assigned. Note that the Shader pass enable/disable flag only affects custom rendering pipelines that use the RenderLoop class (via RenderLoop.DrawRenderers or RenderLoop.DrawShadows).

See Also: GetShaderPassEnabled, RenderLoop, Shader pass tags.