As someone with a programming background, here's a fundamental thing about the Cycles node tree I've been thinking about. Let's say you have a node setup like this:
Here we have two computationally intensive shaders, called "Gigantic Shader A" and "Gigantic Shader B", and a Mix Shader is used to switch between them using some black-and-white mask.
In programming terms, this setup can be thought of as an if-else construct, with shader A and B being the two execution branches of the if-else construct.
Now, in basically every sane programming language, the two if-else branches are evaluated "lazily", meaning that either only the first branch or only the second branch is evaluated, depending on whether the if condition evaluates to true or false.
So here are my questions:
(1) Does Cycles have this lazy evaluation optimization as well? More specifically, is Cycles smart enough to figure out that if Fac=0 or Fac=1 in the above Mix Shader, it can completely ignore either shader B or shader A?
(2) If Cycles does have this optimization, then is it also true that the node tree is actually evaluated from right to left, starting at the Material Output node, and not from left to right, as one would naively assume? Because I can't think of any other way to implement lazy evaluation than going from right to left.