[ieee 2013 seventh international conference on image and graphics (icig) - qingdao, china...

7
Cartoon Rendering Illumination Model based on Phong Shaohao Wang, Yurui Wei, Chengying Gao* School of Software,Sun Yat-sen University Guangzhou, China [email protected] Abstract—3D cartoon rendering has broad application prospect in games, movies and cartoons.To this end, this paper introduces a cartoon rendering illumination model improved from Phong illumination model,and realizes it with 3ds Max SDK in the form of plug-ins. By discretizing diffuse reflection part and specular reflection part in the Phong illumination model,surfaces of models show different blocks of color, among which there are clear boundaries. In addition, by using linear interpolation between different color blocks,boundaries can be soften. The experimental results show that this cartoon rendering illumination model can not only make a cartoon appearance, but also mix with Phong illumination model, and achieve a unique effect. Keywords-NPR;toon shading;Phong I. INTRODUCTION Toon-Shading, also called Cel-Shading, is a special type of non-photorealistic rendering technology, it requires different single-color block and simple texture while rendering. This method discards details, it emphasizes the thickness of lines and simpleness of color block, just use the simple lines and pure color block to render out attractive cartoon effect as the designer demands, so as to build a two- dimensional cartoon world, such as the game Ni no Kuni: Wrath of the White Witch shown in Fig.1 which is launched by level 5 corporation in 2011 on the PS3 platform . II. RELATED WORK Model surface rendering occupies an important position in the cartoon rendering . Image rendered by a traditional Figure 1. Ni no Kuni: Wrath of the White Witch Phong illumination model does not provide abundant information as well as the hand-painted image. So Amy [1] proposes a non-photorealistic lighting model, which is mainly used in technical illustration, the lighting model uses both luminance and changes in hue to indicate surface orientation while preserving highlights and edge lines. Le[2] introduces the light and shade algorithm of cel-shading, which is based on the Phong local illumination model and some further improvements. The website[8] introduces soft cel shading technique, which uses single-dimensional texture to improve Cel-shading. Hao[3] proposes X-Toon algorithm, which extends the traditional one-dimensional texture mapping to two-dimensional texture, uses the vertical component of two-dimensional texture express the change of hue, so as to improve the Cel-shading. Lance[4] proposes the texture shadows technology based on depth shadow map, it can be used to render shadow part of the cartoon model. Nonetheless, these papers above are not provide the strictly illumination model and corresponding formulas[11]. Therefore, this paper analyzes Phong illumination model in detail, and proposes a Cartoon rendering illumination model based on Phong. III. OUR METHOD A. Phong illumination model Phong illumination model is a local illumination model based on experience,uses diffuse and specular reflection to calculate the final results of light reflection. It based on an observed phenomenon: polished surface has lesser area to reflect highlights, while rough surface has a larger area to reflect highlights with luminance gradually changed.This illumination model also include ambient light to simulate the light affect the scene, as Fig.2. Suppose the light source is white, the ambient light and diffuse color is blue, and specular color is white, we can see the final result has a small portion of highlight. The diffuse section will change the intensity according to the direction of the surface, while the ambient section is fixed. Figure 2. Phong illumination model 2013 Seventh International Conference on Image and Graphics 978-0-7695-5050-3/13 $26.00 © 2013 IEEE DOI 10.1109/ICIG.2013.185 926 2013 Seventh International Conference on Image and Graphics 978-0-7695-5050-3/13 $26.00 © 2013 IEEE DOI 10.1109/ICIG.2013.185 926 2013 Seventh International Conference on Image and Graphics 978-0-7695-5050-3/13 $26.00 © 2013 IEEE DOI 10.1109/ICIG.2013.185 925 2013 Seventh International Conference on Image and Graphics 978-0-7695-5050-3/13 $26.00 © 2013 IEEE DOI 10.1109/ICIG.2013.185 913 2013 Seventh International Conference on Image and Graphics 978-0-7695-5050-3/13 $26.00 © 2013 IEEE DOI 10.1109/ICIG.2013.185 913

Upload: chengying

Post on 11-Mar-2017

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: [IEEE 2013 Seventh International Conference on Image and Graphics (ICIG) - Qingdao, China (2013.07.26-2013.07.28)] 2013 Seventh International Conference on Image and Graphics - Cartoon

Cartoon Rendering Illumination Model based on Phong

Shaohao Wang, Yurui Wei, Chengying Gao* School of Software,Sun Yat-sen University

Guangzhou, China [email protected]

Abstract—3D cartoon rendering has broad application prospect in games, movies and cartoons.To this end, this paper introduces a cartoon rendering illumination model improved from Phong illumination model,and realizes it with 3ds Max SDK in the form of plug-ins. By discretizing diffuse reflection part and specular reflection part in the Phong illumination model,surfaces of models show different blocks of color, among which there are clear boundaries. In addition, by using linear interpolation between different color blocks,boundaries can be soften. The experimental results show that this cartoon rendering illumination model can not only make a cartoon appearance, but also mix with Phong illumination model, and achieve a unique effect.

Keywords-NPR;toon shading;Phong

I. INTRODUCTION Toon-Shading, also called Cel-Shading, is a special type

of non-photorealistic rendering technology, it requires different single-color block and simple texture while rendering. This method discards details, it emphasizes the thickness of lines and simpleness of color block, just use the simple lines and pure color block to render out attractive cartoon effect as the designer demands, so as to build a two-dimensional cartoon world, such as the game Ni no Kuni: Wrath of the White Witch shown in Fig.1 which is launched by level 5 corporation in 2011 on the PS3 platform .

II. RELATED WORK Model surface rendering occupies an important position

in the cartoon rendering . Image rendered by a traditional

Figure 1. Ni no Kuni: Wrath of the White Witch

Phong illumination model does not provide abundant information as well as the hand-painted image. So Amy [1] proposes a non-photorealistic lighting model, which is mainly used in technical illustration, the lighting model uses both luminance and changes in hue to indicate surface orientation while preserving highlights and edge lines. Le[2] introduces the light and shade algorithm of cel-shading, which is based on the Phong local illumination model and some further improvements. The website[8] introduces soft cel shading technique, which uses single-dimensional texture to improve Cel-shading. Hao[3] proposes X-Toon algorithm, which extends the traditional one-dimensional texture mapping to two-dimensional texture, uses the vertical component of two-dimensional texture express the change of hue, so as to improve the Cel-shading. Lance[4] proposes the texture shadows technology based on depth shadow map, it can be used to render shadow part of the cartoon model. Nonetheless, these papers above are not provide the strictly illumination model and corresponding formulas[11]. Therefore, this paper analyzes Phong illumination model in detail, and proposes a Cartoon rendering illumination model based on Phong.

III. OUR METHOD

A. Phong illumination model Phong illumination model is a local illumination model

based on experience,uses diffuse and specular reflection to calculate the final results of light reflection. It based on an observed phenomenon: polished surface has lesser area to reflect highlights, while rough surface has a larger area to reflect highlights with luminance gradually changed.This illumination model also include ambient light to simulate the light affect the scene, as Fig.2.

Suppose the light source is white, the ambient light and diffuse color is blue, and specular color is white, we can see the final result has a small portion of highlight. The diffuse section will change the intensity according to the direction of the surface, while the ambient section is fixed.

Figure 2. Phong illumination model

2013 Seventh International Conference on Image and Graphics

978-0-7695-5050-3/13 $26.00 © 2013 IEEE

DOI 10.1109/ICIG.2013.185

926

2013 Seventh International Conference on Image and Graphics

978-0-7695-5050-3/13 $26.00 © 2013 IEEE

DOI 10.1109/ICIG.2013.185

926

2013 Seventh International Conference on Image and Graphics

978-0-7695-5050-3/13 $26.00 © 2013 IEEE

DOI 10.1109/ICIG.2013.185

925

2013 Seventh International Conference on Image and Graphics

978-0-7695-5050-3/13 $26.00 © 2013 IEEE

DOI 10.1109/ICIG.2013.185

913

2013 Seventh International Conference on Image and Graphics

978-0-7695-5050-3/13 $26.00 © 2013 IEEE

DOI 10.1109/ICIG.2013.185

913

Page 2: [IEEE 2013 Seventh International Conference on Image and Graphics (ICIG) - Qingdao, China (2013.07.26-2013.07.28)] 2013 Seventh International Conference on Image and Graphics - Cartoon

• si and di is the specular and diffuse reflection

intensity for each of the light source for the scene. ai represents ambient light, sometimes is calculated by all the light source.

• For each material in the scene of Phong illumination model,the following parameters must be defined:

• sk : constant of specular reflection, represents reflectivity of specular reflection of incident light.

• dk : constant of diffuse reflection, represents reflectivity of diffuse reflection of incident light.

• ak : parameter of ambient light reflection, represents reflectivity of ambient light.

• α : the luminous intensity constant of material, the greater of the constant, the smooth of the surface, the more similar to a mirror. The specular highlights area is very small when this parameter is large.

In addition, luminous is defined as collection of some light source. Take the point light source as example, point light source can be represented as a dot and direction

vector.

mL is the direction vector between one point and a point light source on the surface( m means the mth light

source),∧N is normal vector of the point surface,

mR is the emergent light of total reflection through the point of mth

light source, ∧V is the direction vector to the observer from

this point. Phong illumination model provides calculation method of

lighting intensity formula pIfor each of the points on the

surface :

�∈

∧∧∧∧⋅+⋅+=

lightsmsmmsdmmdaap iVRkiNLkikI )))(( ,,

α (1)

mR can be calculated according to the following formula, vectors in the formula have been normalized:

∧∧∧∧∧

−⋅= mmm LNNLR )(2 (2)

From (2) we can see, observer direction does not affect diffuse part, and only when is parallel to the emergent light,the specular reflection can be relatively larger.The parallel relationship according to the dot product between and , then do the exponent arithmetic with to determine. When the is greater,the more close to specular reflection, the highlights portion will be smaller. Conversely,if is not parallel to , the dot product will less than 1, at this point, the

greater of , the smaller of exponent arithmetic, with severe change.

Although Formula (1) and (2) is the general way to represent Phong illumination model, only when dot product of the two vectors is positive, the result will be used for the following calculation. Such as for the specular part, if , then the result of is 0.

When color is expressed by RGB format,Formula (1) and (2) can be respectively applied to three channels R,G,B,thus different reflection constant can be allowed, such as and can have different values to three channels.

B. Toon illumination model In addition to draw contour line,another important part of

cartoon rendering is coloring of model.During the rendering,all surfaces are classified into three color-block,as normal, shadow,and highlight,each of them has a clear boundary of light and shade. Traditional Phong illumination model based on the surface normal vector to calculate the light intensity of reflection, the result is close to the real lighting effects with smooth surface coloring, which is not apply to the cartoon rendering. Therefore, this paper proposes Toon illumination model, which is an improved cartoon rendering illumination model based on Phong illumination model.

In Phong illumination model, for the fixed light source and certain material, the reflection light intensity is a continuous function according to surface normal vector and the direction of observation. In Toon illumination model, we still use the reflection of light to determine the surface color and divide the result of light into three parts as ambient light, diffuse, specular reflection with ambient light retain unchanged. The improvement of Toon illumination model is, through discretization of diffuse and specular reflection, we can obtain the color piece. Set a threshold for diffuse reflection, if the calculation result higher than the threshold, keep the result of diffuse portion as normal intensity, if the calculation result lower than the threshold, keep the result of diffuse portion as intensity of shadow part. Similarly, set a threshold for specular reflection, when the calculation result higher than the threshold, keep the result of specular portion as intensity of highlight part, when the calculation result lower than the threshold, keep the result of diffuse portion as zero. Finally, we can obtain the cartoon rendering lighting effects by adding the three parts of ambient light, diffuse and specular reflection. That is to say, in Toon illumination model, diffuse reflection is used to distinguish normal and shadow section, and specular reflection is used to detect highlight section. The contrast between Phong and Toon illumination model is as Fig.3.

Figure 3. Different illumination models

927927926914914

Page 3: [IEEE 2013 Seventh International Conference on Image and Graphics (ICIG) - Qingdao, China (2013.07.26-2013.07.28)] 2013 Seventh International Conference on Image and Graphics - Cartoon

For light source, keep the ambient light ai , diffuse

reflection di , and specular reflection si of Phong illumination model unchanged. For the material, retain the

reflectivity of ambient ak , diffuse reflectance dk and

specular reflectance sk , discard the constant of luminous intensity α , and then add the following parameters:

• sf : shadow range parameter,and is directly proportional to the size of the shadow.

• hf : highlight range parameter,and is directly proportional to the size of the highlight.

• sb : luminance of the shadow, represents the shading degree of shadow.

• bb : luminance of the normal color-block, represents the shading degree of normal color-block.

• hb : luminance of highlight, represents the shading degree of highlight.

• sbs : soften degree of shadow block and normal block, and is directly proportional to the size of transition between two color blocks.

• bhs : softening of normal block and highlight block, and is directly proportional to the size of transition between two color blocks.

The calculation formula of Toon illumination model is as follows:

�∈

++=lightsm

smmsdmmdaat ikikikI )( ,, νμ (3)

Among them, mμ and mv are defined as Formula (4) and (5).

���

���

+<⋅<−

⋅−++−−⋅

−≤⋅

+≥⋅

=

∧∧

∧∧∧∧

∧∧

∧∧

sbsmsbs

ssb

msbsb

sb

sbsm

sbsms

sbsmb

m

sfNLsf

bs

NLsfbs

sfNL

sfNLb

sfNLb

,2

)(2

)(

,

,

μ(4)

Formula (4) and (5) shows that the softening portion

actually employ the linear interpolation, thus guarantee the boundary antialiasing between different colors.

���

���

+−<⋅<−−

−−−⋅

+−>⋅

−−≤⋅

=

∧∧

∧∧

∧∧

∧∧

bhhmbhh

hbh

bhhm

bhhmh

bhhm

m

sfVRsf

bs

sfVR

sfVRb

sfVR

11

,2

)1(

1,

1,0

ν (5)

IV. EXPERIMENT & ANALYSIS The hardware is AMD 2.2 GHz CPU 2GB memory,

ATI Mobility Radeon HD 5650 graphics card, under windows 7 operating system, software development is a Visual studio and 3ds Max SDK.

As shown in Fig.4, by setting the different scope of highlight and shadow range parameters, we can control the area of highlight and shadow parts.

As shown in Fig.5, by setting the soften degree, we can control the gradient effect between highlight and normal, as well as the normal and shadow parts, then obtain a different visual effect.

As shown in Fig.6, by setting the luminance of different color-blocks, we can control the color intensity of different color-blocks, and through setting different colors for different color-blocks, we can endow the model with other colors.

As shown in Fig.7, Toon and Phong illumination model can be blended to obtain a unique visual effect.

As shown from Fig.8 to Fig.11, from the comparison between Phong and Toon illumination model, we can seen compared with Phong illumination model, Toon illumination model can render out the boundary of color block, so as to realize the effect of cartoon.

V. CONCLUSION In recent years , there are many research about cartoon

rendering, but the study of illumination model for the cartoon rendering does not have a strict mathematical definition. This paper proposes the Toon rendering illumination model, which can be used to a variety of 3D scene and model, and provides parameters of scope, luminance etc. so that adjusting flexibly. As Toon illumination model is improved by Phong model, the two model can be blended to adjust the balance between the reality and virtuality. The following work will focus on different type of cartoon, such as the style of Japanese studio ghibli, American Disney and pixar, to study and simulate the cartoon rendering illumination of different styles[12,13].

ACKNOWLEDGMENT This work was supported by the National Science Fund

Of China(No.610008), Fundamental Research Funds for the Central Universities (underGrant no.2010620003161035).

928928927915915

Page 4: [IEEE 2013 Seventh International Conference on Image and Graphics (ICIG) - Qingdao, China (2013.07.26-2013.07.28)] 2013 Seventh International Conference on Image and Graphics - Cartoon

REFERENCES

[1] Amy Gooch , Bruce Gooch , Peter Shirley , Elaine Cohen,.A non-photorealistic lighting model for automatic technical illustration.Proceedings of the 25th annual conference on Computer graphics and interactive techniques, 1998:p.447-452.

[2] Yue Dashan, Long Xiaoyuan, Wang Guoping.An Approach to Anime-style Non-photorealistic 3D Rendering.Guangzhou:The 3rd Conference of Digital Entertainment & Art (DEA2008),2008.

[3] Hao Wen.Research for a number of issues for effect of non-photorealistic when rendering 3D models. Shaanxi Normal University:Shaanxi Normal University Master Thesis,2011.

[4] Lance Williams.Casting curved shadows on curved surfaces.Proceedings of the 5th annual conference on Computer graphics and interactive techniques, 1978:p.270-274.

[5] XiaofengMi,Techniques on Non-Photorealistic Rendering,Zhejiang University:Zhejiang University Master Thesis,2003.

[6] Hai Yanmin, Shi Lin, Yang Yuting.Hand painted art animation Methods of computer-aided design[J].Computer Era,2009,(5):p.3-6.

[7] Phong shading,http://en.wikipedia.org/wiki/Phong_shading. [8] Phong B T. Illumination for computer generated pictures.

Communications of the ACM, 1975, 18(6): 311-317. [9] Autodesk.3ds Max SDK

Document.http://download.autodesk.com/global/docs/3dsmaxsdk2012/en_us/index.html,2012.

[10] Tomas Akenine-Moller ,AK Peters.Non-Photorealistic Rendering,Real-Time Rendering Third Edition.,USA:A K Peters/CRC Press,2008:p.507-530.

[11] Liang Lin, Kun Zeng, Yizhou Wang, Ying-Qing Xu, and Song-Chun Zhu, Video Stylization: Painterly Rendering and Optimization with Content Extraction, IEEE Transactions on Circuits and Systems for Video Technology, 23(4): 577-590, 2013.

[12] Tao Lin, Liang Lin, and Qing Wang, Robust Stroke-based Video Animation via Layered Motion and Correspondence, Proc. of ACM Conference Multimedia, 2012.

[13] Liang Lin, Kun Zeng, Han Lv, Yizhou Wang, YingQing Xu, and Song-Chun Zhu, Painterly Animation Using Video Semantics and Feature Correspondence, Proc. of International Symposium on Non-Photorealistic Animation and Rendering, 2010.

Figure 4. Different Highlight Range and Shadow Range

929929928916916

Page 5: [IEEE 2013 Seventh International Conference on Image and Graphics (ICIG) - Qingdao, China (2013.07.26-2013.07.28)] 2013 Seventh International Conference on Image and Graphics - Cartoon

Figure 5. Different Soften Degree

Figure 6. Set different luminance and colors for different color blocks

930930929917917

Page 6: [IEEE 2013 Seventh International Conference on Image and Graphics (ICIG) - Qingdao, China (2013.07.26-2013.07.28)] 2013 Seventh International Conference on Image and Graphics - Cartoon

Figure 7. Blending Toon and Phong illumination model

Figure 8. Comparison between Phong and Toon illumination model

Figure 9. Comparison between Phong and Toon illumination model

931931930918918

Page 7: [IEEE 2013 Seventh International Conference on Image and Graphics (ICIG) - Qingdao, China (2013.07.26-2013.07.28)] 2013 Seventh International Conference on Image and Graphics - Cartoon

Figure 10. Comparison between Phong and Toon illumination model

Figure 11. Comparison between Phong and Toon illumination model

932932931919919