Non-Photorealistic Rendering: Cross Hatching
Total Page:16
File Type:pdf, Size:1020Kb
Final Master Thesis Master of Innovation and Research in Informatics Computer Graphics and Virtual Reality Non-Photorealistic Rendering: Cross Hatching Isadora Albrecht Salvetti supervised by Carlos And´ujarGran Barcelona School of Informatics (FIB) of Polytechnic University Of Catalonia (UPC) with support from King June 2020 Abstract Non-photorealistic rendering can be used to create abstracted images of real- life objects. Cross-hatching is a common style under the non-photorealistic rendering umbrella, where characteristics such as lighting and shape of objects are represented by layered patches of parallel lines. The work in this master thesis explores the creation of cross-hatched ren- ders where lighting and shape can be implied by density and direction of the hatching lines. We choose to place the hatching lines following the curvature characteristics of the object. For this purpose, we describe a way to compute and interpolate principal curvature directions and an image-space algorithm to draw lines following such directions. 1 Contents 1 Introduction 4 2 Previous Work 6 2.1 Non-Photorealistic Rendering . 6 2.1.1 Stylization . 6 2.1.2 Non-Photorealistic Lighting . 7 2.1.3 Outlines and Silhouette detection . 8 2.2 Hatching . 9 3 Overview 12 3.1 Motivation . 12 3.2 Objective . 12 4 Hatching direction field 14 4.1 Concepts . 14 4.2 Identifying Principal Directions . 15 4.2.1 Numerical Approximation . 15 4.3 Interpolation . 16 4.3.1 Smoothing the cross field . 17 4.3.2 Error Analysis . 18 5 Rendering 21 5.1 Line Drawing Algorithm . 21 5.1.1 Overview . 21 5.1.2 Input Image . 21 5.1.3 Definitions . 24 5.1.4 Line Integration . 25 5.1.5 Selecting hatching direction . 25 5.1.6 Seed Selection . 26 5.1.7 Point validation . 27 5.2 Outline . 28 5.3 Unity integration . 29 6 Results 30 6.1 Rendering examples . 30 6.2 Rendering times . 31 7 Conclusions and Future Work 33 8 References 36 2 List of Figures 1 Examples of hatching. 4 2 Examples of NPR styles. 6 3 Results from [EM17]. 7 4 Examples of lookup texture use. 8 5 Hatching textures applied to sphere from [Pra+01]. 9 6 Resulting render from [Sal+97], preceded by user generated tone and direction maps and stroke samples. 10 7 Detail from result from [GI13]. 10 8 Jiffycrew Hatching example. 11 9 Side-by-side results from hatching methods. 12 10 Normal curvature illustrated in plane section [Log]. 14 11 Neighbourhood of P. 15 12 Smoothing results and artifacts. 17 13 Torus highlighting circles of radius R1(pink) and R2(red) [Wik]. 18 14 Histogram of error in principal direction approximation (1). 19 15 Histogram of error in principal direction approximation (2). 20 16 Line drawing scheme. 21 17 Cross hatching result. 22 18 Input image and its channel breakdown. 23 19 Effects of WhiteOffset parameter. 23 20 Portion of field drawn with different dTests. 25 21 Example of long spiral. 25 22 Seed selection scheme. 26 23 Example of inconsistent directions given by high angle tolerances. 27 24 Different outline results. 29 25 Final results on torus and teapot. 30 26 Final results on monkey head. 31 27 Hatching rendering in low poly tree model. 33 3 1 Introduction Non-Photorealistic rendering (NPR) is an area of computer science that seeks to render digital images mimicking the abstraction normally associated with artist representations. There are many different styles to simulate, and the reasons for adapting the trappings of a style go beyond aesthetic preference. Different art styles can be used to emphasize or under play some character- istics of the subject, which changes the how and what information is conveyed in the image. These decisions are normally made by an artist, therefore, in computer graphics, the challenge is not only to copy visual styles but to imitate decisions that would be made by a human. The applications for NPR are as diverse as the styles themselves. They can be seen in cinema, games, and illustrations, to name a few. In some fields, such as technical illustration, the information needed to be conveyed is so well suited for NPR styles that visual realism can be counter productive [Puj11] (Figure 2d). This work focuses on the implementation of one particular NPR style, hatch- ing. Figure 1: Examples of hatching. (top) Part of the exhibition \Prehensility", by Olivia Knapp. (left) Detail of Queens of Persia at the Feet of Alexander. Etching and engraving. [Hic18] (right) Hatching Sketch [Kem20] Hatching is a drawing technique that is characterized by patches of parallel lines. The direction and density of the patches can be used to imply different characteristics of the shape, such as tone, lighting, form, texture or movement. 4 If the hatching is composed of multiple crossing layers, it can also be called cross-hatching. This technique is commonly used with medium that does not allow for smooth color transitions, such as engraving and pen and ink. Hatching lines can be drawn in several styles, from high detail etching to sketching. The density of the hatching is commonly used to imply tone or shadow, while the direction of the lines can be used in many different ways. It is common to have the lines follow the shape of the object, at least partially, as they can be a useful tool to efficiently imply shape. [PK19] In this thesis we seek to develop a method of creating such images. We focus in particular in the method to orient the hatching lines, looking to create a picture similar to Figure 1. We have chosen to develop the process in Unity, thinking of exploring the potential of its rendering engine and the possibility of utilizing the style as part of the visual style in games. 5 2 Previous Work 2.1 Non-Photorealistic Rendering There is a huge body of work exploring NPR. Despite the variety of topics that can be covered within this label, there are some recurring features worth exploring. (a) Team fortress 2 [MFE07] (b) Legend of Zelda: The Wind Waker[Gam] (c) Hatchig result from [Lak+00] (d) Results from [GSC99] Figure 2: Examples of NPR styles. 2.1.1 Stylization A number of papers and commercial solutions look into the creation of digital images with characteristic of specific artistic styles. It is hard to make definitive list of artistic styles and their characteristics, as each author will create their 6 own variations. In computer graphics, stylization may refer not only to the types of marks used to create the image but to the characteristics of the media used. Some stylization can be achieved by applying image filtering algorithms di- rectly to a photograph or render, exemplified in [DLJ14], where the authors rely on the saliency map of an image to produce a Chinese ink painting version of the image. Another example is [DS00], where the authors mimic pen and ink styles. They discuss the use of silhouettes and outlines, with some use of hatching, to render trees as if drawn by pen and ink. Machine learning algorithms can also be used. The work in this field can be extremely versatile, as show in [EM17], where the authors present an improved version of an algorithm capable of adapting and transfer artistic styles, learned from one arbitrary image, to another (Figure 3). Figure 3: Results from [EM17]. In order, the target image, the style source, and the resulting image. 2.1.2 Non-Photorealistic Lighting Lighting is often an important aspect of an image. Besides conveying the scene's light situation, it can be essential for conveying shape information. As such, NPR often includes some kind of lighting abstraction. Most NPR lighting is still based in traditional lighting models. In [MFE07], for example, the authors discuss the contribution of a Lambert, Phong, Ambient and Rim light terms for the lighting model in the style of Team Fortress 2 (Figure 2a). A common feature added to NPR models is cell shading (Figure 2b). These styles consist of using one or more color bands to represent shadows and high- lights. The goal is to eliminate the soft transitions between lit and shaded areas. This can be done by setting a threshold and setting all shades bellow it to dark and all shades above to bright. This approach can be adapted to include extra banding levels by setting multiple thresholds. Alternatively, a lookup texture can be used. Normally a 1D texture is used, where the single dimension represents the brightness level. By manipulating the values at each lighting level it is easy to achieve the hard transitions, while keeping some anti-aliasing. This technique is described in [Lak+00] (Figure 2d). 7 Moreover, lookup textures are a common feature in many different NPR lighting models, and can be used to achieve a variety of effects. It offers better control over the light level transitions and the option to add a tint to light and dark areas. They can be used only as a lighting tint, as shown in [Tec], or to generate more subtle cell-shading-like effects, like in [MFE07]. In [BTM06] the authors expand on the idea and show how to use a 2D lookup-texture for the same purpose, with the second dimension being mapped to depth. Examples of lookup textures are shown in Figure 4. (a) 1D lookup texture from [Tec] (b) 2D lookup texture from [BTM06] Figure 4: Examples of lookup texture use. A similar concept is to use the a set of textures instead of a single lookup texture. The level of light is used to decide which one of these textures will be sampled.