What does it mean "BRANCH" in shader code?

In Unreal shader code, there are many keyword “BRANCH”.
For example in BasePassPixelShader.usf

BRANCH
if (View.OutOfBoundsMask > 0)
{ … }

BRANCH
if (SkyLightParameters.y > 0 && SpecularIBL.a < .999f)
{ … }

What is that? What does it mean?

“If” flow controls in HLSL come in two flavors: “branch” and “flatten.”

Essentially, “branch” says “evaluate the if first, and then only run the code in it if it’s true, otherwise, run the else block”

“Flatten” says “Run both the if and else blocks, but only use the one that is appropriate based on the outcome of the if statement.”

MSDN

1 Like

In Definitions.USF there is a #define BRANCH [branch]
and [branch] attribute instructs compiler to evaluate only one side of IF statement, as mentioned in the other answer.

Just a correction,Now those definitions are in Platform.ush file