Vegetation generation method and device, storage medium and electronic equipment

By generating foundation models and plant attachment locations on complex or three-dimensional object surfaces, combining stress information and grid orientation to generate plant morphological information, the problem of difficulty in generating natural vegetation in the prior art is solved, and plants with efficient generation of natural morphology on complex surfaces are achieved.

CN119810322APending Publication Date: 2025-04-11BEIJING PIXEL SOFTWARE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411877094.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art is difficult to generate natural and realistic vegetation on complex or three-dimensional object surfaces, especially on geometry outside the uniform terrain mesh described by height field.

Method used

By generating a foundation model and dividing it into a grid, the attachment position of each plant is determined, and the morphological information of the generated plant is screened out according to the attachment position, stress information and the morphological information of the grid orientation, and the plant image is rendered based on the morphological information.

Benefits of technology

It realizes the large-scale generation of plants with natural morphology on the surface of any model, which improves the naturalness and sense of reality of vegetation generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810322A_ABST
    Figure CN119810322A_ABST
Patent Text Reader

Abstract

The invention provides a vegetation generation method and device, a storage medium and electronic equipment, and relates to the field of games. Wherein the electronic equipment generates a foundation model, and the surface of the foundation model is divided into grids; for each grid, determining an attachment position for each plant in the grid; according to the attachment position and stress information of each plant and the orientation of the grid, form information of each plant is generated; screening out to-be-displayed plants from the plants according to the attachment position and the form information of each plant; and rendering a plant image of the to-be-displayed plant according to the form information of the to-be-displayed plant. In this way, due to the fact that the form curve of the to-be-displayed plant considers the orientation and the stress condition of the target grid attached to the to-be-displayed plant, the plants with the natural form can be generated on the surface of any model on a large scale.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of games, and more specifically, to a vegetation generation method, device, storage medium and electronic device. Background Art

[0002] In 3D rendering, the main way to generate vegetation programmatically is to divide the virtual scene into blocks, and use the CPU to generate random numbers on the resulting terrain grid blocks to generate the position, size, color and other attributes of a single plant. The vegetation in the block is then culled as a cluster.

[0003] In practice, it is found that the current programmatic generation of vegetation usually relies on pre-divided terrain grid blocks, which are often designed as planes or simple polygons to facilitate calculation and rendering. The position, distribution and form of vegetation generated on this basis are usually limited by the shape of the grid blocks, and it is difficult to adapt to complex, irregular or three-dimensional object surfaces. Specifically, due to the surface characteristics of non-planar objects (such as curvature, inclination, etc.), existing algorithms may not be able to accurately simulate the influence of real environmental factors on vegetation growth, resulting in the generated vegetation appearing unnatural or lacking in realism. The current method of programmatically generating vegetation cannot perform generation calculations on geometries other than uniform terrain grids described by height fields. Summary of the invention

[0004] In order to overcome at least one of the deficiencies in the prior art, the present application provides a vegetation generation method, device, storage medium and electronic device, specifically including:

[0005] In a first aspect, the present application provides a vegetation generation method, the method comprising:

[0006] generating a foundation model, wherein a surface of the foundation model is divided into grids;

[0007] For each of the grids, determining an attachment location for each plant in the grid;

[0008] Generating morphological information of each plant according to the attachment position, force information of each plant and the orientation of the grid;

[0009] Selecting the plants to be displayed according to the attachment position and morphological information of each plant;

[0010] A plant image of the plant to be displayed is rendered according to the morphological information of the plant to be displayed.

[0011] In combination with an optional implementation manner of the first aspect, selecting plants to be displayed according to the attachment position and morphological information of each plant includes:

[0012] Screening out the primary screening plants within the display range according to the attachment position and morphological information of each plant;

[0013] According to the distance between each of the initially screened plants and the camera, the initially screened plants located within a preset distance are regarded as close-range plants, and the initially screened plants located outside the preset distance are regarded as long-range plants;

[0014] Sparse sampling is performed on all the distant plants to obtain sampled plants;

[0015] The close-distance plants and the sampled plants are used as the plants to be displayed.

[0016] In conjunction with an optional implementation manner of the first aspect, determining an attachment position for each plant in the grid includes:

[0017] generating a floating point random number sequence for each of the plants;

