Mtor
Rib Post Processing Curve Widths


return to main index

Related Links

download sample_curves.rib.txt (an mtor RIB file)




before

before post-processing




after

after post-processing



Introduction

As of RenderMan Artist Tools version 11.5.3 the only attribute that can be assigned to a Maya curve using mtor is "constantwidth". Pixar's mtor plugin allows a curve to have a uniform width but not a sequence of width's or colors etc.

However, there are work-arounds. Both techniques involve post-processing the RIB files generated by Maya/mtor in such a way that the Curves statements are modified to include the "extra" attributes that we wish to assign a curve.

The difference between the work-arounds is that the advanced one "fools" Maya/mtor into hiding data in a RIB file that is subsequently used to control a curve. Another tutorial whats in a name demonstrates how this is accomplished.

This tutorial describes the simpliest of the post-processing techniques. In the example shown on this page a sequence of widths are added to a curve. The values happen to be fixed but they could be semi-randon values. The reason why I describe this as the simpliest technique is because the values do not depend on any information in the RIB file itself; they depend solely on the values a TCL script "decides" to add to a curve or curves.

Post processing the orginal RIB's consists of,

  1. copying each RIB file
  2. add/delete data during the copy process

Any general purpose scripting/programming language can be used to post-process RIB files. This tutorial provides an example TCL script that is able to process the RIB files located in a "target" or "source" directory. The script assumes the post-processed RIB's are to be saved in a "destination" directory. Before continuing you may wish to review another tutorial dealing with file filtering.

The script shown on the right assumes,

  • the original Maya curves had 4 cv's, as a consequence
  • each RenderMan Curves statement in the RIB files produced by mtor has 8 cv's.

Because the Curves statements in the RIB files consist of 8 cv's each curve will have 6 segments and as such we will be able to add 6 widths. Refer to the previous tutorial that deals with curve segments for more details.

Before using this script decide what width values you wish to use and edit the script appropriately. Other than that the only other edit you will need to make is to change the paths leading to the input and output directories on the last line of the script.

For example, figure 1 shows that the "source" RIB's are located in the default mtor "rib" directory while the "destination" directory is called "out_ribs".

To run the script save it as "addCurveWidths.tcl". Then "cd" to the directory in which it is saved and enter this command,

tclsh addCurveWidths.tcl

The time taken to produce the copies will obviously depend on the number of RIB's and their size. RIB files 1MB in size will each take about 2.5 seconds to process. Once the copies have been produced they can be batch rendered. If you are using the Cutter text editor choose the menu item Templates->Tcl->cutrPrmanBatchRender.tcl. This will produce another Tcl script that can be used to render all the copied RIB's.



addCurveWidths.tcl

# This script assumes the Curves in the RIB files have 8 cv's
proc addCurveWidths { inpath outpath } {
    set in [open $inpath r]
  
    # base the name of the output rib on the 
    # name of the input rib prefixed with "copy_"
    set inname [file tail $inpath]
    set outname "/copy_"
    append outname $inname
  
    append outpath $outname
    set out [open $outpath w]
    
    # a flag to indicate a Curves
    # statement has been found
    set flag 0
    
    while { [eof $in] != 1 } {
        # read a line of text
        gets $in line
    
        # get the first item from the list of words on a line
        set firstword [lindex $line 0]
    
        # we've found a Curves statement...
        if { $firstword == "Curves" } {
            set flag 1
            }
        # look for AttributeEnd
        if { $flag == 1 && $firstword == "AttributeEnd" } {
            # insert some arbitary width values
            puts $out " \"width\" \[0.4 0.1 0.05 0.01 0.01 0.1\]" 
            set flag 0
            }
        puts $out $line
        }
    close $in
    close $out
    }

proc processRibs { src_dir  dest_dir } {
    set contents [glob -nocomplain -directory $src_dir *.rib]
    foreach item $contents {
        puts "Processing rib file called $item"
        addCurveWidths $item $dest_dir
        }
    }
# Edit this for your rib files
set srcDir "H:/maya/projects/default/rib"
set dstDir "H:/out_ribs"
processRibs $srcDir $dstDir


in_out_folders
figure 1





© 2002-5 Malcolm Kesson. All rights reserved.