Method for texture generation based on circle packing
By employing a circular stacking-based texture generation method, and utilizing Delaunay triangulation and nonlinear optimization techniques, two-dimensional and three-dimensional textures can be generated rapidly. This solves the problems of slow generation speed and difficulty in expansion in existing methods, and achieves efficient texture generation and coherent primitive connection.
Patent Information
- Application Number
- CN202211354396.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-01
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2042-11-01
AI Technical Summary
Existing texture generation methods are slow, making it difficult to generate textures quickly on a two-dimensional plane, and they are difficult to extend to three-dimensional mesh surfaces. Existing methods are prone to causing adjacent instances to intersect or requiring complex parameter adjustments during the generation process.
A texture generation method based on circle stacking is adopted. A uniformly distributed triangular mesh is generated through Delaunay triangulation. The radius and position of the circles are optimized using a nonlinear optimization method. Circles are inserted or deleted to reach a threshold. Texture is generated by combining geometric primitive replacement.
It enables rapid texture generation on 2D planes and 3D mesh surfaces while maintaining detail integrity, solving the problems of slow generation speed and difficulty in expansion in existing methods. The generated texture primitives are coherent and suitable for complex shapes.
Smart Images

Figure CN115908635B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of texture generation and geometric modeling, in particular to a texture generation method based on circle packing. BACKGROUND
[0002] Decorative texture refers to a complex pattern composed of a large number of simple basic primitives, which has a wide range of applications in various scenes in daily life. It is usually time-consuming and laborious to generate these textures manually. Therefore, it is necessary to propose a method for quickly generating such textures using a computer. With the rapid development of computers, a large number of studies have been applied to procedurally generate textures.
[0003] Current texture generation methods mainly fall into two categories, 1. Instance-based texture generation method, instance is some simple geometric primitive, geometric primitive can be a picture, several intersecting curves or polygon, etc., which is usually input by the user. This method considers how to fill these instances into the target surface, which can be a two-dimensional plane or a three-dimensional mesh surface. This method first uniformly samples the target surface and places a small instance at the sampled position, then makes the instances grow continuously, and finally obtains a target surface tightly filled with instances. In the process of instance growth, adjacent instances may intersect, so appropriate deformation, cutting, etc. need to be done to adjacent instances, and sometimes stretching of instances is also needed to make the instance filling more tightly. 2. Procedural texture generation method, procedural texture generation method has attracted much attention in the early stage of computer development. This method can generate complex texture patterns with rich levels through algorithm design and a small number of parameters, but it is not easy to design such a procedural method, and small changes in parameters have a great impact on the final result. Many times the generated texture does not meet people's expectations. Due to the complex structure of the algorithm for generating such textures, it is difficult to have a more general method to popularize it to three-dimensional mesh surfaces. SUMMARY
[0004] The present application aims to solve the problems of slow speed, difficulty in expanding from two-dimensional to three-dimensional, etc. of the existing texture generation method, and provides a new texture generation method based on circle packing, which can quickly calculate circle packing and generate textures on two-dimensional plane and three-dimensional mesh surface.
[0005] The present application comprises the following steps:
[0006] 1) input a two-dimensional closed polygon or a three-dimensional mesh model;
[0007] 2) Set a threshold, Delaunay triangulation of two-dimensional closed polygon, or re-meshing of three-dimensional mesh model, eventually get a vertex uniform distribution of triangular mesh, the threshold determines the density of the vertex in the triangular mesh;
[0008] 3) Each non-boundary vertex in the triangular mesh is regarded as a circle, initialize the radius of these circles, use nonlinear optimization method to optimize each circle until the radius and position of all circles converge;
[0009] 4) Insert or delete circles until the number of circles reaches the threshold;
[0010] 5) Regularly replace the circles with geometric primitives to generate textures.
[0011] In step 1), the input two-dimensional closed polygon, the input two-dimensional closed polygon allows the existence of holes, the boundary and the hole are represented by the vertex coordinates arranged in counterclockwise direction, the triangular mesh is used to represent the circle packing, and the two-dimensional plane is represented by a closed polygon and allows the existence of holes.
[0012] In step 2), the threshold is set to control the number of vertices of the generated mesh; when a larger threshold is set, the average edge length of the triangular mesh becomes longer, and the number of vertices decreases; when a smaller threshold is set, the average edge length of the triangular mesh becomes shorter, and the number of vertices increases; the setting of the threshold is related to the scale of the closed polygon and the three-dimensional mesh model, and it is recommended to be set as the average value of the edge length of the input closed polygon or the average value of the edge length of the input mesh model;
[0013] A two-dimensional triangular mesh with uniform vertex distribution is generated according to the polygon input in step 1) by using a two-dimensional mesh optimization method;
[0014] A triangular mesh model with uniform vertex distribution is generated by re-meshing a three-dimensional mesh model using a three-dimensional mesh optimization method;
[0015] In the Delaunay triangulation of the two-dimensional closed polygon or the re-meshing of the three-dimensional mesh model, the Delaunay triangulation of the two-dimensional closed polygon generates a two-dimensional triangular mesh with the closed polygon as the boundary, and the re-meshing of the three-dimensional mesh model improves the mesh quality, and finally a three-dimensional triangular mesh is obtained.
[0016] In step 3), each non-boundary vertex in the triangular mesh is regarded as a circle, the radius of each circle is initialized, the boundary of the triangular mesh is the input 2D polygon, the points on the polygon are boundary points, the vertices in the triangular mesh except the boundary points are regarded as circles, the initial value of the radius of each circle is 0; each circle is optimized by using a nonlinear optimization method until the radius and position of each circle converges, the nonlinear optimization method is used to solve the target function and constraints, for a circle to be optimized in the triangular mesh, the circle is denoted as a target circle, the target function is the radius and position of the target circle, the constraints are other circles in the neighborhood of the target circle or the boundary, the target circle cannot intersect with other circles or the boundary, and then each circle is optimized by using the nonlinear optimization method; when each circle in the triangular mesh is calculated once, one iteration is completed, and the position and radius of each circle almost do not change after two or three iterations.
[0017] In step 4), the circles are inserted or deleted until the number of circles reaches a threshold value, in step 3), there are areas in the triangular mesh that are not covered by circles and circles with small radii, in order to maintain the details of the input triangular mesh, circles need to be inserted in the areas that are not covered by circles; in order to make the size of the circles more uniform, some circles with large or small sizes need to be deleted, and the deletion of the circles can be realized by deleting the vertices corresponding to the circles in the triangular mesh; the specific steps of inserting the circles can include the following steps:
[0018] (1) define a tangent edge, when a circle is tangent to a circle in the neighborhood of the circle or tangent to a boundary, the edge is defined as a tangent edge, and the tangent edge divides the triangular mesh into several smaller closed polygons;
[0019] (2) for each triangle in the triangular mesh, find the boundary set and vertex set of the smallest closed polygon to which the triangle belongs, write the boundary set and vertex set into a constraint form, set the initial position of the circle, and the initial position is set to the center of gravity of the triangle; if the initial position is inside the circle corresponding to a vertex of the triangle, the coordinate is moved to the boundary of the circle to ensure that the initial position is not covered by the circle; the moving direction is from the center of the circle to the center of gravity coordinate of the triangle; after the constraints and the initial position are set, the maximum circle is solved by using a nonlinear optimization algorithm;
[0020] (3) select the largest circle from the circles obtained in each triangle, and insert the circle into the triangular mesh if the number of circles is less than a threshold value, and steps (1), (2) and (3) are executed again.
[0021] In step 5), the rule is to delete a part of the circle, to twist and deform the circle; the geometric primitive in two dimensions can be a picture, a two-dimensional geometric figure, and the geometric primitive in three dimensions is a three-dimensional mesh model.
[0022] The following gives the principle of the present application:
[0023] T1, The present application converts the circle packing problem into a nonlinear optimization problem, which involves two types of geometric constraints, one is the constraint between circles, that is, two circles cannot intersect, and the other is the constraint between the circle and the boundary, that is, the circle and the boundary cannot intersect, the constraint between the circles can be regarded as the geometric distance between the centers of the two circles must be greater than or equal to the sum of the radii of the two circles, and the constraint between the circle and the boundary is that the distance from the center of the circle to the boundary must be greater than or equal to the radius. Therefore, the geometric constraints of circle packing can be converted into inequality constraints, so that the nonlinear optimization method can be used to quickly solve it.
[0024] T2, When optimizing a circle, how to choose the corresponding constraint is a very key problem, too few constraints may result in incorrect results, too many constraints will slow down the solving speed, and the solved value will be too conservative, in addition, for concave polygons, the setting of constraints is more complex.
[0025] T3, Generally, it is difficult to extend two-dimensional textures to three dimensions, two-dimensional textures are in a plane, and three-dimensional textures are on a curved surface. Mapping two-dimensional textures to a three-dimensional curved surface will cause distortion and deformation of the texture. However, the present application does not directly map two-dimensional textures to a three-dimensional curved surface. For a two-dimensional plane, the present application first generates a circle packing, and then defines rules on the circle packing to generate textures. For a three-dimensional case, the present application first generates a sphere packing, and then generates textures. The difference between the three-dimensional sphere packing and the two-dimensional circle packing is that the three-dimensional coordinates have an additional component, and a tangent plane needs to be calculated. Other calculations are basically the same as in the two-dimensional case.
[0026] Compared with the prior art, the present application has the following outstanding advantages.
[0027] 1. The nonlinear optimization method is used to solve the circle packing problem, which can quickly generate circle packing and well preserve the details of the input figure.
[0028] 2. The circle packing method can handle concave polygons and polygons with holes.
[0029] 3. The circle packing is applied to texture generation, which is faster than existing methods, can flexibly generate various textures, and solves the problem of extending two-dimensional textures to three dimensions. In addition, the generated three-dimensional mesh texture has more coherent connections between primitives. BRIEF DESCRIPTION OF DRAWINGS
[0030] Figure 1 Input 2D polygon.
[0031] Figure 2 Resulting triangle mesh after Delaunay triangulation of polygon.
[0032] Figure 3 Resulting after optimization of circle radius.
[0033] Figure 4 Resulting after insertion of circle.
[0034] Figure 5 Generated texture.
[0035] Figure 6 Input 3D mesh model.
[0036] Figure 7 Resulting triangle mesh model after re-meshing.
[0037] Figure 8 Optimized sphere packing.
[0038] Figure 9 Resulting sphere packing after removal of partial spheres and re-optimization.
[0039] Figure 10 Generated texture with spheres replaced by geometric primitives.
[0040] Figure 11 Circle vs. circle constraint.
[0041] Figure 12 Circle vs. boundary constraint.
[0042] Figure 13 Boundary constraint example.
[0043] Figure 14 Polygon split example.
[0044] Figure 15 Minimum polygon constraint example.
[0045] Figure 16 Concave polygon constraint example.
[0046] Figure 17 Circle vs. boundary constraint for concave polygons.
[0047] Figure 18 Circle packing without handling concave structures.
[0048] Figure 19 Determining concave structures.
[0049] Figure 20 a circle packing for processing the concave structure.
[0050] Figure 21 a spherical three-dimensional texture obtained by the method [2].
[0051] Figure 22 a spherical three-dimensional texture obtained by the method [2].
[0052] Figure 23 a three-dimensional rabbit model texture obtained by the method [2].
[0053] Figure 24 a three-dimensional rabbit model texture obtained by the method [2].
[0054] Figure 25 a two-dimensional English letter pattern texture obtained by the method [3].
[0055] Figure 26 a two-dimensional English letter pattern texture obtained by the method [3].
[0056] Figure 27 a two-dimensional lion pattern texture obtained by the method [3].
[0057] Figure 28 a two-dimensional lion pattern texture obtained by the method [3].
[0058] Figure 29 a three-dimensional twisted tubular mesh model generated by the method of the present application.
[0059] Figure 30 a three-dimensional egg-shaped mesh model generated by the method of the present application.
[0060] Figure 31 replacing the circles in the circle packing with question marks, exclamation marks, and periods by the method of the present application.
[0061] Figure 32 a stylized simulation of a pond by the method of the present application. DETAILED DESCRIPTION
[0062] To make the purpose, technical solutions and characteristics of the present application clearer and more apparent, the following embodiments will be further described in combination with the drawings. The present application can be divided into two steps, the first step of circle packing only needs the user to input a constraint polygon, and the second step is to generate a texture by using the result of the circle packing.
[0063] Referring to Figures 1-10 , the present application comprises the following steps:
[0064] S1, inputting a two-dimensional closed polygon or a three-dimensional mesh model, Figure 1 for the input two-dimensional closed polygon, Figure 6 for the input three-dimensional mesh model;
[0065] S2, set threshold, Delaunay triangulation for two-dimensional closed polygon, re-meshing for three-dimensional mesh model, Figure 2 for two-dimensional input Delaunay triangulation, Figure 7 for three-dimensional input re-meshing;
[0066] S3, initialize the radius of the circle, use nonlinear optimization method to optimize each circle until the radius of the circle converges, Figure 3 for two-dimensional circle packing result, Figure 8 for three-dimensional sphere packing result;
[0067] S4, set radius threshold, stop inserting circles when the radius of the inserted circle is less than the threshold, Figure 4 for two-dimensional circle packing result after inserting circles, Figure 9 for three-dimensional sphere packing result after inserting spheres.
[0068] S5, replace circles with primitives according to rules to generate textures. Figure 5 for two-dimensional circle packing texture, Figure 10 for sphere generated texture replaced by geometric primitives.
[0069] Figure 1 Give the polygon constraint on the two-dimensional plane, the constraint is composed of two circular ring-shaped polygons inside and outside. Figure 2 for the triangular mesh obtained after Delaunay triangulation of the polygon, the vertices on the inner and outer rings are considered as boundary points, and all the remaining vertices are considered as circles after removing these boundary points. The initial radius of the circle is 0. Figure 3 for the circle packing result after optimizing the radius of the circle, after two to three rounds of optimization, the radius of all circles grows to the maximum value. Figure 4 Insert circles on the basis of Figure 3 , this step fills the relatively large gaps left in the previous step. Figure 5 for texture generation, replace the circle packing result with primitives, and replace the previous circle in the following way, first find two adjacent circles, then replace the previous circle with two smaller circles and a line segment connecting the two circles. Figure 6 for three-dimensional mesh model. Figure 7 for the triangular mesh model obtained after re-meshing the three-dimensional mesh model, there are no boundary points in the three-dimensional mesh model, so each vertex in the mesh model is considered as a sphere. Figure 8 for the sphere packing result after optimizing the size of each sphere. Figure 9 for the sphere packing result obtained by inserting spheres. Figure 10The texture generated by the spheres is replaced by geometric primitives. The replacement is as follows: each sphere is replaced by a helical mesh inside the sphere, and an S-shaped mesh between adjacent spheres.
[0070] In step S1, the closed polygon is represented by an array of positions of its vertices, and the vertices are arranged in counterclockwise order. The three-dimensional mesh model is represented by a half-edge data structure.
[0071] In step S2, the closed polygon is Delaunay triangulated, and the threshold is set to the average length of the edges of the closed polygon. After triangulation, new vertices are generated inside the closed polygon, which will be used for the subsequent circular packing.
[0072] In step S3, the radius of each circle is initialized to 0. The nonlinear optimization problem is a mature problem. In this method, the Knitro [BYRD R H, NOCEDAL J, WALTZ R A. Knitro: an integrated package for nonlinear optimization [J]. Large-Scale Nonlinear Optimization, 2006, 83: 35-59] library is used to solve it. First, the geometric constraints in the circular packing problem need to be converted into mathematical inequality constraints. There are two types of constraints in the circular packing problem. One is the constraint between circles, i.e., two circles cannot intersect. The other is the constraint between a circle and a boundary, i.e., a circle cannot intersect with a boundary. The constraint between circles can be regarded as the Euclidean distance between the centers of two circles being greater than or equal to the sum of the radii of the two circles. The constraint between a circle and a boundary is that the distance from the center of the circle to the boundary must be greater than or equal to the radius. Figure 11 The constraint between circles is shown on the left, where the circle on the left is the target circle, i.e., the circle to be optimized, and the circle on the right is the constraint circle, i.e., the fixed circle. The inequality form is (p-p1)·n-r-r1≥0, where p is the center coordinate of the target circle, r is the radius of the target circle, p1 is the center coordinate of the constraint circle, r1 is the radius of the constraint circle, and n is the unit directional vector from p1 to p. Figure 12 The constraint between a circle and a boundary is shown on the left, where the circle on the left is the target circle, and the line segment e a e b is the boundary. The inequality form is (p-p T )·n-r≥0, where p is the center coordinate of the target circle, r is the radius of the target circle, p T is the foot of the perpendicular from p to the line segment e a e b , and n is the unit directional vector from p T to p.
[0073] The Knitro optimization library uses a gradient-based optimization method, requiring the gradient of the corresponding constraint function. For the two-dimensional case, this method has three parameters to optimize: the two coordinate components of point p and the radius r. The partial derivatives of the constraint function with respect to these three variables are as follows: [n] x ,n y [,-1], where n x ,n y These are the two coordinate components of vector n. The constraints in the three-dimensional case are similar to those in the two-dimensional case, still involving three parameters. Point p still moves within a plane, but the difference is that p moves within a plane in three-dimensional space instead of a two-dimensional one. First, a tangent plane is calculated for each vertex in the triangular mesh. Vertices can only move within this plane. A point p in the two-dimensional plane needs to be transformed to the tangent plane by multiplying by a matrix: p' = c + p·M. TBN p' is the transformed coordinate, c represents a point on the tangent plane, and M... TBN It is a 3×3 matrix, whose three row vectors correspond to the tangent vector T, the bitangent vector B, and the normal vector N of the plane containing the mesh vertex, respectively. The gradient representation of the constraint function in the three-dimensional case is as follows:
[0074]
[0075] When optimizing a given circle, this method selects all circles within the annular neighborhood of that circle, as well as the boundary of the annular neighborhood, as constraints. Figure 13 As shown, e1 to e6 are boundary constraints, and v1 to v6 are circle constraints. After setting the constraints, it is also necessary to set the initial values of the variables in the optimization library, namely the initial position and radius of the circle. The initial position is the position of the corresponding vertex of the circle in the triangular mesh, and the radius is 0. After optimizing one circle, the edges are flipped to maintain the Delaunay triangular mesh structure. Optimizing all circles once is counted as one iteration. After two to three iterations, the radius of the circle will converge to its maximum value. Figure 3 As shown, Figure 8 This corresponds to the result of the sphere stacking.
[0076] In S4, a threshold is set. When the number of circles is less than the threshold, a circle is inserted; when the number of circles is greater than the threshold, a circle is deleted. To improve the efficiency of circle insertion, this method defines the concept of a tangent edge. When a circle v is tangent to a circle in its annular neighborhood or to a boundary, this edge is defined as a tangent edge. For a circle tangent to a boundary, a new point is inserted at the tangent point to avoid forming a narrow triangle. The tangent edge and the original boundary in the triangular mesh can divide the triangular mesh into multiple smaller polygons. The boundaries of the smaller polygons are all formed by the tangent edge or the original boundary in the triangular mesh, such as...Figure 14 As shown, the inserted circles are then converted from being inserted in the whole polygon to being inserted in several smaller polygons, and the newly inserted circles can continue to split these polygons. Even if the two triangles sharing the edge do not satisfy the Delaunay structure after fixing the edge, no flip operation is performed.
[0077] The relevant parameter is the number of circles. The circles are inserted or deleted until the number of circles satisfies the relevant parameter. After optimizing the radii of the circles in the previous step, there are areas that are not filled and circles with small radii. At this time, the quality of the circle packing needs to be improved by inserting or deleting circles.
[0078] A triangle-based insertion strategy is used. For each triangle in the triangular mesh, all circle constraints and boundary constraints of the polygon to which the triangle belongs are first found, as shown in Figure 15 The polygon is composed of two triangles, with a boundary constraint set {e1, e2, e3, e4} and a vertex constraint set {v1, v2, v3, v4}. The size of the inserted circle is different from that of the optimized circle. The inserted circle needs to be set with an initial position. In this method, the initial position is generally set as the barycentric coordinates of the triangle. If the barycentric coordinates of the triangle are inside a circle, the coordinates are offset to the boundary of the circle to ensure that the initial position is not covered by a circle. Then, the maximum circle based on the current triangle is solved using the Knitro library. In this way, each triangle in the triangular mesh will calculate a maximum circle based on the current triangle. The largest circle is selected for insertion. The newly inserted circle will be tangent to the original circle, forming a new tangent edge, which needs to be fixed. Since the inserted circle is inserted in the polygon to which the current triangle belongs, it will not affect the external polygons. Therefore, each insertion of a circle is a local optimization problem, and it is not necessary to calculate all the maximum circles based on the current triangle again. Only the triangles inside the closed polygon need to be recalculated.
[0079] In the actual solution of the circle packing, there are often internal recesses or hole structures in the boundary constraints of the target area, as shown in Figure 16 Considering that the boundary constraints in the concave polygon mentioned in this method will compress the actual feasible space. Figure 16 The target area in the middle is a closed concave polygon, with a total of 6 boundary constraints, of which e3 and e4 are internally recessed. Under the boundary constraint proposed in this method, the entire target area is actually divided into three smaller areas, as shown in Figure 18 In this case, only three smaller circles can be generated, and the space of the polygon cannot be effectively utilized. The solution is as follows. First, arrange the boundary constraint edges in the counterclockwise direction, as shown in Figure 19As shown, the arrow represents the result of the direction vector of the edge and the direction vector of the next edge, if the direction vector points from outside the screen to inside the screen, the two edges belong to the concave edge, for the constraint of the concave edge, only the position of the center of the circle is constrained, that is, only the position of the center of the circle is guaranteed not to pass through this boundary constraint, such as Figure 17 As shown, the mathematical form is as follows, (p-e a )·n≥0, while adding a point constraint, the point constraint can be regarded as a circle constraint with a radius of 0, the center of the circle constraint is located at the intersection of the two concave edges, that is, the intersection of e3 and e4 in Figure 20 , the intersection p1 of the two edges e3 and e4. After setting the constraint in this way, the largest circle in the target area with a concave structure can be solved, that is, the circle in Figure 20 .
[0080] Figure 4 is the two-dimensional circle packing result after inserting a circle. Figure 9 is the sphere packing result after deleting part of the sphere and re-optimizing the size. In S5, different textures can be finally obtained by replacing different primitives according to different rules, Figure 5 shows the texture of two-dimensional circle packing, the method for generating the texture is as follows, define a circle pair, a circle pair consists of two circles, one circle in the circle pair must be in the one-ring neighborhood of the other circle, and a circle can only appear in one circle pair, find all circle pairs in the circle packing by using the greedy strategy, and then start drawing, first draw the frame after reducing all circles by 20%, draw a line segment between the two circles for each circle pair, the direction of the line is determined by the center coordinates of the two circles, and the length is the center distance of the two circles minus their radii.
[0081] Figure 10 shows the texture of three-dimensional sphere packing, the method for generating the texture is as follows, define a sphere pair, a sphere pair consists of two spheres, one sphere in the sphere pair must be in the one-ring neighborhood of the other sphere, and a sphere can only appear in one sphere pair, tangent spheres are matched first, find all sphere pairs in the sphere packing by using the greedy strategy, replace part of the circular arc between the sphere pairs with an S-shaped primitive, and add a spiral-shaped geometric primitive to the tangent plane of each sphere in the sphere pair, the starting point of the spiral is the connection position of the two spheres.
[0082] Figures 21-24 shows the comparison of the present application and method [2] (CHEN W, ZHANG X, XIN S, et al. Synthesis of filigrees for digital fabrication [J]. ACM Transactions on Graphics (TOG), 2016, 35 (4): 1-13), Figure 21 and 23 is the result of method [2],Figure 22 and Figure 24 As a result of the method, it can be seen that the method [2] is placed in a three-dimensional grid surface in a spiral shape. The basic element is then allowed to grow, and the adjacent elements may intersect during the growth process. Therefore, method [2] needs to spend a lot of time deforming the elements. The present application is designed on the basis of the ball packing to generate the texture, so it does not need to process the intersection of adjacent elements. Under the premise of generating similar results, the present application has a great advantage in time. Figure 22 and Figure 24 The textures generated in [2] and [3] respectively take 4.74 seconds and 61.189 seconds, while the textures generated by method [2] in [4] and [5] take 1428s and 816s respectively. Therefore, the present application has a great advantage in time. In addition, it can be seen from the figure that the present application has a more coherent connection between adjacent elements. Figure 21 and Figure 23 The textures generated in [2] and [3] respectively take 4.74 seconds and 61.189 seconds, while the textures generated by method [2] in [4] and [5] take 1428s and 816s respectively. Therefore, the present application has a great advantage in time. In addition, it can be seen from the figure that the present application has a more coherent connection between adjacent elements.
[0083] Figures 25-28 The present application is compared with method [3] (SANTONI C, PELLACINI F. gtangle: A grammar for the procedural generation of tangle patterns [J]. ACM Transactions on Graphics (TOG), 2016, 35(6): 1-11), Figure 25 and Figure 27 The textures obtained by method [3], Figure 26 and Figure 28 The textures generated by the present application, Figure 25 and Figure 26 The comparison of filling the letter pattern, Figure 27 and Figure 28 The comparison of filling the lion pattern. The present application can obtain similar results, and the arrangement of elements in the texture generated by the present application is more compact. Method [3] can only generate two-dimensional texture patterns.
[0084] Figures 29-31 The present application generates other textures, Figure 29 and Figure 30 The input of a three-dimensional grid ball packing texture is a twisted tubular grid model, Figure 29 The input of a three-dimensional grid ball packing texture is a twisted tubular grid model, Figure 30 The input of a three-dimensional grid ball packing texture is a twisted tubular grid model, Figure 31 and Figure 32 are two-dimensional grid circle packing textures, Figure 31 Use question marks, exclamation marks, and periods to replace the circles in the circle packing, Figure 32is a stylized simulation of a pond, Figure 32 There are two basic primitives, lotus flower and lotus leaf, which are used to replace the circles in the circle packing. It can be seen that the present application can flexibly generate various two-dimensional and three-dimensional textures.
Claims
1. A method for texture generation based on circle packing, characterized in that The method comprises the following steps: 1) inputting a two-dimensional closed polygon or a three-dimensional mesh model; 2) setting a threshold value γ, performing Delaunay triangulation on the two-dimensional closed polygon, or re-meshing the three-dimensional mesh model, and obtaining a triangular mesh with uniformly distributed vertices after re-meshing; The threshold value γ is used to control the number of vertices of the generated mesh; when a larger value is set, the average edge length of the triangular mesh becomes longer, and the number of vertices decreases; When a smaller value is set, the average edge length of the triangular mesh becomes shorter, and the number of vertices increases; the setting of the threshold value γ is related to the scale of the closed polygon and the three-dimensional mesh model, and is defined by the user; for the two-dimensional case, the threshold value γ is set to the average of the initial closed polygon edge length by default; for the three-dimensional case, the threshold value γ is set to the average of the input mesh model edge length by default; 3) each non-boundary inner vertex in the triangular mesh is regarded as a circle, and the initial radius of each circle is 0; the size and position of each circle are optimized by using a nonlinear optimization method until the radius of all circles converges; When optimizing a certain circle in the triangular mesh, other circles or boundaries in the ring neighborhood corresponding to the circle are selected as constraint conditions, and a nonlinear optimization is used to solve the maximum circle that satisfies the constraint condition; the size of each circle is optimized by using a nonlinear optimization method; there are many circles around each circle, and the nonlinear optimization method calculates the maximum radius and position of the current circle that does not intersect with the surrounding circles and the boundary when optimizing the size of a certain circle; the position and radius of the circle change in the optimization process; when each circle in the triangular mesh is optimized once, it is recorded as one iteration, and the radius and position of the circle converge after two to three iterations; that is, the radius and position of the circle hardly change again; 4) inserting or deleting circles until the number of circles reaches a threshold value; after step 3), there are areas without filling and circles with small radii in the triangular mesh, and the quality of the circle stacking needs to be improved by inserting or deleting circles; The specific steps include: 4.1 define a tangent edge; when a circle is tangent to the circles in its ring neighborhood or tangent to a certain boundary, define the edge as a tangent edge, which divides the triangular mesh into several smaller closed polygons; 4.2 for each triangle in the triangular mesh, find the boundary set and vertex set of the smallest closed polygon to which the triangle belongs, write the boundary set and vertex set into a constraint form, set the initial position of the circle, and move the coordinate to the boundary of the circle to ensure that the initial position is not covered by a certain circle if the initial position is inside the three vertices of the triangle corresponding to the circle; the moving direction is from the center of the circle to the center of the triangle; after setting the constraints and the initial position, the radius and coordinates of the maximum circle are solved by using a nonlinear optimization algorithm; 4.3 In each triangle, the largest circle is selected, and if the number of circles is less than the threshold, it is inserted into the triangular mesh, and steps 4.1, 4.2 and 4.3 are executed again. 5) Replace the circles with geometric primitives according to the rules to generate textures.
2. The circle-stacking based texture generation method of claim 1, wherein In step 1), the input two-dimensional closed polygon is inputted, and the input two-dimensional closed polygon allows holes, the boundary and the hole are represented by the vertex coordinates arranged in a counterclockwise direction, the circle is represented by a triangular mesh, and the two-dimensional plane is represented by a closed polygon allowing holes.
3. The circle-stacking based texture generation method of claim 1, wherein In step 2), the two-dimensional closed polygon is Delaunay triangulated, and a two-dimensional triangular mesh with uniform vertex distribution is generated according to the polygon inputted in step 1) by using a two-dimensional mesh optimization method. In the Delaunay triangulation of the two-dimensional closed polygon or the re-meshing of the three-dimensional mesh model, the Delaunay triangulation of the two-dimensional closed polygon generates a two-dimensional triangular mesh with the closed polygon as the boundary.
4. The circle-stacking based texture generation method of claim 1, wherein In step 2), the three-dimensional mesh model is re-meshed, and a triangular mesh model with uniform vertex distribution is generated after the three-dimensional mesh model is re-meshed by using a three-dimensional mesh optimization method. The re-meshing of the three-dimensional mesh model can improve the mesh quality and facilitate subsequent processing.
5. The circle-stacking based texture generation method of claim 1, wherein In step 3), each non-boundary inner vertex in the triangular mesh is regarded as a circle, the boundary of the triangular mesh includes the external boundary and the internal hole, and the remaining vertices in the triangular mesh are regarded as circles except the vertices on the boundary, the center coordinates of the circle are the same as the coordinates of the vertex, and the initial radius of the circle is set to 0.
6. The circle-stacking based texture generation method of claim 1, wherein In step 5), the rule is to delete a part of the circle, and the circle is twisted and deformed.
7. The circle-packing based texture generation method of claim 1, wherein In step 5), the geometric primitive, in the two-dimensional plane, the geometric primitive is a two-dimensional picture and a two-dimensional geometric figure; in the three-dimensional space, the geometric primitive is a three-dimensional mesh model.
Citation Information
Patent Citations
Scattered point cloud Delaunay triangulation curved surface reconstruction method based on mapping method
CN103985155A
Texture synthesis-based model hole-filling method
CN108230452A