• 沒有找到結果。

Hair Simulation Model

CHAPTER 3 Background

3.3 Hair Simulation Model

In this paper, we focus on non-photorealistic representation of the hair animation.

Therefore we need a dynamic simulation of hair to generate the hair strands as our input. We use particle-based dynamic system based on Chang et al. [6] to generate the hair strands. The system constructs a single hair strand as several chaining particles, and performs dynamic simulation. Then perform the hair-hair interactions to generate the animated hair stands. In real world, a person can have as many as 100,000 hair bristles, but for artists the whole representation of hairs is more important than a single bristle. Therefore instead of simulating all 100,000 hair bristles, we only use hundreds of hair strands or lesser.

14

Chapter 4

Hair Stroke Model

In this chapter, we describe our proposed hair stroke model for generating the comic-style hair rendering. This hair stroke model supports enough information for our system to generating the brush stroke effects.

First, the user input initial positions of the particle joints on each hair strand, and the system will automatically construct the hair stroke model for simulating the hair strokes in real-time. The hair animation will be generated according to the dynamic system similar to Chang et al. [6]. Then the animated hair strands will be transformed to the screen-space stroke paths, as shown in Figure 4.1, with 3D-space particle joints information for stroke simulation.

This chapter is organized as follows. In Section 4.1, we describe the model and information in our input animated hair strands. Then we describe the generation of the stroke paths and the brush model we apply in Section 4.2.

15

Figure 4.1: Hair strand particles are projected to screen space

4.1 Animated Hair Strands

In this section, we introduce the animated hair strands, which is the input to our system for simulating the hair strokes. The hairstyle is defined at this process by the user to give the initial positions of the particle joints on each hair strand. The hair animation is generated in real-time based on the dynamic particle system proposed by Chang et al. [6]. We offer some simple physical simulations like gravity and wind to generate the animated hair strands. These hair strands will later be used to generate the stroke paths. Besides, each stroke generation will also base on the information provided from the animated hair strand, including the 3D positions, and the neighboring strokes of the same hair strand…etc.

Figure 4.2 shows some animated hair strands models, and the corresponding data information is shown in Table 4.1.

Projection

16 Table 4.1: Data of model in Figure 4.2

4.2 Stroke Brush Model and Path Generation

In this section, we first introduce the stroke brush model for simulating the hair strokes, and describe how to generate the stroke paths from the animated hair strands.

We use the brush models of Weng’s [25] and Ho’s [12] works, which take a single circle to simulating the contact region of brush and paper. Applying these brush strokes on the stroke path will produce the painting stroke that seems like the comic artists drawing the

17

clumpy look of hairs. As shown in Figure 4.3, the dark line is the stroke path, and the circles constitute the brush strokes.

Therefore, the animated hair strands described in the previous section will be transformed to stroke paths. The information provided from each hair strand consists of several 3D space positions of each particle joint on the hair strand. We first project these particles to the screen space, and link them to construct the entire stroke path of each hair strand. For performance consideration, we simply use linear interpolation to generate the stroke path. Although it might sometimes produce sharp angle between hair’s segments, if the adjacent particles are too close and the dynamic of hair is violent. It is hard to discover the artifacts.

(a) Stroke on each joint of the hair

strand.

(b) Interpolation of each joint to generate the entire hair stroke.

Figure 4.3: The stroke model

Figure 4.3 shows the stroke model and how we generate the stroke paths and apply the brush strokes. Figure 4.3 (a) shows that each brush stroke apply to each particle joint of the hair strand. Later we linearly interpolate the joint strokes to get the entire single hair stroke as show in Figure 4.3 (b).

18

Chapter 5

Hair Stroke Simulation

In this chapter, we describe the process of brush stroke effect generation. Later we combine all the stroke shaders and render them in a specific order to generate the desired results. Figure 5.1 shows the flowchart of our hair stroke simulation.

In our implementation, the brush stroke effect shaders consist of: base stroke (basic information like size, basic color, and normal of the stroke), silhouette stroke (boundaries and silhouettes effect), cel-shaded stroke (cel-shading effect), highlights stroke (highlights effect), and thin fine hair stroke (some dynamic thin fine hairs). In the rest of this chapter, we introduce a stroke shader in each section. Each shader will generate its own brush stroke effect according to the information of animated hair strands, and apply to the stroke paths.

During rendering, the order of the artistic drawing should be taken into account. We combine all generated strokes and render them in the following order: silhouette strokes, base strokes, diffuse strokes, highlight strokes, and thin fine hair strokes. The depth order should also be ensured. We propose a simple and fast method to combine two orders, as described in in Section 5.2.

