0
Declined
Gabe Newell 4 weeks ago • updated by Joachim Holmér (Developer) 3 weeks ago 3

Is it possible to expose on the created shader the options of the blend node (Darken, Multiply, Pin light, etc...)?

Answer

Answer
Declined

I'm afraid not - this would either be expensive (running all blend modes at the same time, and multiply-branch), slow (branching), or something that SF doesn't support (static branching)

Answer
Declined

I'm afraid not - this would either be expensive (running all blend modes at the same time, and multiply-branch), slow (branching), or something that SF doesn't support (static branching)

Thanks for answering. Ok, so if I was doing a big "if" chain in shader forge based on "Toggle" inputs (that can be exposed as properties), it's a bad idea right? I just don't understand why that would slow the shader down since it will skip over the code, it's not gonna run the code that's in the unused if's right?

+1

That's unfortunately not really the way GPUs deal with if statements. Dynamic branching is very expensive in shader code. For example, if you have an if statement, it's very often cheaper to calculate both outcomes, and multiply one with 0 and the other with 1, and adding them together, rather than doing an actual branch. This means it'll run all branches, but the code is still parallelizable