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"

Material 'Lerp' vs 'If' performance ?

I have a material that needs to apply different logic depending on vertex color, but in my case vertex color can be only 100% Red, 100% Green or 100% Blue. So if vertex has R channel == 1.0, it will do things exclusive to vertexes with (1,0,0) color, and so on. For now it works like this:

alt text

It works OK, but knowing that our vertexes can only have 3 values [(1,0,0), (0,1,0) or (0,0,1)] is there a better, more optimized way to do this? What about 'If' statement, would it be more performant in this case?

(e.g. if Blue channel == 1.0, do logic for blue vertexes, else check if Green channel == 1.0, and so on...)

I will be grateful for some hints! :)

Product Version: UE 4.13 Preview
more ▼

asked Aug 27 '16 at 02:06 PM in Rendering

avatar image

2k 157 153 210

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Good day Slavq,

It depends on a good deal of factors, including your target hardware, and the logic you want to put under each block, and number of adjacent pixels on screen, sharing same vertex color. What you are speaking about here is commonly referenced as dynamic shader branching. IF statement will only skip the block, if it contains no gradient functions,otherwise both blocks will be executed, and one result will be discarded. As a general rough rule, using IF statement will benefit you, if your blocks contain at least 40~50 instructions or a texture sampler.

However, do note, that presently, IF node in material editor will not let you achieve dynamic branching, thus it won't give you any advantages over lerps.

I've covered the issue in detail in **this thread**. There is also an issue tracker link in the first post. Feel free to toss a vote there.

more ▼

answered Aug 27 '16 at 09:06 PM

avatar image

7.9k 130 31 293

avatar image Slavq Aug 27 '16 at 09:43 PM

Thank you! I'll stick with the Lerps then :)

I've voted on the thread and feature request, it would be indeed an useful feature.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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