Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

What does it mean "BRANCH" in shader code?

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

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

What is that? What does it mean?

Product Version: UE Github Master branch
more ▼

asked Jan 13 '17 at 05:32 AM in Rendering

avatar image

1 1 1 1

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

"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."


more ▼

answered Jan 14 '17 at 02:42 AM

avatar image

619 24 28 54

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Jan 15 '17 at 07:42 PM

avatar image

7.7k 129 29 289

avatar image Jeslas Pravin Oct 28 '18 at 06:05 AM

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

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question