[0018] Selecting a sequence value from a floating point random number sequence of each of the plants as a random position of each of the plants in the grid;

[0019] An interpolation calculation is performed according to the random position of each plant in the grid to obtain the attachment position of each plant.

[0020] In combination with the optional implementation manner of the first aspect, a plant thread is created for each of the plants, and a floating point random number sequence is generated for each of the plants, including:

[0021] For each of the plants, calling the corresponding plant thread to calculate the hash value of its own thread identifier;

[0022] The plant thread is called to convert the hash value into a floating point random number sequence of the plant.

[0023] In combination with an optional implementation manner of the first aspect, the morphological information of each plant includes a morphological curve, and the morphological information of each plant is generated according to the attachment position, force information and orientation of the grid of each plant, including:

[0024] For each of the plants, taking the attachment position of the plant as the starting point of a second-order Bezier curve;

[0025] Determining an initial first control point of the second-order Bezier curve according to the starting point and the orientation of the grid;

[0026] Adjusting the initial first control point according to the force information to obtain an optimized first control point;

[0027] Obtaining a second control point of the second-order Bezier curve according to the starting point and the optimized first control point;

[0028] The morphological curve of the plant is obtained according to the starting point, the optimized first control point, and the second control point.

[0029] In combination with an optional implementation manner of the first aspect, the morphological information of the plant to be displayed includes a morphological curve, and rendering the plant image of the plant to be displayed according to the morphological information of the plant to be displayed includes:

[0030] Determining a plurality of segmentation points from the morphological curve of the plant to be displayed;

[0031] Each of the segmentation points is offset to both sides of the morphological curve to obtain vertices located on both sides of the morphological curve, wherein the vertices obtained by offsetting the multiple segmentation points are connected in a preset manner to obtain a geometric model of the plant to be displayed;

[0032] Projecting each of the vertices into the camera space to obtain rasterized pixels of the geometric model;

[0033] Each of the pixels is subjected to coloring calculation to obtain the plant image of the plant to be displayed.

[0034] In combination with the optional implementation manner of the first aspect, the morphological curve of the plant to be displayed takes the attachment position of the plant to be displayed as a starting point;

[0035] The offset corresponding to the segmentation point is inversely correlated with the segmentation length of the segmentation point, wherein the segmentation length represents the length of the curve between the segmentation point and the starting point of the morphological curve.

[0036] In a second aspect, the present application provides a vegetation generation device, the device comprising:

[0037] A foundation model module, used to generate a foundation model, wherein the surface of the foundation model is divided into grids;

[0038] A plant location module, for determining, for each of the grids, an attachment location for each plant in the grid;

[0039] A plant screening module, for generating morphological information of each plant according to the attachment position, force information and orientation of the grid of each plant; and screening the plants to be displayed according to the attachment position and morphological information of each plant;

[0040] The plant rendering module is used to render the plant image of the plant to be displayed according to the morphological information of the plant to be displayed.

[0041] In conjunction with the optional implementation manner of the second aspect, the plant screening module is further specifically used for:

[0042] Screening out the primary screening plants within the display range according to the attachment position and morphological information of each plant;

[0043] According to the distance between each of the initially screened plants and the camera, the initially screened plants located within a preset distance are regarded as close-range plants, and the initially screened plants located outside the preset distance are regarded as long-range plants;

[0044] Sparse sampling is performed on all the distant plants to obtain sampled plants;

[0045] The close-distance plants and the sampled plants are used as the plants to be displayed.

[0046] In conjunction with the optional implementation manner of the second aspect, the plant location module is further specifically used for:

[0047] generating a floating point random number sequence for each of the plants;

[0048] Selecting a sequence value from a floating point random number sequence of each of the plants as a random position of each of the plants in the grid;

[0049] An interpolation calculation is performed according to the random position of each plant in the grid to obtain the attachment position of each plant.

[0050] In combination with the optional implementation manner of the second aspect, a plant thread is created for each plant, and the plant location module is further specifically used for:

[0051] For each of the plants, calling the corresponding plant thread to calculate the hash value of its own thread identifier;

[0052] The plant thread is called to convert the hash value into a floating point random number sequence of the plant.

[0053] In conjunction with the optional implementation manner of the second aspect, the morphological information of each plant includes a morphological curve, and the plant screening module is further specifically used for:

