Approach of Geometric Texture Mapping Based on Discrete Gradient Searching
Ruilin Zhang Weijie Guo Xianghui Zeng Department of Computer Application
College of Information & Electron Zhejiang Sci-Tech University
Hangzhou, Zhejiang, P. R. China
Abstract: Texture mapping has two categories: color texture mapping and geometric texture mapping. This paper mainly studies geometric texture mapping for random fractal surface. Height map of random fractal surface is generated by RMD algorithm. Gradient of each point on height map is calculated by discrete central difference algorithm. So, gray map of fractal surface is obtained by reflection map equation with gradient map. Then, for establishing the relationship between original image and height map of fractal surface, the algorithm named “discrete gradient searching” is proposed in this paper. And texture mapping on hemisphere by formula and discrete gradient searching are taken separately to prove it available. Finally, it is used on mapping of fractal surface. The experimental results show that the proposed algorithm to generate random rough texture surface can get more satisfactory and perfect results. Keywords: texture mapping; geometric texture; discrete;gradient; illumination model; reflection map equation
I. INTRODUCTION Generally, texture has two categories: color texture and
roughness texture. Color texture expresses details of surface by color or light and shade. And roughness texture is generated by irregular and tiny concave and convex, which is called geometric texture.
Texture mapping technology takes the texture image as input, and maps image onto simple geometric shape to synthesize almost real-sense pattern, structure by defining the mapping relationship between texture and object[1-2].
In the real world, the surface properties contain more than just the color, as well as rough and bump. To show the rough sense, bump mapping technology needs to be used by illumination model to realize rough sense.
II. BASIC PRINCIPLES AND THEORIES
A. Diffuse reflection model and Reflection map equation Illumination model describes the relationship between
the color of object surface and the space, direction, physical attributes. When the light irradiates on a surface, three instances will occur: one is reflection, second is transmission (for transparent objects), and another is some parts of light is absorbed to change into heat. However, because only the reflected light and transmitted light can stimulate the human eyes to create colors, the objects’ colors are decided by them. When using illumination model to show the bump effect of surface, which is opaque and rough, such as fabric and land surface, Lambert diffuse reflection model is used in common.
Suppose that the imaging plane is xy plane, and the camera direction coincides with the z-axis. The direction vector of the incident is { }, , 1l l ln p q= − , the direction
vector of the view angle is { }, , 1s s sn p q= − , the surface height function is z=f(x,y), then the normal vector of any point on the surface is { }, , 1n p q= − , (p,q) is surface
gradient, ,p f x q f y= ∂ ∂ = ∂ ∂ . The reflection figure of surfaces is shown as Figure 1.
Figure 1. The reflection figure of surfaces
For the surfaces which have pure diffuse reflection properties, the brightness of the same point of their surface must be the same from any angle, and the feature has nothing to do with the light source type. Lambert reflection follows the cosine law, that is to say, the light intensity of the surface reflection is direct ratio to the cosine of the incident angle of the point source.
Suppose that the projection is the orthogonal projection, the point source is at infinity, and the surface reflection is the Lambert diffuse reflection, then, according to the definition and nature of the Lambert reflection, the light intensity of the point of surface should be consistent with the degree of radiation incident. Besides, the image intensity only depends on the shape of the object. This relationship can be shown by the reflection map equation as follows:
( ), coslI x y I ρ θ= ⋅ ⋅ (1) Although the reflection map can be defined by various
forms, usually, it is defined under the gradient space. Then reflection equation is shown as follows:
Surface z=f(x,y)
sn n
ln
θ
ϕ
view
Incidence light
x
y
z
o
2010 International Conference on Artificial Intelligence and Computational Intelligence
978-0-7695-4225-6/10 $26.00 © 2010 IEEE
DOI 10.1109/AICI.2010.304
315
2010 International Conference on Artificial Intelligence and Computational Intelligence
978-0-7695-4225-6/10 $26.00 © 2010 IEEE
DOI 10.1109/AICI.2010.304
315
),(11
1
),(
2222
qpRqpqp
qqlpplI
nnnnIyxI
ll
l
l
ll
=++++
++⋅⋅=
⋅⋅⋅⋅=
ρ
ρ
(2)
In this form, I(x,y) is standardized gray map. R(p,q) is reflection map equation. B. Texture mapping
Texture mapping [3-7] is that using the corresponding texture function value as brightness of the surface into the illumination model when calculating brightness of the surface.
Blinn proposed a roughness texture mapping technology
[3]. Its principle is: by adding a small perturbation on the coordinates of the sampling points of the surface to change micro-geometry of the surface, it can rise to the disturbance of the vector of each sampling point, then lead to brightness mutation to achieve the bump effect of the surface. However, not every disturbance direction can reach realistic rough effect, and for a good perturbation method, normal vector after disturbance should not depend on the direction and the location of the surface.
III. DISCRETE TEXTURE MAPPING In this paper, in order to get irregular and random
surface, the RMD algorithm[8] for two-dimensional(using mean random migration iteration in rectangular grid) is used to simulate the generation of fractional Brownian surfaces with the irregular, random characteristics:
(1) “Diamond” step: Get the square made of four dots, and then compute the value of center point by adding a random offset on the average of the four vertices. Thus, a prism grid is got. As in Figure 2 (b), (d), black point represents the new point, while white point represents the existing point.
(2) “Square” step: Get the diamond made of four dots, and calculate the value of center point of the diamond. When without the boundary points or diamond angles, replace them with the existing points of the other side which locate on the same column or row corresponding with the center. The value of the center is the result of the average of the four vertices adding a random offset which is equal to the random offset. And the value of point is precisely the midpoint value of every side of the square. Thus, one of the points of Square grid is got, as in Figure 2 (c), (e).
(a) (b) (c) (d) (e)
Figure 2. RMD algorithm for two-dimensional diagram
After repeating “Diamond” step and “Square” step n times, a grid matrix which size is (2n+1)×(2n+1) will be acquired. According to this process, a fractal surface having the characteristics of fractal Brownian motion will be acquired.
The fractal surface isn’t smooth and also can’t be described with a continuous function, so discrete central difference is used to approximate the partial derivatives to overcome the error accumulation, and meanwhile circular forward or backward difference is used in few boundary points without boundary conditions. Suppose that the surface height function is: z=f(x,y), resolution of image is: M×N. The coordinates of discrete domain (i,j)�[1,M]×[1,N] is corresponding to the coordinates of continuous domain(x,y) ∈D, where D is the image area. zij is the corresponding height of the discrete domain coordinates.
1, 1, , 1 , 1, ,,
2 2i j i j i j i j
i j i j
z z z zf fp p q qx y
+ − + −− −∂ ∂= ≈ = = ≈ =∂ ∂
(3)
Now, take the hemisphere with its core at the coordinates origin and radius of r for example, to verify the reasonableness of this method. Hemisphere surface equation is:
2 2 2 2
0x y z rz
⎧ + + =⎨
≥⎩ (4)
Positive direction normal vector of surface is: { }, ,0
n x y zz
=⎧⎪⎨
≥⎪⎩ (5)
Project a shadow on the xoy plane along the z-axis direction, then the projection value of every normal vector on the xoy plane is:
{ }2 2
, ,0xy
xy
n x y
n x y
=
= + (6)
The gradient of hemisphere along the z-axis positive direction is:
2 2
( , ) , ,
( , ) xy
z z x ygradz x yx y z z
nx ygradz x y
z z
⎧ ⎫∂ ∂ ⎧ ⎫= =⎨ ⎬ ⎨ ⎬∂ ∂ ⎩ ⎭⎩ ⎭
+= =
(7)
The height equation of hemispherical projection on xoy plane is:
2 2 2z r x y= − − (8) The projection height image of hemisphere is shown as
Figure 3, and the perspective is at vertical downwards to xoy plane.
Figure 3. The projection height image of hemisphere
316316
According to the formula (formula (7)), the gradient of hemisphere along the z-axis positive direction is acquired, which is shown in Figure 4.
Figure 4. The gradient of hemisphere by the formula
The horizontal and vertical gradient calculated by the discrete central difference algorithm (formula (3)) is shown as Figure 5.
Figure 5. The horizontal and vertical gradient calculated by the discrete
central difference algorithm
These two gradients on orthogonal direction above are normalized to synthesize the gradient of the whole plane domain, which is shown as Figure 6. Comparing Figure 4 with Figure 6, the two gradient maps by formula and difference separately are very similar, and it also proves that the gradient value calculated by discrete central difference algorithm is nearly close to the actual value.
Figure 6. The synthesized gradient of the whole plane domain
After using the discrete central difference method to calculate the horizontal and vertical gradient of each point of hemisphere, gray map is got according to the reflection map equation (formula (2)) under different directions of light source and different kinds of reflectivity, shown as Figure 7.
(0, 0) (0.6, 0.6)
(0.5, 0.5) (-0.5, -0.5)
Figure 7. The gray map of hemisphere under different direction of light source(pl,ql) and different kinds of reflectivities
Applying this conclusion above mentioned to the height map of the fractal Brownian surface generated by RMD
algorithm, a normalized gray map can be obtained, shown as Figure 8.
Figure 8. The height map generated by RMD algorithm and gray map
Then now, how to do texture mapping, if the surface features can not be expressed by mathematical functions?
Suppose that a curve function y=f(x) is continuous and differentiable in [a, b] interval, shown as follows.
Figure 9. Calculation of continuous function’ arc length
Then, arc differential formula is:
[ ]21 ( )ds f x dx′= + (9)
Arc length formula obtained by calculating integral in [a, b] interval, which is:
[ ]21 ( )a
bs f x dx′= +∫ (10)
Then make the continuous function discrete, that is to say, interval [a, b] is divided into n equal parts and each part length is Δx, thenΔy→0 whenΔx→0. The arc length is approximately equal to 2 2x yΔ + Δ when Δx is small enough, namely:
2 2x
s x yεΔ →
Δ = Δ + Δ (11) The total arc length at continuous interval is:
2 2
1 1
n n
i i ii i
s s x y= =
≈ Δ = Δ + Δ∑ ∑ (12)
Based on the conclusion above mentioned, an algorithm named “Discrete gradient search algorithm for pasting maps” is proposed in this paper for texture mapping on irregular surface.
Firstly, locate the coordinates of the point, which is the highest of the height map and the least changing rate for horizontal and vertical gradient. And then search synchronized field along the horizontal and vertical directions beginning with the point got by first step, so that the points in image space correspond to the points in texture space. Finally, the RGB values of pixels in image space are assigned to the pixels in texture space. Thus, texture mapping is completed.
y=f(x)
y
x Δx1 Δx2 Δx3 Δx4
Δy1 Δy2
Δy3
Δy4
317317
Algorithm steps as follows: �Locate the image center �Divide the image into four sectors taking the center as
boundary. �Search both sides from the center, and then calculate
the coordinates of the image space after mapping. �Assign the RGB values of pixels in image space to the
pixels in texture space. �Synthesize the brightness values.
IV. EXPERIMENTAL RESULTS
A. Testify by hemisphere surface The pre-mapping image is shown as left image of Figure
10, and the height map of hemisphere is shown as right image. The pre-mapping image is mapped to height map by formula and discrete gradient search separately.
Figure 10. pre-mapping imageand height map of hemisphere
Mapping results by formula mapping algorithm are shown in left image of Figure 11, while the results by the discrete gradient search algorithm are shown in the right image.
Figure 11. The mapping images of two results
In order to get a better three-dimensional effect, lighting effects are added to the mapping results, shown as Figure 11.
Figure 12. The mapping results added with lighting effect
B. texture mapping of fractal surface With the ordinary pictures as pre-mapping original
images, the mapping images with various texture and light effect are generated by the algorithm above mentioned.
Figure 13. The process of discrete texture mapping
And many kinds of random and rough texture, such as terrain, rough wall and draped effect of fabrics, can be simulated well. All the process is shown by below figure:
Figure 14. Other images of simulation effect
V. CONCLUSIONS The principle of simulating fractal Brownian surfaces by
RMD algorithm is studied in this paper. In order to achieve the texture mapping of fractal surfaces, a novel method named “discrete gradient search algorithm” is put forward to do texture mapping for irregular and rough surfaces. It synthesizes height maps generated by RMD algorithm and brightness maps calculation by reflection map equation to achieve the random and rough effect of surfaces. The experimental results show that the proposed algorithm to generate random rough texture surface can get more satisfactory and reasonable results.
REFERENCE [1] BERTHOLD K.P.HORN. Height and gradient from shading [J].
International Journal of Computer Vision, 1990, 5(1): 37~75. [2] Jerome Maillot, Hussein Yahia, Anne Verroust. Interactive texture
mapping. In: Proc SIGGRAPH, Anaheim, California, 1993,27(8):27-34.
[3] Blinn J.F. A scan line algorithm for the computer display of parametrically defined surfaces. Computer Graphics, 1978,12:10-63.
[4] R. A. Hall, Hybrid Technique for Rapid Image Synthesis. SIGGRAPH Corse Note. 16,1986. Vo 136,10.4,1999.
[5] E. A. Bier, K. R. Sloan, Two-Part Mapping. IEEE Computer Graphics Applications, Vol. 6, No. 9,1986. 40-53.
[6] Williams, L. Pyramidal parametrics. Computer Graphics, 1981,11:32-40.
[7] Terry Welsh. Parallax Mapping with Offset Limiting: A Per-pixel Approximation of Uneven Surfaces, Infiscape Corporation, 2004,1-9.
[8] K. FALCONER. Fractal Geometry: Mathematical Foundation and Applications [M]. Chichester: JohnWilley & Sons. Inc., 1990.
I1: Height map of fractal surface by RMD I2: Gray map of I1 by discrete reflection map equation I3: Pre-mapping image I4: The mapping result from I3 to I1 with gray effect I2
I4I1 I3I2
318318
Top Related