Virtual model rendering method and device, electronic equipment and computer storage medium
By generating and rotating plant models based on preset information when rendering grasslands, the problems of high production costs and low rendering efficiency in the prior art are solved, and a more efficient rendering process is achieved.
Patent Information
- Application Number
- CN202411978321.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-13
AI Technical Summary
When rendering grasslands, the three-dimensional grass model with complex geometric structures is required to perform secondary processing, resulting in high production costs and prone to Quad Overdraw problems, reducing rendering efficiency.
Quad Overdraw is reduced by generating multiple plant models to be rendered in the preset area based on the preset leaf type and size information, and determining and controlling the rotation angle of the plant model according to the orientation of the virtual camera, so that the leaves face to the virtual camera.
It reduces production costs, avoids the need for secondary processing, and effectively reduces Quad Overdraw, improving rendering efficiency.
Smart Images

Figure CN119991900A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of rendering technology, and in particular to a rendering method, device, electronic device and computer-readable storage medium for a virtual model. Background Art
[0002] With the rapid development of the gaming industry, players have higher and higher requirements for the quality of game graphics. Grass is a common natural element in game scenes, usually accounting for a large proportion of the picture, and its rendering effect has a crucial impact on the overall picture quality.
[0003] In the related art, a three-dimensional grass model with a complex geometric structure is usually used to simulate the grassland. In order to make the grass in the grassland look more natural, each three-dimensional grass model needs to be processed again in turn, such as the grass height, curvature, direction, color and other information. However, the vertex position of the grass model needs to be adjusted during the secondary processing, but due to the large number of vertices in the three-dimensional grass model, it consumes a huge production cost, and the large-scale use of grass models is prone to Quad Overdraw problem, that is, the same pixel is covered by multiple grass models, so that the same pixel needs to be repeatedly drawn multiple times, resulting in a waste of GPU resources, thereby reducing rendering efficiency. Summary of the invention
[0004] The present application provides a rendering method, device, electronic device and computer-readable storage medium for a virtual model to reduce production costs and improve rendering efficiency.
[0005] In a first aspect, an embodiment of the present application provides a method for rendering a virtual model, the method comprising:
[0006] Generate multiple plant models to be rendered in a preset area according to preset leaf types and size information of each of the multiple plant models to be generated, wherein the size information includes the leaf length and leaf width of the plant models;
[0007] In response to a rendering instruction for the plurality of plant models to be rendered, determining a target rotation angle corresponding to each of the plant models according to an orientation of a virtual camera relative to each of the plant models, and controlling each of the plant models to rotate to its corresponding target rotation angle so that the leaves of each of the plant models after rotation face the virtual camera;
[0008] The rotated plant model is rendered to obtain a plant model rendering image, wherein the plant model rendering image shows that a plurality of plants corresponding to the plant model grow in the preset area.
[0009] In a second aspect, an embodiment of the present application provides a virtual model rendering device, the device comprising:
[0010] A model generation module, used to generate a plurality of plant models to be rendered in a preset area according to respective preset leaf types and size information of a plurality of plant models to be generated, wherein the size information includes the leaf length and leaf width of the plant models;
[0011] a processing module, for responding to a rendering instruction for the plurality of plant models to be rendered, determining a target rotation angle corresponding to each of the plant models according to an orientation of the virtual camera relative to each of the plant models, and controlling each of the plant models to rotate to its corresponding target rotation angle so that the leaves of each of the plant models after rotation face the virtual camera;
[0012] The rendering module is used to render the rotated plant model to obtain a plant model rendering image, wherein the plant model rendering image shows that a plurality of plants corresponding to the plant model grow in the preset area.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:
[0014] A memory and a processor, wherein the memory and the processor are coupled;
[0015] The memory is used to store one or more computer instructions;
[0016] The processor is used to execute the one or more computer instructions to implement the virtual model rendering method described in any one of the first aspects above.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having one or more computer instructions stored thereon, characterized in that the instruction is executed by a processor to implement the virtual model rendering method described in any one of the first aspects above.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the method for rendering a virtual model as described in any one of the first aspects above.
[0019] Compared with the prior art, this application has the following advantages:
[0020] The virtual model rendering method provided in the present application generates multiple plant models to be rendered in a preset area according to the preset leaf type and size information of each of the multiple plant models to be generated, and the size information includes the leaf length and leaf width of the plant model; in response to the rendering instructions for the multiple plant models to be rendered, the target rotation angle corresponding to each plant model is determined according to the orientation of the virtual camera relative to each of the plant models, and each plant model is controlled to rotate to its corresponding target rotation angle so that the leaves of each plant model after rotation face the virtual camera; the rotated plant models are rendered to obtain a plant model rendering image, and the plant model rendering image shows that plants corresponding to the multiple plant models are growing in the preset area.
[0021] Compared to the prior art, the present application generates each plant model to be rendered in the preset area according to its respective preset leaf type and size information. Therefore, the preset leaf type and size information of the plant model obtained after generation meets the preset expectations, so there is no need to perform secondary processing on each grass model, thus avoiding the huge production cost caused by the need for secondary processing. At the same time, by controlling each plant model to rotate to its corresponding target rotation angle so that the leaves of each plant model after rotation face the virtual camera, it can be ensured that each plant model in the preset area faces the virtual camera during rendering, which can effectively reduce Quad Overdraw and improve rendering efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0023] Figure 1 A schematic diagram of a flow chart of a method for rendering a virtual model provided in one embodiment of the present application;
[0024] Figure 2 A schematic diagram of generating multiple distribution points in a preset area provided in one embodiment of the present application;
[0025] Figure 3 A schematic diagram showing a plurality of distribution points and directions of the distribution points in a preset area provided in one embodiment of the present application;
[0026] Figure 4 A schematic diagram of a target line segment, a target curve and a plant model provided in one embodiment of the present application;
[0027] Figure 5 A schematic diagram showing the comparison of partitioning and clustering before and after the embodiment of the present application;
[0028] Figure 6 A schematic diagram of a plant model before and after optimization provided in one embodiment of the present application;
[0029] Figure 7 A schematic diagram of tangent lines of curve nodes on a plant model provided in one embodiment of the present application;
[0030] Figure 8 A schematic diagram of a plant model before and after a target rotation angle is provided in one embodiment of the present application;
[0031] Fig. 9 A schematic diagram of a plant model before and after width scaling provided in one embodiment of the present application;
[0032] Fig.10 A schematic diagram of the structure of a virtual model rendering device provided in one embodiment of the present application;
[0033] Fig.11 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of the present application.
[0034] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0035] In order to make the purpose, advantages and features of the present application clearer, the present application is described clearly and completely below in conjunction with the accompanying drawings and specific embodiments. In the following description, many specific details are set forth to facilitate a full understanding of the present application. However, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments, and all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0036] It should be noted that, in the description of the present application, the terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance, and a specific order or sequence. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood in specific circumstances. In addition, in the description of the present application, unless otherwise specified, the term "multiple" refers to two or more. The term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can be represented: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are an "or" relationship. The terms "include" and "have" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0037] In order to facilitate understanding of the technical solution of the present application, the relevant concepts involved in the present application are first introduced.
[0038] Rendering triangles: A triangle in rendering refers to a plane composed of three vertices. In computer graphics, triangles are the most commonly used geometric bodies, used to represent the surfaces of various objects. In actual rendering, polygonal meshes are usually used to represent the surface of an object. A polygonal mesh is composed of multiple triangles. The more triangles there are, the lower the rendering performance.
[0039] Overdraw: In computer graphics, Overdraw refers to the phenomenon of repeatedly drawing the same pixel multiple times. Overdraw will waste GPU resources and reduce rendering performance.
[0040] Quad Overdraw: The same pixel on the screen is drawn multiple times. Here Quad refers to a pixel or a pixel block on the screen, and Overdraw means that the pixel is covered by multiple rendered objects.
[0041] AlphaTest: Used to remove completely transparent pixels, which means using alpha channel information during the rendering process to decide which pixels should be drawn and which pixels should be discarded.
[0042] Below, the prior art involved in this application and the problems existing in the prior art are described:
[0043] In the related art, a three-dimensional grass model with a complex geometric structure is usually used to simulate grassland. In order to make the grass in the grassland look more natural, each three-dimensional grass model needs to be processed again in turn to obtain information such as grass height, curvature, direction, color, etc.
[0044] However, the above-mentioned related technologies still have the following problems:
[0045] Problem 1: The vertex position of the grass model needs to be adjusted during secondary processing. However, due to the large number of vertices in the three-dimensional grass model, it consumes a huge production cost. In addition, the extensive use of grass models can easily lead to the Quad Overdraw problem, that is, the same pixel is covered by multiple grass models, which requires repeated drawing on the same pixel, resulting in a waste of GPU resources and thus reducing rendering efficiency.
[0046] Problem 2: 3D grass models are often thin on the sides, which can easily result in jagged edges when rendered, especially when the camera angle or lighting changes.
[0047] Question 3: In order to achieve a dense effect, a large number of three-dimensional grass models need to be used, which will cause a single pixel to draw the triangle faces of multiple grass models, increasing the rendering burden.
[0048] Problem 4: Blades are easily interlaced between 3D grass models, causing a sharp visual effect. Solving these problems requires a lot of manual adjustments, which increases work costs.
[0049] In order to solve the problems existing in the above-mentioned related technologies, the present application provides a virtual model rendering method, a virtual model rendering device corresponding to the method, an electronic device that can implement the virtual model rendering method, and a computer-readable storage medium. The following provides embodiments to describe the above-mentioned method, device, electronic device, and computer-readable storage medium in detail.
[0050] In order to make the purpose and technical solution of the present application clearer and more intuitive, the method provided by the embodiment of the present application will be described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. It is understood that the following embodiments may exist separately, and the following embodiments and features in the embodiments may be combined with each other when there is no conflict between the embodiments provided in the present application, and the same or similar content will not be repeated in different embodiments. In addition, the step sequence in the following method embodiments is only an example, not a strict limitation, and in some cases, the steps shown or described may be performed in a different order from this.
[0051] The present application provides a method, device, electronic device and computer-readable storage medium for rendering a virtual model. Specifically, the method for rendering a virtual model of one embodiment of the present application can be executed by a computer device, wherein the computer device can be a terminal or a server. The terminal can be a terminal device such as a smart phone, a tablet computer, a laptop computer, a touch screen, etc. The terminal can also include a client, which can be a game application client, a browser client carrying a game program, or an instant messaging client. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms.
[0052] Next, combine Figure 1 , a rendering method of a virtual model provided in one embodiment of the present application is described, Figure 1 A flowchart of a method for rendering a virtual model provided in one embodiment of the present application.
[0053] like Figure 1 As shown, the virtual model rendering method includes steps S10-S30:
[0054] S10. Generate multiple plant models to be rendered in a preset area according to respective preset leaf types and size information of the multiple plant models to be generated, wherein the size information includes the leaf length and leaf width of the plant models.
[0055] S20. In response to rendering instructions for multiple plant models to be rendered, determine the target rotation angle corresponding to each plant model according to the orientation of the virtual camera relative to each plant model, and control each plant model to rotate to its corresponding target rotation angle so that the leaves of each plant model face the virtual camera after rotation.
[0056] S30, rendering the rotated plant model to obtain a plant model rendering image, wherein the plant model rendering image shows that a plurality of plants corresponding to the plant models grow in a preset area.
[0057] Next, steps S10 to S30 are described in detail.
[0058] As mentioned above, the preset area is the area where the plant model is to be generated. The shape of the preset area includes but is not limited to circle, ellipse, square, rectangle, diamond, etc. The embodiment of the present application does not impose any limitation on the position, shape and size of the preset area.
[0059] The plant model to be generated can be understood as the plant model expected to be generated, and the size information of the plant model includes but is not limited to the leaf length and leaf width, which is only an example. Optionally, the plant model can be a grass model, and the size information of the grass model includes but is not limited to the grass length and grass width.
[0060] In the above, the preset leaf type is the shape of the leaf of the plant model to be generated, for example, the leaf type of grass plants or irises is a linear leaf, such as a very narrow and long leaf type with a width much smaller than the length.
[0061] In the embodiment of the present application, multiple plant models to be rendered are generated in a preset area according to the preset leaf type and size information of each of the multiple plant models to be generated. That is to say, when each plant model to be rendered is generated in the preset area, it is specifically generated according to its respective preset leaf type and size information, so the preset leaf type and size information of the plant model obtained after generation meets the preset expectations, so that there is no need to perform secondary processing on each grass model later, avoiding the huge production cost caused by the need for secondary processing.
[0062] After generating multiple plant models to be rendered in a preset area, in response to rendering instructions for multiple plant models to be rendered, the target rotation angle corresponding to each plant model is determined according to the orientation of the virtual camera relative to each plant model, and each plant model is controlled to rotate to its corresponding target rotation angle so that the leaves of each plant model after rotation face the virtual camera, so that each plant model in the preset area can be ensured to face the virtual camera during rendering. When all plant models in the preset area face the virtual camera, their front faces the virtual camera as much as possible, reducing the visibility of the side of the plant model. In this way, the probability of displaying multiple plant models at the same time at the pixel position will be reduced, thereby reducing the possibility of repeated drawing on the same pixel multiple times. The rotated plant model is rendered to obtain a plant model rendering image, which shows that plants corresponding to multiple plant models grow in the preset area. For example, if the above-mentioned multiple plant models are all in the plant model, then the plant model rendering image shows that there is a lot of grass growing in the preset area, that is, the preset area presents a grassland landscape.
[0063] The virtual model rendering method provided in the embodiment of the present application generates each plant model to be rendered in the preset area according to its respective preset leaf type and size information. Then, the preset leaf type and size information of the plant model obtained after generation meets the preset expectations, so that there is no need to perform secondary processing on each grass model later, thus avoiding the huge production cost caused by the need for secondary processing. At the same time, by controlling each plant model to rotate to its corresponding target rotation angle so that the leaves of each plant model after rotation face the virtual camera, it can be ensured that each plant model in the preset area faces the virtual camera during rendering, which can effectively reduce Quad Overdraw and improve rendering efficiency.
[0064] Based on the above embodiments, the rendering method of the virtual model provided in the embodiments of the present application is exemplarily described below.
[0065] In an optional implementation manner, an optional implementation manner of the above S10 "generating multiple plant models to be rendered in a preset area according to the preset leaf type and size information of each of the multiple plant models to be generated" includes steps S101-S104:
[0066] S101. Generate a plurality of distribution points in a preset area according to size information of a plurality of plant models to be generated, wherein the distribution points include orientation information, size information, and position information.
[0067] S102. Based on the blade length in the distribution point, generate a target line segment of a target length at a first position where the distribution point is located and perpendicular to the plane where the first position is located, wherein the target length is positively correlated with the blade length in the distribution point.
[0068] S103. Based on the orientation information in the distribution points, the target line segment is processed to obtain a target curve corresponding to the target line segment. The bending direction of the target curve is consistent with the direction represented by the orientation information. The processing parameters include at least one of the following: gravity and / or air resistance.
[0069] S104: Based on the preset leaf type and the leaf width in the distribution point, a plant model to be rendered is generated with the target curve as the leaf axis.
[0070] The following is an exemplary description of steps S101 to S104.
[0071] In an embodiment of the present application, multiple distribution points are generated in a preset area based on the size information of multiple plant models to be generated. The number of generated distribution points is the same as the number of plant models to be generated, and the distribution points correspond to the plant models to be generated one by one. That is, each distribution point is used as the starting point of the root, and a plant model is generated at each distribution point. Each distribution point includes orientation information, size information, and position information, and the size information includes leaf length and leaf width. The position information and orientation information of the distribution point are respectively used to determine the specific position of the plant model to be generated at the distribution point in the above-mentioned preset area and the orientation of the plant model to be generated. The size information of the distribution point is used to determine the leaf length and leaf width of the plant model to be generated at the distribution point.
[0072] In an embodiment of the present application, orientation information is determined for a plurality of distribution points generated within a preset area.
[0073] In an optional implementation manner, a possible implementation manner of the above step of “determining orientation information for multiple distribution points generated in a preset area” includes steps S1011-S1013:
[0074] S1011. Randomly scatter points in a preset area to obtain multiple distribution points.
[0075] S1012: Determine an arc at the edge of the preset area or outside the preset area, with multiple target points distributed on the arc.
[0076] S1013. For each distribution point, determine the target point that is closest to the distribution point, and use the normal direction of the target point on the arc to determine the orientation information of the distribution point.
[0077] As mentioned above, the preset area is the area where the plant model is to be generated. The shape of the preset area includes but is not limited to a circle, a rectangle, a diamond, etc. This is only an example, and the embodiment of the present application does not impose any limitation on this.
[0078] In an embodiment of the present application, multiple distribution points are obtained by randomly scattering points in a preset area according to a preset plant model density. At the edge of the preset area or outside the preset area, an arc is determined, and multiple target points are distributed on the arc. For each distribution point, the target point closest to the distribution point is determined, and the normal direction of the position of the target point on the arc is used to determine the orientation information of the distribution point. This ensures that the orientations of adjacent distribution points are not much different, so that the orientations of the plant models subsequently generated at adjacent distribution points are not much different, which ensures that the plant models in the preset area are relatively neat and avoids the problem of messy orientations of the plant models in the preset area.
[0079] Next, combine Figure 2 An exemplary description is given of determining the orientation information for the distribution point. Figure 2 A schematic diagram of generating multiple distribution points in a preset area provided in one embodiment of the present application. Assume that the shape of the preset area is a circle, such as Figure 2 As shown in (a), a point can be determined on the edge of the preset area and the arc of the point can be determined as zero degrees. A circular arc with an arc from 30° to 150° can be determined on the edge of the preset area in a clockwise direction. There are multiple target points distributed on the circular arc, such as Figure 2 As shown in (b), the normal of each target point on the arc. For each distribution point in the preset area, determine the target point closest to each distribution point on the arc. The normal direction of the arc at the target point is used to determine the orientation information of the corresponding distribution point. Figure 2 As shown in (b), the normal line of the position of target point 1 and the target point corresponding to the distribution point are target point 2. Figure 2 As shown in (c), the orientation information of each distribution point in the preset area is such as the line segment projected from the position of each distribution point.
[0080] For example, in combination Figure 3 An exemplary description is given of generating multiple distribution points in a preset area. Figure 3 A schematic diagram of a plurality of distribution points and the orientation of each distribution point in a preset area provided in one embodiment of the present application. Figure 3 As shown, Figure 3 The elliptical areas shown in (a) and (b) are the same grassland area, i.e., the preset area. Figure 3 (a) is used to indicate that the preset area includes multiple distribution points, such as Figure 3 (b) is used to illustrate the directions of various distribution points in the preset area.
[0081] In an embodiment of the present application, based on the blade length in the distribution point, a target line segment of target length and perpendicular to the plane where the first position is located is generated at the first position where the distribution point is located, and the target length is positively correlated with the blade length in the distribution point.
[0082] For example, assuming that the length of a blade at a distribution point is 7 cm, a target line segment with a target length of 7 cm and perpendicular to the plane where the first position is located is generated at the first position of the distribution point, such as Figure 4 As shown in (a), the target line segment is divided into 7 segments with a unit of 1 cm, and the target line segment includes 8 nodes such as node 0 to node 7.
[0083] In the embodiment of the present application, based on the orientation information in the distribution point, the target line segment is processed to obtain the target curve corresponding to the target line segment, the curvature of the target curve is consistent with the orientation represented by the orientation information, and the processing parameters include at least one of the following: gravity and / or air resistance. Optionally, the target line segment is dynamically solved to obtain the target curve corresponding to the target line segment after the solution, the curvature of the target curve is consistent with the orientation represented by the orientation information, and the dynamic solution parameters include at least one of the following: gravity and air resistance. For example, Figure 4 As shown in (b), after dynamic solution of the target line segment, the target curve is obtained. Figure 4 A schematic diagram of a target line segment, a target curve and a plant model provided in one embodiment of the present application.
[0084] In the embodiment of the present application, based on the preset leaf type and the leaf width in the distribution point, a plant model is generated with the target curve as the leaf axis, the plant model belongs to the preset leaf type, and the width of the plant model is the leaf width, so as to generate multiple plant models in the preset area. For example, assuming that the shape of the preset leaf type is wide at the bottom and pointed at the top, then based on the preset leaf type and the leaf width in the distribution point, the generated plant model is as follows: Figure 4 As shown in (c). Among them, Figure 4 A schematic diagram of a target line segment, a target curve and a plant model provided in one embodiment of the present application.
[0085] In the embodiment of the present application, each plant model is first abstracted into a curve, and a basic leaf model of a natural plant of different forms and types is generated based on the curve. Through simple parameter adjustment (such as the form and bending form of the plant, etc.), various types of physical plants can be quickly generated, and key information such as the axis point and direction of the plant leaves can be automatically generated, which greatly shortens the production cycle and reduces the production cost, thereby improving the generation efficiency of the plant model. The curve-based simulation technology is used to accurately reproduce the natural curvature of the leaves of the plant model, greatly improving the realism of the plant. At the same time, through detailed model information (including direction, size, leaf axis point, etc.), personalized color changes can be achieved for each plant leaf, while supporting rich dynamic effects and interactive effects, making the generated virtual model more vivid and realistic.
[0086] In an optional implementation manner, before step S102 "generating a target line segment of a target length and perpendicular to the plane where the first position is located at the first position of the distribution point based on the blade length in the distribution point", the virtual model rendering method provided in the embodiment of the present application further includes steps S1021-S1022:
[0087] S1021. Determine the number of preset partitions of the preset area and partition the preset area to obtain a preset number of grassland partitions.
[0088] S1022. Cluster the distribution points in each grassland partition according to a preset distribution density, and obtain the distribution points with updated position information after clustering.
[0089] In an embodiment of the present application, a partitioning algorithm (such as the Voronoi algorithm) is used to partition a preset area, and the points in each area are clustered according to a specified clustering degree to achieve the effect of clusters of plants. Figure 5 This is a schematic diagram of the comparison of partitioning and clustering before and after the embodiment of the present application. Figure 5 As shown in (a), the distribution of distribution points in the preset area before partitioning and clustering. Figure 5 As shown in (b), the distribution of distribution points in the preset area after partitioning and clustering.
[0090] In an optional implementation manner, the rendering method of the virtual model provided in the embodiment of the present application further includes the following steps: determining a length scaling parameter and a bending scaling parameter of the plant model according to a target distance between the distribution point and the center of the preset area, wherein the length scaling parameter is negatively correlated with the target distance, and the bending scaling parameter is positively correlated with the target distance.
[0091] In an embodiment of the present application, the length scaling parameter and the curvature scaling parameter of the plant model are determined according to the target distance between the distribution point and the center of the preset area. That is, the length and curvature of each plant model are scaled according to the target distance between the distribution point where the plant model is located and the center of the preset area. Specifically, the larger the target distance between the distribution point where the plant model is located and the center of the preset area, the smaller the length and curvature of the plant model will be; the smaller the target distance between the distribution point where the plant model is located and the center of the preset area, the larger the length and curvature of the plant model will be. By adjusting the length and curvature of the plant model according to the distance in this way, this natural phenomenon can be simulated, making the plants in the preset area look more realistic.
[0092] An optional implementation manner, before step S104 "generating a plant model to be rendered based on the preset leaf type and the leaf width in the distribution point with the target curve as the leaf axis", further includes steps A1-A3:
[0093] A1. Perform intersection detection on the target plant model and each plant model except the target plant model to determine whether the target plant model intersects with other plant models, and the target plant model is any one of the multiple plant models.
[0094] A2. If yes, repeat the first step until the rotated target plant model does not intersect with other plant models, or the accumulated rotation angle of the target plant model is greater than or equal to the rotation angle threshold.
[0095] A3. When the accumulated rotation angle of the target plant model is greater than or equal to the rotation angle threshold, the target plant model is deleted.
[0096] The first step includes steps A21-A22:
[0097] A21. When the accumulated rotation angle of the target plant model is less than the rotation angle threshold, the target plant model is controlled to rotate around the target distribution point at a preset angle, where the target distribution point is a distribution point located at the root of the target plant model.
[0098] A22. Perform intersection detection on the rotated target plant model and each plant model except the target plant model to determine whether the rotated target plant model intersects with other plant models.
[0099] In an embodiment of the present application, after obtaining a group of plant models distributed at the distribution points, in order to avoid the problem of leaves interlacing between the plant models, in an embodiment of the present application, by traversing each plant model, each plant model is intersected with other plant models. If the plant model intersects with other plant models, an attempt will be made to rotate the plant model around its distribution point within a preset angle range, such as (within a 90° range), and the result after each rotation will be intersected with other plant models again. If there is no intersection, the attempt will be exited. Plant models that cannot be rotated to avoid intersection within a preset angle range, such as (within a 90° range) are eliminated, so that the plant models in the preset area do not intersect with each other. After generating multiple plant models in the preset area, the embodiment of the present application also effectively handles the problem of leaf interlacing between plant models, ensuring that leaves will not intersect between plant models, and improving the overall aesthetics of multiple plant models in the preset area.
[0100] Figure 6 This is a schematic diagram of a plant model before and after optimization provided in one embodiment of the present application. Figure 6 As shown, taking the plant model as a grass model, and plant model 1 and plant model 2 in the preset area as examples, it is detected that plant model 1 and plant model 2 are intersecting, and plant model 1 is now rotated. However, an attempt is made to rotate plant model 1 around its distribution point within a preset angle range, such as (within a 90° range), and it is found that there is still a problem of plant model intersection, so it is deleted, such as Figure 6 In the rightmost figure, there is no plant model at the position of the original plant model 1. This improves the problem of plant models interlacing with each other in the preset area to a certain extent.
[0101] In an optional implementation manner, the target curve is divided into N equal segments according to preset lengths, and the target curve includes N+1 curve nodes.
[0102] A possible implementation of "determining the target rotation angle corresponding to each plant model" in the above step S20 includes step S201:
[0103] S201. Determine a target rotation angle corresponding to each curve node on a target curve on each plant model according to the orientation of the virtual camera relative to each plant model.
[0104] A possible implementation of "controlling each plant model to rotate to its corresponding target rotation angle" in the above step S20 includes step S202:
[0105] S202. For each curve node on the target curve in each plant model, control the target vector to rotate by a target rotation angle in a clockwise direction with the curve tangent at the curve node as the axis, and the target vector includes vectors from the curve node to the vertices of the edge models on both sides of the leaf of the plant model.
[0106] In an optional implementation, the target curve is divided into N segments of a preset length, and the target curve includes N+1 curve nodes. A possible implementation of the above step S201 "determining the target rotation angle corresponding to each curve node on the target curve on each plant model according to the orientation of the virtual camera relative to each plant model" includes steps S2011-S2012:
[0107] S2011. Obtain the position of the virtual camera, the position of each curve node on the target curve, and the curve tangent at each curve node on the target curve.
[0108] S2012. Determine a target rotation angle corresponding to the target curve node according to the orientation of the virtual camera relative to each plant model, the position of the target curve node on the target curve, and the curve tangent at the target curve node.
[0109] Figure 7 A schematic diagram of tangent lines of curve nodes on a plant model provided in one embodiment of the present application. Figure 7 As shown in , the position of each curve node on the target curve and the curve tangent at each curve node on the target curve. Figure 7 As shown, the target curve includes 8 curve nodes with node numbers from 0 to 7, and the curve tangent at the curve node 4 is displayed in the local enlarged view of the curve node 4.
[0110] In an optional implementation, according to the orientation of the virtual camera relative to each plant model, the position of the target curve node on the target curve, and the curve tangent at the target curve node, the calculation method of determining the target rotation angle corresponding to the target curve node can refer to Formula 1:
[0111]
[0112] Among them, P cam is the position of the virtual camera, P center is the location of the target curve node, V dir is the tangent vector at the target curve node, V 001 is the unit vector in the Z-axis direction, and θ is the target rotation angle corresponding to the target curve node.
[0113] It should be noted that the first part of Formula 1 It is used to calculate the orientation of the virtual camera relative to the target curve node. cam -P center is a vector used to represent the unit vector from the virtual camera position to the target curve node position, that is, the target curve node position P center To the virtual camera position P cam The direction of this vector is divided by its magnitude |P cam -P center |, the result is a unit vector, which is the position from the target curve node to the virtual camera, that is, it represents the direction of the virtual camera relative to the target curve node. The second part of formula 1 The tangent vector V at the target curve node dir and the unit vector V in the Z-axis direction 001 Finally, the dot product (inner product) of the unit vectors obtained from the two parts of Formula 1 is performed to give the cosine value of the angle between the two vectors, so that the target rotation angle can be calculated. In this way, when the virtual camera shoots the plant model, it is ensured that the plant model moves with the virtual camera, thereby ensuring that the plant model always faces the virtual camera head-on.
[0114] In an embodiment of the present application, the plant model is rotated clockwise at a target rotation angle based on the orientation of the front of the virtual camera relative to the plant model, thereby effectively reducing the visibility of the side of the plant model, thereby significantly reducing the aliasing problem caused by the low pixel coverage on the side, and improving the rendering efficiency and the picture quality of the plant rendering.
[0115] In the embodiment of the present application, the curve nodes of the plant model, the curve tangents of each curve node, and the curve direction are stored in the model vertices on both sides of the curve. Figure 7 Take curve node 2 in the image as an example, the direction of the curve at curve node 2 is stored in the model vertices on both sides of the curve corresponding to curve node 2, that is, stored in model vertex 2-1 and model vertex 2-2. The basic principle of the blade rotating toward the camera is to rotate the vector from the model vertex to its curve by the target rotation angle with the tangent of the curve as the axis. For example, Figure 7 Taking the curve node 4 in the example, the curve direction at the curve node 4 is stored in the vertices on both sides of the curve corresponding to the curve node 4, that is, stored in the model vertex 4-1 and the model vertex 4-2. Figure 7 As shown in the partial enlarged view of the curve node 4, the model vertices 4-1 and 4-2 on both sides of the curve corresponding to the curve node 4 are rotated clockwise by the target rotation angle with the switch at the curve node 4 as the rotation axis.
[0116] Next, combine Figure 8 The effects of rotating the plant model before and after the target rotation angle are illustrated. Figure 8 This is a schematic diagram of the plant model before and after the target rotation angle provided by one embodiment of the present application. Figure 8 As shown in the figure, taking one of the plant models as an example, the side of the plant model before rotation faces the virtual camera, and the front of the plant model after rotation faces the virtual camera. By controlling the rotation angle of the plant model rotation target, so that the leaves of the rotated plant model face the virtual camera, it can be ensured that all plant models in the preset area face the virtual camera during rendering, so that the probability of displaying multiple plant models at the same pixel position at the same time will be reduced, thereby reducing the possibility of repeated drawing on the same pixel multiple times, so it can effectively reduce Quad Overdraw and improve rendering efficiency.
[0117] In an optional implementation manner, the virtual model rendering method provided in the embodiment of the present application also includes the step of: for each plant model, scaling the target vectors from each curve node on the target curve on the plant model to the vertices of the edge models on both sides of the leaves of the plant model.
[0118] In an embodiment of the present application, after the leaves of the plant model are rotated toward the direction of the front of the virtual camera, the vector from the curve node position corresponding to the model vertex to the model vertex position on both sides of the curve node can be scaled, thereby achieving the effect of changing the thickness of the leaves. The plant model of the present application does not need to be rendered through AlphaTest, which fundamentally eliminates the Overdraw problem. By rotating the leaves of the plant model and changing its width (the principle of width change is: the farther the plant model is from the virtual camera, the lower the density of the plant model, and the wider the width of the leaves of the plant model; the closer the plant model is to the virtual camera, the higher the density of the plant model, and the narrower the width of the leaves of the plant model), when the virtual camera is far away from the plant model, the plant density is reduced to increase the width of the leaves of the plant model, thereby avoiding the possibility of the plant model being visually narrow when the distance to the plant model is very far, resulting in the same pixel being covered by multiple plant models, thereby reducing QuadOverdraw and improving rendering efficiency. In addition, the jagged effect caused by the plant model being visually narrow due to the distance to the plant model is also reduced. Taking the virtual camera getting closer and closer to the plant model as an example, as Fig. 9 As shown, the width of the plant model leaves before the width is reduced and the width of the plant model leaves after the width is reduced. Fig. 9 A schematic diagram of a plant model before and after width scaling provided in one embodiment of the present application.
[0119] In an optional implementation manner, the virtual model rendering method provided in the embodiment of the present application further includes the following steps: taking (0,0,0) as the rotation center, controlling the curve normal at the target curve node corresponding to the target model vertex to rotate around the curve tangent at the target curve node by a target rotation angle, and obtaining the normal direction deviation of the target model vertex. The sum of the original normal direction of the target model vertex and the normal direction deviation of the target model vertex is determined as the normal direction of the target model vertex after correction.
[0120] In the embodiment of the present application, the model vertices of the plant model are offset, so the normal needs to be corrected according to the rotation and offset values. Taking the UE4 engine as an example, the original normal direction of the model vertex is rotated by the built-in function RotateAboutAxis(Axis,Angle,Pivot,Position) to obtain the normal direction of the corrected model vertex. Please refer to Formula 2 for the calculation method of the normal direction of the corrected model vertex:
[0121] N 校正 =RotateAboutAxis(V tan ,θ,0,N)+NFormula 2
[0122] Among them, V tanis the tangent direction of the curve node corresponding to the model vertex, N is the original normal direction of the model vertex, N 校正 The corrected normal direction of the model's vertices.
[0123] The following is a description of a rendering device for a virtual model provided in the present application. The rendering device for a virtual model described below and the rendering method for a virtual model described above may refer to each other.
[0124] Fig.10 This is a schematic diagram of the structure of a virtual model rendering device provided in one embodiment of the present application. Fig.10 As shown, the virtual model rendering device 1000 includes: a model generation module 1001 , a processing module 1002 and a rendering module 1003 .
[0125] A model generation module, used to generate a plurality of plant models to be rendered in a preset area according to respective preset leaf types and size information of a plurality of plant models to be generated, wherein the size information includes the leaf length and leaf width of the plant models;
[0126] a processing module, for responding to a rendering instruction for the plurality of plant models to be rendered, determining a target rotation angle corresponding to each of the plant models according to an orientation of the virtual camera relative to each of the plant models, and controlling each of the plant models to rotate to its corresponding target rotation angle so that the leaves of each of the plant models after rotation face the virtual camera;
[0127] The rendering module is used to render the rotated plant model to obtain a plant model rendering image, wherein the plant model rendering image shows that a plurality of plants corresponding to the plant model grow in the preset area.
[0128] In an optional implementation manner, the model generation module is specifically used to:
[0129] According to the size information of the plurality of plant models to be generated, a plurality of distribution points are generated in the preset area; the distribution points include orientation information, size information, and position information;
[0130] Based on the blade length in the distribution point, generating a target line segment of a target length at a first position where the distribution point is located and perpendicular to the plane where the first position is located, wherein the target length is positively correlated with the blade length in the distribution point;
[0131] Based on the orientation information in the distribution points, the target line segment is processed to obtain a target curve corresponding to the target line segment, wherein the curvature orientation of the target curve is consistent with the orientation represented by the orientation information, and the processing parameters include at least one of the following: gravity and / or air resistance;
[0132] Based on the preset leaf type and the leaf width in the distribution points, a plant model to be rendered is generated with the target curve as the leaf axis.
[0133] In an optional implementation manner, the target curve is divided into N segments of preset lengths, and the target curve includes N+1 curve nodes; and the model generation module is specifically used for:
[0134] Determining a target rotation angle corresponding to each curve node on a target curve on each plant model according to the orientation of the virtual camera relative to each plant model;
[0135] The processing module is specifically used for:
[0136] For each curve node on the target curve in each plant model, the target vector is controlled to rotate the target rotation angle with the curve tangent at the curve node as the axis, and the target vector includes vectors from the curve node to the vertices of the edge models on both sides of the leaves of the plant model.
[0137] In an optional implementation manner, the target curve is divided into N segments of preset lengths, and the target curve includes N+1 curve nodes; and the processing module is specifically configured to:
[0138] Acquire the position of the virtual camera, the position of each curve node on the target curve, and the curve tangent at each curve node on the target curve;
[0139] A target rotation angle corresponding to the target curve node is determined according to the position of the virtual camera, the position of the target curve node on the target curve, and the curve tangent at the target curve node.
[0140] In an optional implementation manner, the calculation method for determining the target rotation angle corresponding to the target curve node according to the position of the virtual camera, the position of the target curve node on the target curve, and the curve tangent at the target curve node can refer to Formula 1:
[0141]
[0142] Among them, P cam is the position of the virtual camera, P center is the position of the target curve node, V dir is the tangent vector at the target curve node, V 001 is the unit vector in the Z-axis direction, and θ is the target rotation angle corresponding to the target curve node.
[0143] In an optional implementation manner, the processing module is further used for:
[0144] For each of the plant models, the target vectors from each curve node on the target curve on the plant model to the vertices of the edge models on both sides of the leaves of the plant model are scaled.
[0145] In an optional implementation manner, the processing module is further used for:
[0146] Taking (0,0,0) as the rotation center, control the curve normal at the target curve node corresponding to the target model vertex to rotate the target rotation angle around the curve tangent at the target curve node to obtain the normal direction deviation of the target model vertex.
[0147] The sum of the original normal direction of the vertex of the target model and the normal direction deviation of the vertex of the target model is determined as the normal direction of the vertex of the target model after correction.
[0148] In an optional implementation manner, the model generation module is further used for:
[0149] Randomly scattering points in the preset area to obtain a plurality of distribution points;
[0150] Determine an arc at the edge of the preset area or outside the preset area, where a plurality of target points are distributed on the arc;
[0151] For each of the distribution points, a target point that is closest to the distribution point is determined, and the direction of the normal line of the target point on the arc is used to determine the orientation information of the distribution point.
[0152] In an optional implementation manner, the model generation module is further used for:
[0153] Determine the number of preset partitions of the preset area and partition the preset area to obtain the preset number of grassland partitions;
[0154] The distribution points in each of the grassland partitions are clustered according to a preset distribution density, and after clustering, the distribution points with updated position information are obtained.
[0155] In an optional implementation manner, the model generation module is further used for:
[0156] According to the target distance between the distribution point and the center of the preset area, the length scaling parameter and the bending scaling parameter of the plant model are determined; wherein the length scaling parameter is negatively correlated with the target distance, and the bending scaling parameter is positively correlated with the target distance.
[0157] In an optional implementation manner, the model generation module is further used for:
[0158] Performing intersection detection on a target plant model and each plant model except the target plant model to determine whether the target plant model intersects with other plant models, the target plant model being any one of the multiple plant models;
[0159] If so, repeat the first step until the rotated target plant model does not intersect with other plant models, or the accumulated rotation angle of the target plant model is greater than or equal to the rotation angle threshold;
[0160] When the accumulated rotation angle of the target plant model is greater than or equal to a rotation angle threshold, deleting the target plant model;
[0161] The first step includes:
[0162] When the accumulated rotation angle of the target plant model is less than a rotation angle threshold, controlling the target plant model to rotate around a target distribution point by a preset angle, the target distribution point being a distribution point located at the root of the target plant model;
[0163] An intersection check is performed on the rotated target plant model and each plant model except the target plant model to determine whether the rotated target plant model intersects with other plant models.
[0164] In an optional implementation manner, the plant model belongs to a preset grass piece type.
[0165] The virtual model rendering device provided in this embodiment can be used to execute the technical solution of the virtual model rendering method embodiment described above. Its implementation principle and technical effects are similar and will not be described in detail in this embodiment.
[0166] Fig.11 A schematic diagram of the hardware structure of an electronic device provided in one embodiment of the present application is shown in FIG. Fig.11 As shown, the electronic device 1100 of this embodiment includes: a processor 1101 and a memory 1102;
[0167] Memory 1102, used to store computer-executable instructions;
[0168] The processor 1101 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the virtual model rendering method in the above embodiment. For details, please refer to the relevant description in the above method embodiment.
[0169] Optionally, the memory 1102 may be independent or integrated with the processor 1101 .
[0170] When the memory 1102 is independently provided, the electronic device further includes a bus 1103 for connecting the memory 1102 and the processor 1101 .
[0171] One embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, a technical solution corresponding to the method for rendering a virtual model in any of the above embodiments executed by the electronic device is implemented.
[0172] One embodiment of the present application also provides a computer program product, which includes: a computer program, which is stored in a readable storage medium. At least one processor of an electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device executes the technical solution corresponding to the rendering method of the virtual model in any of the above embodiments.
[0173] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
[0174] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0175] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application.
[0176] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0177] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0178] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0179] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0180] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0181] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for rendering a virtual model, characterized in that: The method comprises: Generate multiple plant models to be rendered in a preset area according to preset leaf types and size information of each of the multiple plant models to be generated, wherein the size information includes the leaf length and leaf width of the plant models; In response to a rendering instruction for the plurality of plant models to be rendered, determining a target rotation angle corresponding to each of the plant models according to an orientation of a virtual camera relative to each of the plant models, and controlling each of the plant models to rotate to its corresponding target rotation angle so that the leaves of each of the plant models after rotation face the virtual camera; The rotated plant model is rendered to obtain a plant model rendering image, wherein the plant model rendering image shows that a plurality of plants corresponding to the plant model grow in the preset area.
2. The method according to claim 1, characterized in that The step of generating a plurality of plant models to be rendered in a preset area according to the preset leaf type and size information of each of the plurality of plant models to be generated comprises: According to the size information of the plurality of plant models to be generated, a plurality of distribution points are generated in the preset area, wherein the distribution points include orientation information, size information, and position information; Based on the blade length in the distribution point, generating a target line segment of a target length at a first position where the distribution point is located and perpendicular to the plane where the first position is located, wherein the target length is positively correlated with the blade length in the distribution point; Based on the orientation information in the distribution points, the target line segment is processed to obtain a target curve corresponding to the target line segment, wherein the curvature orientation of the target curve is consistent with the orientation represented by the orientation information, and the processing parameters include at least one of the following: gravity and / or air resistance; Based on the preset leaf type and the leaf width in the distribution points, a plant model to be rendered is generated with the target curve as the leaf axis.
3. The method according to claim 2, characterized in that The target curve is divided into N equal segments according to a preset length, and the target curve includes N+1 curve nodes; The determining of the target rotation angle corresponding to each of the plant models comprises: Determining a target rotation angle corresponding to each curve node on a target curve on each plant model according to the orientation of the virtual camera relative to each plant model; The controlling each of the plant models to rotate to a corresponding target rotation angle comprises: For each curve node on the target curve in each plant model, the target vector is controlled to rotate the target rotation angle with the curve tangent at the curve node as the axis, and the target vector includes vectors from the curve node to the vertices of the edge models on both sides of the leaves of the plant model.
4. The method according to claim 3, characterized in that The target curve is divided into N segments according to a preset length, and the target curve includes N+1 curve nodes; and the target rotation angle corresponding to each curve node on the target curve on each plant model is determined according to the orientation of the virtual camera relative to each plant model, including: Acquire the position of the virtual camera, the position of each curve node on the target curve, and the curve tangent at each curve node on the target curve; A target rotation angle corresponding to the target curve node is determined according to the position of the virtual camera, the position of the target curve node on the target curve, and the curve tangent at the target curve node.
5. The method according to claim 4, characterized in that The calculation method for determining the target rotation angle corresponding to the target curve node according to the position of the virtual camera, the position of the target curve node on the target curve, and the curve tangent at the target curve node can refer to Formula 1: Among them, P cam is the position of the virtual camera, P center is the position of the target curve node, V dir is the tangent vector at the target curve node, V 001 is the unit vector in the Z-axis direction, and θ is the target rotation angle corresponding to the target curve node.
6. The method according to claim 3, characterized in that Before rendering the rotated plant model to obtain a plant model rendering, the method further includes: For each of the plant models, the target vectors from each curve node on the target curve on the plant model to the vertices of the edge models on both sides of the leaves of the plant model are scaled.
7. The method according to any one of claims 3 to 6, characterized in that: Before rendering the rotated plant model to obtain a plant model rendering, the method further includes: Taking (0,0,0) as the rotation center, control the curve normal at the target curve node corresponding to the target model vertex to rotate the target rotation angle around the curve tangent at the target curve node to obtain the normal direction deviation of the target model vertex. The sum of the original normal direction of the vertex of the target model and the normal direction deviation of the vertex of the target model is determined as the normal direction of the vertex of the target model after correction.
8. The method according to claim 1, characterized in that The generating of a plurality of distribution points in a preset area further comprises: Randomly scattering points in the preset area to obtain a plurality of distribution points; Determine an arc at the edge of the preset area or outside the preset area, where a plurality of target points are distributed on the arc; For each of the distribution points, a target point that is closest to the distribution point is determined, and the direction of the normal line of the target point on the arc is used to determine the orientation information of the distribution point.
9. The method according to claim 2, characterized in that: Before generating a target line segment of a target length and perpendicular to the plane where the first position is located at the first position of the distribution point based on the blade length in the distribution point, the method further includes: Determine the number of preset partitions of the preset area and partition the preset area to obtain the preset number of grassland partitions; The distribution points in each of the grassland partitions are clustered according to a preset distribution density, and after clustering, the distribution points with updated position information are obtained.
10. The method according to claim 2, characterized in that Before generating the plant model to be rendered based on the preset leaf type and the leaf width in the distribution point and taking the target curve as the leaf axis, the method further includes: According to the target distance between the distribution point and the center of the preset area, the length scaling parameter and the bending scaling parameter of the plant model are determined; wherein the length scaling parameter is negatively correlated with the target distance, and the bending scaling parameter is positively correlated with the target distance.
11. The method according to claim 2, characterized in that Before generating the plant model to be rendered based on the preset leaf type and the leaf width in the distribution point and taking the target curve as the leaf axis, the method further includes: Performing intersection detection on a target plant model and each plant model except the target plant model to determine whether the target plant model intersects with other plant models, the target plant model being any one of the multiple plant models; If so, repeat the first step until the rotated target plant model does not intersect with other plant models, or the accumulated rotation angle of the target plant model is greater than or equal to the rotation angle threshold; When the accumulated rotation angle of the target plant model is greater than or equal to a rotation angle threshold, deleting the target plant model; The first step includes: When the accumulated rotation angle of the target plant model is less than a rotation angle threshold, controlling the target plant model to rotate around a target distribution point by a preset angle, the target distribution point being a distribution point located at the root of the target plant model; An intersection check is performed on the rotated target plant model and each plant model except the target plant model to determine whether the rotated target plant model intersects with other plant models.
12. The method according to claim 1, characterized in that The plant model is a grass model.
13. A virtual model rendering device, characterized in that: The device comprises: A model generation module, used to generate a plurality of plant models to be rendered in a preset area according to respective preset leaf types and size information of a plurality of plant models to be generated, wherein the size information includes the leaf length and leaf width of the plant models; a processing module, for responding to a rendering instruction for the plurality of plant models to be rendered, determining a target rotation angle corresponding to each of the plant models according to an orientation of the virtual camera relative to each of the plant models, and controlling each of the plant models to rotate to its corresponding target rotation angle so that the leaves of each of the plant models after rotation face the virtual camera; The rendering module is used to render the rotated plant model to obtain a plant model rendering image, wherein the plant model rendering image shows that a plurality of plants corresponding to the plant model grow in the preset area.
14. An electronic device, characterized in that: The electronic device comprises: Processor; and The memory is used to store a data processing program. After the electronic device is powered on and the program is run by the processor, the virtual model rendering method according to any one of claims 1 to 12 is executed.
15. A computer-readable storage medium, characterized in that: A data processing program is stored, and the program is run by a processor to execute the virtual model rendering method according to any one of claims 1 to 12.