Using Primitive Variables


Introduction -PRimitive Variables


In this tutorial you will see a basic example of how to use Primitive Variables in MTOR. This scene used a Primitive Variable called "mycolor" to drive the color of a constant shader on a sphere.
  


1- First, open Maya and make new scene


First open Maya and in a new scene create a simple sphere. Or to see a finished scene, open the tutorial file:
/mtor/scenes/primvar/primvar.ma


2- Add attribute


Using the Attribute Editor you can select the tab for the shape node on the sphere and click the "Select" button at the bottom of the Attribute Editor tab for the shape node.

Now use Maya's Modify => Add Attribute tool to add a new attribute.

Name the attribute rmanCmycolor and choose Vector as the data type.



MTOR supports RenderMan primitive variables by transmitting data from arbitrary Maya attributes associated with your geometric primitives that obey the following naming convention:

  • rmanFyourvar - constant or vertex floats
  • rmanPyourvar - constant or vertex points
  • rmanVyourvar - constant or vertex vectors
  • rmanNyourvar - constant or vertex normals
  • rmanCyourvar - constant or vertex colors
  • rmanSyourvar - constant string
  • rmanMyourvar - vertex mpoint (for blobs)

When naming your variable, be sure that the name doesn't terminate with the string "Cache" or the number '0'. Maya automatically creates variants of your data by storing cached and preroll versions of your data. So if your data is named rmanFmyS, Maya may create rmanFmyS0 and rmanFmySCache. MTOR ignores variables whose names obey this convention.

You will notice that three new attributes have been created on the shape node for your sphere (one each for X, Y, and Z). In this case we will be using these to control R, G & B in our shader.




3- Create a shading network to read variable


The next step is to create a slim shading network.

Create a new Slim palette (RenderMan => Slim => New Palette) and in it create a new surface appearance. For this example we used a simple constant shading model.

Next select the tab to the left of the color input and change it from "internal" to "connection" and connect the color to "primvar."



The next step is to simply set the variable inside the primvar node to the name of your primitive variable (rmanCmycolor becomes mycolor in the primvar node) like so:




4- Attach shader and set color


Now that we have the shading network completed all we have to do is attach the shader to the sphere and set the color via the attribute added to the shape node in Maya.

For this example we simply changed the "0" in RmanCmycolorX to "1" to make the sphere red.



Now render and…presto! You've got a red sphere. The values on the Maya attributes added to the shape node can be keyed and animated as you please.


5- Render


Here's our resulting image:



 

 

 


 

Pixar Animation Studios
(510) 752-3000 (voice)   (510) 752-3151 (fax)
Copyright © 1996- Pixar. All rights reserved.
RenderMan™ is a registered trademark of Pixar.