Attaching archives during render time with -addsphereRI

This project was about creating and editing RenderMan attributes in Maya. preshapemel attribute was imported to the objects in the scene to switch the points of the actual object with a rib archive or a simple sphere before prman takes the scene over. The interface is created with the help of an rman script which does the heavy lifting of MEL UI programming.

First video on the right is the model without alterations, as seen in the Maya viewport. Second video is with the injected spheres, and the third one is with the custom rib archives.

xxxUI.rman script generates the xxxUI.mel script which is the graphical user interface for the newly created keyable parameters. xxxRI.mel is the actual script file that contains the backend of the replacement process. It calls the procedure in xxxUI.mel file to query the interface and pick up the values. Below are the complete scripts

UPDATE

I added a few more controls to the interface as well as centralizing them on a null (yes they are called nulls, not locators). New controls include the display of the original surface in the render, number of points to be used for injection, and some more experimental (read non-functioning) channels. The reason I wanted everything to be controlled from a null is because there may be more than one object in the scene where an artist might want to slap these injections on.

I have been experimenting with blobby surfaces as well as converting the vertices to particles so that they can generate curves, like a motion trail. This part of the code needs a lot of work, and I also have to find an elegant way to make the converted particles follow the vertices.

NOTE: If you need to delete the rman parameters from your scene and start over and don't have a clean scene file in hand, save your scene file as Maya ascii (it will hang maya for a while if you are on unix), search for all the lines that include "rman" and delete them. RenderMan UI is very buggy in terms of refreshing. Also if you used the script, there should be expressions attached to each shape node linking them to the control null, you will have to go thru each shape node and break the connections manually before removing the RenderMan attributes from the attribute editor. Otherwise you will encounter an epic bug that will force you use the ascii method.

Baking objects into pointclouds

bkmglass-1

Pointclouds and brickmaps can improve the render performance greatly since they “bake” a 3d model with any shader data that is needed for the render just once, and can be used over and over again. In some cases the original model doesn’t even have to be used for the render, brickmap which is free of polygon, or nurbs data can be rendered easily and very fast without encountering any problems that modeling techniques may cause while deforming the object. In this example baking techniques have been used for creating an occlusion pass.

The car model used for this example was brought in from an earlier version of XSI as an obj file. It caused problems with normals in Maya. But that was easily solved with averaging the normals by a very small value which is a built in function in Maya. That solution worked for MentalRay.

But with RenderMan there was another problem, the model seemed not to have any s and t values at all. After working on it for some time I figured out that applying automatic texture projection to the model added the proper s and t values to the rib file. I believe this problem was caused by the obj export plug-in in XSI, which actually built a shader network that worked well with Maya and MentalRay, but probably messed up the u and v coordinates.

bkmnoshadow-2

Here is how it works

The shader is responsible for creating a pointcloud if it doesn’t exist. Then the rib file takes over and bakes the pointcloud into a brickmap, which is tiny in size compared to the pointcloud and faster to render as well.

This takes some time with heavy models and pointcloud file size can easily go over 100-150 megs. After it is complete another rib file reads the brickmap as if it is an object, and renders it. At this point I tried adding render-heavy shaders to the brickmap and got a much much better performance than using the actual model.

bkmraytrace-2

The first picture shows the glass shader that usually takes more than 10 minutes to render on this model per frame. On the brick map it rendered in less than a minute with a HDR environment map.

The image to the right shows a test I ran with raytrace just to see what would I get. I was expecting a very noisy shadow with tiny holes everywhere. But the points in the brickmap were so close to each other, raytracing worked as if it was a real geometry. Brickmap is rendered with defaultsurface shader.

Here is the result with a glass shader and an HDR map applied.. looks cool.

bkmglass-1

Matrix composition

This exercise demonstrates the basics of scripting shapes directly into a RenderMan RIB file. Coding shapes in this way focuses attention on the use of color, opacity and the fundamental concepts related to xyz coordinate system.

The staircase was modeled by coding thru a rib file. After placing 4 stairs in place, I archived the rib filed to duplicate, then 8, 16, and finally 32.

All the objects were archived in one rib file as well, for the sake of organizing a proper rib file.

Images were rendered with 3delight so the rib file is slightly different than Pixar’s RenderMan

download staircase_model.zip

Maya pattern animation

The animation and notes on this page explain how custom shaders written in the RenderMan Shading Language can be animated using SLIM parameter expressions.

Final image is a composite of Maya playblast wireframes and rendered images. All the animation shown here is dynamics except for the stretch and squash.

After setting up a regular 3d bouncing ball simulation I copied the baked animation to the sliders that control the shader animation. One adjustment to the baked keys was to reverse the y axis since renderman t axis is inverse.

