rfm2  22.0
A python-based rewrite of RenderMan for Maya
RenderMan For Maya - take 2

Python vs. C++

We will push as much code as possible to the python side for the following reasons:

  • No need to (re)compile python : code transfers easily from one Maya version to another.
  • Python development is faster than C++
  • Many of our C++ dependencies (json/xml parsers, etc) are just part of Python's standard library.
  • Everything in Maya is now accessible through Python.
  • We can even do lightweight API work (we are using a new and faster python API).
  • It makes a lot of our code more approachable to our more advanced users who may need to fix a crippling bug "right here, right now".
  • Finally, we will get rid of most of the MEL code, but that goes without saying.

Installing

NOTE: RFM tries to ignore environment variables and build a clean environment to operate in maya. You may have to delete old maya module files.

  1. Build the project.
  2. Launch Maya
  3. First ever launch:
    1. Open Windows -> Settings/Preferences -> Plugin Manager
    2. Click Browse
    3. Navigate to ${workspace}/_publish/${toolchain}/RenderManForMaya-22.x/plugins
    4. Load RenderMan_for_Maya.py
  4. Subsequent launches
    1. The plugin will be available in Windows -> Settings/Preferences -> Plugin Manager. You can either set it to auto-load or load it via a script or manually.

Startup sequence

  1. Load RenderMan_for_Maya.py
    1. setup_environment()
      1. use _rfm_directory() to get the current file's location (RenderMan_for_Maya.py) and use that to set RFMTREE.
    2. import rfm2
    3. initializePlugin()

Components

Maya Plugin

RenderMan_for_Maya.py

Python module

  • rfm2: The main module containing most of the plugin's code.
    • api: Public API for scripting RFM2.
    • config: The configuration module created at startup.
    • extensions: Extension attribute management.
    • maya_node: Maya node registration using python's dynamic typing.
    • render: Render functions.
    • renderer: Register RenderMan as a renderer in the Maya UI.
    • nodes: json node description files with validation schema.
    • ui: User interface code
      • ae_template: Attribute Editor templates
      • aov: The AOV UI in the render globals.
      • callbacks: Maya callbacks for HyperShade integration, etc.
      • common: main classes defining regular UI widgets.
      • file_dialog: Our file dialog callbacks to open, save, etc.
      • page: Organise widgets in pages/groups/tabs
      • prefs: Maya preferences UI and prefs API
      • utils: UI utilities
      • widgets: sets up UI widgets
    • utils: Various utilities
      • env: Environment variables access
      • filepath: Cross platform file paths
      • json_file: Read/write json files
      • node_desc: Store a node description
    • vp: Maya Viewport code
      • pxr_light: MPxGeometryOverride dynamic classes for lights
      • vp2: Functions to build vertex and index buffers

Debuging the python code

RenderMan_for_Maya.py is already setup for debugging in vscode:

  • You may need to install the ptvsd module. From a shell:

    sudo pip install ptvsd

  • You will also need the python plugin for vscode
  1. In RenderMan_for_Maya.py, set vsc_remote_dbg to True.
  1. Load RenderMan_for_Maya.py. It will take longer to load when vsc_remote_dbg = True, so I turn it back off when I am done and restart maya so it takes (There is no way to kill the connection once it's been enabled).
  1. In vscode, set up your debugging config:
    1. Open your launch.json by clicking the cog icon on the right side of the DEBUG menu.
    1. In launch.json, insert a new configuration for your Maya version:
      {
          "name": "Maya 2017",
          "type": "python",
          "request": "attach",
          "localRoot": "${workspaceRoot}",
          "remoteRoot": "${workspaceRoot}",
          "secret": "rfm2",
          "host": "localhost",
          "port": 3000
      }
      
    1. save launch.json
  1. Select you config's name in the DEBUG menu ('Maya 2017' in this case).
  1. Set you breakpoints. etc.
  1. Press the green start icon and you should see the debugging bar at the top of the editing window (and the info bar at the bottom will turn orange)
  1. Make crazy things in maya and start debugging !