Vegetation object rendering method and device, computer device, and storage medium
By obtaining the location and attribute parameters of vegetation objects through pseudo-random functions and generating target vegetation models, the problem of low vegetation rendering efficiency in existing technologies is solved, achieving efficient and realistic vegetation object rendering and reducing resource consumption.
Patent Information
- Application Number
- CN202210933316.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-04
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-08-04
AI Technical Summary
Existing vegetation rendering methods require traversing the coordinates of any location on the entire terrain model, which is time-consuming, inefficient, and requires the use of multiple texture maps, resulting in wasted system performance and excessive GPU memory usage.
A pseudo-random function is used to obtain the location coordinates and model attribute parameters of vegetation objects, generate the target vegetation model, and render the vegetation object based on the model. This avoids the use of texture mapping. A pseudo-random function is used to randomly select points in the target area as the location coordinates of vegetation, and the model attribute parameters are automatically generated.
It improves the rendering efficiency of vegetation objects, enhances the realism of vegetation objects, reduces resource consumption, and eliminates the need for offline texture baking, making it easy to port and reuse vegetation objects.
Smart Images

Figure CN115294255B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, specifically to a method, apparatus, computer device, and storage medium for rendering vegetation objects. Background Technology
[0002] To enhance the realism of game scenes, vegetation is a crucial component. Existing vegetation rendering methods typically involve first constructing a texture map of the same size as the game map, recording vegetation density. Then, the position coordinates on the terrain model are converted into a pixel on this texture map, and the pixel value is used to determine whether to render grass at that coordinate on the terrain model. Current vegetation rendering methods require traversing all coordinates across the entire terrain model, which is time-consuming and inefficient. Summary of the Invention
[0003] Therefore, it is necessary to provide a method, apparatus, computer device, and storage medium for rendering vegetation objects to address the aforementioned technical problems and improve the rendering efficiency of vegetation objects.
[0004] Firstly, this application provides a method for rendering vegetation objects, the method comprising:
[0005] Retrieve the object configuration parameters of the vegetation object;
[0006] Based on pseudo-random functions and object configuration parameters, the vegetation location coordinates and model attribute parameters of vegetation objects within the target area are obtained.
[0007] Generate the target vegetation model based on the model attribute parameters and vegetation location coordinates;
[0008] Render vegetation objects in the target area based on the target vegetation model.
[0009] Secondly, this application provides a rendering apparatus for vegetation objects, the apparatus comprising:
[0010] The configuration acquisition module is used to obtain the object configuration parameters of vegetation objects;
[0011] The parameter acquisition module is used to obtain the vegetation location coordinates and model attribute parameters of vegetation objects within the target area based on pseudo-random functions and object configuration parameters.
[0012] The model building module is used to generate a target vegetation model based on the model attribute parameters and vegetation location coordinates.
[0013] The object rendering module is used to render vegetation objects in the target area based on the target vegetation model.
[0014] Thirdly, this application also provides a computer device, which includes:
[0015] One or more processors;
[0016] Memory; and
[0017] One or more applications, wherein one or more applications are stored in memory and configured to be executed by a processor to implement a rendering method for vegetation objects.
[0018] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to execute steps in a method for rendering vegetation objects.
[0019] Fifthly, embodiments of this application provide a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method provided in the first aspect described above.
[0020] The aforementioned method, apparatus, computer equipment, and storage medium for rendering vegetation objects obtain the object configuration parameters of the vegetation objects; based on a pseudo-random function and the object configuration parameters, obtain the vegetation position coordinates and model attribute parameters of the vegetation objects within the target area; generate a target vegetation model based on the model attribute parameters and vegetation position coordinates; and render the vegetation objects in the target area based on the target vegetation model. By randomly selecting points in the target area using a pseudo-random function as the vegetation position coordinates of the vegetation objects, and automatically generating the model attribute parameters of the vegetation objects using the same pseudo-random function, a target vegetation model corresponding to the model attribute parameters is constructed on the vegetation position coordinates. The vegetation objects are then rendered based on the target vegetation model. Since rendering of small areas of vegetation can be achieved without using texture mapping, the efficiency of rendering vegetation objects is greatly improved. Furthermore, the randomness of the vegetation position coordinates and model attribute parameters effectively enhances the realism of the rendered vegetation objects. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1This is a flowchart illustrating the rendering method for vegetation objects in an embodiment of this application;
[0023] Figure 2 This is a flowchart illustrating the steps for obtaining vegetation location coordinates in an embodiment of this application.
[0024] Figure 3 This is a schematic diagram of the target area and vegetation area in the embodiments of this application;
[0025] Figure 4 This is a flowchart illustrating the vegetation object rendering steps in an embodiment of this application.
[0026] Figure 5 This is a schematic diagram illustrating the rendering effect of vegetation objects in an embodiment of this application;
[0027] Figure 6 This is a flowchart illustrating another vegetation object rendering step in an embodiment of this application;
[0028] Figure 7 This is a schematic diagram illustrating the rendering effect of another vegetation object in an embodiment of this application;
[0029] Figure 8 This is another rendering effect diagram of a vegetation object in the embodiments of this application;
[0030] Figure 9 This is a schematic diagram of the structure of the rendering device for vegetation objects in the embodiments of this application;
[0031] Figure 10 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0032] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0033] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0034] In the description of this application, the word "for example" is used to mean "used as an example, illustration, or description." Any embodiment described as "for example" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0035] The virtual scene rendering method provided in this application can run on a terminal device or a server. The terminal device can be a local terminal device. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Taking the application of this virtual scene rendering method to a virtual scene in a video game as an example, the video game server can generate vegetation effects such as grass, shrubs, and forests in the game's virtual scene based on this vegetation object rendering method, thus realizing the rendering of the game world.
[0036] Taking grass as an example, existing grass rendering methods typically involve first constructing a first texture map that records the vegetation density of the game map, then converting the position coordinates on the terrain model into a pixel on the first texture map, and determining whether to render grass at that position coordinate on the terrain model based on the pixel value of that pixel; or, dividing the game map into multiple smaller maps, and correspondingly dividing the terrain model into multiple terrain sub-models, and then combining the texture map to render grass for each terrain sub-model. Existing grass rendering methods require traversing any position coordinate on the entire terrain model (or terrain sub-model), which is time-consuming, has low vegetation rendering efficiency, and performing the same operation on parts of the game map without vegetation leads to a waste of system performance. When rendering individual blades of grass, to improve the realism of the grass clump, a second texture map corresponding to each blade of grass needs to be pre-baked. This second texture map records the rotation or scaling values of the individual blades of grass to increase the clutter of the grass clump. Furthermore, considering the influence of other interactive objects on the grass clump, such as a game character passing through the grass, a third texture map needs to be updated in real time based on the impact of the interactive object. When rendering the vertex animation of the grass clump, perturbation offset values are sampled from the third texture map and applied to the vertex animation. Existing grass rendering methods require pre-baking multiple texture maps offline, resulting in low grass rendering efficiency, inability to verify the rendering effect during the grass rendering process, and significant VRAM consumption of texture maps during runtime.
[0037] To address the aforementioned issues, this application provides a method for rendering vegetation objects, see below. Figure 1 The method includes steps S110 to S140, as follows:
[0038] S110, obtain the object configuration parameters of the vegetation object.
[0039] Among them, vegetation objects can be, but are not limited to, plants in virtual scenes such as trees, grass, and flowers; it should be noted that vegetation objects can refer to a single plant, such as a single blade of grass, tree, or shrub, or a group of vegetation objects including multiple plants, such as grass, shrubs, or forests, etc., without limitation here.
[0040] Here, object configuration parameters refer to the range or value of the vegetation model corresponding to the vegetation object across different model attributes. Specifically, in one embodiment, object configuration parameters include, but are not limited to, the model rotation range, model scaling range, and spacing value of the vegetation model corresponding to the vegetation object; wherein, the rotation range is used to control the size of the rotation angle of the vegetation model corresponding to the vegetation object, the scaling range is used to control the size of the scaling factor of the vegetation model corresponding to the vegetation object, and the spacing value is used to control the distance between adjacent vegetation objects.
[0041] S120, based on a pseudo-random function and object configuration parameters, obtains the vegetation location coordinates of vegetation objects within the target area, as well as the model attribute parameters of vegetation objects.
[0042] The target area refers to a region in the virtual scene, which can be the spatial area currently displayed by the view or the spatial area currently being processed by the server. Specifically, the parameters corresponding to the bounding box can be preset, and then the target area can be defined in the corresponding plot model of the virtual scene by using the bounding box during the rendering of vegetation objects.
[0043] The vegetation location coordinates refer to the location information of the points where vegetation objects are generated within the target area. Specifically, the vegetation location coordinates can be used as the location coordinates of the center point of the vegetation root in the vegetation model corresponding to the subsequent vegetation object. The model attribute parameters refer to the specific values of the vegetation model corresponding to the vegetation object in different model attributes, used to control the shape of the individual vegetation model generated at the vegetation location coordinates. Specifically, the model attribute parameters include, but are not limited to, model rotation angle parameters and model scaling parameters. The model rotation angle parameter refers to the specific value of the vegetation model corresponding to the vegetation object within the model rotation range, and the model scaling parameter refers to the specific value of the vegetation model corresponding to the vegetation object within the model scaling range.
[0044] Understandably, in virtual scenes, vegetation such as grass, shrubs, and forests often has random and chaotic generation locations and growth patterns. By using object configuration parameters and pseudo-random functions to randomly obtain the object locations and model attribute parameters of vegetation objects in the target area, the randomness of the generation locations and growth patterns of vegetation objects can be improved, thereby enhancing the realism of vegetation rendering in virtual scenes.
[0045] The pseudo-random function refers to an algorithm used to calculate pseudo-random numbers with values uniformly distributed between 0 and 1. When calculating pseudo-random numbers using the pseudo-random function, if the initial value (random seed) remains unchanged, the order of the pseudo-random numbers will also remain unchanged. After obtaining the object configuration parameters, the pseudo-random function can be used to filter the object location of vegetation objects in the target area and obtain the model attribute parameters of vegetation objects within the range or value of different attribute parameters given in the object configuration parameters.
[0046] In one embodiment, the model rotation angle parameter of the vegetation object can be determined by a pseudo-random function within the model rotation range of the object configuration parameters.
[0047] Specifically, the model rotation range is [0, 360]. That is, the model rotation angle parameter of the vegetation model corresponding to the vegetation object can be randomly selected from 0 to 360 degrees based on a pseudo-random function. For example, taking a single grass plant as the vegetation object, the model rotation angle parameter of the current single grass plant can be determined using a pseudo-random function within the model rotation range of the grass object's configuration parameters; in the Unity engine, this can be obtained using the random function code Random.Range(0, 360).
[0048] In one embodiment, the model scaling parameters of the vegetation object are determined by a pseudo-random function within the model scaling range of the object configuration parameters.
[0049] The model scaling range is set according to specific circumstances. The model scaling parameters of the vegetation model corresponding to the vegetation object can be randomly selected based on a pseudo-random function. For example, taking a single grass plant as the vegetation object, the model scaling parameters of the current single grass plant can be determined by using a pseudo-random function within the model scaling range of the grass object's configuration parameters. Taking the Unity engine as an example, this can be obtained through the random function code Random.Range(X,Y), where X is the minimum scaling parameter value and Y is the maximum scaling parameter value.
[0050] In one embodiment, vegetation location coordinates of vegetation objects can be obtained within a target area based on a pseudo-random function and the spacing value in the object configuration parameters. As mentioned above, the spacing value in the object configuration parameters controls the distance between different vegetation objects. Points can be selected at intervals within the target area using this spacing value, and the location coordinates of these points can be determined as vegetation location coordinates. To further enhance the randomness of vegetation object generation locations, a random value perturbation is added to the spacing value using a pseudo-random function. This increases the randomness of each interval value during the point selection process, enabling the random selection of points within the target area as vegetation object generation points. The location coordinates of these vegetation object generation points are then the vegetation location coordinates, achieving random rendering of vegetation objects within the target area and improving the realism of the vegetation objects.
[0051] Furthermore, in one embodiment, such as Figure 2 As shown, based on a pseudo-random function and object configuration parameters, the vegetation location coordinates of vegetation objects within the target area are obtained, which may specifically include:
[0052] S210, calculate the position offset based on the pseudo-random function and the spacing value in the object configuration parameters;
[0053] S220, determine the current position coordinates based on the reference position coordinates and position offset within the target area;
[0054] S230, If the current location coordinates are within the vegetation area of the target area, the current location coordinates are determined as the vegetation location coordinates of the vegetation object.
[0055] The reference position coordinates can be the coordinates of a point taken during the last random sampling within the target area, or the coordinates of a fixed point within the target area.
[0056] The position offset can be a scalar used to control the offset distance between the current and previous point selections during interval point selection within the target area. Specifically, a pseudo-random function is used to add random perturbation to the interval value, increasing the randomness of the offset distance for each point selection. For example, the position offset can be obtained using the following formula: D = Gap + Random[-Gap / 2, Gap / 2], where D represents the position offset, Gap represents the interval value, and Random represents a random value within the range [-Gap / 2, Gap / 2]. After obtaining the position offset, the current position coordinates of the current point selection can be determined by moving the position offset in any direction from the reference position coordinates within the target area.
[0057] Furthermore, the position offset can also be a vector, used to control the offset direction and offset distance between the current point selection and the previous point selection during the process of interval point selection within the target area. Specifically, in one embodiment, the interval value includes a first interval value in a first direction and an interval value in a second direction; calculating the position offset based on the pseudo-random function and the interval value in the object configuration parameters includes: obtaining a first offset in the first direction based on the first interval value in the pseudo-random function and the object configuration parameters; and obtaining a second offset in the second direction based on the second interval value in the pseudo-random function and the object configuration parameters.
[0058] Here, the first direction and the second direction are different directions. For example, the first direction could be the direction of the X-axis in the virtual scene, and the second direction could be the direction of the Z-axis. By adding random value perturbations to the first interval value in the first direction and the second interval value in the second direction using a pseudo-random function, the randomness of the point offset direction and offset distance during each point selection process is improved. For example, the position offset can be obtained using the following formula:
[0059] D=vector2(Gap1+Random[-Gap1 / 2, Gap1 / 2], Gap2+Random[-Gap2 / 2, Gap2 / 2])
[0060] Where D represents the position offset, Gap1 represents the first interval value in the first direction, Gap2 represents the second interval value in the second direction, and Random represents a random value within the range. After obtaining the position offset, the position coordinates of the reference position within the target area are taken as the starting point, and the position coordinates of the starting point after moving by the position offset are obtained, which gives the current position coordinates of the point being selected.
[0061] The vegetation area refers to the pre-defined area within the target area where vegetation objects actually need to be rendered; specifically, it can be defined by using bounding boxes within the corresponding land parcel model in the virtual scene. It's understood that the target area and the vegetation area can be the same area or different areas; see reference... Figure 3 , Figure 3 The diagram shows a target area 310 defined by a rectangular bounding box, and two vegetation areas of different shapes (vegetation area 320 and vegetation area 330).
[0062] After obtaining the current location coordinates of the current point, it can be determined whether the current location coordinates are within the vegetation area. If the current location coordinates are within the vegetation area, then the current location coordinates are determined as the vegetation location coordinates of the vegetation object.
[0063] In this embodiment, the generation location of vegetation objects to be rendered in the target area is accurately located by vegetation regions. This eliminates the need to use vegetation density texture maps to render small areas of vegetation, decoupling the generation location of vegetation objects from the specific virtual scene and facilitating the portability and reuse of vegetation objects. Furthermore, by combining pseudo-random functions and object configuration parameters, random points are selected within the vegetation region of the target area, and corresponding model attribute parameters for vegetation objects at those selected points are randomly generated. This controls the rendering effect of vegetation objects within the target area, improving the randomness of vegetation object generation locations and morphology. Simultaneously, by controlling the input to use the same random seed, the rendering effect of vegetation object generation locations and morphology within the target area remains consistent each time.
[0064] Combination Figure 3Taking a single grass plant as an example, the lower left corner point 340 in the target area is used as the starting position coordinate (i.e., the reference position coordinate for the first point selection). The position offset of the first point selection is calculated based on the pseudo-random function and the spacing value in the object configuration parameters. Then, using point 340 as the reference position coordinate, and combining it with the position offset of the first point selection, the position coordinate of the first point selection (i.e., the current position coordinate) is determined. This position coordinate is used to determine whether the first point selection is within the vegetation area. If it is, the current position coordinate is a vegetation position coordinate. Then, the position offset of the second point selection is calculated again based on the pseudo-random function and the spacing value in the object configuration parameters. The position coordinate of the first point selection is used as the reference coordinate position, and the position coordinate of the first point selection is determined by combining it with the position offset of the second point selection. The current position coordinate is used to determine whether the second point selection is within the vegetation area. If it is, the current position coordinate is a vegetation position coordinate. If not, the position offset of the next point selection is calculated again based on the pseudo-random function and the spacing value in the object configuration parameters. The above steps are repeated until the point selection is completed in the target area, obtaining the position coordinates of all vegetation in the target area.
[0065] S130: Generate the target vegetation model based on the model attribute parameters and vegetation location coordinates.
[0066] After obtaining the model attribute parameters and vegetation location coordinates, a vegetation model corresponding to the vegetation object can be constructed at the vegetation location coordinates based on the model attribute parameters and vegetation location coordinates. The constructed vegetation model can then be adjusted using the model attribute parameters to obtain the target vegetation model.
[0067] Specifically, in one embodiment, generating a target vegetation model based on model attribute parameters and vegetation location coordinates includes: obtaining an initial vegetation model of the vegetation object; and adjusting the grid coordinates of each grid vertex in the initial vegetation model based on the model attribute parameters and vegetation location coordinates to obtain the target vegetation model.
[0068] The initial vegetation model is a pre-constructed vegetation model. After obtaining the model attribute parameters and vegetation location coordinates, the vegetation location coordinates are converted into model displacement parameters. Then, based on the model displacement parameters, the model scaling parameters in the model attribute parameters, and the model rotation angle parameters, the grid coordinates of each grid vertex in the initial vegetation model are adjusted to construct target vegetation models with different shapes and sizes at each vegetation location coordinate.
[0069] Specifically, the grid coordinates of each grid vertex in the initial vegetation model are adjusted according to the model scaling parameters, which can be done by shrinking or enlarging the initial vegetation model as a whole; the grid coordinates of each grid vertex in the initial vegetation model are adjusted according to the model rotation angle parameters, which can be done by rotating each grid vertex around the center point of the initial vegetation model by the model rotation angle parameters; and the model displacement parameters can be the displacement relative to the origin of the world coordinate system, and the grid coordinates of each grid vertex in the initial vegetation model are adjusted according to the model displacement parameters, which can be done by moving each grid vertex in the initial vegetation model based on the model displacement parameters.
[0070] S140, renders vegetation objects in the target area based on the target vegetation model.
[0071] After obtaining the target vegetation model, vegetation objects in the target area are generated by rendering based on the target vegetation model.
[0072] Considering that vegetation objects are affected by factors such as wind and gravity, they are often in a slightly swaying state. To improve the realism of vegetation object rendering in the virtual environment, in one embodiment, such as... Figure 4 As shown, the vegetation objects in the target area are rendered based on the target vegetation model, specifically including:
[0073] S410, based on the height value of the grid vertex in the target vegetation model, obtain the reference curvature value corresponding to the grid vertex;
[0074] S420: Obtain the bending parameters of the mesh vertices at different times based on the reference bending value;
[0075] S430, update the grid coordinates of the grid vertices of the target vegetation model at different times based on the bending parameters at different times;
[0076] S440 renders vegetation objects in the target area based on the updated target vegetation model.
[0077] The height value of a grid vertex can be its height relative to the ground level of the terrain model, for example, it can be the value of the grid vertex on the Y-axis. Specifically, the closer a vegetation object is to the root, the less affected it is, while the farther away it is from the root, the more affected it is. For any grid vertex in the target vegetation model, interpolation can be performed based on the height value of the grid vertex to obtain the reference curvature value of that grid vertex. The larger the height value of the grid vertex, the larger the reference curvature value obtained. Alternatively, the difference between the height value of the grid vertex and the ground level can be obtained first, and then interpolation can be performed based on this difference to obtain the reference curvature value of the grid vertex. The larger the difference between the height value and the ground level, the larger the reference curvature value obtained.
[0078] After obtaining the baseline curvature value of each grid vertex, the baseline curvature value can be processed using a cosine or sine function to obtain the curvature parameters at different times. Then, the grid coordinates of the grid vertices of the target vegetation model can be adjusted using the curvature parameters at different times. When rendering the target vegetation model in the subsequent process, a vegetation object that sways slightly with time can be obtained, improving the realism of the vegetation object rendering.
[0079] For example, the baseline curvature value of a mesh vertex can be obtained using the following pseudocode:
[0080] scale = smoothstep(h 地面 h 地面 +h 植被 h 顶点 )
[0081] bend = scale * sin(time)
[0082] Position 顶点 = rotate(bend)
[0083] Where scale represents the baseline bending value; bend represents the bending parameter; sin represents the sine function; smoothstep represents the smooth step function, used to generate a smooth transition value from 0 to 1; rotate represents the transformation that rotates the mesh vertices around a fixed point by the angle value corresponding to bend without deformation; time represents the time parameter, which can be provided by the rendering engine.
[0084] See Figure 5 , Figure 5 The image shows the effect of rendering vegetation objects based on the updated target vegetation model after updating the mesh coordinates of the mesh vertices of the target vegetation model according to the bending parameters at different times. For example, from a to b to c, the rendered vegetation objects sway slightly with time, which is highly realistic.
[0085] Furthermore, considering the interactions between other objects and vegetation objects in a virtual environment, such as game characters passing through vegetation objects or game characters releasing skills through vegetation, the form of vegetation objects will change. Therefore, in one embodiment, such as Figure 6 As shown, the vegetation objects in the target area are rendered based on the target vegetation model, including:
[0086] S610, obtain the interaction position coordinates of the interactive object, and calculate the distance value and direction vector between the interactive object and the vegetation object based on the interaction position coordinates and the vegetation position coordinates;
[0087] S620: Obtain the first rotation angle based on the direction vector, and obtain the second rotation angle based on the distance value;
[0088] S630, adjust the grid coordinates of the grid vertices of the target vegetation model according to the first rotation angle and the second rotation angle;
[0089] S640 renders vegetation objects in the target area based on the adjusted target vegetation model.
[0090] The interactive object can be any object that interacts with the vegetation object. The interaction position coordinates refer to the position information of the interactive object, which can be the position coordinates of the center point of the model corresponding to the interactive object, or the position coordinates of the centroid of the model corresponding to the interactive object, without limitation. For example, in a game scene, the interactive object can be a game character, and the interaction position coordinates refer to the position coordinates of that game character.
[0091] Understandably, the number of interactive objects can be one or more.
[0092] The first rotation angle and the second rotation angle are two different rotation angles used to control the direction of the fallen shape of the vegetation model corresponding to the vegetation object.
[0093] After obtaining the interaction position coordinates of the interactive object, the distance and direction vector between the interactive object and the vegetation object can be obtained based on the interaction position coordinates and the vegetation position coordinates. Then, based on the direction vector and distance between the interactive object and the vegetation object, the rotation angle of the vegetation object is determined. Finally, based on the rotation angle of the vegetation object, the target vegetation model of the vegetation object is adjusted, so that when rendering the target vegetation model subsequently, the vegetation object can achieve the effect of falling away from the interactive object. Figure 7 As shown, this enhances the realism of scene interactions.
[0094] For example, taking a game character as the interactive object, first obtain the interactive position coordinates of the game character; using the Unity engine as an example, the interactive position coordinates can be passed in via C#, and the following code can be used to obtain the interactive position coordinates of the game character object:
[0095] Shader.SetGlobalVectorArray("PlayerPosition",PositionArray());
[0096] PlayerPosition refers to the interaction position coordinates.
[0097] After obtaining the coordinates of the interaction location, the distance and direction vector between the interaction object and the vegetation object can be obtained based on the interaction location coordinates and the vegetation location coordinates; specifically, the direction vector can be represented as:
[0098] dir=normalize(centerposition-PlayerPosition);
[0099] Where dir represents the direction vector between the interactive object and the vegetation object, centerposition represents the coordinates of the vegetation position, and PlayerPosition represents the coordinates of the interactive position.
[0100] After obtaining the direction vector between the interactive object and the vegetation object, the first rotation angle is calculated using the tangent formula. Specifically, the first rotation angle can be obtained through the following code:
[0101] angleZ=(atan2(dir.z, dir.x))
[0102] angleZ = angleZ + (-0.774 * Pi) * 2
[0103] Where angleZ represents the first rotation angle, and atan2 represents the arctangent function; the first rotation angle is obtained based on the values of the X-axis and Z-axis in the direction vector using the arctangent function, and then remapped to the interval [0, 2π]. The X-axis and Z-axis are mutually perpendicular coordinate axes, which can be a reference coordinate system set in the virtual scene; for example, see... Figure 3 , Figure 3 The directions of the X and Z axes in the virtual scene are shown.
[0104] After obtaining the distance between the interactive object and the vegetation object, the second rotation angle can be obtained using the following formula:
[0105] Bend2=(dis 交互 -dis max ) / dis max *Bend max
[0106] Where bend2 represents the second rotation angle; dis 交互 Dis represents the distance between the interactive object and the vegetation object; max This represents the maximum distance value, which can be set according to the actual situation; Bend max This indicates the maximum rotation angle, which can be set according to the actual situation.
[0107] In the above-described method for rendering vegetation objects, the following steps are taken: First, the object configuration parameters of the vegetation object are obtained. Then, based on a pseudo-random function and the object configuration parameters, the vegetation location coordinates and model attribute parameters of the vegetation object within the target area are obtained. Next, a target vegetation model is generated based on the model attribute parameters and the vegetation location coordinates. Finally, the vegetation objects in the target area are rendered based on the target vegetation model. By using a pseudo-random function to randomly select points in the target area as the vegetation location coordinates, and by automatically generating the model attribute parameters of the vegetation object using the same pseudo-random function, a target vegetation model corresponding to the model attribute parameters is constructed at the vegetation location coordinates. The vegetation object is then rendered based on the target vegetation model. Since rendering of small areas of vegetation can be achieved without using texture mapping, the efficiency of rendering vegetation objects is greatly improved. Furthermore, due to the randomness of the vegetation location coordinates and model attribute parameters, the realism of the rendered vegetation objects is significantly enhanced. Furthermore, since no texture mapping is required and offline baking is unnecessary, the rendering results of vegetation objects can be viewed quickly. At runtime, no texture maps consume memory resources, reducing resource consumption. Moreover, the target area is highly customizable, which decouples the generation location of vegetation objects from the specific virtual scene, making it easy to transplant and reuse vegetation objects.
[0108] The rendering method for vegetation objects provided in this application embodiment will be further explained below with reference to a specific application scenario. Specifically, the rendering method for vegetation objects will be applied to the Unity engine for illustration:
[0109] Step 1: Create a large bounding box in Unity.
[0110] Among them, the large enclosed box serves as the target area, such as Figure 3 As shown in 310; during the rendering of vegetation objects, a search is performed within the area of this large bounding box. It is understood that the specific parameters of the large bounding box can be set in advance by the developers.
[0111] Step 2: Define multiple smaller bounding boxes within the area of the larger bounding box.
[0112] The small enclosure serves as a vegetation area, and its shape can be any shape, such as... Figure 3 As shown in 320 and 330, during the rendering of vegetation objects, the vegetation objects are rendered and drawn only on the surface of the small bounding box. It can be understood that the relevant parameters of the small bounding box can be set in advance according to the area of vegetation to be generated in the corresponding map of the virtual scene.
[0113] By using a large bounding box to define the retrieval range and a small bounding box to accurately locate the vegetation generation area, the amount of data processing can be effectively reduced without using vegetation density texture maps. Furthermore, the location of vegetation objects can be obtained, which decouples the location of vegetation objects from the specific virtual scene, making it easier to transplant and reuse vegetation objects.
[0114] Step 3: Obtain the object configuration parameters of the vegetation object.
[0115] One approach is to provide a visual interface through which user-inputted object configuration parameters can be obtained; alternatively, the object configuration parameters corresponding to the vegetation effect in the current scene can be pre-saved into a configuration table, and the object configuration parameters can be directly read from the configuration table during the rendering process of the vegetation object.
[0116] Specifically, the object configuration parameters include model scaling range, spacing rows (i.e., the first spacing value), and spacing width (i.e., the second spacing value). Among them, the model scaling range is used to control the scaling factor of the vegetation model corresponding to the vegetation object; the spacing rows and spacing width are used to control the distance between adjacent vegetation objects.
[0117] Step 4: Based on the pseudo-random function and object configuration parameters, obtain the vegetation location coordinates of the vegetation object within the large bounding box, as well as the model attribute parameters of the vegetation object.
[0118] The pseudo-random function in the Unity C# code is Random.Range(x,y), which randomly selects a value within the range of x to y.
[0119] Furthermore, a random seed can be set using `Random.Seed` (set via `Random.InitState`). This means that with the same random seed, the vegetation location coordinates and model attribute parameters randomly generated based on the object's configuration parameters will be identical. Based on this pseudo-random property, the model attribute parameters of the vegetation object can be pre-set according to the rendering effect of the vegetation object, and a corresponding random seed can be provided. When rendering the vegetation object, the user can input a certain random seed, ensuring that the rendering effect of the vegetation object randomly generated based on the object's configuration parameters is consistent.
[0120] Specifically, based on a pseudo-random function and object configuration parameters, the vegetation location coordinates of the vegetation object within the large bounding box are obtained. The specific process is as follows: obtain the position of the lower left corner of the large bounding box, take points at intervals according to the "interval row" and "interval column" in the object configuration parameters, and determine whether the current point is on the small bounding box. If it is on the small bounding box, the position coordinates of the point are the vegetation location coordinates.
[0121] To enhance the realism of vegetation objects, random value perturbations are added to the "interval rows" and "interval columns." Specifically, the position offset of the current sampling point can be obtained using the following formula:
[0122] D=vector2(Gap1+Random[-Gap1 / 2, Gap1 / 2], Gap2+Random[-Gap2 / 2, Gap2 / 2])
[0123] Where D represents the position offset, Gap1 represents the parameter "interval column", Gap2 represents the parameter "interval row", and Random represents a random value within the range. After obtaining the position offset, the position coordinates of the current point are obtained by moving the lower left corner of the bounding box by that position offset.
[0124] If the current point is on the small bounding box, model attribute parameters on the current point are further generated. These model attribute parameters include model rotation angle parameters and model scaling parameters. The model scaling parameters can be determined within a scaling range using a pseudo-random function, and the model rotation angle parameters can be determined within a range of 0 to 360 degrees using a pseudo-random function.
[0125] Step 5: Generate the target vegetation model based on the model attribute parameters and vegetation location coordinates.
[0126] In Unity, the Graphics.DrawMeshInstanced function is used to generate the target vegetation model. This function requires at least the following three parameters:
[0127] Matrices[]: An array of matrix information for the rendered model, including rotation, translation, and scaling.
[0128] Count: The number of models rendered;
[0129] MaterialPropertyBlock: A material property overriding class that allows the same material to be applied with different parameters.
[0130] Specifically, after obtaining the vegetation location coordinates and model attribute parameters through the above steps, these coordinates can be passed as input parameters to the `Graphics.DrawMeshInstanced` function. The vegetation location coordinates are converted into model displacement parameters. These parameters, along with the model scaling and rotation angle parameters from the model attribute parameters, are then used as the matrix information array `Matrices[]` for the rendered model. The number of all vegetation location coordinates is counted as the number of rendered models (`Count`). Finally, the vegetation location coordinates are used as the material property overload class `MaterialPropertyBlock`.
[0131] like Figure 8 As shown, Figure 8 It shows that in such Figure 3 The diagram shows the effect of generating the target vegetation model using the Graphics.DrawMeshInstanced function within the large and small bounding boxes.
[0132] After generating the target vegetation model, the vegetation objects of the target area are rendered based on the target vegetation model, which often include non-interactive vegetation animations and interactive vegetation animations.
[0133] For non-interactive vegetation animation, interpolation can first be performed based on the height values of each grid vertex in the target vegetation model relative to the ground to obtain the baseline curvature value of each grid vertex. The closer to the ground, the lower the baseline curvature value. Then, a sine function is used to process the baseline curvature values of each grid vertex to obtain a curvature parameter that changes uniformly and repeatedly over time. After updating the grid coordinates of the grid vertices of the target vegetation model based on this time-varying curvature parameter, and rendering the vegetation object based on the updated target vegetation model, a vegetation animation showing the vegetation object swaying slightly over time can be obtained. The resulting effect is shown in the image below. Figure 5 As shown.
[0134] For interactive vegetation animation, the interaction object's position coordinates can be passed in via C#. Then, based on these coordinates, the distance and direction vector between the interaction and vegetation objects can be obtained. Next, based on the direction vector and distance, a first rotation angle along the Z-axis and a second rotation angle along the X-axis are determined. Finally, based on these rotation angles, the target vegetation model is adjusted, allowing the vegetation object to appear to fall backwards, facing away from the interaction object, during subsequent rendering. Figure 7 As shown, this enhances the realism of scene interactions.
[0135] To better implement the vegetation object rendering method provided in the embodiments of this application, based on the vegetation object rendering method proposed in the embodiments of this application, this application also provides a vegetation object rendering device, such as... Figure 9 As shown, the rendering device 900 for vegetation objects includes:
[0136] Configuration acquisition module 910 is used to acquire the object configuration parameters of vegetation objects;
[0137] The parameter acquisition module 920 is used to obtain the vegetation location coordinates of vegetation objects in the target area and the model attribute parameters of vegetation objects based on pseudo-random functions and object configuration parameters.
[0138] Model building module 930 is used to generate a target vegetation model based on model attribute parameters and vegetation location coordinates;
[0139] Object rendering module 940 is used to render vegetation objects of the target area based on the target vegetation model.
[0140] In some embodiments of this application, the parameter acquisition module 920 is specifically used to calculate the position offset based on the pseudo-random function and the spacing value in the object configuration parameters; determine the current position coordinates according to the reference position coordinates in the target area and the position offset; if the current position coordinates are in the vegetation area of the target area, determine the current position coordinates as the vegetation position coordinates of the vegetation object.
[0141] In some embodiments of this application, the spacing value includes a first interval value in a first direction and an interval value in a second direction; the parameter acquisition module 920 is specifically used to obtain a first offset in a first direction based on the first interval value in the pseudo-random function and the object configuration parameters; and to obtain a second offset in a second direction based on the second interval value in the pseudo-random function and the object configuration parameters.
[0142] In some embodiments of this application, the parameter acquisition module 920 is specifically used to determine the model rotation angle parameter of the vegetation object within the model rotation range in the object configuration parameters using a pseudo-random function; and to determine the model scaling parameter of the vegetation object within the model scaling range in the object configuration parameters using a pseudo-random function.
[0143] In some embodiments of this application, the model building module 930 is used to obtain an initial vegetation model of the vegetation object; and adjust the grid coordinates of the initial vegetation model according to the model attribute parameters and the vegetation location coordinates to obtain the target vegetation model.
[0144] In some embodiments of this application, the object rendering module 940 is used to obtain the reference curvature value corresponding to the grid vertex based on the height value of the grid vertex in the target vegetation model; obtain the curvature parameter of the grid vertex at different times based on the reference curvature value; update the grid coordinates of the grid vertex of the target vegetation model at different times based on the curvature parameter at different times; and render the vegetation object of the target area based on the updated target vegetation model.
[0145] In some embodiments of this application, the object rendering module 940 is used to obtain the interaction position coordinates of the interactive object, calculate the distance value and direction vector between the interactive object and the vegetation object based on the interaction position coordinates and the vegetation position coordinates; obtain a first rotation angle based on the direction vector, and obtain a second rotation angle based on the distance value; adjust the grid coordinates of the grid vertices on the target vegetation model according to the first rotation angle and the second rotation angle; and render the vegetation object of the target area based on the adjusted target vegetation model.
[0146] Specific limitations regarding the rendering apparatus for vegetation objects can be found in the above description of the rendering methods for vegetation objects, and will not be repeated here. Each module in the aforementioned vegetation object rendering apparatus can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0147] In some embodiments of this application, the vegetation object rendering apparatus 900 can be implemented as a computer program, which can be implemented in, for example... Figure 10 The computer device shown is running the program. The computer device's memory can store the various program modules that make up the rendering apparatus 900 that constitutes the vegetation object, for example, Figure 9 The configuration acquisition module 910, parameter acquisition module 920, model construction module 930, and object rendering module 940 are shown. The computer program comprised of these modules causes the processor to execute the steps in the vegetation object rendering methods of the various embodiments of this application described in this specification.
[0148] For example, Figure 10 The computer device shown can be used as follows Figure 9The configuration acquisition module 910 in the vegetation object rendering apparatus 900 executes step S110. The computer device can execute step S120 via the parameter acquisition module 920. The computer device can execute step S130 via the model building module 930. The computer device can execute step S140 via the object rendering module 940. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with external computer devices via a network connection. When the computer program is executed by the processor, it implements a method for rendering a vegetation object.
[0149] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0150] In some embodiments of this application, a computer device is provided, including one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor as follows:
[0151] Retrieve the object configuration parameters of the vegetation object;
[0152] Based on pseudo-random functions and object configuration parameters, the vegetation location coordinates and model attribute parameters of vegetation objects within the target area are obtained.
[0153] Generate the target vegetation model based on the model attribute parameters and vegetation location coordinates;
[0154] Render vegetation objects in the target area based on the target vegetation model.
[0155] In some embodiments of this application, when the processor executes the computer program, it also performs the following steps: calculating the position offset based on the pseudo-random function and the spacing value in the object configuration parameters; determining the current position coordinates according to the reference position coordinates in the target area and the position offset; if the current position coordinates are within the vegetation area in the target area, determining the current position coordinates as the vegetation position coordinates of the vegetation object.
[0156] In some embodiments of this application, the spacing value includes a first spacing value in a first direction and a spacing value in a second direction; when the processor executes the computer program, it further implements the following steps: obtaining a first offset in a first direction based on the first spacing value in the pseudo-random function and object configuration parameters; obtaining a second offset in a second direction based on the second spacing value in the pseudo-random function and object configuration parameters.
[0157] In some embodiments of this application, when the processor executes the computer program, it also performs the following steps: determining the model rotation angle parameter of the vegetation object within the model rotation range in the object configuration parameters using a pseudo-random function; and determining the model scaling parameter of the vegetation object within the model scaling range in the object configuration parameters using a pseudo-random function.
[0158] In some embodiments of this application, when the processor executes the computer program, it also performs the following steps: obtaining an initial vegetation model of the vegetation object; adjusting the grid coordinates of the initial vegetation model according to the model attribute parameters and the vegetation location coordinates to obtain the target vegetation model.
[0159] In some embodiments of this application, when the processor executes the computer program, it further implements the following steps: obtaining the reference curvature value corresponding to the grid vertex based on the height value of the grid vertex in the target vegetation model; obtaining the curvature parameter of the grid vertex at different times based on the reference curvature value; updating the grid coordinates of the grid vertex of the target vegetation model at different times based on the curvature parameter at different times; and rendering the vegetation object of the target area based on the updated target vegetation model.
[0160] In some embodiments of this application, when the processor executes the computer program, it further implements the following steps: obtaining the interaction position coordinates of the interactive object, calculating the distance value and direction vector between the interactive object and the vegetation object based on the interaction position coordinates and the vegetation position coordinates; obtaining a first rotation angle based on the direction vector, and obtaining a second rotation angle based on the distance value; adjusting the grid coordinates of the grid vertices on the target vegetation model based on the first rotation angle and the second rotation angle; and rendering the vegetation object of the target area based on the adjusted target vegetation model.
[0161] In some embodiments of this application, a computer-readable storage medium is provided, storing a computer program that is loaded by a processor, causing the processor to perform the following steps:
[0162] Retrieve the object configuration parameters of the vegetation object;
[0163] Based on pseudo-random functions and object configuration parameters, the vegetation location coordinates and model attribute parameters of vegetation objects within the target area are obtained.
[0164] Generate the target vegetation model based on the model attribute parameters and vegetation location coordinates;
[0165] Render vegetation objects in the target area based on the target vegetation model.
[0166] In some embodiments of this application, when the computer program is executed by the processor, it further implements the following steps: calculating the position offset based on the pseudo-random function and the spacing value in the object configuration parameters; determining the current position coordinates according to the reference position coordinates in the target area and the position offset; if the current position coordinates are within the vegetation area in the target area, determining the current position coordinates as the vegetation position coordinates of the vegetation object.
[0167] In some embodiments of this application, the spacing value includes a first interval value in a first direction and an interval value in a second direction; when the computer program is executed by the processor, it further implements the following steps: obtaining a first offset in the first direction based on the first interval value in the pseudo-random function and the object configuration parameters; obtaining a second offset in the second direction based on the second interval value in the pseudo-random function and the object configuration parameters.
[0168] In some embodiments of this application, when the computer program is executed by the processor, it further performs the following steps: determining the model rotation angle parameter of the vegetation object within the model rotation range in the object configuration parameters using a pseudo-random function; and determining the model scaling parameter of the vegetation object within the model scaling range in the object configuration parameters using a pseudo-random function.
[0169] In some embodiments of this application, when the computer program is executed by the processor, it further performs the following steps: obtaining an initial vegetation model of the vegetation object; adjusting the grid coordinates of the initial vegetation model according to the model attribute parameters and the vegetation location coordinates to obtain the target vegetation model.
[0170] In some embodiments of this application, when the computer program is executed by the processor, it further performs the following steps: obtaining the reference curvature value corresponding to the grid vertex based on the height value of the grid vertex in the target vegetation model; obtaining the curvature parameter of the grid vertex at different times based on the reference curvature value; updating the grid coordinates of the grid vertex of the target vegetation model at different times based on the curvature parameter at different times; and rendering the vegetation object of the target area based on the updated target vegetation model.
[0171] In some embodiments of this application, when the computer program is executed by the processor, it further implements the following steps: obtaining the interaction position coordinates of the interactive object; calculating the distance value and direction vector between the interactive object and the vegetation object based on the interaction position coordinates and the vegetation position coordinates; obtaining a first rotation angle based on the direction vector and a second rotation angle based on the distance value; adjusting the grid coordinates of the grid vertices on the target vegetation model based on the first rotation angle and the second rotation angle; and rendering the vegetation object in the target area based on the adjusted target vegetation model.
[0172] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0173] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0174] The above provides a detailed description of the rendering method, apparatus, computer device, and storage medium for a vegetation object provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for rendering vegetation objects, characterized in that, include: Obtain the object configuration parameters of the vegetation object, the object configuration parameters including spacing values, the spacing values including a first interval value in a first direction and a second interval value in a second direction; Based on the pseudo-random function and the object configuration parameters, the model attribute parameters of the vegetation object are obtained, and based on the pseudo-random function and the first interval value in the object configuration parameters, the first offset in the first direction is obtained. Based on the pseudo-random function and the second interval value in the object configuration parameters, obtain the second offset in the second direction; The current position coordinates are determined based on the reference position coordinates within the target area, the first offset, and the second offset. If the current location coordinates are within a vegetation area in the target area, the current location coordinates are determined as the vegetation location coordinates of the vegetation object, wherein the target area is used to limit the retrieval range of the vegetation object, the vegetation area is used to limit the generation range of the vegetation object, and the vegetation area is a preset sub-region in the target area. Obtain the initial vegetation model of the vegetation object; Based on the model attribute parameters and the vegetation location coordinates, adjust the grid coordinates of each grid vertex in the initial vegetation model to obtain the target vegetation model; The vegetation objects of the target area are rendered based on the target vegetation model.
2. The method according to claim 1, characterized in that, The process of obtaining the model attribute parameters of the vegetation object based on the pseudo-random function and the object configuration parameters includes: The pseudo-random function determines the model rotation angle parameter of the vegetation object within the model rotation range in the object configuration parameters. The model scaling parameters of the vegetation object are determined by the pseudo-random function within the model scaling range of the object configuration parameters.
3. The method according to claim 1 or 2, characterized in that, The process of rendering the vegetation object of the target region based on the target vegetation model includes: Based on the height value of the grid vertex in the target vegetation model, obtain the reference curvature value corresponding to the grid vertex; The bending parameters of the mesh vertex at different times are obtained based on the reference bending value; The grid coordinates of the grid vertices of the target vegetation model at different times are updated based on the bending parameters at different times. The vegetation objects of the target region are rendered based on the updated target vegetation model.
4. The method according to claim 1 or 2, characterized in that, The process of rendering the vegetation object of the target region based on the target vegetation model includes: Obtain the interaction position coordinates of the interactive object, and calculate the distance value and direction vector between the interactive object and the vegetation object based on the interaction position coordinates and the vegetation position coordinates; A first rotation angle is obtained based on the direction vector, and a second rotation angle is obtained based on the distance value; Adjust the grid coordinates of the grid vertices on the target vegetation model according to the first rotation angle and the second rotation angle; The vegetation objects of the target region are rendered based on the adjusted target vegetation model.
5. A rendering device for vegetation objects, characterized in that, The device includes: A configuration acquisition module is used to acquire object configuration parameters of vegetation objects. The object configuration parameters include spacing values, which include a first interval value in a first direction and a second interval value in a second direction. The parameter acquisition module is used to obtain model attribute parameters of the vegetation object based on a pseudo-random function and the object configuration parameters, and to obtain a first offset in a first direction based on a first interval value in the pseudo-random function and the object configuration parameters; to obtain a second offset in a second direction based on a second interval value in the pseudo-random function and the object configuration parameters; to determine the current position coordinates based on the reference position coordinates in the target area and the first offset and the second offset; if the current position coordinates are within the vegetation area in the target area, the current position coordinates are determined as the vegetation position coordinates of the vegetation object, wherein the target area is used to limit the retrieval range of the vegetation object, the vegetation area is used to limit the generation range of the vegetation object, and the vegetation area is a preset sub-region in the target area; The model building module is used to obtain the initial vegetation model of the vegetation object; and to adjust the grid coordinates of each grid vertex in the initial vegetation model according to the model attribute parameters and the vegetation location coordinates to obtain the target vegetation model. The object rendering module is used to render vegetation objects in the target area based on the target vegetation model.
6. A computer device, characterized in that, The computer device includes: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the method for rendering vegetation objects according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded by a processor to perform the steps in the method for rendering vegetation objects according to any one of claims 1 to 4.
Citation Information
Patent Citations
Vegetation rendering method and device, storage medium and electronic equipment
CN110838162A
Vegetation object processing method and device, equipment and storage medium
CN112206534A
