Thursday, January 20, 2011

Custom slim.ini

With every new version of Slim, Pixar changes the method of organization their standard templates. And adding custom templates to default hierarchy each time became a bit tricky. With RMS 1.0 I was forced to be rejected of my previous methods and started to learn, how to use very smart palette conception.


Define some variables at first.
#
# Use RAT_SCRIPT_PATHS to locate this slim.ini 
#
set userTempl [GetEnv RAT_SCRIPT_PATHS]
set vers [GetVersion]
LogMsg INFO [concat {current slim version:} $vers]
LogMsg INFO [concat {RAT_SCRIPT_PATHS:} $userTempl]
Next, I define shader compiler with options for back compatibility and include directory where located my .h (header) files for custom slim templates.
%I - will be replaced with standard include directories.
SLIM_USER_INCLUDE - user defined environment variable (e.g. d:/slim/INCLUDE)

SetPref ShaderCompiler {"$RMANTREE/bin/shader" -back -I%I -I[GetEnv SLIM_USER_INCLUDE] %f}
Load custom commands and user interface (UI) templates
#-------- Custom UI/Cmd
LoadExtension slim [file join $userTempl mesh//meCustomCmd.slim] customcmd

LoadExtension slim [file join $userTempl mesh//meMacros.slim] customui
LoadExtension slim [file join $userTempl mesh//meCustomUI.slim] customui
LoadExtension slim [file join $userTempl mesh//meSoftBoxUI.slim] customui
LoadExtension slim [file join $userTempl mesh//meCombineAOV_UI.slim] customui
LoadExtension slim [file join $userTempl mesh//meAddAttribute_UI.slim] customui
LoadExtension slim [file join $userTempl mesh//meEnsemble_UI.slim] customui
LoadExtension slim [file join $userTempl mesh//meVisualizers.slim] slim
Create list of custom slim templates
#-------- Registered
set custom_list {
  "mesh//meBake.slim" { 
   { mesh,meBakeableColor#0 color "meBakeableColor"  utility }
   { mesh,meBakeableFloat#0 float "meBakeableFloat"  utility }
   { mesh,meBake3D_F#0 float "meBake3D_float"  utility }
   { mesh,meBake3D_C#0 color "meBake3D_color"  utility }
   { mesh,meTexture3D_F#0 float "meTexture3D_float"  utility }
   { mesh,meTexture3D_C#0 color "meTexture3D_color"  utility }
   { mesh,meBakeAreas#0 surface "meBakeAreas"  surface }
   { mesh,meBakeRadiosity#0 surface "meBakeRadiosity"  surface }
   { mesh,meBakeSSS#0 surface "meBakeSSS"  surface }
 }
  "mesh//meIBI.slim" { 
   { mesh,meIBI#1 shadingmodel "meIBI" shade }
   { mesh,meDiffuseIBI#0 color "meDiffuseIBI" shade } 
   { mesh,meSpecularIBI#0 color "meSpecularIBI" shade }
 }
... skipped
}; # end of custom_list
Register templates
foreach {fileref tmpltList} $custom_list {
  set filter {}
  foreach template $tmpltList {
    foreach {id type label tags icon} $template {}; # multi-assignment
    array unset interface
    array set   interface {}
    
    if {[llength $type] > 1} {
      array set interface $type
      if [info exists interface(outputs)] {
        set type $interface(outputs)
   if {[llength $type] > 1} {
     set type "multiple"
        }   
      }
    }
    LoadExtension slimtmplt [file join $userTempl $fileref] 
    [list $id $type $label $filter $tags $icon [array get interface]]
  }
}
After starting Slim with this slim.ini, when all custom templates are successfully loaded, create new smart palettes with rules describing their location by templateID, attachment type, output types, tags and so on. Slim will create slim.prefs file somewhere in user home directory ( e.g. on Win7 it is located in C:\Users\mesh\AppData\Roaming\Pixar\RenderMan_Studio\1.0 ). Copy the part with smart palette description at the end of your custom slim.ini:
SetPref SmartPalettes(create) {
  smartpalette meshPalette {
    criterion templateID {contains mesh}
    smartpalette Attachable {
      state closed
      criterion attachmenttype {isNot {}}
      smartpalette Surface {
        criterion attachmenttype {is surface}
      }
      smartpalette Displacements {
        criterion attachmenttype {is displacement}
      }
      smartpalette Other {
        criterion attachmenttype {isNot surface}
        criterion attachmenttype {isNot displacement}
        criterion attachmenttype {isNot light}
        criterion attachmenttype {isNot volume}
      }
      smartpalette Volumes {
        criterion attachmenttype {is volume}
      }
      smartpalette Lights {
        criterion attachmenttype {is light}
      }
    }
    smartpalette Subordinate {
      state closed
      criterion attachmenttype {is {}}
      smartpalette ColorFloat {
        criterion outputtypes {include ColorFloat}
      }
      smartpalette Floats {
        criterion outputtypes {include float}
        smartpalette Maps {
          criterion tags {include map}
        }
        smartpalette Pattern {
          criterion tags {include pattern}
        }
        smartpalette Trace {
          criterion tags {include trace}
        }
        smartpalette Utility {
          criterion tags {include utility}
        }
      }
      smartpalette Colors {
        criterion outputtypes {include color}
        smartpalette Shade {
          criterion tags {include shade}
        }
        smartpalette Maps {
          criterion tags {include map}
        }
        smartpalette Pattern {
          criterion tags {include pattern}
        }
        smartpalette Trace {
          criterion tags {include trace}
        }
        smartpalette Utility {
          criterion tags {include utility}
        }
      }
      smartpalette Manifolds {
        criterion outputtypes {include manifold}
      }
      smartpalette Geometry {
        count any
        criterion outputtypes {include point}
        criterion outputtypes {include vector}
        criterion outputtypes {include normal}
      }
      smartpalette String {
        criterion outputtypes {include string}
      }
      smartpalette ShadingModelFloat {
        criterion outputtypes {include ShadingModelFloat}
      }
      smartpalette SoftBoxCard {
        criterion outputtypes {include SoftBoxCard}
      }
    }
  }
... skipped
  
}

No comments:

Post a Comment