Short Contents

7.11 Rendering Outlines for Illustrations

3Delight has advanced "inking" features for "toon rendering" and other illustration purposes. This is implemented using edge detection algorithms in image space. All edge detection features are controlled through parameters to the RiDisplay call. Since 3Delight can output many such displays in one render, it becomes possible to output different edge detection results into different files or framebuffers. For example, one display can output edge detection based on depth variation and another one on surface normals variation.

outlines

Figure 7.5: Outlines on Oi (opacity) and z (depth). Note how outlines get thinner with distance. Example scene available in `$DELIGHT/examples/toon'.

Additionally, it is possible to output, in the same display, edges detected on many variables at once (such as depth, normals and any other surface variable). Table 7.1 contains the list of all edge detection parameters accepted by RiDisplay.

Parameter Default Value Description
"string edgevariables" "" Comma separated list of variables to be used for edge detection.
"float edgethreshold" 1e30 Controls edge detector sensitivity.
"float edgefilterwidth" 2 Controls edge width. This can be a fractional number and can be set to smaller than 1.0 to get very thin outlines. Note that to have proper anti-aliasing on thin outlines, one should use higher PixelSamples.
"float edgewidth" 0 Controls edge width. This can be specified instead of edgefilterwidth. It is relative to the frame width (eg. 0.001 on a 1k frame will give 1 pixel edges).
"color edgecolor" [1 1 1] Color of the generated edges.
"float edgefadeout" [near far minwidth] Controls edge thickness fadeout with depth. near and far specify the depth range in which the fadeout will be performed. minwidth specifies the minimum outline width.
Table 7.1: RiDisplay parameters for edge detection.

At least edgevariables and edgethreshold must be specified to enable edge rendering. It works by looking for abrupt variations of one or more output variables over the image. For example, rendering outlines based on changes in depth would be done with:

Declare "outline" "color"
Quantize "outline" 255 0 255 0.5
Display "depth_outline.tif" "tiff" "outline"
    "string edgevariables" "z"
    "float edgethreshold" 0.1
    "float edgefilterwidth" 1.5

The Declare command specifies an aribitrary output variable which is used as a placeholder for edge data. A Quantize command is used to specify that the output is to be 8-bit. Variables specified with edgevariables (in this case only 'z') are the ones processed to detect edges.

It is possible to use any predefined or user-defined output variable to control the presence of outlines. It is also possible to process more than one variable in the same image. For example, to emphasize the contour of the object in the previous example we would use:

Declare "outline" "color"
Quantize "outline" 255 0 255 0.5

DisplayChannel "N"
    "float edgefilterwidth" 1
    "float edgethreshold" 0.3

DisplayChannel "Oi"
    "float edgefilterwidth" 2.5
    "float edgethreshold" 0.1
    "color edgecolor" [1 0.3 0.3]

Display "mixed_outline.tif" "tiff" "outline"
    "string edgevariables" "N,Oi"

Notice that this time we base most of the edge detection on normals instead of depth. Which is better depends on the scene involved and the goals of the artist. Finally, 3Delight allows basic compositing of detected edges over any output variable. For example, to see what the edges would look like over the normal image:

DisplayChannel "N"
    "float edgefilterwidth" 2
    "float edgethreshold" 0.3
    "color edgecolor" [0 0 0]

Display "cheesy.tif" "tiff" "rgb"
    "string edgevariables" "N"

color image outline image outline image color image
Figure 7.6: Example of edge detection using normals. The first image is a standard render. The next one is the result of finding normal outlines. The third image is a combination of normal outlines and opacity outlines. The final image is of black outlines composited over the rgb display.

3Delight 10.0. Copyright 2000-2011 The 3Delight Team. All Rights Reserved.