In our final class of this course we develop a new algorithm, a layered fbm noise, that we implement in all 3 languages of this course: se expressions, OSL, and C++ pattern nodes. We then have a starting point for doing some comparison tests to see which renders faster, is easier to code, more versatile, and the pro's and cons of all 3.
We continue programming our first pattern from class 8, exploring the distinction between uniform and varying parameters for upstream connection, and some gotcha's to eliminate artifacts and getting new parameters setup correctly with GetParamTable and the enum data structure for paramId. Continuing with some useful utility for our custom pattern node, we show how to read a custom primvar attribute such as our MatteID, and writing to a custom AOV. We can do the same with some "builtin" variables such as curvature, surface normals, derivatives, and others.
We now jump into C++ Patterns! Since there is a lot of overhead for writing and compiling C++ patterns, we start off with the simplest possible example by just setting a color that is connectable upstream. First an overview in Maya how it fits into our existing Kitchen scene file shader network, then we jump in to the user interface .args file to setup the parameters and register our custom node in RenderMan for Maya. We then jump into the .cpp code and show the overhead setup for a Pattern node, then where the custom stuff happens inside our shading context loop. We need to compile our C++ pattern so we go through that on OSX/Linux, then in Windows via the Cutter program used earlier in this course. We finish up this lesson with an overview slide and showing how we can also connect our custom OSL patterns made earlier in this course into our newly created C++ pattern node, all in the hypershade node editor.
The next step in our OSL shaders progression is adding shader metadata for more useful user-interface options, but this requires us some setup steps to "register" our plugin with RfM. The good news is once we set this up we are good to go for all future custom plugins, including C++ patterns, bxdf's, integrators, etc. This class shows you how to setup your dev environment for all these plugins for yourself or the whole studio, in OSX/Linux/Windows.
"Understanding Projections" is the theme of our 3rd class in OSL, and we cover ST, UV projections, then move onto transforming our point P into Screen/NDC projections and finally triplanar. We do all this from scratch in OSL on our recurring Kitchen scene, and show the results of these projections using 3 examples:
1) the useful ratGrid.tex
2) a simple sketch texture mixed with an upstream pattern PxrDirt
3) the beauty render using Pixar128 library textures fed into our OSL and PxrSurface
We also show how we can plug in any pattern upstream from our OSL, like PxrDirt or Curvature, then manipulate it in our OSL, then output it to PxrSurface BxDF.