13.1.1 RenderMan\textregistered RIB export

The module cgkit.ribexport contains the class RIBExporter that exports the current scene as RIB and creates shaders from the materials and light sources used in the scene.

To use the exporter you can simply use the save() command and pass a file name with suffix .rib (see chapter 6). The plugin supports the following options that can be passed to the save() command:

Option Default Description
camera None Camera object to be used
output None Output image file name or output specs
output_framebuffer True Framebuffer output?
bake False Activate texture baking mode
bakemodel None Determines the model to bake
bakestvar "st" Variable name of the bake texture coordinates

camera specifies the camera object to be used for rendering the scene. If None is specified the first camera found in the scene is used.

output is the output image file name or a list of output specifiers. Each specifier is a 4-tuple (filename, type, mode, params) containing the parameters for a RiDisplay() call. The additional parameters must be given as a dictionary. output can also be None in which case no RiDisplay() call is made.

output_framebuffer is a flag that specifies if a framebuffer display should be opened in addition to writing the output image file to disk. This flag is only used when output is a string.

If bake is True the exported scene will bake a texture map instead of producing a final image.

bakemodel is either the name of a WorldObject or a WorldObject itself. The texture will be baked for the specified model. This parameter doesn't have to be specified if there is only one mesh in the scene.

bakestvar is the name of the primitive variable that holds the texture coordinates that should be used for baking.

The plugin uses the following global options:

Option Default Description
displaymode "rgb" Display mode
output None Output image file name or output specs (see abvove)
resolution (640,480) Output image resolution
pixelsamples (2,2) Number of pixel samples
shadingrate 1.0 Shading rate
pixelfilter None Pixel filter setting
tiles None Render the image in tiles
rib None Additional global RIB requests

displaymode is the mode string for the RiDisplay() call and determines what data is written to the output. Usually you might want to switch between "rgb" (default) and "rgba".

output is the image output name or a list of output specifiers (see above).

resolution is either a 2-tuple (width, height) or a 3-tuple (width, height, pixel aspect) specifying the outpout image resolution.

pixelsamples is a 2-tuple containing the pixel samples setting.

shadingrate contains the shading rate setting.

pixelfilter is a 2-tuple (filter, (xwidth, ywidth)) that sets the pixel filter to use. If None is passed the default pixel filter of the renderer is used. Example: ("gaussian", (2,2))

tiles contains two sequences that defines the positions where the image is split. The first sequence contains the x positions and the second sequence the y positions where a split should occur. Each value lies between 0 and 1, so for example tiles=((0.5,), (0.5,)) will render the image in four equal tiles. The tiles can than be stitched together using the stitch module.

rib is a string containing additional RIB requests that are written in front of the frames.

It is possible to attach user RIB requests to an object simply by adding a string attribute called rib. When present this string will be written right before the geometry calls. For example, this can be used to set attributes that are specific to a particular renderer:

s = Sphere(...)
s.rib = 'Attribute "visibility" "transmission" "opaque"'

For an object to be exported as RIB it has to use a geometry that supports the IGeometry protocol. Materials must support the IMaterial protocol and light sources the ILightSource protocol. For details on these protocols see the sub sections below. If there is an object that does not support one of these protocols an adapter can be written that implements the protocol on behalf of the original object.

The remainder of this section is meant to be read by developers who want to extend the functionality of the exporter either by implementing adapter classes for existing classes or by implementing new geometries, materials or light sources that natively support the respective protocol.



Subsections