as stated (but you just chose to ignore) your code isn’t really properly branching.
some of your code is probably being nested into the branch (which would explain the performance difference). however check your generated HLSL code, you’ll see something like this:
local 100 = someStuff1;
local 101 = someStuff2;
local 102 = [branch] if ( A >= B)
{
return someStuff1;
}
else
{
return someStuff1;
}
finalcolor = local102;
once you see this you’ll understand that your node isn’t really nesting things inside your branch, as it’s still declaring and processing everything outside of the branch and then simply branching the final decision of what to use. and this is exactly what is written in the original post
Plenty of things have been discussed in this thread, I’d ask you to take some time to read through it to properly understand how this whole thing is behaving in UE4. otherwise we end up with a very redundant discussion and/or you will keep working under false assumptions
also try using a more real-like scenario than simply using colors and math. you’ll know your branch works when you have a texture hooked and the material fails to compile complaining that it cannot have divergent gradient operations inside flow control (which was also mentioned in this thread). you’ll be entering the topic of DDX/DDY and block pixel processing on shader units, which should hint you at the tradeoff of parallelism vs flow control (which means branching isn’t necessarily better in all cases). or in other words, that things aren’t as simple as you think and things have been discussed for a reason