Page tree

Versions Compared

Key

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

Image Added

Simple PxrVary Example

One of the most common requirements of shading in animation or visual effects is varying the shader attributes efficiently for many objects. This can be anything from crowd simulations to leaves in a forest. This variation can make scenes more realistic and visually appealing. However, having to hand-alter dozens to hundreds of shaders can be prohibitive. This is where PxrVary comes in!

Image Added

Attached is a Katana example file showing how to use OpScripts to generate the source variables when using the pattern. Read about the logic of the scene setup below.

Info
  • Notice that Identifier ID will work without OpScripts in Preview and Live rendering, however, they will fail with a Disk Render without the OpScript to define them. This is because we auto-generate IDs only for interactive rendering sessions (the ID picker), not Disk Renders. Identifier Name does not need an OpScript.

 

  • For Attribute selections, be sure and prefix with "user:" in the PxrVary node. In our example we use, user:rmanFloatAttr

 

 

This is an example OpScript used to create an ID on a sphere.

Code Block
Interface.SetAttr('prmanStatements.attributes.identifier.id', IntAttribute(1))

Interface.SetAttr('prmanStatements.attributes.user.rmanFloatAttr', FloatAttribute(3))

gb = GroupBuilder()
gb:set("value", FloatAttribute(1))
gb:set("scope", StringAttribute("primitive"))
gb:set("inputType", StringAttribute("float"))
Interface.SetAttr("geometry.arbitrary.FloatPrimvar", gb:build())

 

The OpScript is assigned just below the primitive create. Each one is slightly different.

Image Added

From here you will notice there are different outputs, four exactly, illustrating the different results from using different PxrVary sources (Name, ID, PrimVar, Attribute). Rendering each of these will produce a different colored sphere. Download the scene to experiment!

PxrVary Katana 2.6v4 scene