Microsoft KB Archive/180226

INFO: Toon Rendering with SOFTIMAGE 3D and Mental Ray

PSS ID Number: Q180226 Article last modified on 02-06-1998

IRIX:3.7; WINNT:3.7

IRIX winnt

================================================================ ==

The information in this article applies to:

 Softimage 3D for IRIX, version 3.7 == Softimage 3D for Windows NT, version 3.7 == 

= SUMMARY =

This article provides an explanation for the following:


 * 1) Toon Rendering
 * 2) Toon Shaders
 * 3) The ToonAssistant
 * 4) When to apply Toon material shaders manually when using the ToonAssistant
 * 5) Antialiasing settings when using Toon rendering
 * 6) Toon rendering slower than normal rendering
 * 7) Special modeling techniques for Toon rendering
 * 8) Using mental ray’s motion blur when Toon rendering
 * 9) Using mental ray’s depth of field when Toon rendering
 * 10) Setting up materials for Toon rendering
 * 11) Visible ink lines
 * 12) Color(s) of Ink lines
 * 13) Making an object composed of several models appear as one model, without the “seams” visible where the models intersect
 * 14) Dialog that appears every time you render with the ToonAssistant
 * 15) Simulating a “dark” Toon scene (night scene)
 * 16) Ink Variation controls

= MORE INFORMATION =


 * 1) Toon rendering

Toon rendering with SOFTIMAGE 3D (SI3D) is a method of simulating cel animation (such as 2D or traditional animation) using 3D-animation techniques; common characteristics of cel animation, such as contour lines, outlines, and solid color shading are all replicated. It is possible to render 3D models and animation so that the results are indistinguishable from images created using traditional cel techniques. Because the images you are imitating are produced using ink-and-paint techniques, you can refer to many of the 3D equivalents using similar terms: ink (instead of contour lines), paint (shading), etc.

2.Toon Shaders

To create a Toon rendering, shaders are used. The mental ray renderer uses the shaders to achieve the ink and paint effects. Shaders, like plug-ins for other software, enhance the basic capabilities of mental ray. When Toon rendering, instead of shading models with Phong, Flat, or Lambert shading (the defaults), you can use Toon shading to create the flat-color highlights and shadows on surfaces.

There are two Toon shaders that are relied on most: a lens shader (for ink effects) and a material shader (for paint effects). These shaders work together to create a complete Toon rendering. The lens shader has a global control over ink; it allows control over line width, waviness, color, etc. The material shader, because it is applied to each individual model (or parts of a model if it is a polygonal mesh), allows local control of Toon rendering attributes. That is, local control of both the paint effect (size of highlight, style of highlight, etc.), and certain parameters of the ink used on each model (for example, each Toon material shader may specify a different line width, relative to the line width specified to the lens shader).

Though you can use the material shader alone without the lens shader, the ink effects are not rendered. None of the lens shader’s ink effects will render without the material shader applied to models, so the two shaders are usually used together.

 The ToonAssistant

The ToonAssistant is a plug-in for SI3D that offers a convenient interface for managing the shaders application (allows previews of the scene, and animation of the various rendering parameters). Using the ToonAssistant allows you to apply materials and textures as you normally would when using SI3D, then apply the Toon effects as a final step in rendering. It is not necessary to go through the tedious steps of applying shaders to each material, lens shaders to the camera, etc. When using the ToonAssistant, it is not necessary to apply the Toon lens shader, though there are particular models where it is useful to manually apply Toon material shaders.

 When to apply Toon material shaders manually when using the ToonAssistant

As mentioned earlier, there are certain properties local to each material that you can manipulate from the Toon material shader interface, such as object grouping, line width, etc. If the ToonAssistant produces satisfactory results, you will not need to use the Toon Shaders. If however, the results are unsatisfactory, and it is necessary to tweak the ink-line width of only one model, then you can apply the Toon material shader to that one model and adjust the line width from the Toon material shader interface. When rendering with the ToonAssistant, all existing Toon material shaders are left untouched and their values are used to alter the rendering properties for the models to which they are applied.

 Antialiasing settings when using Toon rendering</li></ol>

