phase 12:
non-photorealistic rendering:
automated technical illustration
overview
this assignment was to explore and implement techniques for rendering images in non-photorealistic styles. one such technique is to automate the process of creating technical illustrations from 3D geometry, as presented in the paper "A Non-Photorealistic Lighting Model for Automatic Techincal Illustration" by Amy Gooch, et al., at the University of Utah Computer Science NPR Group.
technical illustration model and theory
The purpose of technical illustrations is to communicate geometry to the person viewing the image. One long-standing convention with this goal in mind is to draw the outlines of surfaces, typically making them black. The interiors of surfaces are then shaded to convey information about the curvature of the surface. Typically, bright hilites are drawn in white. We would like the hilites and outlines to be visually distinct from the rest of the surface shading, which effectively restricts the range of intensity values available to us.
Standard shading models vary from complete black in areas of no illumination to the surface's diffuse color (which could be close to white) at areas of full illumination, which inherently poses problems since we are trying to avoid intensities close to black or white. Furthermore, in regions where the dot product of the light vector L and the surface normal N is less than 0, a surface is considered to be unilluminated (and thus is rendered black), which means that we are not communicating information about surface curvature for (on average) half of each surface. This is not good.
The solution, inspired by observations of how technical artists tend to draw, is to employ a shift in color hue to communicate surface curvature. Rather than range from L dot N = 0 to L dot N = 1, we range from L dot N = -1 to L dot N = 1, shifting from a cool color to a warm one. In this manner, we use the full range of L dot N to communicate surface curvature. The cool and warm colors are chosen with intensities such that the full range is visually distinct from both black and white. If desired, the user may specify blending parameters such that the cool and warm colors used for each surface are somewhat dependent on the surface's diffuse color. For example, in Gooch's paper, a blue-to-yellow shift is typically employed, with variable blending to convey surface color as well. Thus, a surface with a red diffuse color might appear as shifting from violet to orange.
object outlines
Object outlines are generated by traversing a polygonal mesh, and adding polygon edges to be drawn if one of the three following conditions is met: 1.) the edge is a topological edge of the surface; 2.) the edge has one visible triangle and one obscured triangle; 3.) the angle between surface normals of the edge's two triangles is greater than some threshold value. Getting the resulting segments to render properly using a z-buffer requires offsetting each segment slightly from the actual surface.
The following images depict the outlines generated for a torus (since a torus has no topological edges or sharp angles, we only see edges drawn as the result of rule #2). The first image shows all such edges drawn without z-buffering, and the second image uses z-buffering to hide the edge lines that should be obscured.
hue-based rendering
Given that I had already written my own software z-buffer renderer, modifying it to incorporate hue-based rendering was fairly trivial. The user specified cool, warm, hilite, and outlining colors, and blending parameters for the cool and warm colors. The renderer determines (or, if using Gouraud shading, approximates) L dot N at each pixel and assigns the color accordingly.
The following images depict, on the top, the same torus with both standard and hue-based lighting models. The bottom row adds object outlines; the bottom-left has a white diffuse surface color and the bottom right has a red surface.
some examples
the following image depicts five toruses drawn using the same parameters to the technical illustrator (using hue-based shading from yellow to blue), with different surface colors (from the bottom: white, red, yellow, green, blue). the following sequence of images depicts a simplified version of a differential for a car, using various rendering models -- in order, default shading (the image is rather hard to decipher), just outlining (the image is somewhat easy to parse, but we have no information about surface curvature), default shading with object outlining (the outlines add some clarity, but in dark regions cannot be distinguised), hue-based shading (object distinctions are somewhat unclear, but now surface curvature in un-iluminated regions is evident), hue-based shading with object outlining (curvature and object boundaries are distinct), and hue-based shading with object outlining and color-coding of various components (the coloring helps us partition the image into separate objects).
what's a differential?
In case you don't know, and yet care, a differential is a gearing assembly in a car which allows the transmission of power to the wheels even when the wheels may be turning at different rates (because the car is cornering). In the color-coded images, the orange shaft at the bottom connects to the car's transmission, and the blue and green shafts connect to the car's wheels. When the car is going straight, the blue and green shafts turn at the same rate and the red and yellow gears remain stationary. However, when cornering, the blue and green shafts will inherently need to turn at different rates, and so the red and yellow gears turn accordingly so that on average the blue and yellow shafts turn at the same rate as the big white gear. The animations at the top of this page demonstrate this (they are each several megabytes, so my apologies for delays in loading)