Bag paper dyes the computer emulation method of figure
Technical field
The present invention relates to computer picture emulation technology, relate in particular to and utilize the mobile emulation technology implementation method with artistic effect texture of drawing of computer mould fluid analogy.
Background technology
It is the paper skill form that a kind of ancient Arab countries invent the earliest that bag paper dyes (Paper marbling), it is a kind of method at water surface design configuration, this paper technology is mainly to form various patterns at water or the mobile pigment of thick liquid surface operation, as produced the exquisite pattern of the forms such as smooth similar bag, and by design transfer the surface to paper or fabric.In recent years, people decorate books, picture background, pinup picture etc. with these bag paper.
Because traditional bag paper dyeing technique requires can not there be a mistake in the whole process of operation, once error to some extent not only will restart, and can waste a large amount of pigment.Therefore,, if can be highly significant by the emulation of computer realization paper skill making effect, so, not only make cost of manufacture reduce, and can reduce the wasting of resources and environmental pollution.
In recent years, more existing researchs of flowing to draw the texture with artistic effect by Computer Simulation fluid.
Current emulation mode has three classes: the emulation mode of the two dimensional fluid model based on physics, the emulation mode of polar plot and the emulation mode based on figure coordinate conversion function.Document [1] uses hydrodynamic force to gain knowledge to simulate fluid motion and realized the function of the rambling figure of drawing similar bag, but this method needs all motion paths of initialization before drafting starts, and is difficult to accomplish real-time rendering; Document [2] has proposed a kind of Real-Time Rendering based on GPU (Graphics Processing Unit), but the graphic limit generating is fuzzyyer.The method of document [3], [4] can generate clear boundary: wherein, document [3] by generating clear boundary with B-spline curves insertion method on Eulerian mesh, and document [4] adopts the mode of vector plot to draw fluid, control border according to the turbulivity of the flexibility of local boundary and speed, but these two kinds of methods can only generate unpredictable grain effect.Document [5] is expanded document [3], solve in conjunction with CIP (ConstrainedInterpolation Profile) interpolation method and MacCormack method NS (Navier-Stokes) equation that represents velocity field and fluid density field, obtain fluid boundary clearly, but in the time that simulation multiple fluid flows, each fluid all needs to build grid, in the time of continuous increase fluid, calculated amount can increase greatly.Document [6] is by mathematical notation method, drawn some and had the figure of special characteristic by the coordinate transform function of some figures.This method formation speed is very fast, but it does not reflect the flow characteristics of pigment.
List of references:
[1]Mao X,Suzuki T,Imamiya A.AtelierM:a physically based interactivesystem for creating traditional marbling textures.In:Proceedings of the 1stinternational conference on Computer graphics and interactive techniques inAustralasia and South East Asia,New York,USA:2003.79-86.
[2]Jin X,Chen S,Mao X.Computer-generated marbling textures:a GPU-baseddesign system.IEEE computer graphics and applications,2007,27(2):78-84.
[3]Acar R,Boulanger P.Digital marbling:a multiscale fluid model.IEEETransactions on Visualization and Computer Graphics,2006,12:600-614.
[4]Ando R,Tsuruno R.Vector fluid:a vector graphics depiction of surface flow.In:Proceedings of the 8th International Symposium on Non-PhotorealisticAnimation and Rendering.New York,USA:2010.129-135.
[5]Xu J,Mao X,Jin X.Non-dissipative marbling.IEEE Computer Graphics andApplications,2008,28(2):35-43.
[6]Lu S,Jaffer,A.,Jin X,Zhao H,MaoX.Mathematical Marbling.IEEEComputer Graphics and Applications,2011,99:1-1.
Summary of the invention
The problem existing based on above-mentioned prior art, the present invention proposes the computer emulation method that a kind of bag paper dyes figure, integrated fluid mechanics and polar plot technology, utilize Computer Simulation to go out to generate the pattern with artistic effect that graph outline is clear, complete, realize similar shell stone patterns.
Bag paper dyes a computer emulation method for figure, and in conjunction with the flow process of fluid Simulation pigment, its simulation realizes by the given mathematical description of any given moment convection cell state in process fluid flow; And the output that utilizes polar plot technology to realize bag paper to dye figure, the method comprises the following steps:
Step 1, builds velocity field based on Hydrodynamics Theory:
Wherein, u is fluid velocity, and ρ is fluid density, and p is pressure item, and f is external force, and v is coefficient of viscosity.
Speed territory is defined on the uniform grid of a n × n, obtains the variation of velocity field by central difference simultaneous solution equation (1) and (2)
Step 2, fluid boundary is followed the trail of and is optimized: use vectorgraph charting fluid boundary, when adding after external force, along with the continuous variation of velocity field, follow the tracks of the motion conditions on pigment border: the speed u (p that adopts bilinear interpolation method computation bound node i place
i), and then calculate the reposition p of boundary node i in next moment
i+1
u(p
i)=t2(s2*u
i,j+s1*s1*u
i,j+1)+t1(s2*u
i+1,j+s1*u
i+1,j+1) (4)
p
i+1=p
i+u(p
i)·Δt (5)
Step 3, Boundary filling and output: adopt the template test method fill fluid profile of template buffer memory to obtain solid fluid based on OpenGL, adopt SVG formatted output figure;
Step 4, single fluid is to the expansion of multiple fluid: single fluid simulation is expanded to multiple fluid simulation., need to consider the adhesive characteristics of different fluid, in the time of the new fluid of user add, to add to the speed v of exterior circumferential diffusion by the initial boundary node of convection cell profile, the value of speed v is subject to the impact of inherent viscosity coefficient value visc of fluid, that is:
v(i)=(1-visc)*V (6)
Wherein, v represents the speed of fluid boundary node i on speed grid, and V represents coefficient of viscosity value, and visc is the speed of 1 o'clock.
Described in fluid motion process, control the increase and decrease of boundary node by controlling node distance threshold d, keep the flatness of fluid boundary, degree of crook based on local boundary carrys out adjustable range threshold value d, guarantee that distance between two neighborhood of nodes is between d and d/2, reduce node in the place of contour smoothing, increase node in the place of border bending.
The distance threshold d at boundary node i place
icomputing formula be:
Wherein, d
maxrepresent the ultimate range between fluid boundary neighborhood of nodes.
for the curvature at node i place.
Compared with the conventional method, bag paper of the present invention dyes the computer emulation method of figure, not only can realize the Computer Simulation that bag paper dyes, and simulation result can farthest approach actual bag paper and dye the graphical effect that skill obtains, fidelity is high.
Brief description of the drawings
Fig. 1 is the computer emulation method overall flow figure that bag paper dyes figure;
Fig. 2 is bilinear interpolation algorithm schematic diagram;
Fig. 3 is the unordered texture graphics schematic diagram simulating by emulation mode of the present invention;
Fig. 4 is the decorative pattern reason pictorial diagram simulating by emulation mode of the present invention;
Fig. 5 is for passing through fluid boundary of the present invention flow schematic diagram towards periphery;
Simulation result when Fig. 6 (a) and 5 (b) represent respectively inviscid difference and toughness difference.
Embodiment
Below in conjunction with accompanying drawing, specific embodiment of the invention is elaborated:
As shown in Figure 1, be computer emulation method overall flow figure of the present invention, the method mainly comprises the following steps:
1. build fluid velocity field.
In order to simulate the flow process of pigment, the state of any given moment convection cell that must be in simulation process has a mathematical description, wherein most important part is the velocity field of fluid, speed has not only determined how fluid itself moves, and it also affects relevant fluid around simultaneously.At present most of research about simulation fluid is all based on NS system of equations, and it has described variation and the relation thereof of internal fluid speed and pressure.Because equation is nonlinear, exact solution cannot be asked for, and can only use the method approximate solution of discretize.The present invention adopts incompressible fluid equation, as follows:
Wherein, u is fluid velocity, and ρ is fluid density, and p is pressure item, and f is external force, and v is coefficient of viscosity.
The present invention is defined in speed territory on the uniform grid of a n × n, obtains the variation of velocity field by simultaneous solution equation (1) and (2).
2. fluid boundary is followed the trail of and is optimized
Polar plot is the figure describing by mathematical method, can not affect the sharpness of figure while zooming in or out figure arbitrarily, and therefore the present invention takes to represent fluid boundary based on the method for polar plot, and then represented region, border is filled.
First, initialization fluid profile border.In traditional bag paper dyeing technique, pigment drips to liquid surface to connect rotund shape, therefore chooses some discrete points on initial filled circles zone boundary initial boundary node as this fluid.When adding after external force, along with the continuous variation of velocity field, need to follow the tracks of the motion conditions on pigment border.
The present invention adopts the speed u (p at bilinear interpolation method computation bound node i place
i), specifically by shown in formula (3).Obtain the reposition p of boundary node i in next moment according to formula (4) again
i+1.
u(p
i)=t2(s2*u
i,j+s1*s1*u
i,j+1)+t1(s2*u
i+1,j+s1*u
i+1,j+1) (3)
p
i+1=p
i+u(p
i)·Δt (4)
Pi is the coordinate (x, y) of sampled point, s1, s2, t1, the scale-up factor that t2 is bilinear interpolation, linear interpolation algorithm schematic diagram as shown in Figure 2.
Only those boundary nodes of tracking initiation can not well be described fluid profile, therefore need the new boundary node of suitable interpolation to obtain fluid boundary true to nature.The present invention controls the increase and decrease of boundary node by controlling node distance threshold d, the cardinal rule of following is to guarantee that distance between two neighborhood of nodes is between d and d/2.In order to reduce calculated amount, obtain fluid boundary level and smooth, true to nature, the degree of crook that the present invention is based on local boundary carrys out adjustable range threshold value d, reduce some nodes in the smoother place of profile, and more bending place increases some nodes more on border.
The distance threshold d at boundary node i place
icomputing formula be:
Wherein, d
maxrepresent the ultimate range between fluid boundary neighborhood of nodes.
for the curvature at node i place.
3. Boundary filling and output
Obtain at any time after the positional information of boundary node, can generate easily the polygon being formed by boundary node, next need to fill this polygonal region.The template test method fill fluid profile that the present invention is based on OpenGL employing template buffer memory, obtains solid fluid.While zooming in or out arbitrarily based on polar plot, can not affect the characteristic of the sharpness of figure, according to SVG open standard, adopt SVG formatted output figure, use the method well to avoid distortion phenomenon.
4. single fluid is to the expansion of multiple fluid
While equally obtaining abundant figure for image-stone line paper dyeing technique, the drafting of only simulating single fluid is inadequate, and we need to expand to method of the present invention in the mobile simulation of multiple fluid.If the method proposing before adopting, so different fluids has identical adhesive characteristics, and this way does not meet pigment attribute rule.
Therefore, in the time drawing multiple fluid, need to consider the adhesive characteristics of different fluid, in order visually to allow people experience bag paper dyeing technique, can observe the different attribute between different pigment fluids, the present invention is that fluid has added inherent viscosity coefficient.Be not difficult to find by observation, in visual effect, general people can only observe near the impact that different fluid interphase interaction produces profile border, therefore in the time of the new fluid of user add, can add to the speed v of exterior circumferential diffusion by the initial boundary node of convection cell profile, as shown in Figure 2, the value of speed v is subject to the impact of inherent viscosity coefficient value visc of fluid, that is:
v(i)=(1-visc)*V (6)
Wherein, v represents the speed of fluid boundary node i on speed grid, and V represents coefficient of viscosity value, and visc is the speed of 1 o'clock, in the system realizing herein, and V=1.Simulation result when Fig. 3 (a) and 3 (b) represent respectively inviscid difference and toughness difference.
The present invention has mainly realized the fluid simulation of two kinds of grain effect figures, and one is rambling texture maps (Fig. 4), and a kind of have the figure (Fig. 5) of special pattern effect for class floweriness etc.