...
Now that we have one mesh instanced twice with the same shader, how to do we override the shader of one of the two instances ? It is usual in scene graph APIs to have a hierarchical assignment strategy where the leaf nodes inherit parent attributes. In such scenarios, overriding of attributes is possible only on the child nodes. In our case, the child node has a shader assigned to it already. Thankfully, NSI allows you to perform top-down overrides by specifying priories on connections. We can connect an attribute node, along with its shader, on the instance transform node.
...
Code Block | ||||
---|---|---|---|---|
| ||||
/** Create another simple shader node using the standard OSL "emitter" shader. User default shader prameters. */ nsi.Create( "simpleshader2", "shader" ); nsi.SetAttribute( "simpleshader", NSI::CStringPArg("shaderfilename", "emitter") ); const char *k_attributes_override = "attribute override"; nsi.Create( k_attributes_override, "attribute" ); /* Default priiority is 0, so 1 will override */ nsi.Connect( k_simpler_shader2, "", k_attributes_override, "surfaceshaders", NSI::IntegerArg( "priority", 1) ); /* Connecting the attributes to the second instance transform will override the shader below because of higher priority. */ nsi.Connect( k_attributes_override, "", k_instance2, "geometryattributes" ); |
Multi-Camera output, in One Render.
...