[0054] For each of the plants, taking the attachment position of the plant as the starting point of a second-order Bezier curve;

[0055] Determining an initial first control point of the second-order Bezier curve according to the starting point and the orientation of the grid;

[0056] Adjusting the initial first control point according to the force information to obtain an optimized first control point;

[0057] Obtaining a second control point of the second-order Bezier curve according to the starting point and the optimized first control point;

[0058] The morphological curve of the plant is obtained according to the starting point, the optimized first control point, and the second control point.

[0059] In conjunction with the optional implementation manner of the second aspect, the morphological information of the plant to be displayed includes a morphological curve, and the plant rendering model is further specifically used for:

[0060] Determining a plurality of segmentation points from the morphological curve of the plant to be displayed;

[0061] Each of the segmentation points is offset to both sides of the morphological curve to obtain vertices located on both sides of the morphological curve, wherein the vertices obtained by offsetting the multiple segmentation points are connected in a preset manner to obtain a geometric model of the plant to be displayed;

[0062] Projecting each of the vertices into the camera space to obtain rasterized pixels of the geometric model;

[0063] Each of the pixels is subjected to coloring calculation to obtain the plant image of the plant to be displayed.

[0064] In combination with the optional implementation manner of the second aspect, the morphological curve of the plant to be displayed takes the attachment position of the plant to be displayed as a starting point;

[0065] The offset corresponding to the segmentation point is inversely correlated with the segmentation length of the segmentation point, wherein the segmentation length represents the length of the curve between the segmentation point and the starting point of the morphological curve.

[0066] In a third aspect, the present application further provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the vegetation generation method is implemented.

[0067] In a fourth aspect, the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the vegetation generation method is implemented.

[0068] Compared with the prior art, this application has the following beneficial effects:

[0069] The present application provides a vegetation generation method, device, storage medium and electronic device. Among them, the electronic device generates a foundation model, wherein the surface of the foundation model is divided into grids; for each of the grids, an attachment position is determined for each plant in the grid; the morphological information of each plant is generated according to the attachment position, force information and orientation of the grid; the plant to be displayed is selected according to the attachment position and morphological information of each plant; and the plant image of the plant to be displayed is rendered according to the morphological information of the plant to be displayed. In this way, since the morphological curve of the plant to be displayed takes into account the orientation and force conditions of the target grid to which the plant to be displayed is attached, plants with natural morphology can be generated on a large scale on the surface of any model. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0071] Figure 1 A flow chart of a vegetation generation method provided in an embodiment of the present application;

[0072] Figure 2 A schematic diagram of a triangular strip provided in an embodiment of the present application;

[0073] Figure 3 A schematic diagram of the structure of a vegetation generation device provided in an embodiment of the present application;

[0074] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0075] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0076] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0077] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0078] In the description of the present application, it should be noted that the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance. In addition, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0079] Based on the above statement, as introduced in the background technology, the current method of programmatically generating vegetation cannot perform generation calculations on geometries other than uniform terrain grids described by height fields.

[0080] Based on the discovery of the above technical problems, the inventors have proposed the following technical solutions to solve or improve the above problems through creative work. It should be noted that the defects in the solutions in the above prior art are the results obtained by the inventors after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed in the embodiments of the present application for the above problems below should all be the contributions made by the inventors to the present application in the process of invention and creation, and should not be understood as technical contents known to those skilled in the art.

[0081] In view of the above problems, this embodiment provides a vegetation generation method. In this method, an electronic device generates a foundation model, wherein the surface of the foundation model is divided into grids; for each of the grids, an attachment position is determined for each plant in the grid; the morphological information of each plant is generated according to the attachment position, force information and orientation of the grid; the plants to be displayed are screened out according to the attachment position and morphological information of each plant; and the plant images of the plants to be displayed are rendered according to the morphological information of the plants to be displayed. In this way, since the morphological curve of the plants to be displayed takes into account the orientation and force conditions of the target grid to which the plants to be displayed are attached, plants with natural morphology can be generated on a large scale on the surface of any model.

