Static bool parameter with dynamic branch - when it will be fully implemented?

Hello,

I know that UE can turn the static bool parameter to use dynamic branching for some time. However the material interface still lacks functionality to actually change the value at runtime. Since we needed this badly, and the HLSL generator seems to fully support this, I went ahead and added the missing functionality in the interface. It seems to work as expected and it wasn’t that much work. When we can expect official support in Unreal though? This is very handy feature to have!

Thanks,

Ivo

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

P.s. If you’d like to share the diff of the changes you made I can quickly take a look.