[mattr “pCube1._parameter_” f$] tcl expression was used to feed the Maya animation data to RenderMan shader variables.

It is possible to control the color of the surface, the ball, and the line, the position of the ball and the line, the size of the ball in terms of its radius, squash and stretch, and the line in terms of its thickness.

Even though the shader isn’t complex, it is still having trouble with image maps and causing maya and RAT not to respond, occasionally. Couldn’t figure out why...

download patternanim_shader.sl

st coloration

cross_shader
surface
cross_shader()
{
    color surfcolor = (1);
    if (t >= 0.2 && t <= 0.8)
        surfcolor = color .2; //(1,0.52,0);
    if (s >= 0.2 && s <= 0.8)
        surfcolor = color .2; //(1,0.52,0);
    Ci = surfcolor;
}
surface
diagonal_shader()
{
    color surfcolor = (0.36,0.28,0.0001);
    if (t >= 0.2 && t <= 0.8 && s >= 0.2 && s <= 0.8)
        surfcolor = color .2;
    Ci = surfcolor;
}
surface
quadrant_shader()
{
    color surfcolor = (1);
    if (t < sqrt(1-(s*s)))
        surfcolor = color .2;
    Ci = surfcolor;
}
square_shader
surface
square_shader()
{
    color surfcolor = (1);
    if (t >= 0.2 && t <= 0.8 && s >= 0.2 && s <= 0.8)
        surfcolor = color .2;
    Ci = surfcolor;
}
unique_shader
surface
unique_shader()
{
    color surfcolor = (1);
    if ((s-.5)*(s-.5)+(t-.5)*(t-.5) > .30) //surrounding circle
        surfcolor = color .2; //(1,0.52,0);
    if (t > s*-6 +1.4 && t < s*-6 +2.1 && t > .1 && t < .8) //long vertical of "h"
        surfcolor = color .2;
    if (t > s*-6 +2 && t < s*-6 +2.9 && t > .445 && t < .56) //horizontal of "h"
        surfcolor = color .2;
    if (t > s*-6 +2.55 && t < s*-6 +3.21 && t > .48 && t < .8) //short vertical of "h"
        surfcolor = color .2;
    if ((s-.4)*(s-.4)+(t-.5)*(t-.5) < .003 && t < .5 && s >.4) // interior 1 quadrant circle of "h"
        surfcolor = color .2;
    if ((s-.294)*(s-.294)+(t-.6)*(t-.6) > .002 && t > .56 && t < .595 && s > .25 && s < .3) // exterior left quadrant circle of "h"
        surfcolor = color .2;
    if ((s-.285)*(s-.285)+(t-.6)*(t-.6) > .002 && t > .56 && t < .595 && s > .3 && s < .35) // exterior right quadrant circle of "h"
        surfcolor = color .2;
    if (t > s*-6 +3.9 && t < s*-6 +4.7 && t > .48 && t < .98) // long vertical of "p"
        surfcolor = color .2;
    if (t > s*-6 +5.2 && t < s*-6 +5.9 && t > .53 && t < .8) //short vertical of "p"
        surfcolor = color .2;
    if (t > s*-6 +4 && t < s*-6 +5.6 && t > .48 && t < .595) //upper horizontal of "p"
        surfcolor = color .2;
    if ((s-.84)*(s-.84)+(t-.536)*(t-.536) < .003) // interior upper quadrant circle of "p"
        surfcolor = color .2;
    if (t > s*-6 +4.5 && t < s*-6 +5.6 && t > .74 && t < .85) //lower horizontal of "p"
        surfcolor = color .2;
    if ((s-.795)*(s-.795)+(t-.795)*(t-.795) < .003) // interior lower quadrant circle of "p"
        surfcolor = color .2;
    if ((s-.725)*(s-.725)+(t-.635)*(t-.635) > .002 && t < .635 && t > .58 && s < .725 && s > .65) // exterior left top circle of "p"
        surfcolor = color .2;
    if ((s-.72)*(s-.72)+(t-.635)*(t-.635) > .002 && t < .635 && t > .58 && s > .725 && s < .8) // exterior right top circle of "p"
        surfcolor = color .2;
    if ((s-.705)*(s-.705)+(t-.7)*(t-.7) > .002 && t > .7 && t < .8 && s < .77 && s > .65) // exterior bottom circles of "p"
        surfcolor = color .2;
    Ci = surfcolor;
}

These images show the results of using the RenderMan Shading Language (RSL) to write a variety of special effects surface shaders. The notes and RSL code accompanying each image explain how each effect was achieved.

Most challenging part of this project was to figure out how to get circular shapes, and as it turns out (x-x1)*(x-x1)+(y-y1)*(y-y1)+r is the way to go, since it graphs a circle centered on x1,y1 with the radius of r.