Performance of Static Switch vs. If

Node-based Shader Editor

Performance of Static Switch vs. If

Postby JordyJS » Wed Sep 05, 2018 3:45 pm

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.
JordyJS
 
Posts: 4
Joined: Wed Sep 05, 2018 3:42 pm

Re: Performance of Static Switch vs. If

Postby Ricardo Teixeira » Wed Sep 05, 2018 4:09 pm

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!
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!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Performance of Static Switch vs. If

Postby JordyJS » Wed Sep 05, 2018 4:17 pm

Ah, good to know! Thank you for the quick reply.
JordyJS
 
Posts: 4
Joined: Wed Sep 05, 2018 3:42 pm

Re: Performance of Static Switch vs. If

Postby Ricardo Teixeira » Wed Sep 05, 2018 4:29 pm

JordyJS wrote:Ah, good to know! Thank you for the quick reply.


No problem!
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!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 10 guests

cron