Real-Time Rendering——Chapter 15Non-Photorealistic Rendering非真实感渲染15.1 Toon Shading15.1卡通阴影

“Using a term like ‘nonlinear science’ is like referring to the bulk of zoology as ‘the study of nonelephant animals.’ ”
—Stanislaw Ulam

“使用‘非线性科学’这样的术语就像把动物学的大部分称为‘对非灵长类动物的研究’" —斯坦尼斯拉夫·乌拉姆
Photorealistic rendering attempts to make an image indistinguishable from a photograph.Non-photorealistic rendering (NPR), also called stylized rendering, has a wide range of goals. One objective of some forms of NPR is to create images similar to technical illustrations. Only those details relevant to the goal of the particular application are the ones that should be displayed. For example, a photograph of a shiny Ferrari engine may be useful in selling the car to a customer, but to repair the engine,a simplified line drawing with the relevant parts highlighted may be more meaningful(as well as less costly to print).

照片真实感渲染试图使图像与照片无法区分。非真实感渲染(NPR),也称为风格化渲染,具有广泛的目标。某些形式的NPR的一个目的是创造类似于技术插图的图像。只有那些与特定应用程序的目标相关的细节才是应该显示的。例如,一张闪亮的法拉利发动机的照片可能有助于向客户销售汽车,但要维修发动机,突出显示相关零件的简化线条画可能更有意义(打印成本也更低)。

Another area of NPR is in the simulation of painterly styles and natural media,e.g., pen and ink, charcoal, and watercolor. This is a huge field that lends itself to an equally huge variety of algorithms that attempt to capture the feel of various media. Some examples are shown in Figure 15.1. Two older books provide coverage of technical and painterly NPR algorithms [563, 1719]. Given this breadth, we focus here on techniques for rendering strokes and lines. Our goal is to give a flavor of some algorithms used for NPR in real time. This chapter opens with a detailed discussion of ways to implement a cartoon rendering style, then discusses other themes within the field of NPR. The chapter ends with a variety of line rendering techniques.

NPR的另一个领域是绘画风格和自然媒体的模拟,如钢笔和墨水,木炭和水彩。这是一个巨大的领域,有助于同样多种多样的算法,试图捕捉各种媒体的感觉。一些例子如图15.1所示。两本较老的书提供了技术和绘画NPR算法的范围。鉴于这种广度,我们在这里集中讨论渲染笔画和线条的技术。我们的目标是给出实时NPR使用的一些算法的味道。本章首先详细讨论了实现卡通渲染风格的方法,然后讨论了NPR领域的其他主题。本章以各种线条渲染技术结束。

Figure 15.1. A variety of non-photorealistic rendering styles applied to a coffee grinder. (Generated using LiveArt from Viewpoint DataLabs.) 

图15.1。应用于咖啡研磨机的各种非真实感渲染样式。(使用来自视点数据实验室的LiveArt生成。)

15.1 Toon Shading

15.1卡通阴影

Just as varying the font gives a different feel to the text, different styles of rendering have their own mood, meaning, and vocabulary. There has been a large amount of attention given to one particular form of NPR, cel or toon rendering. Since this style is identified with cartoons, it has connotations of fantasy and childhood. At its simplest,objects are drawn with solid lines separating areas of different solid colors. One reason this style is popular is what McCloud, in his classic book Understanding Comics [1157],calls “amplification through simplification.” By simplifying and stripping out clutter,one can amplify the effect of information relevant to the presentation. For cartoon characters, a wider audience will identify with those drawn in a simple style.

正如改变字体会给文本带来不同的感觉一样,不同风格的渲染也有自己的情绪、含义和词汇。有大量的注意力给了一种特殊形式的NPR,cel或卡通渲染。由于这种风格与卡通一致,它具有幻想和童年的内涵。最简单的方法是,用实线来分隔不同纯色的区域。这种风格流行的一个原因是麦克劳德在他的经典著作《理解漫画》( 1157)中所说的“通过简化放大”通过简化和剔除杂乱的信息,可以放大与演示相关的信息的效果。对于卡通人物,更广泛的观众会认同那些以简单风格绘制的人物。