[0082] It is worth noting that the electronic device implementing the above-mentioned vegetation generation method may be, but is not limited to, a mobile terminal, a tablet computer, a laptop computer, a desktop computer, a game console, a server and other devices. When a server is used as the above-mentioned electronic device, the server group may be centralized or distributed (for example, the server may be a distributed system). In some embodiments, the server may be local or remote relative to the user terminal. In some embodiments, the server may be implemented on a cloud platform; as an example only, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud (Community Cloud), a distributed cloud, an inter-cloud (Inter-Cloud), a multi-cloud (Multi-Cloud), etc., or any combination thereof. In some embodiments, the server may be implemented on an electronic device having one or more components.

[0083] To make the solution provided by this embodiment clearer, the following uses a server as an electronic device and combines Figure 1 Each step of the method is described in detail. However, it should be understood that the operations of the flowchart may not be implemented in order, and steps without logical contextual relationships may be reversed in order or implemented simultaneously. In addition, those skilled in the art may add one or more other operations to the flowchart, or remove one or more operations from the flowchart under the guidance of the content of this application. Figure 1 As shown, the method includes:

[0084] S1, generate foundation model.

[0085] Among them, the surface of the foundation model is divided into grids. The foundation model in this embodiment refers to a three-dimensional model constructed for natural or artificial objects such as the ground, mountains, and hills in the game scene. The surface of the model is gridded, so the grid is the basic unit that constitutes the entire terrain. In addition, these grids can have a variety of shapes, including but not limited to triangles, quadrilaterals, pentagons, etc. Each grid carries part of the terrain information, such as height, slope, direction, etc. Therefore, these grids can show the diversity and complexity of the terrain, and provide accurate positioning and fitting basis for the programmatic generation of vegetation.

[0086] Continue to see Figure 1 The vegetation generation method provided in this embodiment further includes:

[0087] S2, for each grid, determine the attachment position for each plant in the grid.

[0088] In this regard, it should be noted that the above-mentioned plants can be, but are not limited to, herbs, flowers, etc. In addition, the number of grids located on the surface of the foundation model can be one or more. And each grid can accommodate one or more plants. For example, assuming that the shape of each grid is a triangle, the server can calculate the area of ​​each grid according to the area formula of the triangle, and multiply it by the preset vegetation density to obtain the number of plants that can be accommodated in the grid. Finally, according to the number of plants, the attachment position of each plant in the grid and the corresponding morphological curve are determined.

[0089] Based on the introduction of the number of plants in each grid in the above embodiment, in order to make the distribution of plants appear more natural, a random number is used to confirm the attachment position of each plant in the grid. Therefore, this embodiment provides the following optional implementation of step S2:

[0090] S2-1, generate a floating point random number sequence for each plant.

[0091] In practice, we found that if we use the CPU to generate random numbers to generate the attachment position, size, color and other attribute information of a single plant, and then organize these attribute information into a buffer and transmit them to the GPU for rendering, however, due to the limitation of the CPU computing power in each frame, it is impossible to perform detailed physical simulation calculations for all plants; and the transmission efficiency from memory to video memory is poor, and it is impossible to efficiently draw ultra-large-scale plants (for example, more than 100,000) in each frame.

[0092] In view of the above problems, this embodiment uses a compute shader in the GPU to start a corresponding number of GPU thread groups according to the number of grids on the surface of the foundation model, and each thread group includes one or more plant threads. For example, for a certain grid, assuming that after calculation, it is found that the grid can accommodate 100 plants, 100 plant threads are created for the grid to parallelly calculate the parameters required for rendering each plant.

[0093] For the floating-point random number sequence of each plant mentioned above, the server calls the corresponding plant thread to calculate the hash value of its own thread identifier; and calls the plant thread to convert the hash value into the floating-point random number sequence of the plant.

[0094] For example, the plant thread uses the thread ID to perform a hash operation to obtain a 32-bit integer A, and divides the integer A by 4294967295.0 to obtain a random floating point number between 0.0 and 1.0. Then, the integer A is further hashed to obtain another 32-bit integer B, and the integer B is divided by 4294967295.0 to obtain a random floating point number between 0.0 and 1.0. In this way, a floating point random number sequence can be obtained.

[0095] Based on the floating point random number sequence obtained in the above embodiment, an optional implementation of step S2 further includes:

[0096] S2-2, selecting a sequence value from the floating point random number sequence of each plant as the random position of each plant in the grid.

[0097] S2-3, performing interpolation calculation according to the random position of each plant in the grid to obtain the attachment position of each plant.

