a dynamic noise primitive for coherent stylization styles ... · p. bénard, a. lagae, p. vangorp,...
TRANSCRIPT
Eurographics Symposium on Rendering 2010
Jason Lawrence and Marc Stamminger
(Guest Editors)
Volume 29 (2010), Number 4
A Dynamic Noise Primitive for Coherent Stylization
Styles Cookbook
P. Bénard1 A. Lagae2,3 P. Vangorp3 S. Lefebvre4 G. Drettakis3 J. Thollot1
1Grenoble University 2Katholieke Universiteit Leuven 3INRIA Sophia-Antipolis 4INRIA Nancy Grand-Est / Loria
1. Rendering Algorithm for Temporally Coherent Stylization
NPR Gabor Noise Spla�er
TriangularMesh
diffuse intensitycurvatureobject ID
Pa�erntexture(s)
Post-Processing Final stylizedimage
colorthreshold mapthreshold param.
Figure 1: Schematic representation of our rendering algorithm for temporally coherent stylization using NPR Gabor Noise.
Our rendering algorithm for temporally coherent stylization is a two-step process (see figure 1) based on deferred shading. In
the first step, we generate one or more noise layers using NPR Gabor noise. This is done using a general noise shader. We can
use scene attributes (such as shading, surface curvature [Rus04] and object ID) to locally control the parameters of the noise
(frequency, bandwidth and orientation). In the second step, we composite the noise layers to produce the final result. This is
done using a style-specific shader.
In the remainder of this document, we give a detailed description of the individual styles (Sec. 2), including the threshold
function we used for several styles (Sec. 3), and the compositing functions we used (Sec. 4).
2. Styles
In this section we provide pseudo-code for the style-specific shaders as well as the parameters that we used to produce the styles
shown in the paper.
2.1. Stippling
c© 2010 The Author(s)
Journal compilation c© 2010 The Eurographics Association and Blackwell Publishing Ltd.
Published by Blackwell Publishing, 9600 Garsington Road, Oxford OX4 2DQ, UK and
350 Main Street, Malden, MA 02148, USA.
P. Bénard, A. Lagae, P. Vangorp, S. Lefebvre, G. Drettakis & J. Thollot / A Dynamic Noise Primitive for Coherent Stylization
f l o a t pa t t e rn = t e x t u r e ( no ise_tex ture0 , texCoord ) . r ;
vec3 s t roke = t e x t u r e ( thresholdMap , vec2 ( pat tern1 , d i f f u s e I n t e n s i t y ) ) . rgb ;
vec3 f i n a l _ c o l o r = s t roke ;
2.2. Cross-Hatching
vec3 st roke1 = t e x t u r e ( thresholdMap , vec2 ( pat tern1 , d i f f u s e I n t e n s i t y ) ) . rgb ;
vec3 st roke2 = t e x t u r e ( thresholdMap , vec2 ( pat tern2 , d i f f u s e I n t e n s i t y ) ) . rgb ;
vec3 f i n a l _ c o l o r = s t roke1∗st roke2 ;
2.3. Graphite
f l o a t pa t te rn1 = t e x t u r e ( no ise_tex ture0 , texCoord ) . r ;
f l o a t pa t te rn2 = t e x t u r e ( no ise_tex ture1 , texCoord ) . r ;
f l o a t pa t te rn3 = t e x t u r e ( no ise_tex ture2 , texCoord ) . r ;
vec3 st roke1 = t e x t u r e ( thresholdMap , vec2 ( ( pa t te rn1+pa t te rn3 ) / 2 . 0 , d i f f u s e I n t e n s i t y ) ) . rgb ;
vec3 st roke2 = t e x t u r e ( thresholdMap , vec2 ( ( pa t te rn2+pa t te rn3 ) / 2 . 0 , d i f f u s e I n t e n s i t y ) ) . rgb ;
vec3 f i n a l _ c o l o r = (1.0−(1.0− st roke1∗st roke2 )∗pa t te rn3 ) ;
i f ( isBackground ) f i n a l _ c o l o r = vec3 ( 0 . 8 ) ;
c© 2010 The Author(s)
Journal compilation c© 2010 The Eurographics Association and Blackwell Publishing Ltd.
P. Bénard, A. Lagae, P. Vangorp, S. Lefebvre, G. Drettakis & J. Thollot / A Dynamic Noise Primitive for Coherent Stylization
2.4. Chalk
f l o a t pa t te rn1 = t e x t u r e ( no ise_tex ture0 , texCoord ) . r ;
f l o a t pa t te rn2 = t e x t u r e ( no ise_tex ture1 , texCoord ) . r ;
f l o a t pa t te rn3 = t e x t u r e ( no ise_tex ture2 , texCoord ) . r ;
vec3 st roke1 = t e x t u r e ( thresholdMap , vec2 ( ( pa t te rn1+pa t te rn3 ) / 2 . 0 , d i f f u s e I n t e n s i t y ) ) . rgb ;
vec3 st roke2 = t e x t u r e ( thresholdMap , vec2 ( ( pa t te rn2+pa t te rn3 ) / 2 . 0 , d i f f u s e I n t e n s i t y ) ) . rgb ;
vec3 f i n a l _ c o l o r = 1.0−(1.0−(1.0− st roke1∗st roke2 )∗pa t te rn3 ) ;
i f ( isBackground ) f i n a l _ c o l o r = vec3 ( 0 . 0 ) ;
2.5. Color Strokes
f l o a t pa t te rn1 = texture2D ( no ise_tex ture0 , texCoord ) . r ;
f l o a t pa t te rn2 = texture2D ( no ise_tex ture1 , texCoord ) . r ;
vec3 background = vec3 (0 . 9 9 , 0 . 9 6 , 0 . 9 ) ;
vec3 f i n a l _ c o l o r = background ;
f l o a t alpha = th resho ld ( pat tern1 , 25 , 0 .5 ) ;
f i n a l _ c o l o r = alphaBlend ( f i n a l _ c o l o r , over lay ( c o l o r ∗0.85 , pat tern1 , 1 . 2 ) , alpha ) ;
alpha = th resho ld ( pat tern2 , 25 , 0 .5 ) ;
f i n a l _ c o l o r = alphaBlend ( f i n a l _ c o l o r , over lay ( co lo r , pat tern2 , 1 . 0 ) , alpha ) ;
i f ( isBackground ) f i n a l _ c o l o r = background ;
c© 2010 The Author(s)
Journal compilation c© 2010 The Eurographics Association and Blackwell Publishing Ltd.
P. Bénard, A. Lagae, P. Vangorp, S. Lefebvre, G. Drettakis & J. Thollot / A Dynamic Noise Primitive for Coherent Stylization
2.6. Watercolor
We use a watercolor stylization algorithm similar to the algorithm by Bousseau et al. [BKTS06], using one turbulence texture
and one pigment texture.
2.7. Ink on Canvas
f l o a t pa t te rn1 = texture2D ( no ise_tex ture0 , texCoord ) . r ;
f l o a t pa t te rn2 = texture2D ( no ise_tex ture1 , texCoord ) . r ;
f l o a t pa t te rn3 = texture2D ( no ise_tex ture2 , texCoord ) . r ;
f l o a t pa t te rn4 = texture2D ( no ise_tex ture3 , texCoord ) . r ;
vec3 f i n a l _ c o l o r = c o l o r ;
f l o a t alpha = th resho ld ( pat tern3 , 25 , 0 .5 ) ;
f i n a l _ c o l o r = alphaBlend ( f i n a l _ c o l o r , over lay ( c o l o r ∗0.9 , pat tern3 , 1 . 0 ) , alpha ) ;
alpha = th resho ld ( pat tern2 , 25 , 0 .5 ) ;
f i n a l _ c o l o r = alphaBlend ( f i n a l _ c o l o r , over lay ( c o l o r ∗0.95 , pat tern2 , 1 . 0 ) , alpha ) ;
alpha = th resho ld ( pat tern1 , 25 , 0 .5 ) ;
f i n a l _ c o l o r = alphaBlend ( f i n a l _ c o l o r , over lay ( c o l o r ∗1.05 , pat tern1 , 1 . 0 ) , alpha ) ;
f i n a l _ c o l o r = over lay ( f i n a l _ c o l o r , pat tern4 , 1 . 2 ) ;
i f ( isBackground ) f i n a l _ c o l o r = vec3 (0 .17 ,0 .1 ,0 .017 ) ;
c© 2010 The Author(s)
Journal compilation c© 2010 The Eurographics Association and Blackwell Publishing Ltd.
P. Bénard, A. Lagae, P. Vangorp, S. Lefebvre, G. Drettakis & J. Thollot / A Dynamic Noise Primitive for Coherent Stylization
2.8. Painterly
f l o a t pa t te rn1 = texture2D ( no ise_tex ture0 , texCoord ) . r ;
f l o a t pa t te rn2 = texture2D ( no ise_tex ture1 , texCoord ) . r ;
f l o a t pa t te rn3 = texture2D ( no ise_tex ture2 , texCoord ) . r ;
vec3 pa t te rn4 = texture2D ( no ise_tex ture3 , texCoord ) . rgb ;
vec3 f i n a l _ c o l o r = over lay ( co lo r , pat tern3 , 0 .7 ) ;
f l o a t alpha1 = th resho ld ( pat tern1 , 25 , 0 .5 ) ;
vec3 s t roke1_co lo r = over layAlpha ( f i n a l _ c o l o r , c o l o r ∗0.8 , pat tern4 , 1 .2 , alpha1 ) ;
f l o a t alpha2 = th resho ld ( pat tern2 , 25 , 0 .5 ) ;
f i n a l _ c o l o r = over layAlpha ( s t roke1_co lo r , c o l o r ∗0.9 , pat tern3 , 1 .2 , alpha2 ) ;
i f ( isBackground ) f i n a l _ c o l o r = vec3 (0 . 9 6 , 0 . 7 8 , 0 . 5 ) ;
We can add a bump mapping effect to emphasize the brush fiber layers, similar to the algorithm by Hertzmann [Her02].
3. Threshold Function
0 0.2 0.4 0.6 0.8 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
pattern
threshold(pattern,σ,0.5)
σ=50
σ=25
σ=10
σ=5
(a) Smoothness parameter (σ)
0 0.2 0.4 0.6 0.8 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
pattern
threshold(pattern,10,µ
)
µ=0.2
µ=0.4
µ=0.6
µ=0.8
(b) Position parameter (µ) (c) Threshold Map
Figure 2: Threshold functions: (a,b) threshold curves; (c) threshold map
We use thresholding for various styles. The threshold function is a sigmoid-shaped function. We use a threshold function
based on the error function, the integral of a Gaussian function, with parameters µ and σ, which control the position and the
smoothness of the threshold respectively (see Fig 2).
f l o a t th resho ld ( f l o a t pa t te rn , f l o a t sigma , f l o a t mu)
{
r e t u r n ( e r f ( ( sigma ∗ ( pa t t e rn − mu) ) ) + 1 .0 ) / 2 . 0 ;
}
c© 2010 The Author(s)
Journal compilation c© 2010 The Eurographics Association and Blackwell Publishing Ltd.
P. Bénard, A. Lagae, P. Vangorp, S. Lefebvre, G. Drettakis & J. Thollot / A Dynamic Noise Primitive for Coherent Stylization
Instead of a threshold function, we can also use a threshold map (see Fig. 2(c)), an X-toon texture [BTM06] that graphically
defines a spatially varying relationship between the threshold function and another variable (for example, shading).
4. Compositing functions
We used the following functions for compositing the noise layers.
Alpha Blending
vec3 alphaBlend ( vec3 i n i t C o l o r , vec3 colorToBlend , f l o a t alpha )
{
r e t u r n (1.0−alpha ) ∗ i n i t C o l o r + alpha ∗ colorToBlend ;
}
Overlay
vec3 over lay ( vec3 i n i t C o l o r , vec3 colorToOver lay , f l o a t over layFac to r )
{
r e t u r n i n i t C o l o r ∗over layFac to r ∗(1.0−(1.0− i n i t C o l o r ) ∗(1.0− colorToOver lay ) ) ;
}
Overlay - Alpha
vec3 over layAlpha ( vec3 backColor , vec3 i n i t C o l o r , vec3 colorToOver lay , f l o a t over layFactor , f l o a t alpha )
{
r e t u r n backColor∗(1.0−alpha ) + alpha∗ i n i t C o l o r ∗over layFac to r ∗(1.0−(1.0− i n i t C o l o r ∗alpha ) ∗(1.0−
colorToOver lay ) ) ;
}
References
[BKTS06] BOUSSEAU A., KAPLAN M., THOLLOT J., SILLION F.: Interactive watercolor rendering with temporal coherence and abstrac-tion. In Proc. 4th Int. Symposium on Non-Photorealistic Animation and Rendering (2006), pp. 141–149. 4
[BTM06] BARLA P., THOLLOT J., MARKOSIAN L.: X-toon: An extended toon shader. In NPAR ’2006: international symposium on
non-photorealistic animation and rendering (2006), ACM. 6
[Her02] HERTZMANN A.: Fast paint texture. In NPAR ’2002: international symposium on non-photorealistic animation and rendering
(2002), ACM, p. 91. 5
[Rus04] RUSINKIEWICZ S.: Estimating curvatures and their derivatives on triangle meshes. In Symposium on 3D Data Processing, Visual-
ization, and Transmission (2004). 1
c© 2010 The Author(s)
Journal compilation c© 2010 The Eurographics Association and Blackwell Publishing Ltd.