Page tree

Contents

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!

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.

  • Notice that Identifier ID will work without OpScripts to define the ID.  We auto-generate both identifier ID and identifier Name, so they will work without 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.

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 to ensure variation.

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

PxrVary Katana 2.6v4 scene