+1

IF node doesn't use ternary operator

behealed 8 years ago 0

Ternary operator:


float IfNodeResult = (A > B) ? Output1 : ((A == B) ? Output2 : Output3);


The above line of code is all you need to do everything that shader forge's IF node does.


Seems like this would be easier to read and maybe faster to process than the current code that it generates which uses like 3 lines of code, two step() calls, several multiplications, and a lerp.


Note that this ternary operator is not optimized, it still computes all sides of it. It can actually run some limited code inside the various parts of the operation (for example, you can do a += on any of those variables).