The settings depend on the results you want for the rendered images. Higher levels of antialiasing produce better results. Insufficient antialiasing is particularly noticeable where ink lines are drawn; the lines chatter during animation (in some cases, the lines show the dreaded “jaggies”). If every other frame of the animation is rendered, then less antialiasing is required. The recommended settings are:

  Use mental ray’s adaptive sampling algorithm. This minimizes wasted samples (on large empty areas of the frame). </li>  For medium-quality work with decent lines (sufficient for broadcast), set Min Samples to -1 and Max Samples to 2. When higher quality is required (film applications), set Min Samples to 0 and Max Samples to 2. For print work, add the Gaussian filter with a width and height of 2 (this adds additional smoothness by blurring neighboring samples together, though rendering is much longer). </li>  Set low over-sampling thresholds: perhaps 0.02, 0.02, 0.02. NOTE: This separates the SI3D Toon Shaders from other similar rendering products. The algorithm SI3D used for ink lines is not post-processing (graphical edge, detection), but rather, the ink lines are generated during the sampling stage, whereas post-processing filters are applied to finished pixels. SI3D ink lines are thus capable of resolving sub- pixel sized details in the model. </li></ul>

<ol start="6" style="list-style-type: decimal;"> Toon rendering slower than normal rendering</li></ol>

The Toon lens shader does more sampling (i.e., firing of rays) than mental ray’s eye-ray casting. On average, Toon rendering fires about five times the usual number of rays from the camera to render a frame. This is offset because the shading computations for Toon rendering are much simpler than those required by Phong shading. Also, because SI3D ink is rendered during the sampling process, there is no post-processing time to take into account. If multiple processors/machines are being used co-operatively, then the processing time for ink lines are divided among them. (This is not the case when post-processing is employed to render contours.) Nonetheless, rendering times are longer.

<ol start="7" style="list-style-type: decimal;"> Special modeling techniques for Toon rendering</li></ol>

Toon rendering produces satisfactory results with most models. You may prefer free-form surfaces (i.e., standard and NURBS patches) to polygonal meshes. Toon rendering free-form surfaces results in very smooth surfaces. This is necessary in simulating cel animation because most cel-animated characters and objects are drawn with smooth surfaces.

To ensure perfectly smooth surfaces when using patches, you may specify that a surface be tessellated using a view-dependant method (i.e., specify how many pixels wide each triangle resulting from patch subdivision will appear). To set the subdivision method for any model, use Info->Selection, for groups of models, use Info->mental ray. Polygonal surfaces, on the other hand, will show irregular contours at the edge of highlights if care is not used to create the illusion of smoothness.

When surfaces are smooth-shaded, such as with Phong and Lambert shading, discontinuities in surface curvature are nearly all hidden by the shading itself, though there are limits: if very large polygons are used, their flatness is obvious. Unless a stylized cutout look is desired, polygon models look best when modeled with high detail.

When polygon modeling for Toon rendering, it is recommended that you set SI3D’s display to show edge flags and sometimes even surface Normals. As well, it may be necessary to raise the automatic discontinuity threshold higher than the default 60 degrees. Where edge flags or discontinuities are shown in the SI3D modeling interface, ink lines are drawn as well. (This is an advantage because it allows modeling of ink lines by toggling edge flags between adjacent polygons.) All of the Viewpoint polygonal models that come as gifts with SOFTIMAGE 3D Toon render properly.

<ol start="8" style="list-style-type: decimal;"> Using mental ray’s motion blur when Toon rendering</li></ol>

Both ink and paint effects will motion blur. Expect much longer rendering times than without motion blur. (This is the case when not using Toon shaders, as well.)

<ol start="9" style="list-style-type: decimal;"> Using mental ray’s depth of field when Toon rendering</li></ol>

Both ink and paint effects can be rendered out of focus, but expect longer rendering times. You may need to increase the level of antialiasing.

<ol start="10" style="list-style-type: decimal;"> Setting up materials for Toon rendering</li></ol>

The simplest method for this process is to apply materials as you would when setting up a scene to render with SI3D. (The same rules apply: materials are inherited by children in a hierarchy, models without material are rendered using a default material, etc.) Then, without assigning any Toon shaders, use the ToonAssistant for the rest.

<ol start="11" style="list-style-type: decimal;"> Visible ink lines</li></ol>

The Toon lens shader “inks” the rendering in the following places:


 * The outlines of objects (i.e., their silhouettes).
 * The intersection of different models.
 * Discontinuities in models’ surfaces (such as areas of high curvature or depth from the camera, edge flags and automatic discontinuity on polygonal models).
 * Between colors (an option only available through the Toon material shader interface).

<ol start="12" style="list-style-type: decimal;"> Color(s) of Ink lines</li></ol>

With either the ToonAssistant or the Toon material shader, two basic options are available: use the ambient color assigned in the Material Editor for the ink lines, or use a custom color. If the ToonAssistant is being used, it is best to set each material’s ambient color to one appropriate for the ink lines on the model (or collection of polygons) to which the material is applied. Then, in the ToonAssistant’s Ink Color tab, make sure you choose Material Ambient for the Ink color. This allows each model to have its own ink color, as set in the Material Editor.

