Multi Shader

Node-based Shader Editor

Multi Shader

Postby Juarez » Fri Jun 22, 2018 7:13 pm

Hello. I have a question about the switch between shaders at runtime.

In my game, I have some enemies with only one material. Sometimes I need to change the shader of the material to highlight or to disintegrate the enemy for example. The idea is to make one shader that contains all the possible effects in the game and defines the output with a switch. In terms of optimization, do you think that is a good idea?

Is it better to have that huge shader with all possibilities, is it better to keep all the effects separated like one per material and change the whole material when needed, or it does not make so much difference? One of the main concerns I have about putting everything in the same shader and just switching between them, is that I don't know if the inactive shaders will be still doing calculus, thus being very expensive to put all of them together
Juarez
 
Posts: 1
Joined: Fri Jun 22, 2018 7:11 pm

Re: Multi Shader

Postby Ricardo Teixeira » Mon Jun 25, 2018 6:06 pm

Juarez wrote:Hello. I have a question about the switch between shaders at runtime.

In my game, I have some enemies with only one material. Sometimes I need to change the shader of the material to highlight or to disintegrate the enemy for example. The idea is to make one shader that contains all the possible effects in the game and defines the output with a switch. In terms of optimization, do you think that is a good idea?

Is it better to have that huge shader with all possibilities, is it better to keep all the effects separated like one per material and change the whole material when needed, or it does not make so much difference? One of the main concerns I have about putting everything in the same shader and just switching between them, is that I don't know if the inactive shaders will be still doing calculus, thus being very expensive to put all of them together


Hello there!

I got back to you via email but I'll post my reply here for other users, it might be useful.

I'm afraid that it always depends on the actual complexity of the shaders used, and how it's implemented.

You have a couple of nodes at your disposal that might be useful:

    The Toggle Switch Node allows you to toggle specific node networks but both inputs are simultaneously processed, you can think of it as a standard Lerp Node.

Be sure to let us know if you have any follow-up questions, we would be happy to elaborate!

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


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 31 guests