Page tree

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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 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.

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.

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