Hello,
I am currently working on a shader that became quite long to compile (between 5 to 15mn). At first I though it was due to an over-use of functions (I have functions using functions using functions... and this is pretty useful to maintain the code and reuse some parts).
After some comparison with an older version of the shader is appears it is due to an over-use of the If statements. I replace some functions by simpler code and it is already a lot shorter to compile. Beside I don't have the Compiling small window appearing anymore.
I still have some If statements here and there though. They are pretty useful because easy to read. I could replace them but I am not sure it is always needed. After some reading on the web it looks like in many cases the compiler is able to do a good optimization for the code with it, and in some more complex cases it cannot.
Hence my question: When is it interesting to replace the If nodes by a lerp (or a max, or something else more analytic)?
Beside how can I check the results? Is there a profiler or a tool that would tell me that a branch has been created in the shader?
Thank you
I am currently working on a shader that became quite long to compile (between 5 to 15mn). At first I though it was due to an over-use of functions (I have functions using functions using functions... and this is pretty useful to maintain the code and reuse some parts).
After some comparison with an older version of the shader is appears it is due to an over-use of the If statements. I replace some functions by simpler code and it is already a lot shorter to compile. Beside I don't have the Compiling small window appearing anymore.
I still have some If statements here and there though. They are pretty useful because easy to read. I could replace them but I am not sure it is always needed. After some reading on the web it looks like in many cases the compiler is able to do a good optimization for the code with it, and in some more complex cases it cannot.
Hence my question: When is it interesting to replace the If nodes by a lerp (or a max, or something else more analytic)?
Beside how can I check the results? Is there a profiler or a tool that would tell me that a branch has been created in the shader?
Thank you
Comment