Compiling RenderMan extensions in Mac OS X

The RenderMan Shading Language is very feature rich, but at some point, you may need to extend the language to do something it doesn’t do out of the box. To do this, you must write a DSO Shadeop.

I have written several of these using PRMan’s SDK at school, but when it came time to write one at home using 3Delight on my Mac, I was at a loss. The 3Delight documentation regarding DSOs describes how to write a very simple one and compile it using the command line. Compiling stuff with the command line is cumbersome, so I worked out a way to do it with the XCode IDE.

First, I tried creating a compiling one of XCode’s C++ dynamic library projects, but was unable to link the resulting library in when it came time to compile the shader. The example in the 3Delight documentation compiles to a “.so” file (shared object, I assume), so I set about trying to create one with XCode.

To do this, first create a new project of type CFBundle.

Create Project

Once done, delete everything in the External Frameworks and Libraries group - we won’t be linking against the CoreFoundation framework (of course, leave it in there if you want to link against CF).

This project will generate a “.bundle” file, which is actually a directory with a bunch of stuff inside. What we want to do is grab the actual library out of this directory, append the “.so” extension to it, move it to the build directory, and delete the bundle. I found a nice script to do this on an Apple mailing list. Add a new “Run Script” build phase to the target (right-click on the bundle target and select Add->New Build Phase->New Run Script Build Phase). Add the following script:

cd ${BUILD_DIR}/${CONFIGURATION} mv ${PRODUCT_NAME}.${WRAPPER_EXTENSION}/Contents/MacOS/${PRODUCT_NAME} ${BUILD_DIR}/${CONFIGURATION}/${PRODUCT_NAME}.so rm -rf ${PRODUCT_NAME}.${WRAPPER_EXTENSION}

Here is what it should look like:

script.jpg

At this point, you can add source to the project, and follow the directions here to write your DSO. Once finished, add the resulting .so file to some directory you’ll remember (I used /Applications/Graphics/3Delight-7.0.0/lib). When you compile the DSO, add an include flag to the shader compiler pointing at the lib directory:

shaderdl -I/Applicaitons/Graphics/3Delight-7.0.0/lib/ myShader.sl

or

shaderdl -I$DELIGHT/lib/ myShader.sl

I hope that helps!