Dynamic flow control in materials

MostHost LA came across this again and thought it’s only responsible to post what I believe is the solution here. It can be done as when the code generated via the material editor gets compiled to asm, it will the code for each result into its own branch.

So to achieve this you just use a custom node with the BRANCH HLSL macro as so.

Inspecting the pixel in the API call in RenderDoc shows this asm, which to me is a pretty clear indicator that this actually works (surprisingly).
I believe this is also the same on PS4 when the code gets ported to PSGL. Not sure about other platforms.

Please let me know if you think is somehow wrong, but to me it seems as clear as day that this should work.
Would love to see this integrated with BlendMaterialAttributes to branch whole layers.