[0098] It can be understood that the server selects two floating point numbers from the floating point random number sequence as the coordinates of the plant in the grid, but the coordinates are actually only relative positions relative to the grid itself. Therefore, the coordinates of the grid vertices (for example, the coordinates of the three corners of the triangle grid) can be used for interpolation to convert the random position of the plant in the grid into the attachment position in the world coordinate system.

[0099] Continue to see Figure 1 Based on the attachment position of each plant in each grid obtained in the above embodiment, the server further obtains the morphological curve of each plant through the following implementation method:

[0100] S3, generating the morphological information of each plant according to the attachment position, force information and orientation of the grid of each plant.

[0101] In this embodiment, the morphological information of each plant includes the morphological curve, extension direction and front direction of the plant. The morphological curve is used to describe the shape of the plant body, and the extension direction represents the width direction of the plant. As for the front direction of the plant, it should be understood that the plants in nature are not straight at right angles to the ground, but tend to be in the direction of sufficient sunlight. Therefore, this embodiment uses the front direction of the plant to describe this direction.

[0102] Regarding the shape of the plant, this embodiment simplifies the plant into Figure 2 The geometric model shown is called a triangle strip 10, which includes 15 vertices 12, and these 15 vertices 12 can be wrapped into a triangular face of a single plant according to a preset index method. Figure 2 The triangular strip 10 shown describes the morphological curve 11 of the plant in 3D space using the second-order Bezier curve Position-V1-V2, where Position represents the starting point of the second-order Bezier curve. In this embodiment, the attachment position of the plant is used as the starting point of the second-order Bezier curve. Therefore, the starting point of the second-order Bezier curve can be regarded as the root of the plant. V1 and V2 represent two control points of the second-order Bezier curve. In addition, a set of orthogonal vector bases are defined. Up in the orthogonal vector base represents the orientation of the grid where the plant is located. In this embodiment, the normal vector of the grid is used as the orientation. Right represents the extension direction of the triangle face, and Front is the front direction of the plant orthogonal to the first two vectors.

[0103] Based on the introduction of the triangular strips of plants in the above embodiment, this embodiment provides the following optional implementations of step S3:

[0104] S3-1, for each plant, the attachment position of the plant is used as the starting point of the second-order Bezier curve.

[0105] S3-2, determining the initial first control point of the second-order Bezier curve according to the starting point and the orientation of the target grid.

[0106] S3-3, adjusting the initial first control point according to the force information to obtain an optimized first control point.

[0107] The force information of the plant includes gravity and wind force. The magnitude and direction of these two forces can be pre-configured by the developer, or dynamically calculated by providing corresponding algorithms. The superposition of the two forces will affect the positions of the two control points of the second-order Bezier curve, causing the shape of the second-order Bezier curve to change, thereby changing the shape of the plant.

[0108] S3-4, obtaining a second control point of the second-order Bezier curve according to the starting point and the optimized first control point.

[0109] For example, continue with Figure 2 Take the morphological curve 11 as an example. It can be obtained by the following method Figure 2 The morphological curve 11 is shown. First, without external force, the starting point of the second-order Bezier curve and the other two control points are represented as Position-V1 ini -V2 ini , all pointing to the direction of Up. At this time, based on the vector relationship between them, the initial first control point can be obtained:

[0110] V1 ini =Position+length*Up

[0111] Where, length represents the length of the morphological curve.

[0112] Then, under the action of gravity and wind, the vector sum of gravity and wind is multiplied by the randomly generated bending coefficient of the plant, V1 ini According to the result of force addition, we translate and get the optimized first control point:

[0113] V1=V1 ini +w+g

[0114] In the formula, w represents wind force and g represents gravity. Finally, the position of V2 can be calculated based on the distance between Position and V1 to replace the original V2. ini. In this way, we get Figure 2 The starting point Position, the first control point V1, and the second control point V2 of the second-order Bezier curve shown in the figure can be controlled by these three points to obtain Figure 2 The morphological curve 11 is shown. Therefore, step S3 also includes:

[0115] S3-5, obtaining the morphological curve of the plant according to the starting point, the first control point and the second control point after optimization.

