Hi Ivo,
The current material translator has no real support for dynamic branching: it will compile a “branch” with a lerp or ternary operator instead of factoring subexpressions needed for one or the other case. So even if it looks like it’s doing a branch, I’d suggest to inspect the generated HLSL to see what it’s really generating: if you have heavy opeations like texture samples feeding into the true and false pins separately, they will all be evaluated in the shader, even if one won’t actually contribute to the final result.
We’re in the process of greatly improving our material backend and proper support for dynamic branching is on the list of features it will have.
Meanwhile, I recommend using your workaround.
Kind Regards,
Massimo