Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

After the displacement has been done, any smooth analytical normals that the original surface may have had (for example a smooth subdivision surface or NURBS patch) are no longer valid – they do not correspond to the displaced surface.  Each micropolygon has a geometric normal Ngn.  In addition, for some surface types a smooth shading normal will be automatically computed for each ray hit – this is done by considering the orientation of not only the micropolygon that the ray hit, but also the adjacent micropolygons.

(( Displaced polygon meshes deserve a special mention here.  Polygon meshes do not by themselves have smooth normals, but are often defined with a normal at each polygon mesh vertex point.  When a ray hits a face of an undisplaced polygon mesh, the shading normal Nn can be computed by interpolating the normals of the face vertices, leading to a smooth appearance.  But for a ray hit on a displaced polygon mesh, those vertex normals are no longer valid after the displacement.  A classic and very useful trick is to add back the difference between ... at ray hits on the displaced polygon mesh.  WAIT A MINUTE – this trick is for bump mapping, not displacement, right?? The PxrBump shading node and RixBump() function both employ this trick. ))

Displacement bounds

BVH bbox tightening.  Not too large: important for ttfp.  Not too small: holes.  Balance.  Will give warning after (rendering completed) if too small or more than 10 times too large.

TO DO: Figure with holes due to too small displacement bound.

In order to ray trace a scene efficiently, RenderMan needs to know where the objects are.  Objects are organized into a ray acceleration data structure: a bounding volume hierarchy (BVH) where each node in the hierarchy is a bounding box for the objects below it in the hierarchy.  For displaced surfaces computing these bounding boxes is a bit tricky because we don't know where the surface points actually are until the displacement shader has run.  But we don't want to run the displacement shader on all displaced surfaces before tracing the first rays – if we did, the time-to-first-pixel would suffer.  What we need is a rough indication of how large the the displacement might be, without the expense of running the displacement shader to determine the exact displacement.  Such an indication must be provided with a displacement bound for each displaced object, which is an upper bound on the displacement on that object.  For example, if we know that the maximum magnitude of displacement on a given object is 0.5 units, then we can specify the displacement bound like this:

  Attribute "displacementbound" "float sphere" [0.5]

This bound means that any ray that is farther than 0.5 units away from the undisplaced surface can ignore that surface.  Only when a ray hits this "padded" bounding box do we need to run the displacement shader.  Once the displacement shader has run and all the positions are known, their bounding box is computed and the BVH node bounding box is tightened.  Selecting an appropriate displacement bound is important: if it is too large, the time to first pixel will be slow; if it is too small, the image will have holes (see figure below).  In most case, the displacement bound is just the same as the magnitude parameter of the displacement.  To help select an appropriate displacement bound in harder cases, RenderMan will give a warning (after rendering completed) if the specified displacement bound was too small or more than ten times too large.

Example

Here is an example of a fragment of a rib RIB file with a sphere being turned into a five-pointed star:

...

In this example, the displacement amount computed by dispstar gets passed on to the PxrDisplace displacement shader, which does the actual displacement.  Here is an image of a sphere and the same sphere displaced with this combination of shaders (along with an image with holes rendered with too small displacement bound):

TO DO: image images of sphere, displaced sphere = star, and displaced sphere with holes due to too small displacement bound.

The seasoned RenderMan user will notice this is all very similar to how displacement was done in the classic RenderMan Shading Language (RSL) – see for example Apodaca and Gritz, 2000 section 8.2.