[0116] Based on the morphological curves of each plant obtained in the above embodiment, it is found in practice that if all plants are rendered each time, a large amount of computing resources and rendering time will be consumed. Therefore, this embodiment selects some plants to be displayed. That is, the vegetation generation method provided in this embodiment also includes:

[0117] S4, selecting plants to be displayed according to the attachment position and morphological information of each plant.

[0118] It should be understood that, compared with rendering all the plants in the grid, this embodiment screens the plants that are not visible on the screen to avoid wasting computing resources. In this regard, this embodiment provides the following optional implementation of step S4:

[0119] S4-1, based on the attachment position and morphological information of each plant, screen out the initial screening plants within the display range.

[0120] In this regard, this embodiment provides two strategies, namely, orientation culling and frustum culling, for screening out the initial screening plants within the display range. Figure 2 Taking the triangle strip 10 shown as an example, the two culling strategies are described in detail:

[0121] For orientation culling, if the angle between the camera direction and the right direction of the plant is close to 0 or 180°, the plant can only be seen from the side, so there are fewer pixels after rasterization, and this embodiment culls it. It should be noted that in game development, the camera refers to a virtual device used to determine which part of the game world the player can see. It defines the viewing angle displayed on the screen, the field of view (FOV), the clipping plane (i.e. the farthest and closest distances that the camera can see), and some other parameters.

[0122] For frustum culling, Position and V2 as well as the segmentation points calculated by the Bezier curve are transformed to the screen space using the projection matrix to detect whether they are in the screen. If they are not in the screen, it is considered that the plant cannot be seen, so it is culled.

[0123] In this way, the primary screening plants within the display range can be screened out. Considering that the primary screening plants far from the camera do not need to be rendered at a higher density, they can be eliminated to further reduce the consumption of computing resources. Therefore, step S4 also includes:

[0124] S4-2, according to the distance between each primary screened plant and the camera, the primary screened plants located within the preset distance are regarded as close-range plants, and the primary screened plants located outside the preset distance are regarded as long-range plants.

[0125] S4-3, sparse sampling of all distant plants to obtain sampled plants;

[0126] S4-4, the close-up plants and the sampled plants are taken as the plants to be displayed.

[0127] In this way, for the initially screened plants within the display range, the density of the plants outside the preset distance is reduced, thereby further reducing the computing resources required for rendering.

[0128] Based on the above introduction to the displayed plants, based on the reference Figure 1 The vegetation generation method provided in this embodiment also includes:

[0129] S5, rendering a plant image of the plant to be displayed according to the morphological curve of the plant to be displayed.

[0130] In an optional implementation, the server may determine multiple segmentation points from the morphological curve of the plant to be displayed; offset each segmentation point to both sides of the morphological curve to obtain vertices located on both sides of the morphological curve, wherein the vertices obtained by offsetting multiple segmentation points are connected in a preset manner to obtain a geometric model of the plant to be displayed; project each vertex into the camera space to obtain a pixel after rasterization of the geometric model; perform shading calculations on each pixel to obtain a plant image of the plant to be displayed.

[0131] For example, continue with Figure 2 Take the triangle strip 10 shown as an example. Since there are 14 preset vertices 12, these vertices are distributed along both sides of the shape curve 11. In this embodiment, these vertices can be obtained by shifting the segmentation points 13 on the shape curve to both sides. In this embodiment, the shape curve can be segmented according to the ratio of t[0,1 / 7,2 / 7,...1], where 1 / 7 means there is a segmentation point at the position of 1 / 7 of the curve length, and 2 / 7 means there is a segmentation point at the position of 2 / 7 of the curve length. Therefore, based on the above segmentation ratio, Figure 2 The shape curve 11 is divided into 7 curve segments of the same length. Each segmentation point 13 is offset according to the following expression to obtain the vertices 12 located on both sides of the shape curve.

[0132] Right*width*(1.0-t)

[0133] In the formula, t represents the above segmentation ratio. Therefore, it is not difficult to see that the offset corresponding to the segmentation point is inversely correlated with the segmentation length of the segmentation point, where the segmentation length represents the length of the curve between the segmentation point and the attachment position of the morphological curve. That is, the closer to the root of the plant, the greater its offset. In this way, all the vertices constituting the geometric model of the plant to be displayed can be obtained.

