graphicsrenderingrenderman

Rendering entities in Renderman


This is regarding Renderman Pro Server 19 with no Maya (or any such GUI) interface.

The Renderman documentation clearly explains how to define entities: https://renderman.pixar.com/forum/docs/RPS_19/ribBinding.php#rib-entity-file-example, but nowhere does it define how to include the entities in our main code.

Since the link might go dead in the future, I'll quote the part of the documentation here:

A RIB Entity File contains a single User Entity. RIB Entity Files are incomplete since they do not contain enough information to describe a frame to a renderer. RIB Entity Files depend on Render Management services for integration into "legal," or complete, RIB Files. These files provide the mechanism for 3-D "clip-art" by allowing Render Managers to insert objects into preexisting scenes.

RIB Entity Files must conform to the User Entity Conventions described in the User Entities section. To summarize, a User Entity must be delimited by an attribute block, must have a name attribute, and must be completely contained within a single attribute block. Three additional requirements must also be met:

  • The header hint: ##RenderMan RIB-Structure 1.1 Entity must be included as the first line of the file.

  • The Entity must be built in an object coordinate system which is centered about the origin.

  • The Entity must have a RIB bound request to provide a single bounding box of all geometric primitives in the User Entity

and the following code for an entity example is attached:

##RenderMan RIB-Structure 1.1 Entity
AttributeBegin  #begin unit cube
Attribute "identifier" "name" "unitcube"
Bound -.5 .5 -.5 .5 -.5 .5
TransformBegin
# far face
Polygon "P" [.5 .5 .5  -.5 .5 .5  -.5 -.5 .5  .5 -.5 .5]
Rotate 90  0 1 0
# right face
Polygon "P" [.5 .5 .5  -.5 .5 .5  -.5 -.5 .5  .5 -.5 .5]
# near face
Rotate 90  0 1 0
Polygon "P" [.5 .5 .5  -.5 .5 .5  -.5 -.5 .5  .5 -.5 .5]
# left face
Rotate 90  0 1 0
Polygon "P" [.5 .5 .5  -.5 .5 .5  -.5 -.5 .5  .5 -.5 .5]
TransformEnd
TransformBegin
# bottom face
Rotate 90  1 0 0
Polygon "P" [.5 .5 .5  -.5 .5 .5  -.5 -.5 .5  .5 -.5 .5]
TransformEnd
TransformBegin
# top face
Rotate -90  1 0 0
Polygon "P" [.5 .5 .5  -.5 .5 .5  -.5 -.5 .5  .5 -.5 .5]
TransformEnd
AttributeEnd  #end unit cube

Now, it would be really cumbersome to include the same piece of code again and again in the main RIB file (abstractions required), so entities seem like a good way to go.

So, how should I go about including these entities in my main file?


Solution

  • This can be done by using the Archive directive. Suppose, I want to include the above code in another file, say main.rib, I'll simply say:

    # main.rib
    # other_stuff
        ReadArchive "unitcube.rib"
    

    And it will be as if that rib code was written in the main.rib file.