In certain cases, it may be desirable to use the custom ink color swatch/sliders in the Toon material shader interface (or, alternately, ToonAssistant Ink Color tab) - if, for example, the material’s ambient color is required to render shadows falling on a surface. In this case, unless you are using the same ink color for all models, use the Toon material shader interface. In either case, in addition to the basic color set for ink lines there are also options in both ToonAssistant and Toon material shader interfaces for drawing the outlines in a brighter/darker and less/more-saturated color than that used for internal contours. There are also options for modifying the color of ink lines based on whether the ink line being drawn is in or out of shadow.

<ol start="13" style="list-style-type: decimal;"> Making an object composed of several models appear as one model, without the “seams” visible where the models intersect</li></ol>

It is possible to group any number of models with each other, such that ink lines are not drawn at their intersections. This is an option available through the Toon material shader interface but not through the ToonAssistant interface. (It is compatible with the ToonAssistant tool.)

In the Ink section of the Toon material shader interface, click the option titled “Hide Seam With Objects.” A browser appears allowing you to select one or more models. (Select multiple models by holding down the SHIFT key while clicking on models’ names). To eliminate the seams from separate models, attach the Toon material shader to the primary model and, using the model browser, put the names of the other models in its Hide Seam With Objects field. If you are only trying to eliminate the seams between certain parts of the models, you need only put the name of the primary model in each of the other model’s Hide Seam fields. All though the ink is not drawn between the seams, discontinuities in surface curvature at the intersection of models will be visible as discontinuous illumination. This is remedied only by better modeling.

<ol start="14" style="list-style-type: decimal;"> Dialog that appears every time you render with the ToonAssistant</li></ol>

This informs you that some of the materials in the scene already have material shaders attached and that the ToonAssistant will not replace these shaders. This is necessary to allow use of the Toon material shaders in the same scene as the ToonAssistant (for fine control, for example).

<ol start="15" style="list-style-type: decimal;"> Simulating a “dark” Toon scene (night scene)</li></ol>

Usually, two lighting qualities distinguish nighttime images from those simulating daylight: so-called “high-key lighting” and low lighting levels. The term “high-key” refers to a high ratio of key light to fill (ambient) light, usually accomplished by having very dark shadows (in the CG world, low “ambient” illumination). “Low lighting” means lights that produce little illumination (have fairly dark colors). Keep the following point in mind when replicating this in the Toon universe. First, highlights add: this means that where two lights create overlapping highlights on a surface, the colors combine additively.

It is common to have only one light source in a Toon scene, more so for night scenes where, for example, the moon is the only light source. This is important to consider when creating a dark scene because multiple light sources will create brighter and brighter areas on surfaces that have overlapping highlights. The highlight color on a surface is actually a product of both the color of illumination reaching the surface and the specular color set in the Material Editor dialog. Thus, a red light (color 1, 0, 0) hitting a surface with a material with a blue (0, 0, 1) specular color will have no visible highlights because the product of the illumination and specular colors is black. Also, dark scenes should always have a very dark shadow color (the diffuse color in the Material Editor dialog). Consider that when no light reaches a surface with the Toon material shader applied, it will be colored with the shadow color. Therefore, this is the darkest that such a surface will be rendered.

16: Ink Variation controls

The parameters in the Ink Variation tab of the ToonAssistant or in the Toon lens shader allow you to randomly vary ink lines’ thickness and color. This is useful for achieving a realistic touch to the renderings, as well as for simulating various common drawing types (such as oil paint, crayon, Japanese brush, etc.). In the case of thickness, you have control over the amount and frequency (rate) of the variation of the line thickness. The greater the amount, the greater the difference in thickness between a line at its thickest and thinnest states. A higher rate means a line with more “wiggles,” while a lower frequency gives a smooth, varying line.

This is also true for color: you can set different amounts of variation for each of H (hue), L (“luminance” or brightness), and S (saturation), and a rate chosen for all three together. Last, you can animate all of these random variations, either by keyframing the values, or by choosing an animation speed (the animation field) other than zero. A higher value for animation gives faster variations over time; a very high number gives a “chattering” line. One thing to keep in mind is that the effects of variation settings differ depending on the rendering resolution.

= REFERENCES =

If you have any questions concerning the information contained in this article, contact support@softimage.com by e-mail. ====================================================================== Keywords : si si3d si3dmr si3dren Version : IRIX:3.7; WINNT:3.7 Platform : IRIX winnt Issue type : kbinfo ============================================================================= Copyright Microsoft Corporation 1998.