Toggles, unused branches and performance

Node-based Shader Editor

Toggles, unused branches and performance

Postby AdultLink » Sat Sep 01, 2018 12:27 pm

Hey everyone,

I've been using ASE for a while now and I'm in love with it. I personally love providing shaders with a lot of cuztomization options, and as the amount of toggles, values and effects increase, I have a feeling I'm not doing things the optimum way in regards to performance.

This is a small portion of a shader I'm working on:

Image

As you can see, towards the right end I'm using a few toggles to allow the user to activate/deactivate a "scanline" effect on all three axes separately, and additionally to that, there are three more toggles before those. The result of all this will be multiplied with a texture afterwards.

On the left side you can also see I'm using sine and time nodes to generate those scanlines, plus a a few float nodes to tweak the wave. All these nodes are properties that I'm

My question is, are all these calculations still performed even when the final toggle is off? (I'm guessing the answer is yes). And if so, what can I do to avoid that? Is there any other way of structuring a graph like this performance-wise, some kind of conditional compilation?

Here are a couple more examples that I feel are not that performant :(

Image

Image

Here's how the inspector looks:

Image

If you'd like to check the shader by yourself, you can find it here (unitypackage under releases): https://github.com/AdultLink/TexturePanner

Thank you for your time! :)
AdultLink
 
Posts: 4
Joined: Thu May 10, 2018 7:27 pm



Return to Amplify Shader Editor

Who is online

Users browsing this forum: Bing [Bot] and 43 guests