[0134] It should be noted that the above operations such as determining the information required for rendering each plant (attachment position, morphological information, color, etc.) and rendering the plant image of the plant to be displayed can be completed by the GPU, using the parallel computing capability of the GPU to improve the rendering effect.

[0135] Based on the same inventive concept as the vegetation generation method provided in this embodiment, this embodiment also provides a vegetation generation device. The device includes at least one software function module that can be stored in a memory in the form of software. The processor in the electronic device is used to execute the executable module stored in the memory. For example, the software function module and computer program included in the device. Please refer to Figure 3 , functionally speaking, the device may include:

[0136] A foundation model module 21 is used to generate a foundation model, wherein the surface of the foundation model is divided into grids;

[0137] A plant location module 22, for determining, for each grid, an attachment location for each plant in the grid;

[0138] The plant screening module 23 is used to generate the morphological information of each plant according to the attachment position, force information and grid orientation of each plant; and screen the plants to be displayed according to the attachment position and morphological information of each plant;

[0139] The plant rendering module 24 is used to render a plant image of the plant to be displayed according to the morphological information of the plant to be displayed.

[0140] In this embodiment, the foundation model module 21 is used to implement Figure 1 In step S1, the plant location module 22 is used to implement Figure 1 In step S2, the plant screening module is used to implement Figure 1 In steps S3 and S4, the plant rendering module 23 is used to implement Figure 1Therefore, for the detailed description of each of the above modules, please refer to the specific implementation of the corresponding step. Of course, in view of the same inventive concept as the above vegetation generation method, the vegetation generation device can also implement other steps or sub-steps of the method through the above modules or other modules included, which will not be described in detail in this embodiment.

[0141] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0142] It should also be understood that if the above implementation is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.

[0143] Therefore, this embodiment further provides a storage medium, which is a computer-readable storage medium. The storage medium stores a computer program, and when the computer program is executed by a processor, the vegetation generation method provided in this embodiment is implemented. Among them, the storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, etc., which can store program codes.

[0144] This embodiment provides an electronic device for implementing a vegetation generation method. Figure 4 As shown, the electronic device may include a processor 32 and a memory 31. In addition, the memory 31 stores a computer program, and the processor implements the vegetation generation method provided in this embodiment by reading and executing the computer program corresponding to the above implementation in the memory 31.

[0145] Continue to see Figure 4 The electronic device further includes a communication unit 33. The memory 31, the processor 32 and the communication unit 33 are electrically connected to each other directly or indirectly through a system bus 34 to achieve data transmission or interaction.

[0146] The memory 31 may be an information recording device based on any electronic, magnetic, optical or other physical principle, used to record execution instructions, data, etc. In some embodiments, the memory 31 may be, but is not limited to, a volatile memory, a non-volatile memory, a storage drive, etc.

[0147] In some embodiments, the volatile memory may be a random access memory (RAM); in some embodiments, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), a flash memory, etc.; in some embodiments, the storage drive may be a disk drive, a solid-state drive, any type of storage disk (such as a CD, a DVD, etc.), or a similar storage medium, or a combination thereof, etc.

[0148] The communication unit 33 is used to send and receive data through a network. In some embodiments, the network may include a wired network, a wireless network, a fiber optic network, a telecommunication network, an intranet, the Internet, a local area network (LAN), a wide area network (WAN), a wireless local area network (WLAN), a metropolitan area network (MAN), a wide area network (WAN), a public switched telephone network (PSTN), a Bluetooth network, a ZigBee network, or a near field communication (NFC) network, or any combination thereof. In some embodiments, the network may include one or more network access points. For example, the network may include a wired or wireless network access point, such as a base station and / or a network switching node, through which one or more components of the service request processing system may be connected to the network to exchange data and / or information.

[0149] The processor 32 may be an integrated circuit chip having a signal processing capability, and the processor may include one or more processing cores (e.g., a single-core processor or a multi-core processor). By way of example only, the processor may include a central processing unit (CPU), an application specific integrated circuit (ASIC), an application specific instruction set processor (ASIP), a graphics processing unit (GPU), a physical processing unit (PPU), a digital signal processor (DSP), a field programmable gate array (FPGA), a programmable logic device (PLD), a controller, a microcontroller unit, a reduced instruction set computer (RISC), or a microprocessor, or any combination thereof.