19

Final Result Stroke Path

Base Stroke

Cel-shaded Stroke Highlight Stroke

Stroke Simulation

Thin Fine Hair Stroke

Silhouette Stroke

Figure 5.1: The flowchart of stroke simulation

20

5.1 Base Stroke

In this section, we generate the basic information of a stroke. There are two attributes we need to determine in this step, one is the size of the stroke, the other is the basic color of the stroke. These attributes will also be used in the other shaders.

5.1.1 Stroke Size

To mimic the clumpy look of hairs, first we need to define the size s of each hair stroke path, which stands for the thickness or the quantity of the hair clump. Later we need to imitate the shrinking effect when hair stroke path moving toward the hair tail. Here we proposed a method combining two shrinking functions to achieve the desired result.

The first one take a shrinking point x on the hair stroke path as an input, where the size start to shrink. The function is defined as follows:

{

𝑠𝑖𝑧𝑒1(𝑖) = 𝐬, 𝑖𝑓 𝑖 < 𝑥 𝑠𝑖𝑧𝑒1(𝑖) = 𝑖 − 𝑥

𝑛𝑢𝑚 − 𝑥∙ 𝐬, 𝑖𝑓 𝑖 ≥ 𝑥 (𝟓. 𝟏)

where i is a point on the hair stroke path, and num stands for the total number of current hair stroke path. This function generates the shrinking effect when a point on stroke path is behind the shrinking point x. But, at the shrinking point, it might create a sharp angle. Thus we further introduce another shrinking function which scales the size by the sine function, as shown below:

𝑠𝑖𝑧𝑒2(𝑖) = sin ((𝑜𝑓𝑓𝑠𝑒𝑡 + 𝑖

𝑛𝑢𝑚(1 − 𝑜𝑓𝑓𝑠𝑒𝑡)) ∙ 𝜋) ∙ 𝐬 (𝟓. 𝟐)

where offset is a displacement of the sine function as shown in Figure 5.2. This function also creates the shrinking effect of the hair strand when moving toward the hair tail. But this effect is not obvious that makes the hair clump seems too thick. This thick effect is not always

21

satisfied, for example the bangs part of hairs. Therefore, we combine the two shrinking function with weighting coefficient to obtain the desired result, as shown below:

𝑠𝑖𝑧𝑒𝑓(𝑖) = 𝑤𝑒𝑖𝑔ℎ𝑡 ∙ 𝑠𝑖𝑧𝑒1(𝑖) + (1 − 𝑤𝑒𝑖𝑔ℎ𝑡) ∙ 𝑠𝑖𝑧𝑒2(𝑖) (𝟓. 𝟑) where 𝑠𝑖𝑧𝑒𝑓 is the final size of a point on the hair stroke path.

Figure 5.3 shows the effect of the shrinking functions. In order to perturb the size of different hair strokes, the user can apply different weighting values.

Figure 5.2: Size generated by size2

(a) Function size1 (b) Function size2 (c) Function size3

Figure 5.3: Stroke size samples of each function

𝑖

𝑜𝑓𝑓𝑠𝑒𝑡

22

5.1.2 Basic Color of Stroke

From the comic and cartoon examples in Figures 3.2 and 3.3, we can see that there are two types of color representation of the hair. One is the pure color, and the other is with diffuse effect. Our system provides both types of simulation for all stroke generation. Pure color simulation is simply by setting a single color. Diffuse effect is generated by applying the Phong reflection model 𝒍 ∙ 𝒏. The problem is that the hair stroke paths only consist of particles and no any geometry, such as the mesh surface for normal information. Therefore, we propose an alternative way to obtain the approximate normal vector from the hair strand particles.

A simple way is using the head position chead as the center and creating a radial normal vector from head position to each hair strand particle. But there will be a problem when facing to the long hair at the hair tail. Thus, for each hair strand, we first compute the mean position cmean of the whole particles on the hair strand. Then shift the head position chead amount to the mean position cmean to get the new center cshift. The normal vector now is from the shifted center cshift to each hair strand particle. The amount of shifting can be controlled. Figure 5.4 (a) show the shifted center cshift, then we modify the current normal to get more correct result.

23

As shown in Figure 5.4 (b), we put three points on the same hair stroke. The outward vector from the shifted center is marked as vector Oi, which is the current normal result. We also give the backward vector Bi of each point that points backward to the previous point on the same hair stroke. Then we will compute the angle between the outward vector Oi and the backward vector Bi. If this angle is vertical, the outward vector Oi is the same as normal vector Ni, for example, at the point p2 in Figure 5.4 (b). Otherwise, we will modify the outward vector Oi according to the angle between two vectors to get the normal vector Ni. Consider points p1 and p3 in Figure 5.4 (b). The modified function is as follows:

𝐍𝑖 = 𝐎𝑖− 𝐾(𝐎𝑖 ∙ 𝐁𝑖)𝐁𝑖 (𝟓. 𝟒)

where the K is the coefficient that controls the amount of modification. Now we can use the Phong reflection model to compute the diffuse color.

5.2 Silhouette Stroke

In this section, we introduce how to generate the silhouette stroke effect from our model without mesh information. Our model takes particles as input to generate the hair stroke paths, which lead to no hair polygon mesh. Therefore traditional methods to find feature lines on the surface cannot be applied to our model. We propose a method to generate the silhouette effect in the following paragraphs..

Using the size information generated in the base shader, we simply enlarge the size to create the boundary lines stroke effect as shown in Figure 5.5 (a). It gets problem when rendering in depth order as shown in Figure 5.5 (b). If we follow the artists’ drawing order that first draw silhouette strokes and then base strokes, the final result will only consist of

24

boundary lines as shown in Figure 5.5 (c). Thus we need to combine the depth order and the artists’ drawing order to get the desired result as shown in Figure 5.5 (d).

(a) (b) (c) (d) Figure 5.5: Silhouette stroke model and rendering order problem

(a) Our silhouette stroke model. (b) Render in depth order.

(c) Render in stroke order. (d) Expected result.

A simple idea to combine the two orders is to render each strand of hair stroke separately.

First sort and render the hair stroke strand by strand in depth order, and then render each strand in artists’ drawing order. But it may create the popping effect when the strand order changes between contiguous frames. Computing stroke order strand by strand also needs extra time to statistically compute the depth of all particles on the hair strand, which will decrease the performance. Therefore, we use a re-ordering mechanism that adjust each stroke order in depth based on the artists’ drawing order, and render them just using depth test, which will be faster and less popping effect.

Each effect shader only generates its own hair stroke effect. From the depth information of hair strands particles, each projected hair stroke can be a piece of surface in space. For a given strand of hair stroke path, it will generate several stroke effects on the same position.

Therefore we need to render these stroke effects in the right order to get the desired result.

Silhouettes stroke

Base stroke

25

Our method is to give a new depth value to each stroke, and render them using depth test. The base shader gives the basic position, where depth value we do not change. For other shaders, we will change the depth value of the given stroke based on the artists’ drawing order with the depth value of the corresponding stroke from base shader. Take silhouette shader as an example, the silhouettes stroke should draw before the other strokes. Thus we apply the new depth value that shift the depth value of the corresponding stroke farther from base shader.

Consider Figure 5.6. The blue and green surfaces are two different strands of hair stroke.

The darker ones are the silhouette stroke planes, and the lighter ones are the base stroke planes. The darker one is a little larger than the corresponding lighter one to create the silhouette effect. The darker one is also shifted farther than the lighter one. Figure 5.6 (a) shows the side-view of these four surfaces, and we can see different depth orders at different segments of the stroke path. Figure 5.6 (b) displays the top-view of these four surfaces. Let the lighter ones be the same white color, and the darker ones be the same black color. We can obtain the result as shown in Figure 5.6 (c), which is the silhouette effect we need. The amount of shift can be controlled by the user, which will affect the density of the silhouettes as shown in Figure 5.7.

(a) Depth order of each stroke from side-view.

(b) Top-view. (c) Silhouette stroke effect.

Figure 5.6: Re-order strokes example: silhouette strokes simulation

z

26

(a) Only boundaries (b) Few silhouettes (c) Dense silhouettes Figure 5.7: Silhouette stroke density controlled by the depth shifting

5.3 Cel-shaded Stroke

The cel-shaded stroke is similar to the base stroke that also offers both pure color and diffuse color. In this shader, we generate the feathering cel-shaded stroke. The feathering effect is common in comics and cartoon animations, which is often used by the artists to express rich dynamics of hair strands in a clump of hairs. Figure 5.8 gives a simple overview of cel-shaded stroke generation. We first determine the cel-shading region by the gray level information from the shaded hair. Then we generate the feathering effect in the cel-shading region. Finally, we apply color to the strokes based on the basic color generated in the base shader.

Figure 5.8: The flowchart of cel-shaded stroke simulation Determine region

from gray level Feathering effect Coloring strokes

27

5.3.1 Cel-shading Region and Color

Our method to generate cel-shading effect is similar to traditional methods that adding a threshold to the gray level of shaded model. We use the normal model introduced in the base stroke section to create the gray level of the diffuse shaded stroke based on Phong reflection model. Then use a threshold to determine the cel-shading region. The user can control the threshold to determine the cel-shading region. We also provide perturbation to create more dynamic results. The effects of perturbation are shown in Figure 5.11.

In the cel-shading region, our system offers both pure and diffuse color effects. Both two types of color are defined based on the basic color generated in the base stroke with lighter or darker result, depending on the cel-shading region.

5.3.2 Feathering Effect

Before generating the feathering effect, we first determine where to apply the strokes within the cel-shading region of the stroke path. The feathering effect is spread on the clump of hairs. Thus these strokes are not just applied on the stroke paths that generated from the

28

(a) Compute the positions direction (b) Create positions at the direction Figure 5.9: Position of cel-shaded stroke path

We have determined the stroke color and position. Now we need to compute the size of all strokes in the cel-shading region to create the feathering effect. Our feathering stroke size depends on the diffuse gray level and the basic size of the base stroke. First we determine the basic size of the each feathering stroke. For a given hair strand stroke, the number of the feathering strokes in the cel-shading region is define as Nfeather. The basic size of each feathering stroke is simply computed by the following equation:

Size𝑓𝑒𝑎𝑡ℎ𝑒𝑟basic (𝑖) =Size𝑏𝑎𝑠𝑒(𝑖)

N𝑓𝑒𝑎𝑡ℎ𝑒𝑟 (𝟓. 𝟓) where Sizebase is the basic size from the base stroke.

For creating feathering effect, we further introduce another gray level threshold 𝜀𝑓𝑢𝑙𝑙 which is dependent on the threshold 𝜀𝑐𝑒𝑙 in determining the cel-shading region. For example, if the cel-shading region generates the darker color than the base stroke, then this threshold should be darker. If the cel-shading region has lighter color, then it should be much

F

F F

pi

pi+1

29

lighter. Within this region, the sizes of the feathering strokes are the basic size defined by the Equation 5.5. Outside the region, the sizes shrink to zero when reaching the cel-shading stroke i is within the threshold region or not. Figure 5.10 shows the effect of shrinking. Gray stroke gives the gray level information and the size of base stroke. We can easily find that these two thresholds separate the regions with different sizes of the cel-shaded stroke. The system also provides perturbation for both thresholds. In Figure 5.11, we can see the difference whether the perturbation is applied or not.

Figure 5.10: Size of cel-shaded stroke

30

(a) Cel-shading region (no perturbation) (b) Cel-shading region (with perturbation) Figure 5.11: Perturbation for feathering effect

5.4 Highlight Stroke

Highlight effects can be classified in two types: one is like Figure 3.1 that the highlight stroke is long or even spread to the hair end; the other is like Figure 3.2 (a) and Figure 3.3 (b), which is only at small region and feel like specular effect. Our system provides both effects for the users.

The second effect is simple and generated in the way like the cel-shaded stroke, while we replace the gray level of diffuse shaded model with the specular term of the Phong reflection model. Two thresholds are also needed to determine the region and create the feathering effect.

Using gray level of the specular to generate the highlight effect only consists of small region. Thus, to achieve the highlight effect that spread on the hair stroke path, we need

31

(a) Highlights in specular region. (b) Highlights spread through whole hairs.

Figure 5.13: Two types of highlight stroke

Shrunk highlight stroke

32

5.5 Thin Fine Hair Stroke

The fine hair stroke is a special stroke and its properties are different from the other stroke effects. Although artists often draw clumpy look of hairs, some of them will also add thin lines to represent fine hairs expression. These effects are usually added at the final step of painting that gives the hair result more dynamic and attractive.

So far, the stroke shaders we introduce are all bounded in the clumpy region, which is the basic size generated from the base strokes. Besides, the stroke paths are the same or derived from the base strokes. The thin fine hair strokes are different that they use their own stroke

So far, the stroke shaders we introduce are all bounded in the clumpy region, which is the basic size generated from the base strokes. Besides, the stroke paths are the same or derived from the base strokes. The thin fine hair strokes are different that they use their own stroke

相關文件