Performance of Static Switch vs. If
Performance of Static Switch vs. If
I'm trying to optimize my shaders by making certain features toggleable, but I wanted to know which method was the most efficient? I've heard using conditional statements in shaders is generally frowned upon, so I thought I'd ask just to be sure.
- Ricardo Teixeira
- Posts: 954
- Joined: Fri Aug 09, 2013 2:26 pm
Re: Performance of Static Switch vs. If
Greetings,
You should definitely go for Static Switches whenever possible as they are more performant than conditional statements that execute all functions before comparing their results.
For additional information on how Unity handles this type of behavior, be sure to check the link below.
https://docs.unity3d.com/Manual/SL-Mult ... iants.html
Thanks!
You should definitely go for Static Switches whenever possible as they are more performant than conditional statements that execute all functions before comparing their results.
For additional information on how Unity handles this type of behavior, be sure to check the link below.
https://docs.unity3d.com/Manual/SL-Mult ... iants.html
Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Re: Performance of Static Switch vs. If
Ah, good to know! Thank you for the quick reply.
- Ricardo Teixeira
- Posts: 954
- Joined: Fri Aug 09, 2013 2:26 pm
Re: Performance of Static Switch vs. If
No problem!JordyJS wrote:Ah, good to know! Thank you for the quick reply.
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!