Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Consider the following simplified line of code and the corresponding evaluation:


Code Block
Ci = Kd * diffuse() + Ks * specular();

Image Modified




Code Block
Ci = Kd * diffuse() + Ks * specular();




...

In this diagram, "vertex_color" and "Kd" are connected to an OSL node which
executes getattribute(). All the other variables are "folded".


A "drawback" of this method is that one can't easily get the default parameter value if the primitive variable is undefined. But bear in mind that 99% of shader networks are machine generated and this gives us two possible solutions to this problem:

  1. Don't output the getattribute() node when the primitive variable is not present.
  2. Output the proper default value in the getattribute() node in case the primitive variable is not present. This involves shader node interrogation.

...