Terrain model rendering method and device, electronic equipment and readable storage medium
Patent Information
- Application Number
- CN202310356546.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-30
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2043-03-30
AI Technical Summary
[0004]鉴于上述问题,本申请实施例提出了一种地形模型的渲染方法、装置、电子设备及可读存储介质,以解决相关技术中因地形渲染操作复杂导致的地形渲染的效率低的问题
Smart Images

Figure CN116402932B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, electronic device, and readable storage medium for rendering terrain models. Background Technology
[0002] Terrain is a general term for the various shapes of land features in the game, including plateaus, mountains, plains, hills, basins, etc. Different terrains have different altitudes.
[0003] Currently, the typical method for rendering terrain involves professional artists using sophisticated terrain editing tools to edit the terrain, including creating special features like ridges and depressions. Other models, such as cliffs and roads, are edited in the engine editor and then moved to the appropriate positions for placement. While this method produces accurate and aesthetically pleasing terrain, it requires extensive professional knowledge and skilled operation. Only professionals specializing in scene editing and terrain creation can produce suitable results. Therefore, current terrain rendering methods suffer from complexity, high labor costs, and low rendering efficiency. Summary of the Invention
[0004] In view of the above problems, this application proposes a terrain model rendering method, apparatus, electronic device and readable storage medium to solve the problem of low efficiency of terrain rendering caused by the complexity of terrain rendering operations in related technologies.
[0005] According to one aspect of the embodiments of this application, a method for rendering a terrain model is provided, comprising:
[0006] Obtain the terrain mesh data of the terrain to be rendered; the terrain mesh data includes the terrain mesh of the terrain to be rendered, the grid height corresponding to each grid point of each terrain mesh, and the ground elevation height;
[0007] Based on the grid height corresponding to each grid point of each terrain grid, the object model corresponding to each terrain grid is obtained;
[0008] The object model corresponding to each terrain grid is rendered based on the grid height of each grid point and the ground elevation.
[0009] According to one aspect of the embodiments of this application, a terrain model rendering apparatus is provided, comprising:
[0010] The acquisition module is used to acquire terrain mesh data of the terrain to be rendered; the terrain mesh data includes the terrain mesh of the terrain to be rendered, as well as the grid height and ground elevation height corresponding to each grid point of each terrain mesh.
[0011] The matching module is used to obtain the object model corresponding to each terrain grid based on the grid height corresponding to each grid point of each terrain grid.
[0012] The rendering module renders the object model corresponding to each terrain grid based on the grid height of each grid point and the ground elevation.
[0013] According to one aspect of the embodiments of this application, an electronic device is provided, including: a processor; and a memory storing computer-readable instructions, which, when executed by the processor, implement the terrain model rendering method as described above.
[0014] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which computer-readable instructions are stored, which, when executed by a processor, implement the terrain model rendering method described above.
[0015] In the solution provided in this application, the terrain to be rendered is divided into terrain meshes. Based on the grid height of each grid point in each terrain mesh, the object model of each terrain mesh is determined. Only by adjusting the grid height of the grid points, an object model with natural outline and realistic details can be automatically obtained. The operation is convenient and can improve the efficiency of terrain rendering. Furthermore, rendering the object model based on the ground elevation height and object height can enhance the visual effect of the rendered terrain. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0017] Figure 1 This is a schematic flowchart illustrating a terrain model rendering method according to an embodiment of this application.
[0018] Figure 2 This is a schematic diagram of an object model with different height levels according to an embodiment of this application.
[0019] Figure 3 This is a flowchart illustrating an object model determination method according to an embodiment of this application.
[0020] Figure 4 This is a schematic diagram of a preset object model according to an embodiment of this application.
[0021] Figure 5This is a flowchart illustrating a rendering object model according to an embodiment of this application.
[0022] Figure 6 This is a flowchart illustrating an object model rendering method according to an embodiment of this application.
[0023] Figure 7 This is a schematic diagram of the model vertices of an object model according to an embodiment of this application.
[0024] Figure 8 This is a schematic diagram of a target object model according to an embodiment of this application.
[0025] Figure 9 This is a schematic diagram of the normals of the grid points according to an embodiment of this application.
[0026] Figure 10 This is a block diagram of a terrain model rendering apparatus according to an embodiment of this application.
[0027] Figure 11 A schematic diagram of the structure of an electronic device suitable for implementing embodiments of this application is shown. Detailed Implementation
[0028] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0029] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0030] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0031] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0032] It should be noted that "multiple" in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0033] To facilitate understanding of the technical solution of this application, the rendering method, apparatus, electronic device and computer-readable storage medium of the terrain model provided in this application will be introduced below in combination with actual application scenarios.
[0034] The technical solution of this application will be described in detail below with reference to specific embodiments.
[0035] Figure 1 This is a flowchart illustrating a terrain model rendering method according to an embodiment of this application. This method can be executed by an electronic device with image rendering capabilities, such as a server, smartphone, tablet, personal computer, etc., without specific limitations herein. (Refer to...) Figure 1 The method includes at least steps 210 to 230, which are detailed below:
[0036] Step 210: Obtain the terrain mesh data of the terrain to be rendered.
[0037] The terrain mesh data includes the terrain mesh of the terrain to be rendered, as well as the grid height and ground bulge height corresponding to each grid point of each terrain mesh. Grid height refers to the actual height of each grid point in the virtual scene, and ground bulge height refers to the bulge height of each grid point in each terrain mesh. The bulge height is a smooth representation of terrain elevation, and can be obtained by inputting the grid height of each grid point into a preset quadratic function. There can be multiple terrain meshes for the terrain to be rendered.
[0038] In this embodiment of the application, the grid height and ground elevation height can be pre-stored; the grid height and ground elevation height data can also be input by the user.
[0039] In this embodiment, the terrain to be rendered can be a rectangular area. This area is divided into grids using the horizontal and vertical axes of the world coordinate system. Each grid is large enough to hold one model.
[0040] In this embodiment, the terrain to be rendered is a general term for various landform shapes in a virtual scene, including but not limited to plateaus, mountains, plains, hills, and basins. The terrain to be rendered can be a rectangular area, which is divided into grids along the horizontal and vertical axes of a world coordinate system. Each grid is used as a terrain grid for the terrain to be rendered, and each terrain grid can contain an object model. The object models contained in each terrain grid are combined to form the terrain to be rendered. The object model can be a pre-made 3D model.
[0041] In this embodiment of the application, the terrain to be rendered can be presented by varying its height. The height of each grid point of each terrain grid and the ground elevation can represent the height variation of each grid point of the terrain grid.
[0042] In this embodiment of the application, each terrain grid corresponds to a grid container, which is used to store the object model of the terrain grid corresponding to the grid container. In some implementations, the object model of each terrain grid corresponds to the grid height of each grid point of the terrain grid. That is, when the grid height of the grid point of the terrain grid is changed, the object model in the grid container corresponding to the terrain grid needs to be adjusted accordingly.
[0043] In this embodiment, the grid height and ground elevation of each grid point in each terrain grid can be stored in the form of a two-dimensional array. The subscript of this two-dimensional array corresponds to the horizontal and vertical coordinates of the terrain grid, and the array elements correspond to the grid height and ground elevation of each grid point in the terrain grid. To distinguish between the grid height and ground elevation of each grid point in each terrain grid, a grid height array can be established to store the grid height of each grid point in each terrain grid in the form of a two-dimensional array. Similarly, a ground elevation height array can be established to store the ground elevation of each grid point in each terrain grid in the form of a two-dimensional array.
[0044] Step 220: Obtain the object model corresponding to each terrain grid based on the grid height of each grid point in each terrain grid.
[0045] In this embodiment, an object model for each terrain grid can be constructed based on the grid height corresponding to each grid point. For example, for each terrain grid, a preset model can be obtained, and the grid heights corresponding to each grid point of the terrain grid can be mapped onto the preset model to construct the object model corresponding to that terrain grid. The preset model can be a patch with high point density. By mapping the grid heights corresponding to each grid point of the terrain grid onto the patch, an object model with height is formed, which is the object model corresponding to that terrain grid. Specifically, mapping the grid heights corresponding to each grid point of the terrain grid onto the preset model yields an intermediate model, and mapping the ground elevation heights corresponding to each grid point of the terrain grid onto the intermediate model yields the object model.
[0046] In this embodiment, considering that redrawing the object model every time the terrain mesh is determined would increase performance consumption and reduce rendering efficiency, this application implements the pre-drawing of multiple object models, each object model corresponding to a set of grid height ranges. When it is necessary to adjust or determine the object model of each terrain mesh, the object model that matches the terrain mesh is selected from the multiple object models only according to the grid height of each grid point of the terrain mesh.
[0047] Furthermore, in some embodiments of this application, considering that drawing an object model for each set of grid point heights would result in a large amount of data, to reduce the number of object models, an object model can be drawn for each height difference based on the height differences between the grid points corresponding to each grid point of each terrain grid. When selecting an object model for each terrain grid, the height difference of each terrain grid is determined based on the grid point heights corresponding to each grid point of each terrain grid, and an object model matching each terrain grid is selected from multiple object models based on the height differences of each terrain grid. Here, the height difference characterizes the type of height difference between the grid points of the terrain grid.
[0048] For example, for a square terrain mesh, which includes four grid points, there are four types of height difference: 1) all four grid points have the same height; 2) none of the four grid points have the same height; 3) three of the four grid points have the same height; 4) two of the four grid points have the same height, and the remaining two have different heights. Correspondingly, there are four types of object models: first-order height object model, second-order height object model, third-order height object model, and fourth-order height object model. In the first-order height object model, all four grid points have the same height; in the fourth-order height object model, none of the four grid points have different heights; in the second-order height object model, three of the four grid points have the same height; and in the third-order height object model, two of the four grid points have the same height, and the remaining two have different heights. Figure 2 As shown, Figure 2 Figure (a) shows a second-order height object model. Figure 2 Figure (b) shows a 3rd-order height object model. Figure 2 Figure (c) shows the object model with a fourth-order height. Therefore, for a square terrain grid, a matching object model can be selected from the four object models based on the grid height corresponding to each grid point of the terrain grid.
[0049] Step 230: Render the object model corresponding to each terrain grid according to the grid height and ground elevation of each grid point.
[0050] In this embodiment of the application, for each terrain grid, the grid height and ground elevation of each grid point of the terrain grid are projected onto the object model corresponding to the terrain grid to obtain the target object model, and the target object model is rendered by a shader.
[0051] In this embodiment, the grid height and ground elevation of each grid point of each terrain grid can also be passed to the GPU. The GPU calls the shader to render the object model corresponding to each terrain grid based on the grid height and ground elevation of each grid point of each terrain grid.
[0052] In some embodiments, during the rendering process, in order to enable the GPU to better save terrain data and generate terrain with better visual effects without relying on a quadtree, this application embodiment generates a terrain map based on the grid height and ground elevation of each grid point of each terrain grid, and saves the terrain data in the form of a terrain map. Optionally, the terrain map can be a two-dimensional array, where the subscript of the two-dimensional array corresponds to the horizontal and vertical coordinates of the terrain grid, and the array element values correspond to the grid height and ground elevation of each grid point of the terrain grid. Therefore, each value in the terrain map can be converted into the three-dimensional coordinates of each grid point of the terrain grid. Optionally, different grayscale values are used in the terrain map to represent the grid height and ground elevation of each grid point of different terrain grids.
[0053] Specifically, the method for generating topographic maps includes steps a1 to a2:
[0054] Step a1: Create a blank graph.
[0055] In this design, the number of pixels in the blank image is the same as the number of terrain grids in the terrain to be rendered, and the size of the blank image is the same as the size of the terrain to be rendered. The arrangement of pixels in the blank image is the same as the sorting of terrain grids in the terrain to be rendered; that is, each terrain grid in the terrain to be rendered corresponds to a unique pixel in the blank image. For example, if the terrain to be rendered includes 9 terrain grids, with 3 on the horizontal axis and 3 on the vertical axis, then the number of pixels in the created blank image is 3*3. Starting from the starting point of the terrain to be rendered, the first terrain grid in the first row on the horizontal axis corresponds to the pixel with image coordinates (0, 0) in the blank image, the second terrain grid in the first row on the horizontal axis corresponds to the pixel with image coordinates (1, 0) in the blank image, and the first terrain grid in the first row on the horizontal axis corresponds to the pixel with image coordinates (2, 0) in the blank image.
[0056] Step a2: Sequentially write the grid height and ground elevation of each grid point of each terrain grid into the color channel of the corresponding pixel in the blank map to obtain the terrain map.
[0057] Optionally, step a2 includes: for each terrain grid, writing the grid heights corresponding to the top left, top right, bottom right, and bottom left grid points of the terrain grid, as well as the ground elevation height, into the red, green, blue, and alpha channels of the corresponding pixels in the blank image in sequence. That is, the grid heights corresponding to the top left, top right, bottom right, and bottom left grid points of the terrain grid, as well as the ground elevation height, are respectively used as the values of the red, green, blue, and alpha channels of the corresponding pixels in the blank image.
[0058] Optionally, to distinguish between grid point height and ground elevation, the topographic map includes a ground elevation map and a grid point height map. A grid point height map can be generated based on the grid point height corresponding to the topographic grid, and a ground elevation map can be generated based on the ground elevation corresponding to the topographic grid. Specifically, a grid point height map is generated according to steps a1 to a2 based on the grid point height corresponding to each grid point of each topographic grid, and a ground elevation map is generated according to steps a1 to a2 based on the ground elevation corresponding to each grid point of each topographic grid.
[0059] Optionally, when rendering, the GPU can obtain the grid height and ground elevation height of each grid point of each terrain grid according to the grid height map and ground elevation map of the terrain to be rendered. For the object model corresponding to each terrain grid, the grid height and ground elevation height of the terrain grid corresponding to the object model are mapped onto the object model to obtain the target object model. The target object model is then rendered through a shader.
[0060] In this context, a shader can be a Unity shader, a code snippet executed on the graphics card to represent the effect of light on the surface of a target object model. In practical applications, shaders can be written to achieve the desired surface texture in a virtual scene. As a concrete example, for common objects such as metal, stone, and plastic, the surface texture of the target object model can be abstracted into different parameters. The shader then uses these parameters to render the target object model in the virtual scene, thus achieving the corresponding surface texture. Specifically, parameters can include surface color, metallicity, and roughness. Surface color expresses the color distribution of the target object model, metallicity expresses the conductivity of the target object model's surface, and roughness expresses whether the target object model's surface is smooth or rough. In Unity, surface color can be recorded using a color map, metallicity using a metallicity map, and roughness using a roughness map.
[0061] Optionally, during rendering, the GPU can extract the grid height and ground elevation height corresponding to each grid point of each terrain mesh from the color channels of the pixels in the grid height map and ground elevation map of the terrain to be rendered. Understandably, each terrain mesh in the terrain to be rendered corresponds to one pixel in the grid height map, and the color channel of this pixel stores the grid height corresponding to each grid point of the corresponding terrain mesh; similarly, each terrain mesh in the terrain to be rendered corresponds to one pixel in the ground elevation map, and the color channel of this pixel stores the ground elevation height corresponding to each grid point of the corresponding ground elevation map, and the color channel of this pixel stores the ground elevation height of the corresponding ground elevation map. Each terrain mesh consists of four grid points. The color channels include a red channel, a green channel, a blue channel, and an alpha channel.
[0062] Optionally, during rendering, the GPU can convert the grayscale value of each pixel in the grid height map and ground height map of the terrain to be rendered into the corresponding grid height and ground elevation height of each grid point in the terrain grid, using preset rules. The preset rules can be conversion rules set according to actual needs, such as 1 grayscale value representing 1 meter, meaning a point with a grayscale value of 50 in the grid height map and ground height map is a point with a height of 50 meters. Of course, the preset rules can also be other rules, such as 1 grayscale value representing 10 meters, 20 meters, etc., and this application does not specifically limit this.
[0063] The terrain model rendering method provided in this application divides the terrain to be rendered into a terrain grid. Based on the grid height of each grid point in each terrain grid, the object model of each terrain grid is determined. Only the grid height of the grid points needs to be adjusted to automatically obtain an object model with natural outline and realistic details, which can improve the efficiency of terrain rendering. Furthermore, rendering the object model based on the grid height of each grid point in the terrain grid and the ground elevation can improve the visual effect of the rendered terrain.
[0064] In some embodiments, during terrain model rendering, a two-dimensional terrain array can be established to facilitate the storage and retrieval of grid point heights and ground elevation heights. In this array, the index value of each element is used to locate different terrain grids (x, y), and each element stores the grid point height and ground elevation height of each terrain grid. Specifically, in the terrain grid (x, y), x indicates the position of the terrain grid on the horizontal axis of the terrain to be rendered, and y indicates the position of the terrain grid on the vertical axis. For example, (1, 1) represents the first terrain grid in the first row of terrain grids on the horizontal axis, starting from the starting point of the terrain to be rendered.
[0065] Optionally, the terrain array includes a first terrain array and a second terrain array. In the first terrain array, the index of each element is used to locate different terrain grids (x, y), and the element stores the grid height of each terrain grid. In the second terrain array, the index of each element is used to locate different terrain grids (x, y), and the element stores the ground elevation of each terrain grid. For example, the grid heights {g1, g2, g3, g4} corresponding to the top-left, top-right, bottom-right, and bottom-left grids of the terrain grid at position (1, 1) in the terrain to be rendered are assigned to the element with index (1, 1) in the first terrain array.
[0066] In some embodiments of this application, to improve rendering efficiency and provide a more convenient method for determining object models, embodiments of this application generate height codes based on the grid heights corresponding to each grid point of each terrain grid, and obtain object models matching the height codes from a preset dictionary. The preset dictionary includes multiple pre-made preset object models and a preset height code for each preset object model. The height code can be obtained based on the height levels corresponding to each grid point of the terrain grid. Specifically, as... Figure 3 As shown, Figure 3 This is a flowchart illustrating the object model determination method provided in an embodiment of this application. The object model determination method shown includes steps 221 to 223:
[0067] Step 221: For each terrain grid, determine the height level corresponding to each grid point of the terrain grid based on the grid point height corresponding to each grid point of the terrain grid.
[0068] The height level characterizes the type of height difference among the grid points of the terrain grid, including first-order height, second-order height, third-order height, and fourth-order height. First-order height indicates that the height of each grid point in the terrain grid is uniform; fourth-order height indicates that the height of each grid point in the terrain grid is not uniform; third-order height indicates that there are three different heights among the grid points in the terrain grid; and second-order height indicates that there are two different heights among the four grid points in the terrain grid. In some embodiments, the height level corresponding to each grid point of the terrain grid can be represented numerically, for example, 0 for first-order height, 1 for second-order height, 2 for third-order height, and 3 for fourth-order height.
[0069] Understandably, when a grid point in a terrain grid corresponds to a fourth-order height, the height of each grid point in that terrain grid is different. When the maximum height level corresponding to each grid point in a terrain grid is the third-order height, the heights of two grid points in that terrain grid are the same. When the maximum height level corresponding to each grid point in a terrain grid is the second-order height, the heights of three grid points in that terrain grid are the same. When the height levels corresponding to all grid points in a terrain grid are the first-order height, the heights of all grid points in that terrain grid are the same.
[0070] In some embodiments, step 221 includes steps b1 to b3:
[0071] Step b1: Determine the target height value of each grid point in the terrain grid based on the grid height corresponding to each grid point.
[0072] To facilitate the generation of height codes, the target height of a grid point can be obtained based on the difference between the minimum grid point height and the grid point heights of all grid points in the terrain grid. This ensures that the target height of each grid point is a natural number greater than or equal to 0. Specifically, step b1 includes:
[0073] (1) Determine the minimum grid height of the terrain grid based on the grid height corresponding to each grid point.
[0074] (2) The target height of each grid point of the terrain grid is obtained based on the difference between the grid height of each grid point and the minimum grid height.
[0075] Step b2: Sort the target heights of each grid point in the terrain grid to obtain the sorting results of the target heights of each grid point in the terrain grid.
[0076] Optionally, the smallest non-repeating target height can be selected from the target height values of each grid point in the terrain grid each time to obtain the sorting result of the target heights of each grid point in the terrain grid. Specifically, the sorting method in step b2 includes:
[0077] (1) Obtain the historical target height stored in the preset first array, and obtain the first target height with the smallest target height value outside the preset first array from the target height of each grid point of the terrain grid; the historical target height stored in the first array is determined from the target height of each grid point of the terrain grid.
[0078] (2) Compare the historical target height with the first target height.
[0079] (3) If the height of the historical target is the same as the height of the first target, then discard the height of the first target.
[0080] (4) If the historical target height is different from the first target height, the first target height is written into the preset first array to obtain the updated preset first array.
[0081] Traverse the target height of each grid point in the terrain grid, and sort the target height of each grid point in the terrain grid according to the sorting method described above to obtain the sorting result of the target height of each grid point in the terrain grid.
[0082] Optionally, the sorted results of the target heights of each grid point in the terrain grid can be stored in an array. Specifically, a new array named "min" is created. Starting from the first position of the "min" array, all elements are selected, and the target height value with the smallest target height among all grid points in the terrain grid is assigned to that position. Then, the second position of the "min" array is selected, and the target height value with the smallest target height among the remaining grid points in the terrain grid is assigned to the second position. This process is repeated until all grid points in the terrain grid have been traversed, and the sorted results of the target heights of each grid point in the terrain grid are obtained.
[0083] Step b3: Based on the sorting results of the target heights of each grid point in the terrain grid, obtain the height level corresponding to each grid point in the terrain grid.
[0084] The number of target heights in the sorting results is the number of height levels corresponding to each grid point of the terrain grid.
[0085] Optionally, when the number of target heights in the sorting results is 1, the height level corresponding to each grid point of the terrain grid is the first-order height.
[0086] Optionally, when the number of target heights in the sorting result is not 1, the target heights of each grid point of the terrain grid can be compared with the target heights in the sorting result. Based on the comparison result, the height level corresponding to each grid point of the terrain grid is obtained. Specifically, the target height of each grid point of the terrain grid is compared with the target heights in the sorting result in turn. Based on the comparison result, the sequential position of the target heights that are the same as the target height of each grid point in the sorting result is obtained. Based on the sequential position, the height level corresponding to each grid point of the terrain grid is obtained. For example, when the sorting result is {0, 22} and the target heights of each grid point of the terrain grid are 0, 0, 22, 0 in sequence, then the height levels corresponding to each grid point of the terrain grid are determined to be first-order height, first-order height, second-order height, and first-order height, respectively. That is, the height levels corresponding to each grid point of the terrain grid are {0010}.
[0087] Optionally, for each terrain grid, an array can be created to store the height levels corresponding to each grid point of the terrain grid. Specifically, a new cellHeight array {0000} is created. Starting from the first position of the min array obtained in step b2 above, the target heights of the four grid points of the terrain grid are traversed. If the target height of a grid point is the same as the corresponding height in the min array, the cellHeight value at this position is 0. The target heights of the remaining grid points are traversed. If the target height is the same as the corresponding height at the second position in the min array, the cellHeight value at this position is 1. This process is repeated until all grid points of the terrain grid have been traversed, and the height levels corresponding to each grid point of the terrain grid are obtained.
[0088] Step 222: Encode the height level corresponding to each grid point of the terrain grid to obtain the height code of the terrain grid.
[0089] In some embodiments, the height level corresponding to each grid point of the terrain grid can be encoded using a preset encoding method to obtain the height code of the terrain grid. The preset encoding method can be a number base conversion, hash encoding, etc., and this embodiment does not specifically limit its use.
[0090] Step 223: Based on the height encoding of the terrain grid and the preset dictionary, obtain the object model that matches the terrain grid.
[0091] The preset dictionary includes multiple preset height codes and a preset object model corresponding to each height code.
[0092] Specifically, based on the height code of the terrain grid, a target preset height code that matches the height code of the terrain grid can be found from a preset dictionary. The preset object model corresponding to the target preset height code is set as the object model that matches the terrain grid, and the object model that matches the terrain grid is written into the grid container corresponding to the terrain grid.
[0093] In some embodiments, considering that drawing a corresponding preset object model for each preset height encoding might lead to redundancy in the preset dictionary, and that preset object models with different preset height encodings are transformed through translation or rotation, for example, such as... Figure 4 As shown, where, Figure 4 Figure (a) shows a preset object model with a preset height code of 0100. Figure 4 The preset height code for the preset object model shown in Figure (b) is 0010. Figure 4 The preset object model shown in Figure (b) can be used to... Figure 4The preset object model shown in (a) is obtained by rotating the preset object model 90 degrees clockwise along the vertical axis. Therefore, for a preset object model that can be converted by rotating the preset object model, a preset object model with a preset height code can be drawn, and the rotation angle between the preset object model with the preset height code and other convertible preset object models can be determined. This can reduce the number of preset object models drawn. That is, the preset dictionary includes multiple preset height codes, as well as the preset object model corresponding to each preset height code or the rotation angle and preset object model corresponding to each preset height code.
[0094] In step 223, an initial object model matching the terrain grid can be obtained based on the height encoding of the terrain grid and a preset dictionary. If there is a rotation angle between the preset dictionary and the initial object model matching the height encoding, the initial object model is rotated according to the rotation angle to obtain the object model. If there is no rotation angle between the preset dictionary and the initial object model matching the height encoding, the initial object model is set as the object model.
[0095] In some embodiments of this application, after determining the object model corresponding to each terrain grid, the grid height map and ground height map of the terrain to be rendered, generated according to steps a1-a2 based on the grid height of each grid point and the ground elevation height of each terrain grid, are passed to the GPU. The GPU is then invoked to render each object model based on the terrain map of the terrain to be rendered. Specifically, taking a terrain map that includes a grid height map and a ground height map as an example, such as... Figure 5 As shown, step 230 includes at least:
[0096] Step 231: For each object model, based on the position information of the preset anchor points of the object model, the position information of the starting point of the terrain to be rendered, and the size of the terrain to be rendered, obtain the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered.
[0097] The preset anchor point is the origin of the object model, and the position information of the preset anchor point of the object model is the world coordinates of the preset anchor point of the object model.
[0098] Furthermore, in some embodiments, the grid height and ground elevation of each grid point of the terrain mesh corresponding to the object model can be obtained by sampling the grid height map and ground elevation map based on the position information of the preset anchor points of the object model. Specifically, the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered is obtained based on the position information of the preset anchor points of the object model and the size of the terrain to be rendered. Based on the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered, a first target pixel point whose pixel position in the grid height map matches the target position information is determined, and a second target pixel point whose pixel position in the ground elevation map matches the target position information is determined. The grid height of each grid point of the terrain mesh corresponding to the object model is extracted from the color channel of the first target pixel point, and the ground elevation of each grid point of the terrain mesh corresponding to the object model is extracted from the color channel of the second target pixel point.
[0099] Optionally, the terrain mesh of the terrain to be rendered corresponds one-to-one with the pixels in the grid height map and the pixels in the ground height map. The color channel of each pixel in the grid height map is used to store the grid height of each grid point of the corresponding terrain mesh, and the color channel of each pixel in the ground height map is used to store the ground elevation height of each grid point of the corresponding terrain mesh. Therefore, based on the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered, the first target pixel whose pixel position in the grid height map matches the target position information, and the second target pixel whose pixel position in the ground height map matches the target position information, can be determined. The grid height of each grid point of the terrain mesh corresponding to the object model can be extracted from the color channel of the first target pixel, and the ground elevation height of each grid point of the terrain mesh corresponding to the object model can be extracted from the color channel of the second target pixel.
[0100] Specifically, the method for determining grid height and ground uplift height based on grid height maps and ground height maps includes steps c1 to c2:
[0101] Step c1: For each object model, based on the position information of the preset anchor points of the object model, the position information of the starting point of the terrain to be rendered, and the size of the terrain to be rendered, obtain the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered.
[0102] Step c2: Based on the target location information, obtain the grid height of each grid point of the terrain grid corresponding to the object model from the grid height map, and obtain the ground elevation height of each grid point of the terrain grid corresponding to the object model from the ground height map.
[0103] The location information of the starting point of the terrain to be rendered refers to the world coordinates of the starting point of the terrain in the world coordinate system. Optionally, the world coordinate system can be established with the center point of the terrain as the origin, or it can be established with the starting point of the terrain as the origin. The starting point can be a corner point of the terrain; for example, when the terrain is rectangular, the starting point can be the lower left corner. Optionally, the size of the terrain to be rendered includes the length and width; optionally, the size of the terrain to be rendered includes the number of terrain grids on the horizontal axis and the number of terrain grids on the vertical axis.
[0104] Furthermore, in some embodiments, the target location information includes first target location information and second target location information, wherein the first target location information is used to obtain the first target pixel corresponding to the terrain grid of the object model from the grid height map, and the second target location information is used to obtain the second target pixel corresponding to the terrain grid of the object model from the ground height map.
[0105] Optionally, the first target position information of the terrain mesh corresponding to the object model in the terrain to be rendered can be obtained based on the position information of the preset anchor point of the object model, the position information of the starting point of the terrain to be rendered, and the size of the terrain to be rendered. For example, for any object model, obtain the position information of the preset anchor point WorldPos1 of the object model, the position information of the starting point of the terrain to be rendered TerrainOffset, and the length and width TerrainSize of the terrain to be rendered, and obtain the first target position information of the terrain mesh corresponding to the object model in the terrain to be rendered by (WorldPos1-TerrainOffset) / TerrainSize.
[0106] Optionally, considering that the ground elevation of each vertex in the object model is different, the determination of the second target position information also needs to consider the position information of the model vertices of the object model and the size of the terrain mesh. The position information of the model vertices of the object model consists of their world coordinates in the x and y directions in the world coordinate system, and the size of the terrain mesh is its length and width. Based on the position information of the model vertices of the object model, the position information of the starting point of the terrain to be rendered, the size of the terrain mesh, and the size of the terrain to be rendered, the second target position information of the terrain mesh corresponding to the object model in the terrain to be rendered is obtained. For example, based on the position information of the model vertices of the object model (WorldPos2), the position information of the starting point of the terrain to be rendered (TerrainOffset), the number of terrain meshes in the horizontal axis and the number of terrain meshes in the vertical axis (TerrainCellCount), and the size of the terrain mesh (TerrainCellSize), the second target position information of the terrain mesh corresponding to the object model in the terrain to be rendered is obtained by using floor((WorldPos1-TerrainOffset) / TerrainCellSize) / TerrainCellCount. Where floor represents the floor function, which rounds down.
[0107] Optionally, the position information of the model vertices of the object model can be obtained from the model vertex data of the object model. The model vertex data of the object model includes, but is not limited to, the position information, height information, color information, rendering type, and material type of each vertex of the object model. Optionally, the grid height of each grid point of the terrain mesh corresponding to the object model can be obtained from the grid height map based on the first target position information of the terrain mesh corresponding to the object model in the terrain to be rendered. Based on the grid height of each grid point of the terrain mesh corresponding to the object model, each vertex of the object model is stretched in the y-axis direction of the world coordinate system. Based on the world coordinate values of the vertices in the x-direction and y-direction of the stretched object model, the position information of the model vertices of the object model is obtained.
[0108] Step 232: Based on the target location information, obtain the grid height of each grid point of the terrain grid corresponding to the object model from the grid height map, and obtain the ground elevation height of each grid point of the terrain grid corresponding to the object model from the ground height map.
[0109] Step 233: Based on the grid height of each grid point of the terrain grid corresponding to the object model, obtain the vertex height of the model vertex of the object model; and based on the ground elevation height of each grid point of the terrain grid corresponding to the object model, obtain the ground elevation height of the model vertex of the object model.
[0110] Step 234: Render the object model based on the ground elevation height and vertex height of the model vertices.
[0111] Furthermore, in some embodiments, for each object model, the object model is rendered according to the vertex height of the model vertices and the ground ridge height, based on the vertex renderer.
[0112] The vertex height of a model vertex refers to the height that a model vertex needs to move from its current position to a preset position.
[0113] Furthermore, in some embodiments, the vertex height of the model vertices of the object model can be determined based on the grid height of each grid point of the terrain mesh corresponding to the object model, the height level corresponding to each grid point of the terrain mesh corresponding to the object model, and the vertex height level of the model vertices of the object model. Specifically, the method for determining the vertex height of the model vertices of the object model includes:
[0114] (1) Determine the height level of each grid point of the terrain grid corresponding to the object model based on the grid height of each grid point of the terrain grid corresponding to the object model.
[0115] (2) Based on the vertex height level of the model vertex corresponding to the object model, determine the target height level that matches the vertex height level.
[0116] (3) Determine the vertex height of the model vertex corresponding to the object model based on the grid height of each grid point corresponding to the target height level.
[0117] This allows us to obtain the height of each model vertex in the object model and the minimum grid height of each grid point in the terrain mesh corresponding to the object model. By subtracting the minimum grid height from the height of each model vertex in the object model, we can obtain the vertex height level of each model vertex.
[0118] Optionally, the maximum grid height among the grid heights of the terrain mesh corresponding to the object model can be determined based on the grid heights of each grid point of the terrain mesh corresponding to the object model, and the height level corresponding to each grid point of the terrain mesh corresponding to the object model can be determined. Based on the vertex height level of the model vertex corresponding to the object model, the target height level matching the vertex height level can be determined. Based on the grid heights of each grid point corresponding to the target height level and the height of the model vertex, the height of the model vertex from the target height level can be obtained. Based on the height of the model vertex from the target height level and the maximum grid height, the vertex height of the model vertex corresponding to the object model can be obtained.
[0119] Optionally, based on the grid heights of each grid point in the terrain mesh corresponding to the object model, the maximum and minimum grid heights can be obtained, and the height level corresponding to each grid point in the terrain mesh corresponding to the object model can be determined. The number of height levels corresponding to each grid point in the terrain mesh corresponding to the object model can be determined. If the number of levels is equal to 2, a first preset height level threshold is determined. Based on the vertex height levels of the model vertices corresponding to the object model, a first target vertex with a vertex height level greater than the first preset height level threshold and a second target vertex with a vertex height level less than or equal to the first preset height level threshold are selected. Based on the vertex height level of the first target vertex, a target height level matching the vertex height level is determined. Based on the grid heights of each grid point corresponding to the target height level and the first target vertex, the height of the first target vertex from the target height level is obtained. Based on the height of the first target vertex from the target height level and the maximum grid height, the vertex height of the first target vertex corresponding to the object model is obtained, and the minimum grid height is determined as the vertex height of the second target vertex.
[0120] For example, when the number of height levels is equal to 2, meaning there are three grid points with the same height in the terrain mesh, indicating that the object model is a second-order model, the first preset height level threshold is set to 1.5. Then, the first target vertex with a height level greater than 1.5 is selected from the model vertices of the object model. Figure 7 In the block diagram, the selected model vertex is determined to be the second-order height, which matches the vertex height level. The model height of the second-order height is 2. Based on the height of the first target vertex, local_height1, the height of the first target vertex from the target height level is obtained by subtracting local_height1 from 2. Based on the maximum grid height, max_height, the vertex height of the first target vertex corresponding to the object model is obtained by subtracting max_height2 from local_height1. The minimum grid height, min_height, is determined as the vertex height of the second target vertex whose vertex height level is less than or equal to 1.5.
[0121] Here, model height represents the height value of the model vertices at each height level in the object model. For example, for a 2-level object model, its first-level model height is 0, and its second-level model height is 2; for a 3-level object model, its first-level model height is 0, its second-level model height is 2, and its third-level model height is 4; for a 4-level object model, its first-level model height is 0, its second-level model height is 2, its third-level model height is 4, and its fourth-level model height is 6. This is understandable, as... Figure 2As shown, the height values of model vertices are the same in each level of the object model. Therefore, in the rendering of the object model, it is necessary to determine the vertex height of each model vertex in the object model according to the vertex height determination method of the above model vertex, based on the height of each grid point of the terrain mesh, and stretch the object model based on the vertex height.
[0122] Optionally, if the number of levels is greater than 2, multiple height level thresholds are obtained. Based on the multiple height level thresholds and the vertex height levels of the model vertices of the object model, the model vertices of the object model are grouped to obtain multiple model vertex groups. The target height level that matches each model vertex group is determined. For each model vertex group, the vertex height of each model vertex in each model vertex group is obtained based on the grid height corresponding to the target height level that matches the model vertex group, the preset height, and the height of each model vertex in the model vertex group.
[0123] For example, when the number of levels is 3, such as Figure 2As shown in Figure (b), the object model includes three different height levels, i.e., the object model is a third-order model. The first preset height level threshold is determined to be 1.5, the second preset height level threshold is 3.5, the third target vertex with a vertex height level greater than 3.5 is selected from the model vertices of the object model, the first target vertex with a vertex height level less than or equal to 3.5 and a vertex height greater than 1.5 is selected from the model vertices of the object model, and the second target vertex with a vertex height level less than or equal to 1.5 is selected from the model vertices of the object model. For the third target vertex, the height level of the third target vertex that matches the vertex height level of the third target vertex is determined as the third-order height. The model height of the third-order height is 4. Based on the height of the third target vertex, local_height2, the height between the third target vertex and the third target height level is obtained by subtracting local_height2 from 4. Based on the height between the third target vertex and the third target height level and the maximum grid height, max_height, the vertex height of the third target vertex is obtained by subtracting 4-local_height2 from max_height. For the first target vertex, the target height level that matches the vertex height level is determined as the second-order height. The model height of the second-order height is 2. Based on the height of the first target vertex, local_height1, the height of the first target vertex from the target height level is obtained by subtracting local_height1 from 2. Based on the second largest grid height, middle_height, the vertex height of the first target vertex corresponding to the object model is obtained by subtracting 2-local_height1 from middle_height. The minimum grid height, min_height, is determined as the vertex height of the second target vertex whose vertex height level is less than or equal to 1.5.
[0124] For example, when the number of levels is 4, such as Figure 2As shown in Figure (c), the object model includes four different height levels, i.e., the object model is a fourth-order model. The first preset height level threshold is determined to be 1.5, the second preset height level threshold is 3.5, and the third preset height level threshold is 5.5. For the fourth target vertex with a vertex height level greater than 5.5, the fourth target height level that matches the vertex height level of the fourth target vertex is determined to be the fourth-order height, where the model height of the fourth-order height is 6. Based on the height of the fourth target vertex local_height3, the height between the fourth target vertex and the fourth target height level is obtained by max_height-6. Based on the maximum grid point height max_height and the height between the fourth target vertex and the fourth target height level, the vertex height of the fourth target vertex is obtained by max_height-6-local_height3. For the third target vertex with a vertex height level less than or equal to 5.5 but greater than 3.5, the third target height level that matches the vertex height level of the third target vertex is determined to be the third-order height, where the model height of the third-order height is 4. Based on the height of the third target vertex local_h For example, using `eight2`, the height between the third target vertex and the third target height level is obtained by subtracting `4-local_height2`. Based on the height between the third target vertex and the third target height level, and the height of the second largest grid point `middle_height0`, the vertex height of the third target vertex is obtained by subtracting `4-local_height2` from `middle_height0`. For the first target vertex with a height level less than or equal to 3.5 but greater than 1.5, the target height level matching the vertex height level is determined as the second-order height, where the model height of the second-order height is 2. Based on the height of the first target vertex `local_height1`, the height of the first target vertex from the target height level is obtained by subtracting `2-local_height1` from `2-local_height1`. Based on the height of the third largest grid point `middle_height1`, the vertex height of the first target vertex corresponding to the object model is obtained by subtracting `2-local_height1` from `middle_height1`. For the second target vertex with a height level less than or equal to 1.5, the minimum grid point height `min_height` is determined as the vertex height of the second target vertex.
[0125] Furthermore, in some embodiments, in step 233, the relative position of the model vertex of the object model in the terrain grid can be obtained based on the ground elevation height corresponding to each grid point of the terrain grid and the position information of the model vertex of the object model. The ground elevation height of the model vertex of the object model can be obtained based on the relative position of the model vertex in the terrain grid and the ground elevation height corresponding to each grid point of the terrain grid. Specifically, as shown... Figure 6 As shown, step 233 includes at least steps 2331 to 2332:
[0126] Step 2331: Based on the position information of the model vertices, the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered, the size of the terrain to be rendered, the position information of the starting point, and the size of the terrain mesh corresponding to the object model, obtain the relative position of the model vertices of the object model in the terrain mesh corresponding to the object model.
[0127] The relative position of the grid refers to the relative position of the model vertices of the object model within the terrain grid corresponding to the object model.
[0128] In some embodiments, the relative position of the model vertex in the terrain mesh corresponding to the object model can be obtained by WorldPos2, the second target position information UV of the terrain mesh corresponding to the object model in the terrain to be rendered, the size of the terrain to be rendered TerrainCellCount, the position information TerrainOffset of the starting point, and the size TerrainCellSize of the terrain mesh corresponding to the object model, through WorldPos-TerrainOffset-UV*TerrainCellCount*TerrainCellSize.
[0129] Step 2332: Based on the relative position of the grid and the ground elevation height of each grid point of the terrain grid corresponding to the object model, obtain the ground elevation height of the model vertex.
[0130] Furthermore, in some embodiments, the ground elevation height of each grid point of the terrain grid corresponding to the object model can be linearly interpolated based on the relative grid positions to obtain the ground elevation height of the model vertex. For example, taking the ground elevation heights of the top-left, top-right, bottom-left, and bottom-right grid points of the terrain grid corresponding to the object model as height0, height1, height2, and height3 respectively, and the relative grid position as LocalPos, a linear interpolation can be performed based on height0, height1, height2, height3, and LocalPos to obtain the first initial ground elevation height and the second initial ground elevation height of the model vertex. A second linear interpolation can then be performed based on the first and second initial ground elevation heights of the model vertex to obtain the final ground elevation height of the model vertex. For example, the first initial ground elevation height d0 of the model vertex can be obtained by height0*(1-LocalPos.x)+height1*LocalPos.x, the second initial ground elevation height d1 of the model vertex can be obtained by height2*(1-LocalPos.x)+height3*LocalPos.x, and the ground elevation height of the model vertex can be obtained by d0*(1-LocalPos.y)+d1*LocalPos.y.
[0131] Furthermore, in some embodiments, after obtaining the vertex heights and ground elevations of the object model's vertices, the object model's vertices are stretched according to their heights to obtain an intermediate object model. The vertex heights of the intermediate object model's vertices are then adjusted according to their ground elevations to obtain the target object model. Figure 8 As shown, Figure 8 This is a schematic diagram of the target object model provided in the embodiments of this application. The target object model information is rendered by the vertex shader according to the preset color map.
[0132] Furthermore, in some embodiments, to enhance the detailed features of the rendered terrain and ensure its visual effect, it is necessary to adjust the normals of the object model. This adjustment is performed based on a preset normal map and a preset color map before rendering. The normal map is a special texture that can be applied to 3D surfaces, giving each pixel on each plane of the rendered terrain more surface information, thus creating a more dimensional visual effect on the surface of the rendered terrain. Specifically, the normal map can record the difference in surface normal directions between low-polygon and high-polygon models. Later, the shader uses the normal map to process the direction of light reflection, creating an illusion for the viewer and thereby increasing the detail of the low-polygon model's surface.
[0133] Specifically, step 234 includes steps d1 to d5:
[0134] Step d1: Determine the normal direction of each grid point of the terrain mesh corresponding to the object model.
[0135] For each grid point of the terrain mesh corresponding to the object model, the normal direction of that grid point can be obtained by determining the normal direction of the triangular face adjacent to the grid point. For example, the top-left grid point of the terrain mesh corresponding to the object model will be used as an example. Figure 9 As shown, when the position information of the grid point is P0, and the position information of the adjacent grid points are P1, P2, P3, and P4 respectively, the vector V0 above the grid point is obtained by subtracting P1 from P0, the vector V1 to the left of the grid point is obtained by subtracting P4 from P0, the vector V2 below the grid point is obtained by subtracting P3 from P0, and the vector V3 to the right of the grid point is obtained by subtracting P2 from P0. Then, the vectors are obtained using cross(V0,V1), cross(V1,V2), and cross(V0,V1), cross(V1,V2), and cross(V0,V1), cross(V1,V2), and cross(V0,V1), cross(V1,V2), cross(V0,V1), cross(V1,V2), cross(V1 ... oss(V2,V3) and cross(V3,V4) obtain the normals N0, N1, N2, and N3 of the triangular faces adjacent to the grid point at the top left, bottom left, bottom right, and top right, respectively. Based on the normals N0, N1, N2, and N3 of the triangular faces adjacent to the grid point at the top left, bottom left, bottom right, and top right, normalize them using normalize(0.25*(N0+N1+N2+N3)) to obtain the normal direction of the grid point.
[0136] Step d2: Perform linear interpolation on the normal direction based on the relative position of the mesh to obtain the vertex normal direction of the model vertex of the object model.
[0137] In some implementations, the normal directions of each grid point of the terrain grid can be linearly interpolated once based on the relative positions of the grids to obtain the first initial vertex normal direction and the second initial vertex normal direction of the model vertex. Then, the first initial vertex normal direction and the second initial vertex normal direction of the model vertex can be linearly interpolated again to obtain the vertex normal direction of the model vertex of the object model. For example, taking normal0, normal1, normal2, and normal3 as the normal directions of the grid points corresponding to the top left, top right, bottom left, and bottom right corners of the terrain grid corresponding to the object model, and the relative grid positions as (LocalPos.x, LocalPos.y), we can illustrate the process by using normal0*(1-LocalPos.x)+normal1*LocalPos.x to obtain the first initial vertex normal direction n1, and normal2*(1-LocalPos.x)+normal3*LocalPos.x to obtain the second initial vertex normal direction n2. Based on the first initial vertex normal direction n1 and the second initial vertex normal direction n2, we can obtain the vertex normal direction of the model vertex of the object model by using n0*(1-LocalPos.y)+n1*LocalPos.y.
[0138] Step d3: Based on the vertex normal direction of the object model's vertices, obtain the offset data of the object model's vertices relative to the vertex normal direction.
[0139] Furthermore, in some embodiments, the vertex height of the model vertex and the vertex normal direction of the object model vertex can be multiplied by a preset control coefficient to obtain the offset data of the object model vertex relative to the vertex normal direction. For example, the vertex height of the model vertex and the vertex normal direction of the object model vertex can be multiplied by a preset control coefficient to obtain the offset data of the object model vertex relative to the vertex normal direction.
[0140] Furthermore, in some embodiments, the initial normal direction of the model vertex of the object model can be obtained according to step d1, and the initial normal direction of the model vertex of the object model can be compared with the vertex normal direction of the model vertex of the object model to obtain the offset data of the model vertex of the object model relative to the vertex normal direction.
[0141] Step d4: Adjust the object model based on the offset data, vertex height, and ground elevation to obtain the target object model.
[0142] Furthermore, in some embodiments, the model vertices of the object model can be stretched according to the vertex height of the model vertices to obtain an intermediate object model. The vertex height of the intermediate object model can be adjusted according to the ground elevation height of the model vertices to obtain an initial target object model. The model vertices of the initial target object model can be offset according to the offset data to obtain the target object model.
[0143] Furthermore, in some embodiments, the model vertices of the object model can be offset using offset data to obtain an offset object model. The model vertices of the offset object model can be stretched according to the vertex height of the model vertices to obtain an intermediate object model. The vertex height of the intermediate object model can be adjusted according to the ground elevation height of the model vertices to obtain the target object model.
[0144] Step d5: Render the target object model.
[0145] Furthermore, in some embodiments, after obtaining the target object model, the target object model is rendered according to a preset normal map and a preset color map.
[0146] In some embodiments of this application, considering that calling the graphics drawing interface once for each object model rendered may increase performance overhead, multiple target object models can be batch rendered after the target object model is obtained. For example, static batch rendering, dynamic batch rendering, or instance batch rendering can be performed on multiple target object models.
[0147] In some embodiments of this application, there may be object models in the terrain to be rendered that do not need to be rendered, such as flat land, occluded areas, etc. Therefore, after determining the object model corresponding to each terrain mesh, the object models that do not need to be rendered are removed from the object models corresponding to all terrain meshes. The removed object models are then rendered according to steps 231 to 232 described above.
[0148] Furthermore, in some embodiments, if the object model corresponding to each terrain grid is determined and eliminated, it may reduce processing efficiency. Based on this, this embodiment combines the object models corresponding to adjacent terrain grids into an initial object model cluster according to the location information of the terrain grid. Based on the vertex position information of the bounding box formed by each initial object model cluster, multiple initial object model clusters are filtered to obtain object model clusters. The object models in each object model cluster are rendered according to steps 231-232 above. Here, the bounding box formed by the initial object model cluster refers to the three-dimensional model drawn by the maximum and minimum values in the x-direction, y-direction, and z-direction of the initial object model cluster in the world coordinate system.
[0149] Specifically, the methods for determining object model clusters include:
[0150] (1) Based on the preset area range and the location information of each terrain grid, the object models corresponding to each terrain grid are grouped to obtain multiple initial object model clusters.
[0151] (2) Determine the bounding box of each initial object model cluster and the vertex position information of the bounding box.
[0152] (3) Based on the vertex position information of the bounding box of each initial object model cluster, multiple initial object clusters are filtered to obtain object model clusters whose vertex position information meets the preset position requirements.
[0153] (4) Render the object models in each of the object model clusters according to the grid height map and the ground height map.
[0154] The preset area can have a preset number of terrain meshes. For example, the object models corresponding to every adjacent 4x4 terrain meshes within the terrain mesh to be rendered can be combined into an initial object model cluster. Alternatively, object models belonging to the same model type within every adjacent 4x4 terrain meshes within the terrain mesh to be rendered can be combined into an initial object model cluster. Here, "the same model type" means that the object models within the terrain meshes are mutually convertible. Figure 4 Figure (a) and Figure 4 The two object models shown in (b) are the same model.
[0155] Optionally, for each initial object model cluster, the bounding box of the initial object model cluster can be obtained by merging the bounding boxes of each object model in the initial object model cluster.
[0156] The vertex position information of the bounding box refers to the world coordinates of the corner points of the bounding box in the world coordinate system.
[0157] The preset position requirement is that all vertices on the bounding box are inside the preset view frustum.
[0158] Optionally, the vertex position information of the bounding box of each initial object model cluster can be input into the preset model to obtain the first value of each initial object model cluster. The second value of each initial object model cluster can be obtained based on the position information of the center point of the bounding box of each initial object model cluster. For each initial object model cluster, the difference between the first value and the second value of the initial object model cluster is used to determine whether the initial object model cluster meets the preset position requirements.
[0159] Specifically, the second value can be obtained by using the position information Orig of the center point of the bounding box of the initial object model cluster, and by A*Orig.x+B*Orig.y+C*Orig.z+D. The first value can be obtained by using the vertex position information (A, B, C) of the bounding box of each initial object model cluster and the size boxExtent, and by abs(A)*abs(boxExtent.x)+abs(B)*abs(boxExtent.y)+abs(C)*abs(boxExtent.z). If the second value - the first value > 0, it means that the vertices on the bounding box are not inside the preset view frustum, and the initial object model cluster does not meet the preset position requirement. If the second value - the first value ≤ 0, it means that the vertices on the bounding box are all inside the preset view frustum, and the initial object model cluster meets the preset position requirement.
[0160] The following describes an apparatus embodiment of this application, which can be used to perform the methods described in the above embodiments of this application. For details not disclosed in the apparatus embodiments of this application, please refer to the method embodiments described in the above embodiments of this application.
[0161] Figure 10 This is a block diagram of a terrain model rendering apparatus according to an embodiment of this application, such as... Figure 10 As shown, the rendering device for this terrain model includes:
[0162] The acquisition module 11 is used to acquire the terrain mesh data of the terrain to be rendered; the terrain mesh data includes the terrain mesh of the terrain to be rendered, as well as the grid height and ground elevation height of each grid point of each terrain mesh.
[0163] Matching module 12 is used to obtain the object model corresponding to each terrain grid based on the grid height corresponding to each grid point of each terrain grid.
[0164] Rendering module 13 renders the object model corresponding to each terrain grid based on the grid height and position height of each grid point in each terrain grid.
[0165] Furthermore, in some embodiments of this application, the matching module 12 is used for:
[0166] For each terrain grid, the height level corresponding to each grid point is determined based on the grid height of each grid point. The height level represents the type of height difference between each grid point of the terrain grid, and the height levels include first-order height, second-order height, third-order height and fourth-order height.
[0167] The height level corresponding to each grid point of the terrain grid is encoded to obtain the height code of the terrain grid;
[0168] Based on the height encoding of the terrain grid and a preset dictionary, an object model matching the terrain grid is obtained; the preset dictionary includes multiple preset height codes and a preset object model corresponding to each height code.
[0169] Furthermore, in some embodiments of this application, the matching module 12 is used for:
[0170] The target height of each grid point in the terrain grid is determined based on the grid height corresponding to each grid point.
[0171] The target heights of each grid point in the terrain grid are sorted to obtain the sorting result of the target heights of each grid point in the terrain grid.
[0172] Based on the sorting results of the target heights of each grid point in the terrain grid, the height level corresponding to each grid point in the terrain grid is obtained.
[0173] Furthermore, in some embodiments of this application, the matching module 12 is used for:
[0174] Determine the minimum grid height among the grid heights corresponding to each grid point of the terrain grid;
[0175] The target height of each grid point in the terrain grid is obtained by comparing the height of each grid point with the minimum grid height.
[0176] Furthermore, in some embodiments of this application, the rendering module 13 is used for:
[0177] Based on the grid height corresponding to each grid point of each terrain grid, a grid height map of the terrain to be rendered is obtained. Based on the ground elevation corresponding to each grid point of each terrain grid, a ground elevation map of the terrain to be rendered is obtained. The terrain grids of the terrain to be rendered correspond one-to-one with the pixels in the grid height map and the pixels in the ground elevation map. The color channel of each pixel in the grid height map is used to store the grid height of each grid point of the corresponding terrain grid, and the color channel of each pixel in the ground elevation map is used to store the ground elevation of each grid point of the corresponding terrain grid.
[0178] The GPU is invoked to render the object models corresponding to each terrain grid based on the grid height map and the ground height map.
[0179] Furthermore, in some embodiments of this application, the rendering module 13 is used for:
[0180] Based on the preset regional range and the location information of each terrain grid, the object models corresponding to each terrain grid are grouped to obtain multiple initial object model clusters;
[0181] Determine the bounding box of each initial object model cluster and the vertex position information of the bounding box;
[0182] Based on the vertex position information of the bounding box of each initial object model cluster, multiple initial object clusters are filtered to obtain object model clusters whose vertex position information meets the preset position requirements;
[0183] Render the object models in each object model cluster based on the grid height map and the ground height map.
[0184] Furthermore, in some embodiments of this application, the rendering module 13 is used for:
[0185] For each object model, based on the position information of the preset anchor point of the object model, the position information of the starting point of the terrain to be rendered, and the size of the terrain to be rendered, the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered is obtained.
[0186] Based on the target location information, the grid height of each grid point of the terrain grid corresponding to the object model is obtained from the grid height map, and the ground elevation height of each grid point of the terrain grid corresponding to the object model is obtained from the ground height map.
[0187] Based on the grid height of each grid point of the terrain grid corresponding to the object model, the vertex height of the model vertex of the object model is obtained; and based on the ground elevation height of each grid point of the terrain grid corresponding to the object model, the ground elevation height of the model vertex of the object model is obtained.
[0188] The object model is rendered based on the ground elevation of the model vertices and the vertex height.
[0189] Furthermore, in some embodiments of this application, the rendering module 13 is used for:
[0190] Based on the position information of the model vertices, the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered, the size of the terrain to be rendered, the position information of the starting point, and the size of the terrain mesh corresponding to the object model, the relative position of the model vertices of the object model in the terrain mesh corresponding to the object model is obtained.
[0191] The ground elevation of the model vertex is obtained based on the relative position of the grid and the ground elevation of each grid point of the terrain grid corresponding to the object model.
[0192] Furthermore, in some embodiments of this application, the rendering module 13 is used for:
[0193] Determine the normal direction of each grid point of the terrain mesh corresponding to the object model;
[0194] Linear interpolation of the normal direction based on the relative position of the mesh yields the vertex normal direction of the model vertex of the object model;
[0195] Based on the vertex normal direction of the object model's vertices, obtain the offset data of the object model's vertices in the vertex normal direction;
[0196] The model vertices of the object model are adjusted based on the offset data, and the height of the object model is adjusted based on the vertex height of the model vertices and the ground elevation height to obtain the target object model.
[0197] Render the target object model.
[0198] Furthermore, in some embodiments of this application, the rendering module 13 is used for:
[0199] Based on the grid height of each grid point of the terrain grid corresponding to the object model, determine the height level corresponding to each grid point of the terrain grid corresponding to the object model.
[0200] Based on the vertex height level of the model vertices corresponding to the object model, determine the target height level that matches the vertex height level in the height level;
[0201] Based on the grid height of each grid point corresponding to the target height level, determine the vertex height of the model vertices corresponding to the object model.
[0202] Figure 11 This is a schematic diagram of an electronic device according to an embodiment of this application. The electronic device can be a server, or other devices that can be used to execute the terrain model rendering method provided in this application.
[0203] like Figure 11 As shown, it may include a memory 20, a processor 30, and a communication unit 40. The memory 20 stores a terrain model rendering program that can be executed by the processor 30. When the electronic device 100 is running, the processor 30 and the memory 20 communicate with each other via a bus. The processor 30 executes the terrain model rendering program and the terrain model rendering method.
[0204] The memory 20, processor 30, and communication unit 40 are electrically connected directly or indirectly to each other to achieve signal transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The terrain model rendering program is stored in the memory 20 as a software functional module. The processor 30 is used to execute the executable modules (such as the software functional modules or computer programs included in the terrain model rendering program) stored in the memory 20.
[0205] The memory 20 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0206] Optionally, processor 30 is used to perform one or more functions described in this embodiment. Optionally, processor 30 may include one or more processing cores (e.g., a single-core processor (S) or a multi-core processor (S)). By way of example only, processor 30 may include a Central Processing Unit (CPU), an Application-Specific Integrated Circuit (ASIC), an Application-Specific Instruction-set Processor (ASIP), a Graphics Processing Unit (GPU), a Physics Processing Unit (PPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), a Programmable Logic Device (PLD), a controller, a microcontroller unit, a Reduced Instruction Set Computing (RISC) computer, or a microprocessor, or any combination thereof. When processor 30 executes the above-described terrain model rendering method, the CPU can render the terrain model by calling the GPU.
[0207] For ease of explanation, only one processor is described in electronic device 100. However, it should be noted that electronic device 100 in this embodiment may also include multiple processors, and therefore the steps performed by one processor as described in this embodiment may also be performed jointly or individually by multiple processors. For example, if the server's processor performs steps A and B, it should be understood that steps A and B may also be performed jointly by two different processors or individually by one processor. For example, one processor performs step A, and a second processor performs step B, or the first and second processors jointly perform steps A and B.
[0208] In this embodiment, the memory 20 is used to store the program, and the processor 30 is used to execute the program after receiving the execution instruction. The process definition method disclosed in any implementation of this embodiment can be applied to the processor 30, or implemented by the processor 30.
[0209] The communication unit 40 is used to establish a communication connection between the electronic device 100 and other devices via a network, and to send and receive data via the network.
[0210] Furthermore, in some embodiments of this application, the network can be any type of wired or wireless network, or a combination thereof. As an example only, the network may include wired networks, wireless networks, fiber optic networks, telecommunications networks, intranets, the Internet, local area networks (LANs), wide area networks (WANs), wireless local area networks (WLANs), metropolitan area networks (MANs), public switched telephone networks (PSTNs), Bluetooth networks, ZigBee networks, or near field communication (NFC) networks, or any combination thereof.
[0211] In this embodiment, the electronic device 100 may be, but is not limited to, a laptop computer, a mobile terminal, a personal computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), and other electronic devices. This embodiment does not impose any restrictions on the specific type of electronic device.
[0212] Although not shown, the electronic device 100 may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the electronic device 100 loads the executable files corresponding to the processes of one or more applications into the memory 20 according to the following instructions, and the processor 30 runs the applications stored in the memory 20 to realize various functions, as follows:
[0213] Obtain the terrain mesh data of the terrain to be rendered; the terrain mesh data includes the terrain mesh of the terrain to be rendered, as well as the grid height and ground elevation of each grid point of each terrain mesh;
[0214] Based on the grid height corresponding to each grid point of each terrain grid, the object model corresponding to each terrain grid is obtained;
[0215] The object model corresponding to each terrain grid is rendered based on the grid height of each grid point and the ground elevation.
[0216] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the terrain model rendering method as described in any of the above method embodiments is implemented. For example, the computer-readable instructions can perform the following steps:
[0217] Obtain the terrain mesh data of the terrain to be rendered; the terrain mesh data includes the terrain mesh of the terrain to be rendered, as well as the grid height and ground elevation of each grid point of each terrain mesh;
[0218] Based on the grid height corresponding to each grid point of each terrain grid, the object model corresponding to each terrain grid is obtained;
[0219] The object model corresponding to each terrain grid is rendered based on the grid height of each grid point and the ground elevation.
[0220] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0221] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0222] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0223] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this application.
[0224] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0225] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for rendering a terrain model, characterized in that, The method includes: Obtain the terrain mesh data of the terrain to be rendered; the terrain mesh data includes the terrain mesh of the terrain to be rendered, the grid height corresponding to each grid point of the terrain mesh, and the ground elevation height; Based on the grid height corresponding to each grid point of the terrain grid, the object model corresponding to each terrain grid is obtained; The object model corresponding to each terrain grid is rendered based on the grid height of each grid point and the ground elevation. The step of obtaining the object model corresponding to each terrain grid based on the grid height corresponding to each grid point of each terrain grid includes: For each of the terrain grids, the height level corresponding to each grid point of the terrain grid is determined according to the grid point height corresponding to each grid point; the height level represents the type of height difference between each grid point of the terrain grid, and the height level includes first-order height, second-order height, third-order height and fourth-order height; The height level corresponding to each grid point of the terrain grid is encoded to obtain the height code of the terrain grid; Based on the height encoding of the terrain grid and a preset dictionary, an object model matching the terrain grid is obtained; the preset dictionary includes multiple preset height codes and a preset object model corresponding to each height code.
2. The rendering method according to claim 1, characterized in that, The step of determining the height level corresponding to each grid point of the terrain grid based on the grid point height of each grid point includes: The target height of each grid point in the terrain grid is determined based on the grid height corresponding to each grid point in the terrain grid. The target heights of each grid point in the terrain grid are sorted to obtain the sorting result of the target heights of each grid point in the terrain grid. Based on the sorting results of the target heights of each grid point in the terrain grid, the height level corresponding to each grid point in the terrain grid is obtained.
3. The rendering method according to claim 2, characterized in that, Determining the target height of each grid point in the terrain grid based on the grid point height corresponding to each grid point includes: Determine the minimum grid height among the grid heights corresponding to each grid point of the terrain grid; The target height of each grid point in the terrain grid is obtained based on the difference between the grid height corresponding to each grid point and the minimum grid height.
4. The rendering method according to claim 1, characterized in that, The step of rendering the object model corresponding to each terrain grid based on the grid height of each grid point and the ground elevation height includes: Based on the grid height corresponding to each grid point of each terrain grid, the grid height map of the terrain to be rendered is obtained; Based on the ground elevation height corresponding to each grid point of the terrain grid, a ground elevation map of the terrain to be rendered is obtained; the terrain grid of the terrain to be rendered corresponds one-to-one with the pixels in the grid elevation map and the pixels in the ground elevation map, respectively; the color channel of each pixel in the grid elevation map is used to store the grid height of each grid point of the corresponding terrain grid, and the color channel of each pixel in the ground elevation map is used to store the ground elevation height of each grid point of the corresponding terrain grid; The GPU is invoked to render the object model corresponding to each terrain grid based on the grid height map and the ground height map.
5. The rendering method according to claim 4, characterized in that, The step of rendering the object model corresponding to each terrain grid based on the grid height map and the ground height map includes: Based on the preset area range and the location information of each terrain grid, the object models corresponding to each terrain grid are grouped to obtain multiple initial object model clusters; Determine the bounding box of each initial object model cluster and the vertex position information of the bounding box; Based on the vertex position information of the bounding box of each initial object model cluster, the multiple initial object clusters are filtered to obtain object model clusters whose vertex position information meets the preset position requirements; The object models in each of the object model clusters are rendered based on the grid height map and the ground height map.
6. The rendering method according to claim 4 or 5, characterized in that, The rendering of the object model corresponding to each terrain grid based on the grid height map and the ground height map includes: For each of the object models, based on the position information of the preset anchor points of the object model, the position information of the starting point of the terrain to be rendered, and the size of the terrain to be rendered, the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered is obtained. Based on the target location information, the grid height of each grid point of the terrain grid corresponding to the object model is obtained from the grid height map, and the ground elevation height of each grid point of the terrain grid corresponding to the object model is obtained from the ground height map; The vertex height of the model vertex of the object model is obtained based on the grid height of each grid point of the terrain grid corresponding to the object model, and the ground elevation height of the model vertex of the object model is obtained based on the ground elevation height of each grid point of the terrain grid corresponding to the object model. The object model is rendered based on the ground elevation height and vertex height of the model vertices.
7. The rendering method according to claim 6, characterized in that, The step of obtaining the ground heave height of the model vertices of the object model based on the ground heave height of each grid point of the terrain grid corresponding to the object model includes: Based on the position information of the model vertices, the target position information of the terrain mesh corresponding to the object model in the terrain to be rendered, the size of the terrain to be rendered, the position information of the starting point, and the size of the terrain mesh corresponding to the object model, the relative position of the model vertices of the object model in the terrain mesh corresponding to the object model is obtained; The ground elevation of the model vertex is obtained based on the relative position of the grid and the ground elevation of each grid point of the terrain grid corresponding to the object model.
8. The rendering method according to claim 7, characterized in that, The rendering of the object model based on the ground elevation height and vertex height of the model vertices includes: Determine the normal direction of each grid point of the terrain mesh corresponding to the object model; Linear interpolation is performed on each of the normal directions based on the relative positions of the meshes to obtain the vertex normal directions of the model vertices of the object model; Based on the vertex normal direction of the model vertex of the object model, the offset data of the model vertex of the object model relative to the vertex normal direction is obtained; The object model is adjusted based on the offset data, the vertex height, and the ground elevation to obtain the target object model. Render the target object model.
9. The rendering method according to claim 6, characterized in that, The step of obtaining the vertex height of the model vertices of the object model based on the actual grid height of each grid point of the terrain mesh corresponding to the object model includes: Based on the actual grid height of each grid point of the terrain grid corresponding to the object model, determine the height level corresponding to each grid point of the terrain grid corresponding to the object model; Based on the vertex height level of the model vertices corresponding to the object model, determine the target height level that matches the vertex height level among the height levels; The vertex height of the model vertex corresponding to the object model is determined based on the actual grid height of the grid point corresponding to the target height level.
10. A rendering apparatus for a terrain model, characterized in that, The device includes: The acquisition module is used to acquire terrain mesh data of the terrain to be rendered; the terrain mesh data includes the terrain mesh of the terrain to be rendered, as well as the grid height and ground elevation height corresponding to each grid point of each terrain mesh. The matching module is used to obtain the object model corresponding to each terrain grid based on the grid height corresponding to each grid point of each terrain grid. The rendering module renders the object model corresponding to each terrain grid according to the grid height and ground elevation of each grid point. The step of obtaining the object model corresponding to each terrain grid based on the grid height corresponding to each grid point of each terrain grid includes: For each of the terrain grids, the height level corresponding to each grid point of the terrain grid is determined according to the grid point height corresponding to each grid point; the height level represents the type of height difference between each grid point of the terrain grid, and the height level includes first-order height, second-order height, third-order height and fourth-order height; The height level corresponding to each grid point of the terrain grid is encoded to obtain the height code of the terrain grid; Based on the height encoding of the terrain grid and a preset dictionary, an object model matching the terrain grid is obtained; the preset dictionary includes multiple preset height codes and a preset object model corresponding to each height code.
11. An electronic device, characterized in that, include: processor; A memory storing computer-readable instructions that, when executed by the processor, implement the method as described in any one of claims 1 to 9.
12. A computer-readable storage medium storing computer-readable instructions thereon, characterized in that, When the computer-readable instructions are executed by a processor, the method as described in any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Terrain rendering method and device and electronic equipment
CN114648616A
Object rendering method and apparatus, electronic device, and storage medium
WO2023197729A1