The toon rendering style has been used in computer graphics for decades to integrate three-dimensional models with two-dimensional cel animation. It lends itself well to automatic generation by computer because it is easily defined, compared to other NPR styles. Many video games have used it to good effect [250, 1224, 1761].See Figure 15.2.

卡通渲染风格已经在计算机图形学中使用了几十年,用于将三维模型与二维cel动画相结合。它非常适合计算机自动生成,因为与其他NPR风格相比,它很容易定义。许多电子游戏已经使用它取得了良好的效果。参见图15.2。

Figure 15.2. An example of real-time NPR rendering from the game Okami. (Image courtesy of Capcom Entertainment, Inc.) 

图15.2。游戏Okami中实时NPR渲染的一个例子。(图片由卡普空娱乐公司提供)

The outlines of objects are often rendered in a black color, which amplifies the cartoon look. Finding and rendering these outlines is dealt with in the next section.There are several different approaches to toon surface shading. The two most common methods are to fill the mesh areas with solid (unlit) color or to use a two-tone approach,representing lit and shadowed areas. The two-tone approach, sometimes called hard shading, is simple to perform in a pixel shader by using a lighter color when the dot product of the shading normal and light source direction are above some value, and a darker tone if not. When the illumination is more complex, another approach is to quantize the final image itself. Also called posterization, this is a process of taking a continuous range of values and converting to a few tones, with a sharp change between each. See Figure 15.3. Quantizing RGB values can cause unpleasant hue shifts, as each separate channel changes in a way not closely related to the others. Working a huepreserving color space such as HSV, HSL, or Y’CbCr is a better choice. Alternately, a one-dimensional function or texture can be defined to remap intensity levels to specific shades or colors. Textures can also be preprocessed using quantization or other filters.Another example, with more color levels, is shown in Figure 15.16 on page 665.

物体的轮廓通常被渲染成黑色,这增强了卡通效果。寻找和渲染这些轮廓将在下一节讨论。有几种不同的方法来处理卡通表面阴影。两种最常见的方法是用纯色(无光)填充网格区域,或者使用双色调方法,表示有光和有阴影的区域。双色调方法有时称为硬着色,在像素着色器中很容易执行,当着色法线和光源方向的点积高于某个值时,使用较浅的颜色,否则使用较深的色调。当照明更复杂时,另一种方法是量化最终图像本身。也称为色调分离,这是一个获取连续范围的值并转换为几个色调的过程,每个色调之间有一个急剧的变化。参见图15.3。量化RGB值可能会导致令人不愉快的色调变化,因为每个单独的通道的变化方式与其他通道没有密切关系。使用HSV、HSL或Y'CbCr等保色色彩空间是更好的选择。或者,可以定义一维函数或纹理来将强度级别重新映射到特定的阴影或颜色。纹理也可以使用量化或其他过滤器进行预处理。另一个例子,有更多的色阶,如图15.16所示。

Figure 15.3. The basic rendering on the left has solid fill, posterization, and pencil shading techniques applied in turn. (Jade2 model by Quidam, published by wismo [1449], Creative Commons 2.5 attribution license.) 

图15.3。左边的基本渲染依次应用了纯色填充、色调分离和铅笔阴影技术。(Quidam的Jade2模型,wismo [1449]出版,知识共享2.5归属许可。)

Barla et al. [104] add view-dependent effects by using two-dimensional maps in place of one-dimensional shade textures. The second dimension is accessed by the depth or orientation of the surface. This allows objects to smoothly soften in contrast when distant or moving rapidly, for example. This algorithm, combined with a variety of other shading equations and painted textures, is used in the game Team Fortress 2 to give a blend of cartoon and realistic styles [1224]. Variations on toon shaders can be used for other purposes, such as for exaggerating contrast when visualizing features on surfaces or terrain [1520].

Barla等人[104]通过使用二维贴图代替一维阴影纹理来添加依赖于视图的效果。第二维度由表面的深度或方向来确定。例如,这允许对象在远离或快速移动时平滑地变软。这种算法与各种其他着色方程和绘制的纹理相结合,用于游戏团队堡垒2中,以提供卡通和现实主义风格的融合[1224]。卡通着色器的变体可用于其他目的,如在可视化表面或地形上的特征时放大对比度[1520]。

猜你喜欢

转载自blog.csdn.net/m0_37609239/article/details/126846747