[0150] Understandably, Figure 4 The structure shown is for illustration only. The electronic device may also have Figure 4 More or fewer components than shown, or with Figure 4 Different configurations shown. Figure 4 The components shown may be implemented in hardware, software or a combination thereof.

[0151] It should be understood that the apparatus and method disclosed in the above-mentioned embodiments can also be implemented in other ways. The apparatus embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the apparatus, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0152] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A vegetation generation method, characterized in that: The method comprises: generating a foundation model, wherein a surface of the foundation model is divided into grids; For each of the grids, determining an attachment location for each plant in the grid; Generating morphological information of each plant according to the attachment position, force information of each plant and the orientation of the grid; Selecting the plants to be displayed according to the attachment position and morphological information of each plant; A plant image of the plant to be displayed is rendered according to the morphological information of the plant to be displayed.

2. The vegetation generation method according to claim 1, characterized in that: According to the attachment position and morphological information of each plant, the plants to be displayed are selected, including: Screening out the primary screening plants within the display range according to the attachment position and morphological information of each plant; According to the distance between each of the initially screened plants and the camera, the initially screened plants located within a preset distance are regarded as close-range plants, and the initially screened plants located outside the preset distance are regarded as long-range plants; Sparse sampling is performed on all the distant plants to obtain sampled plants; The close-distance plants and the sampled plants are used as the plants to be displayed.

3. The vegetation generation method according to claim 2, characterized in that: Determining the attachment position for each plant in the grid includes: generating a floating point random number sequence for each of the plants; Selecting a sequence value from a floating point random number sequence of each of the plants as a random position of each of the plants in the grid; An interpolation calculation is performed according to the random position of each plant in the grid to obtain the attachment position of each plant.

4. The vegetation generation method according to claim 3, characterized in that: A plant thread is created for each of the plants, and a floating point random number sequence is generated for each of the plants, including: For each of the plants, calling the corresponding plant thread to calculate the hash value of its own thread identifier; The plant thread is called to convert the hash value into a floating point random number sequence of the plant.

5. The vegetation generation method according to claim 1, characterized in that: The morphological information of each plant includes a morphological curve, and the morphological information of each plant is generated according to the attachment position, force information and orientation of the grid of each plant, including: For each of the plants, taking the attachment position of the plant as the starting point of a second-order Bezier curve; Determining an initial first control point of the second-order Bezier curve according to the starting point and the orientation of the grid; Adjusting the initial first control point according to the force information to obtain an optimized first control point; Obtaining a second control point of the second-order Bezier curve according to the starting point and the optimized first control point; The morphological curve of the plant is obtained according to the starting point, the optimized first control point, and the second control point.

6. The vegetation generation method according to claim 1, characterized in that: The morphological information of the plant to be displayed includes a morphological curve, and rendering the plant image of the plant to be displayed according to the morphological information of the plant to be displayed includes: Determining a plurality of segmentation points from the morphological curve of the plant to be displayed; Each of the segmentation points is offset to both sides of the morphological curve to obtain vertices located on both sides of the morphological curve, wherein the vertices obtained by offsetting the multiple segmentation points are connected in a preset manner to obtain a geometric model of the plant to be displayed; Projecting each of the vertices into the camera space to obtain rasterized pixels of the geometric model; Each of the pixels is subjected to coloring calculation to obtain the plant image of the plant to be displayed.

7. The vegetation generation method according to claim 6, characterized in that: The morphological curve of the plant to be displayed takes the attachment position of the plant to be displayed as the starting point; The offset corresponding to the segmentation point is inversely correlated with the segmentation length of the segmentation point, wherein the segmentation length represents the length of the curve between the segmentation point and the starting point of the morphological curve.

8. A vegetation generating device, characterized in that: The device comprises: A foundation model module, used to generate a foundation model, wherein the surface of the foundation model is divided into grids; A plant location module, for determining, for each of the grids, an attachment location for each plant in the grid; A plant screening module, for generating morphological information of each plant according to the attachment position, force information and orientation of the grid of each plant; and screening the plants to be displayed according to the attachment position and morphological information of each plant; The plant rendering module is used to render the plant image of the plant to be displayed according to the morphological information of the plant to be displayed.

9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the vegetation generation method according to any one of claims 1 to 7 is implemented.

10. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the vegetation generation method according to any one of claims 1 to 7 is implemented.