RenderMan
Reverse Orientation & Quadrics


return to main index


Introduction

Prior to Cutter version 5.2.9 rib files generated by Rman Tools were structured loosely on a simplified version of a typical rib file generated by mtor. Mtor was a Pixar plugin that enabled Maya to use the facilities of RenderMan. The plugin was part of a suite of applications collectively known as RenderMan Artist Tools (RAT). The problem relating to the shading of quadric surfaces outlined on this page was caused by mtor's use of the rib statement ReverseOrientation.

In 2007 Pixar replaced RAT with RenderMan Studio (RMS). RMS rib files do not use ReverseOrientation because its plugin "RenderMan for Maya Pro" (Rfm Pro) specifies geometry with "right-handed" orientation whereas the mtor plugin specified geometry in RenderMan's native "left-handed" orientation. The following notes have been retained despite the fact they are far less relevant now that Cutter, following Rfm Pro, also no longer uses ReverseOrientation in the rib files it creates.

Following the standard practice of "converting" the world block to right-handed orientation, mtor, Rfm Pro and Cutter apply a negative scaling to the z-axis of the camera/world transformations. This ensures the world block will use a right-hand coordinate system - listing 1 (red text).

Listing 1


Option "searchpath" "shader" "@:PATH_TO_YOUR/shaders"
Option "searchpath" "texture" "PATH_TO_YOUR/textures"

Display "untitled" "framebuffer" "rgb"
Format 427 240 1
Projection "perspective" "fov" 40
ShadingRate 1

Translate  0 0 5
Rotate -30 1 0 0
Rotate 0   0 1 0
Scale 1 1 -1

WorldBegin
    ReverseOrientation
  
    # Lights and surfaces etc
WorldEnd

The rib files produced by mtor and Rfm Pro use a single ConcatTransform statement rather than a sequence of individual transformation commands ie.

ConcatTransform [ 0.707 -0.331 -0.625  0.0
                  0.0    0.884 -0.469  0.0 
                 -0.707 -0.331 -0.625  0.0 
                  0.0    0.0   44.822  1.0 ]

Cutter uses a sequence of transformation commands because they are easier to understand.


The World According to Mtor

Although the world block is right-handed, surfaces such as polygons have their vertices ordered to conform to RenderMan's native coordinate orientation ie. left-handed. The ReverseOrientation shown in blue text, in effect, tells the renderer to compensate for the mis-match of right and left-handedness. This works for all types of geometry except surfaces known as quadrics. The ReverseOrientation statement has the undesired effect of turning quadric surfaces "inside-out".

Therefore, when testing a shader with a rib file generated by Cutter, version 5.2.8 or earlier, or a rib file written by mtor care had to be taken with quadrics.

Listing 2


surface
outside_red(float    Kd = 1)
{
color   surfcolor = color(0,1,0);
normal  n = normalize(N);
normal  nf = faceforward(n, I);
  
Oi = Os;
  
color  diffusecolor = Kd * diffuse(nf);
  
if(n == nf)
    surfcolor = color(1,0,0);
  
Ci = Oi * Cs * surfcolor * diffusecolor;
}

The shader shown in lising 2 assigns red to the (outside) front facing surfaces of an object and green to (inside) rear-facing surfaces. Figure 1 shows an image of a sphere that was rendered without taking ReverseOrientation into account. Figure 2 shows the effect of undoing the default ReverseOrientation by applying another ReverseOrientation immediately before the sphere.



Figure 1 - incorrect

        AttributeBegin
            Surface "outside_red"
            Sphere 1 -1 0 360
        AttributeEnd

Figure 2 - correct

        AttributeBegin
            Surface "outside_red"
            ReverseOrientation
            Sphere 1 -1 0 360
        AttributeEnd

Prior to Rfm Pro it was essential to "sandwich" a quadric and an additional ReverseOrientation within an AttributBegin/AttributeEnd block. TransformBegin/TransformEnd could not be used because doing so would have caused ReverseOrientation to be applied to other objects defined in the rib file.


The situation is made more confusing when reflections are taken into account. Figure 3 shows what happens to the reflected image of a quadric cylinder that has not received an additional (compensating) ReverseOrientation!



Figure 3



© 2002- Malcolm Kesson. All rights reserved.