CN116402932A - Rendering method and device of terrain model, electronic equipment and readable storage medium - Google Patents

Rendering method and device of terrain model, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN116402932A
CN116402932A CN202310356546.XA CN202310356546A CN116402932A CN 116402932 A CN116402932 A CN 116402932A CN 202310356546 A CN202310356546 A CN 202310356546A CN 116402932 A CN116402932 A CN 116402932A
Authority
CN
China
Prior art keywords
grid
terrain
height
object model
vertex
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310356546.XA
Other languages
Chinese (zh)
Inventor
金紫凤
孔令胜
林云龙
陈家挺
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202310356546.XA priority Critical patent/CN116402932A/en
Publication of CN116402932A publication Critical patent/CN116402932A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02ATECHNOLOGIES FOR ADAPTATION TO CLIMATE CHANGE
    • Y02A90/00Technologies having an indirect contribution to adaptation to climate change
    • Y02A90/10Information and communication technologies [ICT] supporting adaptation to climate change, e.g. for weather forecasting or climate simulation

Abstract

The application relates to the technical field of computers and discloses a rendering method, a rendering device, electronic equipment and a readable storage medium of a terrain model, wherein the object model corresponding to each terrain grid is obtained according to the grid point height corresponding to each grid point of each terrain grid by acquiring terrain grid data of the terrain to be rendered, the object model corresponding to each terrain grid is rendered according to the grid point height corresponding to each grid point of each terrain grid and the ground bump height, the object model of each terrain grid is determined according to the grid point height of each grid point of each terrain grid by dividing the terrain to be rendered, and the object model of each terrain grid can be automatically obtained with natural outline only by adjusting the grid point height of each grid point, so that the terrain rendering efficiency can be improved; and render the object model based on the grid point height and the ground bump height corresponding to the grid points of each terrain grid, so that the visual effect of the rendered terrain can be improved.

Description

Rendering method and device of terrain model, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for rendering a terrain model, an electronic device, and a readable storage medium.
Background
The topography is a generic term for various shapes of ground objects in games, including plateau, mountain, plain, hills, basin, etc., and the height of the topography varies differently.
At present, a general terrain rendering mode is to edit terrain by using a complex terrain editing tool by a professional art staff, wherein the special terrain comprises special terrain such as bulges, sags and the like, and other models such as cliffs, roads and the like are translated to a proper position for placement after being edited in an engine editor. Although the terrain manufactured in this way is accurate and attractive, a great deal of expertise and skilled operation skills are required, and only the expertise and the artist who engage in scene editing and terrain manufacturing can make a proper product, so that the conventional terrain rendering has the problems of complex operation, high labor cost and low rendering efficiency.
Disclosure of Invention
In view of the above problems, embodiments of the present application provide a method, an apparatus, an electronic device, and a readable storage medium for rendering a terrain model, so as to solve the problem of low efficiency of terrain rendering caused by complex terrain rendering operations in the related art.
According to an aspect of the embodiments of the present application, there is provided a rendering method of a terrain model, including:
Obtaining terrain grid data of the terrain to be rendered; the terrain grid data comprises terrain grids of the terrain to be rendered, grid point heights corresponding to grid points of the terrain grids and ground bump heights;
obtaining an object model corresponding to each terrain grid according to the grid height corresponding to each grid point of each terrain grid;
and rendering the object model corresponding to each terrain grid according to the grid point height corresponding to each grid point of each terrain grid and the ground bump height.
According to an aspect of the embodiments of the present application, there is provided a rendering apparatus of a terrain model, including:
the acquisition module is used for acquiring terrain grid data of the terrain to be rendered; the terrain grid data comprises terrain grids of the terrain to be rendered, and grid point heights and ground bump heights corresponding to grid points of the terrain grids;
the matching module is used for obtaining an object model corresponding to each terrain grid according to the grid height corresponding to each grid point of each terrain grid;
and the rendering module is used for rendering the object model corresponding to each terrain grid according to the grid point height corresponding to each grid point of each terrain grid and the ground bump height.
According to an aspect of an embodiment of the present application, there is provided an electronic device including: a processor; and a memory having stored thereon computer readable instructions which, when executed by the processor, implement a method of rendering a terrain model as described above.
According to an aspect of embodiments of the present application, there is provided a computer readable storage medium having stored thereon computer readable instructions which, when executed by a processor, implement a method of rendering a terrain model as described above.
In the scheme provided by the application, the terrain to be rendered is divided into the terrain grids, the object model of each terrain grid is determined according to the grid point heights of all grid points of each terrain grid, the object model with natural outline and vivid details can be automatically obtained only by adjusting the grid point heights of the grid points, the operation is convenient, and the terrain rendering efficiency can be improved; and render the object model based on the ground bump height and the object height, so that the visual effect of the rendered terrain can be improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application. It is apparent that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
Fig. 1 is a flow chart illustrating a method of rendering a terrain model according to an embodiment of the present application.
FIG. 2 is a schematic diagram of object models of different height levels, according to an embodiment of the present application.
Fig. 3 is a flow chart illustrating an object model determination method according to an embodiment of the present application.
Fig. 4 is a schematic diagram of a preset object model according to an embodiment of the present application.
FIG. 5 is a flow diagram illustrating rendering an object model according to an embodiment of the present application.
Fig. 6 is a flow chart illustrating a method of rendering an object model according to an embodiment of the present application.
FIG. 7 is a schematic diagram of a model vertex of an object model, shown in accordance with an embodiment of the present application.
FIG. 8 is a schematic diagram of a target object model, according to an embodiment of the present application.
Fig. 9 is a schematic diagram of a normal to a grid point shown in accordance with an embodiment of the present application.
Fig. 10 is a block diagram of a rendering apparatus of a terrain model according to an embodiment of the present application.
Fig. 11 shows a schematic structural diagram of an electronic device suitable for implementing embodiments of the present application.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the present application. One skilled in the relevant art will recognize, however, that the aspects of the application can be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the application.
The block diagrams depicted in the figures are merely functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The flow diagrams depicted in the figures are exemplary only, and do not necessarily include all of the elements and operations/steps, nor must they be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the order of actual execution may be changed according to actual situations.
It should be noted that: references herein to "a plurality" means two or more. "and/or" describes an association relationship of an association object, meaning that there may be three relationships, e.g., a and/or B may represent: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship.
In order to facilitate understanding of the technical solution of the present application, the method, apparatus, electronic device and computer readable storage medium for rendering a terrain model provided in the present application will be described below in connection with an actual application scenario.
The technical scheme of the present application is described in detail below with specific examples.
Fig. 1 is a flowchart of a method for rendering a terrain model, which may be performed by an electronic device with image rendering capabilities, such as a server, a smart phone, a tablet, a personal computer, etc., according to one embodiment of the present application, without specific limitation. Referring to fig. 1, the method at least includes steps 210 to 230, which are described in detail as follows:
step 210, obtaining terrain mesh data of the terrain to be rendered.
The terrain grid data comprises terrain grids of the terrain to be rendered, grid point heights corresponding to grid points of the terrain grids and ground bump heights. The height of each grid point refers to the actual height of each grid point of the terrain grid in the virtual scene, the height of the ground bulge refers to the height of each grid point of each terrain grid, the height of the bulge is a smooth representation of terrain lifting, and the height of each grid point can be input into a preset quadratic function to obtain the height of the ground bulge of each grid point. Wherein the terrain mesh of the terrain to be rendered may be a plurality.
In the embodiment of the application, the lattice point height and the ground bump height can be pre-stored; the grid point height and ground bump height data may also be user entered.
In the embodiment of the application, the terrain to be rendered may be a rectangular area. The region is divided into individual grids by a horizontal axis and a vertical axis in the world coordinate system. A lattice is just sized to accommodate a pattern.
In the present embodiments, the terrain to be rendered is a generic term for various terrain shapes in a virtual scene, including, but not limited to, plateaus, hills, basins, and the like. The terrain to be rendered can be a rectangular area, the area is divided into grids by a transverse axis and a longitudinal axis in a world coordinate system, each grid obtained through division is used as a terrain grid of the terrain to be rendered, each terrain grid can accommodate an object model, and the object models accommodated in each terrain grid are combined to form the terrain to be rendered. Wherein the object model may be a prefabricated three-dimensional model.
In the embodiment of the application, the terrain to be rendered can be presented in a height-changing mode, and the height of each grid point of each terrain grid and the height of the ground bump can be presented in the height-changing mode.
In this embodiment of the present application, each terrain mesh corresponds to a mesh container, where the mesh container is used to store an object model of the terrain mesh corresponding to the mesh container, and in some embodiments, the object model of each terrain mesh corresponds to a height of a lattice point corresponding to each lattice point of the terrain mesh, that is, when the height of the lattice point corresponding to the lattice point of the terrain mesh is changed, the object model in the mesh container corresponding to the terrain mesh needs to be adjusted accordingly.
In the embodiment of the application, the grid point heights and the ground bump heights corresponding to the grid points of the terrain grids can be stored in a two-dimensional array mode, wherein the subscript of the two-dimensional array corresponds to the abscissa of the terrain grids, and the array elements correspond to the grid point heights and the ground bump heights corresponding to the grid points of the terrain grids. In order to distinguish the grid point height and the ground elevation height corresponding to the grid points of each terrain grid, a grid point height array can be established, the grid point height corresponding to each grid point of each terrain grid is stored in a two-dimensional array mode through the grid point height array, the ground elevation height array is established, and the ground elevation height corresponding to each grid point of each terrain grid is stored in a two-dimensional array mode through the ground elevation height array.
And 220, obtaining an object model corresponding to each terrain grid according to the grid point height corresponding to each grid point of each terrain grid.
In the embodiment of the application, the object model of each terrain grid can be constructed according to the grid point height corresponding to each grid point of each terrain grid. For each terrain grid, a preset model can be obtained, the grid point heights corresponding to the grid points of the terrain grid are mapped to the preset model, and an object model corresponding to the terrain grid is constructed. The preset model may be a patch with higher point density, and the object model with height is formed by mapping the height of the grid point corresponding to each grid point of the terrain grid onto the patch, where the object model with height is the object model corresponding to the terrain grid. Specifically, the heights of grid points corresponding to the grid points of the terrain grid are mapped to a preset model to obtain an intermediate model, and the heights of ground bumps corresponding to the grid points of the terrain grid are mapped to the intermediate model to obtain an object model.
In the embodiment of the application, considering that if redrawing of the object model is performed every time the object model of the terrain mesh is determined, performance consumption is increased and rendering efficiency is reduced, based on the fact that the method and the device draw a plurality of object models in advance, each object model corresponds to a group of grid point height ranges, when the object model of each terrain mesh needs to be adjusted or determined, the object model matched with the terrain mesh is selected from the plurality of object models only according to the grid point heights of all grid points of the terrain mesh.
Further, in some embodiments of the present application, considering that if the heights of each set of grid points draw an object model, the data size is larger, in order to reduce the number of object models, an object model may be drawn according to the height difference between the heights of the grid points corresponding to each grid point of each terrain grid, and when selecting an object model corresponding to each terrain grid, the height difference of each terrain grid is determined according to the height of the grid point corresponding to each grid point of each terrain grid, and an object model matching each terrain grid is selected from a plurality of object models according to the height difference of each terrain grid. Wherein the height difference characterizes a height difference type of each grid point of the terrain grid.
For example, for a square terrain grid, it includes four grid points, i.e., the type of height difference includes four types: 1) The heights of the grid points corresponding to the four grid points are consistent; 2) The heights of the grid points corresponding to the four grid points are inconsistent; 3) The heights of the grid points corresponding to three of the four grid points are consistent; 4) The heights of two corresponding lattice points in the four lattice points are consistent, the heights of the remaining two corresponding lattice points are inconsistent, and the object model comprises four types of corresponding lattice points: the method comprises the steps of 1-order high object model, 2-order high object model, 3-order high object and 4-order high object model, wherein the heights of all the grid points corresponding to four grid points of a terrain grid corresponding to the 1-order high object model are consistent, the heights of all the grid points corresponding to four grid points of the terrain grid corresponding to the 4-order high object model are inconsistent, the heights of all the grid points corresponding to three grid points in the four grid points of the terrain grid corresponding to the 2-order high object model are consistent, the heights of all the grid points corresponding to two grid points of the four grid points of the terrain grid corresponding to the 3-order high object model are consistent, the heights of the grid points corresponding to the remaining two grid points are inconsistent, as shown in fig. 2, a graph (a) in fig. 2 is the 2-order high object model, a graph (b) in fig. 2 is the 3-order high object model, and a graph (c) in fig. 2 is the 4-order high object model. Therefore, for a square terrain grid, a matched object model can be selected from four object models according to the grid point height corresponding to each grid point of the terrain grid.
And 230, rendering the object model corresponding to each terrain grid according to the grid point height corresponding to each grid point of each terrain grid and the ground bump height.
In the embodiment of the application, for each terrain grid, projecting the grid point height corresponding to each grid point of the terrain grid and the ground bump height to an object model corresponding to the terrain grid to obtain a target object model, and rendering the target object model through a shader.
In the embodiment of the application, the grid point height and the ground bump height corresponding to each grid point of each terrain grid can be transmitted to the GPU, and the GPU calls the shader to render the object model corresponding to each terrain grid according to the grid point height and the ground bump height corresponding to each grid point of each terrain grid.
In some embodiments, in a rendering process, in order to better save terrain data by a GPU without depending on a quadtree and generate a terrain with better visual effect, in the embodiments of the present application, a terrain map is generated according to a grid point height corresponding to each grid point of each terrain grid and a ground bump height, and the terrain data is saved in the form of the terrain map. Alternatively, the topography may be a two-dimensional array, where the subscript of the two-dimensional array corresponds to the abscissa of the topography grid, and the array element values correspond to the height of the grid point and the height of the ground bump corresponding to each grid point of the topography grid. Each value in the topography map can thus be translated into three-dimensional coordinates of the grid points of the topography grid. Optionally, the height of each grid point and the height of the ground bump corresponding to each grid point of different terrain grids are represented by different gray values in the terrain map.
Specifically, the topographic map generating method includes steps a1 to a2:
step a1, creating a blank graph.
The number of the pixel points in the blank map is the same as the data of the terrain grids included in the terrain to be rendered, the size of the blank map is the same as the size of the terrain to be rendered, the arrangement mode of the pixels on the blank map is the same as the ordering mode of the terrain grids in the terrain to be rendered, namely, each terrain grid included in the terrain to be rendered corresponds to a unique pixel point on the blank map. For example, when the terrain to be rendered includes 9 terrain meshes and 3 terrain meshes in the horizontal axis direction and 3 terrain meshes in the vertical axis direction, the number of pixels of the created blank image is 3*3, starting from the starting point of the terrain to be rendered, the first terrain mesh in the first row on the horizontal axis corresponds to the pixel point of the blank image with the image coordinate of (0, 0), the second terrain mesh in the first row on the horizontal axis corresponds to the pixel point of the blank image with the image coordinate of (1, 0), and the first terrain mesh in the first row on the horizontal axis corresponds to the pixel point of the image with the image coordinate of (2, 0).
And a2, sequentially writing the grid point heights corresponding to the grid points of each terrain grid and the ground bump heights into the color channels of the corresponding pixel points of the blank map to obtain the terrain map.
Optionally, step a2 includes: for each terrain grid, the heights of the grid points corresponding to the upper left grid point, the upper right grid point, the lower right grid point and the lower left grid point of the terrain grid and the ground bump height are sequentially written into the red channel, the green channel, the blue channel and the alpha channel of the corresponding pixel points of the blank map, namely, the heights of the grid points corresponding to the upper left grid point, the upper right grid point, the lower right grid point and the lower left grid point of the terrain grid and the ground bump height are respectively used as the values of the red channel, the green channel, the blue channel and the alpha channel of the corresponding pixel points of the blank map.
Optionally, in order to distinguish the grid point height and the ground elevation, the topography map includes a ground elevation map and a grid point elevation map, and the grid point elevation map may be generated according to the corresponding grid point height of the topography grid, and the ground elevation map may be generated according to the corresponding ground elevation of the topography grid, specifically, the grid point elevation map may be generated according to steps a1 to a2 according to the grid point heights corresponding to the grid points of the topography grids, and the ground elevation map may be generated according to steps a1 to a2 according to the ground elevation heights corresponding to the grid points of the topography grids.
Optionally, when the GPU performs rendering, the grid point height and the ground bump height corresponding to each grid point of each terrain grid may be obtained from the grid point height map and the ground height map of the terrain to be rendered, and for the object model corresponding to each terrain grid, the grid point height and the ground bump height of the terrain grid corresponding to the object model are mapped onto the object model to obtain a target object model, and the target object model is rendered through the shader.
The Shader may be a Shader (loader) in Unity, which is used to express code fragments that light acts on the surface of the target object model and runs on the graphics card. In practical application, the required surface texture can be realized in the virtual scene by writing the shader. As a specific example, for some common objects, such as metal, stone, plastic and other materials, the surface texture of the target object model is abstracted into different parameters, and then the shader uses the parameters to render the target object model in the virtual scene, so as to realize the corresponding surface texture in the virtual scene. Specifically, the parameters may include a surface color for expressing a color distribution of the target object model, a degree of metallicity for expressing a degree of conductivity of the target object model surface, a roughness for expressing whether the target object model surface is a smooth surface or a rough surface, and the like. In Unity, the surface color may be recorded by color mapping, the metaliness may be recorded by metaliness mapping, and the roughness may be recorded by roughness mapping.
Optionally, when the GPU performs rendering, the grid point height and the ground bump height corresponding to each grid point of each terrain grid may be extracted from the color channels of the grid point height map and the pixel points of the ground height map of the terrain to be rendered. It can be understood that each terrain grid of the terrain to be rendered corresponds to a pixel point in the grid point height map of the terrain to be rendered, the color channel of the pixel point stores the grid point height corresponding to each grid point of the corresponding terrain grid, and one color channel of the pixel point stores the grid point height of one grid point of the corresponding terrain grid; each terrain grid of the terrain to be rendered corresponds to one pixel point in the ground height map of the terrain to be rendered, the color channel of the pixel point stores the ground elevation corresponding to each grid point of the corresponding ground height map, and one color channel of the pixel point stores the ground elevation corresponding to one grid point of the terrain grid, and each terrain grid comprises four grid points. Wherein the color channels include a red channel, a green channel, a blue channel, and an alpha channel.
Optionally, when the GPU performs rendering, the gray value of each pixel point in the grid point height map and the ground height map of the terrain to be rendered may be converted into the grid point height and the ground bump height corresponding to each grid point of each terrain grid through a preset rule. The preset rule may be a conversion rule set according to actual needs, for example, 1 gray represents 1 meter, that is, a point with a gray value of 50 in the grid point height map and the ground height map is a point with a height of 50 meters, and of course, the preset rule may also be other rules, for example, 1 gray represents 10 meters, 20 meters, and the like, which is not limited in this application.
According to the terrain model rendering method, the terrain to be rendered is divided into the terrain grids, the object model of each terrain grid is determined according to the grid point heights of all grid points of each terrain grid, the object model with natural outline and vivid details can be automatically obtained only by adjusting the grid point heights of the grid points, and the terrain rendering efficiency can be improved; and render the object model based on the grid point height corresponding to each grid point of the terrain grid and the ground bump height, so that the visual effect of the rendered terrain can be improved.
In some embodiments, in the rendering of the terrain model, to facilitate storage and reading of grid point heights and ground bump heights, a two-dimensional terrain array may be created in which index values for each element are used to locate different terrain grids (x, y), the values stored for each element being the respective grid point heights and ground bump heights of each terrain grid. Wherein x in the terrain meshes (x, y) indicates position information of the terrain meshes on a transverse axis of the terrain to be rendered, and y indicates position information of the terrain meshes on a longitudinal axis of the terrain to be rendered, e.g., (1, 1) characterizes a first one of the first row of terrain meshes on the transverse axis starting from a starting point of the terrain to be rendered.
Optionally, the terrain arrays include a first terrain array and a second terrain array, wherein an index value of each element of the first terrain array is used for locating different terrain grids (x, y), and the value stored by the element is a grid point height of each terrain grid; the index value of each element of the second terrain array is used to locate a different terrain grid (x, y), the element storing values for the ground elevation height of each terrain grid. For example, the upper left grid point, the upper right grid point, the lower right grid point and the lower left grid point of the terrain grid with the position (1, 1) in the terrain to be rendered are respectively corresponding to the grid point heights { g1, g2, g3, g4} and assigned to the element with the index value (1, 1) in the first terrain array.
In some embodiments of the present application, in order to improve rendering efficiency, a more convenient method for determining an object model is provided, and in the embodiments of the present application, a height code is generated according to a grid point height in grid point heights corresponding to grid points of each terrain grid, and an object model matched with the height code is obtained from a preset dictionary. The preset dictionary comprises a plurality of preset object models which are manufactured in advance, and preset height codes of each preset object model. Wherein the altitude coding can be obtained according to the altitude grade corresponding to each grid point of the terrain grid. Specifically, as shown in fig. 3, fig. 3 is a flowchart of an object model determining method provided in an embodiment of the present application, where the object model determining method includes steps 221 to 223:
Step 221, determining, for each terrain grid, a height level corresponding to each grid point of the terrain grid according to the grid point height corresponding to each grid point of the terrain grid.
The height grade characterizes the height difference type of each grid point of the terrain grid and comprises a first-order height, a second-order height, a third-order height and a fourth-order height, wherein the first-order height characterizes the height consistency of each grid point of the terrain grid, the fourth-order height characterizes the height consistency of each grid point of the terrain grid, three different heights exist in each grid point of the third-order height characterizes the terrain grid, and two different heights exist in four grid points of the second-order height characterizes the terrain grid. In some embodiments, the height level for each grid point of the terrain grid may be represented numerically, e.g., a first order height represented by 0, a second order height represented by 1, a third order height represented by 2, and a fourth order height represented by 3.
It can be understood that when the height level corresponding to the grid points in the terrain grid is the fourth-order height, the grid point height of each grid point in the terrain grid is different, when the height level corresponding to each grid point in the terrain grid is the third-order height at maximum, the grid point heights of two grid points in the terrain grid are the same, when the height level corresponding to the grid point in the terrain grid is the second-order height at maximum, the grid point heights of three grid points in the terrain grid are the same, and when the height level corresponding to the grid point in the terrain grid is the first-order height, the grid point heights of all grid points in the terrain grid are the same.
In some embodiments, step 221 includes steps b 1-b 3:
and b1, determining a target height value of each grid point of the terrain grid according to the grid point height corresponding to each grid point of the terrain grid.
In order to facilitate the generation of the height code, the target height of the grid point may be obtained according to a difference between a minimum grid point height of the grid point heights corresponding to the grid points of the terrain grid and the grid point heights corresponding to the grid points of the terrain grid, so as to ensure that the target height of each grid point is a natural number greater than or equal to 0, specifically, step b1 includes:
(1) And determining the minimum grid point height of the terrain grid according to the grid point height corresponding to each grid point of the terrain grid.
(2) And obtaining the target height of each grid point of the terrain grid according to the difference value between the grid point height corresponding to each grid point of the terrain grid and the minimum grid point height.
And b2, sequencing the target heights of all grid points of the terrain grid to obtain sequencing results of the target heights of all grid points of the terrain grid.
Optionally, a minimum target height that is not repeated may be selected from the target height values of the grid points of the terrain grid each time, so as to obtain a ranking result of the target heights of the grid points of the terrain grid, and specifically, the ranking method in step b2 includes:
(1) Acquiring a historical target height stored in a preset first array last time, and acquiring a first target height with a minimum target height value outside the preset first array from the target height of each grid point of the terrain grid; the historical target heights last stored in the first array are determined from the target heights of the grid points of the terrain grid.
(2) The historical target height is compared to the first target height.
(3) And discarding the first target height if the historical target height is the same as the first target height.
(4) If the historical target height is different from the first target height, writing the first target height into a preset first array to obtain an updated preset first array.
Traversing the target height of each grid point of the terrain grid, and sequencing the target height of each grid point of the terrain grid according to the sequencing method to obtain a sequencing result of the target height of each grid point of the terrain grid.
Optionally, the sorting result of the target height of each grid point of the terrain grid can be stored through an array, specifically, a min array is newly built, all elements are selected from the 1 st position of the min array, the position of the target height value with the smallest target height in each grid point of the terrain grid is selected, the 2 nd position of the min array is selected, the 2 nd position of the target height with the smallest target height is selected from the rest grid points of the terrain grid, and the process is repeated until the traversal of each grid point of the terrain grid is completed, and the sorting result of the target height of each grid point of the terrain grid is obtained.
And b3, obtaining the height grade corresponding to each grid point of the terrain grid according to the sequencing result of the target heights of each grid point of the terrain grid.
The number of target heights in the sequencing result is the number of height grades corresponding to all grid points of the terrain grid.
Optionally, when the number of target heights in the sorting result is 1, the height level corresponding to each grid point of the terrain grid is the first-order height.
Optionally, when the number of the target heights in the sorting result is not 1, the target heights of the grid points of the terrain grid can be compared with the target heights in the sorting result, and according to the comparison result, the height grade corresponding to the grid points of the terrain grid is obtained. Specifically, the target height of each grid point of the terrain grid is compared with the target height in the sequencing result in sequence, the sequential position of the target height which is the same as the target height of each grid point in the sequencing result is obtained according to the comparison result, and the height grade corresponding to each grid point of the terrain grid is obtained according to the sequential position. For example, when the sorting result is {0, 22}, and the target height of each grid point of the terrain grid is 0, 22,0 in turn, it is determined that the height grades corresponding to each grid point of the terrain grid are the first-order height, the second-order height, and the first-order height, respectively, that is, the height grades corresponding to each grid point of the terrain grid are {0010}, respectively.
Optionally, for each terrain grid, an array may be created, and the height level corresponding to each grid point of the terrain grid is stored, specifically, a cellHeight array {0000} is newly created, from the 1 st position of the min array obtained in the step b2, the target heights of 4 grid points of the terrain grid are traversed, and if the target heights of the grid points are the same as the corresponding heights in the min array, the cellHeight value at the position is 0; traversing the target height of the remaining grid points, if the target height is the same as the corresponding height at the 2 nd position in the min array, the celHeight value at the position is 1, repeating the steps until the grid points of the terrain grid are traversed, and obtaining the height grade corresponding to the grid points of the terrain grid.
Step 222, encoding the height level corresponding to each grid point of the terrain grid to obtain the height encoding of the terrain grid.
In some embodiments, the height level corresponding to each grid point of the terrain grid may be encoded by a preset encoding mode, so as to obtain the height encoding of the terrain grid. The preset encoding mode may be binary conversion, hash encoding, etc., which is not specifically limited in this embodiment of the present application.
And step 223, obtaining an object model matched with the terrain grid according to the height code of the terrain grid and the preset dictionary.
The preset dictionary comprises a plurality of preset height codes and preset object models corresponding to the height codes.
Specifically, a target preset height code consistent with the height code of the terrain grid can be queried from a preset dictionary according to the height code of the terrain grid, a preset object model corresponding to the target preset height code is set as an object model matched with the terrain grid, and the object model matched with the terrain grid is written into a grid container corresponding to the terrain grid.
In some embodiments, considering that if each preset height code draws a corresponding preset object model, this may cause redundancy of the preset dictionary, and some preset object models of different preset height codes are converted by displacement or rotation, as shown in fig. 4, for example, in fig. 4, where the preset height code (a) in fig. 4 is a preset object model of preset height code 0100, the preset height code (b) in fig. 4 is 0010, and the preset object model (b) in fig. 4 may be obtained by rotating the preset object model (a) in fig. 4 by 90 degrees clockwise along the vertical axis, so that for the preset object model that may realize conversion of the preset object model by rotating the preset object model, a preset object model of preset height code may be drawn, and the rotation angle between the preset object model of preset height code and other switchable preset object models may be determined, so that the number of preset object models may be reduced, that is, the preset dictionary includes a plurality of preset heights and the preset object models corresponding to each preset height code or each preset object model of preset height code corresponds to each preset object model of rotation angle.
In step 223, an initial object model matched with the terrain mesh may be obtained according to the altitude code of the terrain mesh and the preset dictionary, if the preset dictionary has a rotation angle with the initial object model matched with the altitude code, the initial object model is rotated according to the rotation angle to obtain the object model, and if the preset dictionary does not have a rotation angle with the initial object model matched with the altitude code, the initial object model is set as the object model.
In some embodiments of the present application, when determining an object model corresponding to each terrain grid, transmitting a grid point height map and a ground height map of the terrain to be rendered, which are generated according to steps a 1-a 2, according to the grid point height and the ground elevation corresponding to each grid point of each terrain grid, to a GPU, and calling the GPU to render each object model according to the terrain map of the terrain to be rendered. Specifically, taking the example that the topographic map includes a grid point elevation map and a ground elevation map, as shown in fig. 5, step 230 includes at least:
step 231, for each object model, obtaining target position information of the terrain grid corresponding to the object model in the terrain to be rendered according to 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 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 coordinate of the preset anchor point of the object model.
Further, in some embodiments, the grid point height map and the ground height map may be sampled according to the position information of the preset anchor point of the object model to obtain the grid point height and the ground bump height of each grid point of the terrain grid corresponding to the object model. Specifically, target position information of a terrain grid corresponding to the object model in the terrain to be rendered is obtained according to position information of a preset anchor point of the object model and the size of the terrain to be rendered, a first target pixel point, of which the pixel position is matched with the target position information, in a grid point height map is determined according to the target position information of the terrain grid corresponding to the object model in the terrain to be rendered, a second target pixel point, of which the pixel position is matched with the target position information, in the ground height map is determined, grid point heights of all grid points of the terrain grid corresponding to the object model are extracted from a color channel of the first target pixel point, and ground uplift heights of all grid points of the terrain grid corresponding to the object model are extracted from a color channel of the second target pixel point.
Optionally, the terrain grids of the terrain to be rendered are respectively in one-to-one correspondence with the pixel points in the grid point height map and the pixel points in the ground height map, the color channel of each pixel point in the grid point height map is used for storing the grid point heights of the grid points of the corresponding terrain grids, and the color channel of each pixel point in the ground height map is used for storing the ground bump heights of the grid points of the corresponding terrain grids. Therefore, according to the target position information of the terrain grid corresponding to the object model in the terrain to be rendered, a first target pixel point, of which the pixel position is matched with the target position information, in the grid point height map is determined, a second target pixel point, of which the pixel position is matched with the target position information, in the ground height map is determined, the grid point heights of all grid points of the terrain grid corresponding to the object model are extracted from the color channel of the first target pixel point, and the ground bulge heights of all grid points of the terrain grid corresponding to the object model are extracted from the color channel of the second target pixel point.
Specifically, the method for determining the grid point height and the ground elevation based on the grid point height map and the ground elevation map includes steps c1 to c2:
step c1, aiming at each object model, obtaining target position information of a terrain grid corresponding to the object model in the terrain to be rendered according to position information of a preset anchor point of the object model, position information of a starting point of the terrain to be rendered and the size of the terrain to be rendered.
And c2, obtaining the grid point height of each grid point of the terrain grid corresponding to the object model from the grid point height map according to the target position information, and obtaining the ground elevation height of each grid point of the terrain grid corresponding to the object model from the ground height map.
Wherein, the position information of the starting point of the terrain to be rendered refers to the world coordinates of the starting point of the terrain to be rendered in the world coordinate system. Alternatively, the world coordinate system may be established by taking the center point of the terrain to be rendered as the origin of coordinates, or the world coordinate system may be established by taking the starting point of the terrain to be rendered as the origin of coordinates, where the starting point may be a corner point of the terrain to be rendered, for example, when the terrain to be rendered is rectangular, the starting point of the terrain to be rendered may be a lower left corner point of the terrain to be rendered. Optionally, the dimensions of the terrain to be rendered include a length and a width of the terrain to be rendered; optionally, the dimensions of the terrain to be rendered include a number of terrain meshes for the terrain to be rendered on a lateral axis and a number of terrain meshes on a longitudinal axis.
Further, in some embodiments, the target position information includes first target position information and second target position information, where the first target position information is used to obtain, from the grid point altitude map, a first target pixel point corresponding to a terrain grid corresponding to the object model, and the second target position information is used to obtain, from the ground altitude map, a second target pixel point corresponding to a terrain grid corresponding to the object model.
Optionally, the first target position information of the terrain grid corresponding to the object model in the terrain to be rendered can be obtained according to 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, acquiring position information WorldPos1 of a preset anchor point of the object model, position information TerratinOffset of a starting point of a terrain to be rendered and length and width TerratinSize of the terrain to be rendered, and obtaining first target position information of a terrain grid corresponding to the object model in the terrain to be rendered through (WorldPos 1-TerratinOffset)/TerratinSize.
Optionally, in consideration of the difference in ground elevation height of each vertex in the object model, in the second target position information determination, position information of model vertices of the object model, which is a world coordinate value of model vertices of the object model in the x-direction and a world coordinate value of model vertices of the object model in the y-direction in the world coordinate system, and a size of a terrain grid, which is a length and a width of the terrain grid, are also required to be considered. And obtaining second target position information of the terrain grid corresponding to the object model in the terrain to be rendered according to the position information of the model vertex of the object model, the position information of the starting point of the terrain to be rendered, the size of the terrain grid and the size of the terrain to be rendered. For example, according to the position information of the model vertexes of the object model being WorldPos2, the position information of the starting points of the terrain to be rendered being TerratinOffset, the number of the terrain meshes of the terrain to be rendered in the horizontal axis direction and the number of the terrain meshes in the vertical axis being TerratinCellCount, and the size of the terrain meshes being TerratinCellSize, the second target position information of the terrain meshes corresponding to the object model in the terrain to be rendered is obtained through floor ((WorldPos 1-TerratinOffset)/TerratinCellSize)/TerratinCellCount. Wherein floor is rounded downwards.
Alternatively, the position information of the model vertices of the object model may be obtained from model vertex data of the object model, which includes, but is not limited to, position information of each vertex of the object model, height information, color information of the object model, rendering type, material type, and the like. Optionally, the grid point height of each grid point of the terrain grid corresponding to the object model can be obtained from the grid point height map according to the first target position information of the terrain grid corresponding to the object model in the terrain to be rendered, stretching processing is performed on each vertex of the object model in the y-axis direction in the world coordinate system according to the grid point height of each grid point of the terrain grid corresponding to the object model, and the position information of the model vertex of the object model is obtained according to the world coordinate value of the vertex in the x-direction and the world coordinate value in the y-direction in the world coordinate system in the stretched object model.
Step 232, according to the target position information, obtaining the grid point height of each grid point of the terrain grid corresponding to the object model from the grid point height map, and obtaining the ground elevation height of each grid point of the terrain grid corresponding to the object model from the ground height map.
Step 233, obtaining the vertex height of the model vertex of the object model according to the lattice point heights of the lattice points of the terrain mesh corresponding to the object model, and obtaining the ground bump height of the model vertex of the object model according to the ground bump height of the lattice points of the terrain mesh corresponding to the object model.
Step 234, rendering the object model according to the ground elevation height of the model vertices and the vertex heights.
Further, in some embodiments, for each object model, the object model is rendered according to a vertex renderer in terms of a vertex height and a ground bump height of model vertices of the object model.
The vertex height of the model vertex refers to the height that the model vertex needs to move when moving from the current position to the preset position.
Further, in some embodiments, the determining method for determining the vertex height of the model vertex of the object model may include:
(1) And determining the height grade corresponding to each grid point of the terrain grid corresponding to the object model according to the grid point height of each grid point of the terrain grid corresponding to the object model.
(2) And determining a target height grade matched with the vertex height grade in the height grade according to the vertex height grade of the model vertex corresponding to the object model.
(3) And determining the vertex height of the model vertex corresponding to the object model according to the grid point height of each grid point corresponding to the target height level.
The height of each model vertex in the object model and the minimum grid point height of each grid point of the terrain grid corresponding to the object model can be obtained, and the vertex height grade of each model vertex is obtained by subtracting the minimum grid point height from the height of each model vertex in the object model.
Optionally, the maximum grid point height of the grid points of the terrain grid corresponding to the object model and the height level corresponding to the grid points of the terrain grid corresponding to the object model may be determined according to the grid point heights of the grid points of the terrain grid corresponding to the object model, the target height level matched with the vertex height level in the height level may be determined according to the vertex height level of the model vertex corresponding to the object model, the height of the model vertex from the target height level may be obtained according to the grid point heights of the grid points corresponding to the target height level and the height of the model vertex, and the vertex height of the model vertex corresponding to the object model may be obtained according to the height of the model vertex from the target height level and the maximum grid point height.
Optionally, the maximum grid point height and the minimum grid point height of the grid points of the terrain grid corresponding to the object model may be obtained according to the grid point heights of the grid points of the terrain grid corresponding to the object model, the height level corresponding to the grid points of the terrain grid corresponding to the object model is determined, if the number of levels is equal to 2, a first preset height level threshold is determined, a first target vertex whose vertex height level is greater than the first preset height level threshold and a second target vertex whose vertex height level is less than or equal to the first preset height level threshold are selected according to the vertex height level of the first target vertex, a target height level matching with the vertex height level in the height level is determined according to the vertex height level of the first target vertex, the vertex height of each grid point corresponding to the target height level and the first target vertex are obtained according to the vertex height of each grid point corresponding to the first target height level, the vertex distance between the first target vertex and the first target vertex is determined according to the vertex height level of the first target vertex, and the vertex height of the first target vertex is determined as the first target height.
For example, when the number of height levels is equal to 2, that is, the number of grid points with three grid points in the terrain grid is the same, that is, the object model is a 2-order model, a first preset height level threshold is determined to be 1.5, a first target vertex with a vertex height level greater than 1.5 is selected from model vertices of the object model, as selected model vertices in the block diagram in fig. 7, the target height level matched with the vertex height level is determined to be a second order height, wherein the model height of the second order height is 2, the height of the first target vertex from the height level is obtained through 2-local_height1 according to the height of the first target vertex, the vertex height of the first target vertex corresponding to the object model is obtained through max_height, and the minimum grid point height min_height is determined to be the height of the second target vertex with the vertex height level less than or equal to 1.5 according to the maximum grid point height max_height 1.
Wherein the model height characterizes the height value of the model vertex at each level of height in the object model, for example, for an object model of 2 levels, the model height of the first level is 0 and the model height of the second level is 2; for an object model with 3-order height, the model height of the first-order height is 0, the model height of the second-order height is 2, and the model height of the third-order height is 4; for an object model of 4-step height, the model height of the first step height is 0, the model height of the second step height is 2, the model height of the third step height is 4, and the model height of the third step height is 6. It will be appreciated that, as shown in fig. 2, the height values of model vertices in each level of height in the object model are the same, so in the rendering of the object model, the vertex height of each model vertex in the object model needs to be determined according to the vertex height determination method of the model vertices according to the lattice point heights corresponding to the lattice points of the terrain mesh, and the object model is stretched based on the vertex heights.
Optionally, if the number of the levels is greater than 2, a plurality of height level thresholds are obtained, model vertices of the object model are grouped according to the plurality of height level thresholds and the vertex height levels of the model vertices of the object model, a plurality of model vertex groups are obtained, a target height level matched with each model vertex group in the height level is determined, and for each model vertex group, the vertex height of each model vertex in each model vertex group is obtained according to the lattice point height, the preset height and the height of each model vertex in the model vertex group corresponding to the target height level matched with the model vertex group.
For example, when the number of levels is 3, as shown in the (b) diagram of fig. 2, the object model includes three different levels, that is, the object model is a third order model, a first preset level threshold value of 1.5 is determined, a second preset level threshold value of 3.5, a third target vertex having a vertex level greater than 3.5 is selected from model vertices of the object model, a first target vertex having a vertex level less than or equal to 3.5 and a vertex level greater than 1.5 is selected from model vertices of the object model, and a second target vertex having a vertex level less than or equal to 1.5 is selected from model vertices of the object model. For a third target vertex, determining a third target height grade matched with the vertex height grade of the third target vertex as a third-order height, wherein the model height of the third-order height is 4, obtaining the height between the third target vertex and the third target height grade through 4-local_height2 according to the height local_height2 of the third target vertex, and obtaining the vertex height of the third target vertex through max_height2 according to the height between the third target vertex and the third target height grade and the maximum lattice point height max_heightof the third target vertex; and for the first target vertex, determining that the target height grade matched with the vertex height grade in the height grade is a second-order height, wherein the model height of the second-order height is 2, obtaining the height of the first target vertex from the target height grade through 2-local_height1 according to the height local_height1 of the first target vertex, obtaining the vertex height of the first target vertex corresponding to the object model through the middle_height2-local_height1 according to the second big lattice height, and determining the minimum lattice height min_heightas the vertex height of the second target vertex with the vertex height grade smaller than or equal to 1.5.
For example, when the number of levels is 4, as shown in the (c) diagram in fig. 2, the object model includes four different levels, that is, the object model is a fourth-order model, a first preset level threshold is determined to be 1.5, a second preset level threshold is determined to be 3.5, a third preset level threshold is determined to be 5.5, for a fourth target vertex whose vertex level is greater than 5.5, a fourth target vertex whose vertex level matches the vertex level of the fourth target vertex is determined to be a fourth-order height, wherein the model height of the fourth-order height is 6, the height between the fourth target vertex and the fourth target vertex is obtained by max_height-6 according to the height local_height3 of the fourth target vertex, and the height between the fourth target vertex and the fourth target vertex is obtained by max_height-6 according to the height of the maximum lattice point between the fourth target vertex and the fourth target vertex; for a third target vertex with the vertex height grade smaller than or equal to 5.5 and larger than 3.5, determining that a third target height grade matched with the vertex height grade of the third target vertex in the height grade is third-order height, wherein the model height of the third-order height is 4, the height between the third target vertex and the third target height grade is obtained through 4-local_height2 according to the height of the third target vertex, and the vertex height of the third target vertex is obtained through middle_height0-4-local_height2 according to the height between the third target vertex and the third target height grade and the second big lattice point height middle0; for the first target vertexes with the vertex height grades smaller than or 3.5 and larger than 1.5, determining that the target height grade matched with the vertex height grade in the height grades is a second-order height, wherein the model height of the second-order height is 2, obtaining the height of the first target vertexes from the target height grade according to the height local_height1 of the first target vertexes through 2-local_height1, and obtaining the vertex height of the first target vertexes corresponding to the object model according to the third big lattice point height middle_height1 through middle_height1-2-local_height1; for a second target vertex having a vertex height level less than or equal to 1.5, the minimum lattice height min_height is determined as the vertex height of the second target vertex.
Further, in some embodiments, in step 233, the grid relative position of the model vertex of the object model in the terrain grid may be obtained according to 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, and the ground elevation height of the model vertex of the object model may be obtained according to the grid relative position of the model vertex of the object model in the terrain grid and the ground elevation height corresponding to each grid point of the terrain grid, specifically, as shown in fig. 6, step 233 at least includes steps 2331 to 2332:
step 2331, obtaining the grid relative position of the model vertex of the object model in the terrain grid corresponding to the object model according to the position information of the model vertex, the target position information of the terrain grid 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 grid corresponding to the object model.
The grid relative position refers to the relative position of the model vertex of the object model in the terrain grid corresponding to the object model.
In some embodiments, the grid relative position LocalPos of the model vertex of the object model in the terrain grid corresponding to the object model may be obtained according to the position information WorldPos2 of the model vertex, the second target position information UV of the terrain grid corresponding to the object model in the terrain to be rendered, the size TerrainCellCount of the terrain to be rendered, the position information TerrainOffset of the starting point, the size TerrainCellSize of the terrain grid corresponding to the object model, and the grid relative position LocalPos of the model vertex of the object model in the terrain grid corresponding to the object model.
Step 2332, obtaining the ground elevation height of the model vertex according to the grid relative position and the ground elevation height of each grid point of the terrain grid corresponding to the object model.
Further, in some embodiments, the ground elevation height of each grid point of the terrain grid corresponding to the object model may be obtained by performing a linear difference on the ground elevation height of each grid point according to the grid relative position. For example, taking the example that the ground elevation heights corresponding to the left upper grid point, the right upper grid point, the left lower grid point and the right lower grid point of the terrain grid corresponding to the object model are respectively height0, height1, height2, height3 and the grid relative position are LocalPos as illustrations, linear interpolation can be performed once according to height0, height1, height2, height3 and LocalPos to obtain the first initial ground elevation height of the model vertex and the second initial ground elevation height of the model vertex, and linear interpolation is performed again according to the first initial ground elevation height and the second initial ground elevation height of the model vertex to obtain the ground elevation height of the model vertex. For example, the first initial ground elevation d0 of the model vertex may be obtained by height0 (1-localpos.x) +height1 x localpos.x, the second initial ground elevation d1 of the model vertex may be obtained by height2 (1-localpos.x) +height3 x localpos.x, and the ground elevation of the model vertex may be obtained by d0 (1-localpos.y) +d1 x localpos.y.
Further, in some embodiments, after obtaining the vertex height and the ground elevation height of the model vertex of the object model, stretching the model vertex of the object model according to the vertex height of the model vertex of the object model to obtain an intermediate object model, and adjusting the vertex height of the model vertex of the intermediate object model according to the ground elevation height of the model vertex to obtain a target object model, as shown in fig. 8, fig. 8 is a schematic diagram of the target object model provided in the embodiment of the present application, and the target object model information is rendered according to a preset color map by a vertex shader.
Further, in some embodiments, to increase the detail features of the rendered terrain, and ensure the visual effect of the rendered terrain, the normal line of the object model needs to be adjusted, and the normal line is rendered after being adjusted according to the preset normal line map and the preset color map. The normal map is a special texture which can be applied to a 3D surface, so that each pixel of each plane of the rendered terrain has more surface information, and more stereoscopic vision effects can be created on the surface of the rendered terrain. Specifically, the normal map may record the difference in surface normal direction between the bottom surface number model and the high surface number model, and the post-shader uses the normal map to process the reflection direction of the light ray, so as to generate illusions for the viewer, thereby increasing the details of the low surface number model surface.
Specifically, step 234 includes steps d 1-d 5:
and d1, determining the normal direction of each grid point of the terrain grid corresponding to the object model.
For each grid point of the terrain grid corresponding to the object model, the normal direction of the grid point can be obtained by determining the normal direction of the triangular surface adjacent to the grid point, and by taking the upper left grid point of the terrain grid corresponding to the object model as an example for illustration, as shown in fig. 9, when the position information of the grid point is P0, the position information of the grid point adjacent to the grid point is P1, P2, P3 and P4 respectively, the vector V0 above the grid point is obtained through P1-P0, the vector V1 to the left of the grid point is obtained through P4-P0, the vector V2 below the grid point is obtained through P3-P0, P2-P0 obtains a vector V3 of the lattice point in the right direction, and the normals N0, N1, N2, N3 of the triangular surfaces in the upper left, lower right, and upper right adjacent to the lattice point are obtained by cross (V0, V1), cross (V1, V2), cross (V2, V3), and cross (V3, V4), respectively, and the normal direction of the lattice point is obtained by normalization by normal (0.25 x (n0+n1+n2+n3)).
And d2, carrying out linear interpolation on the normal direction according to the relative positions of the grids to obtain the vertex normal direction of the model vertex of the object model.
In some embodiments, linear interpolation can be performed on the normal direction of each grid point of the terrain grid at the grid relative position to obtain a first initial vertex normal direction and a second initial vertex normal direction of the model vertex, and linear interpolation is performed again according to the first initial vertex normal direction and the second initial vertex normal direction of the model vertex to obtain the vertex normal direction of the model vertex of the object model. For example, the normal direction of the grid point corresponding to the upper left corner, the upper right corner, the lower left corner and the lower right corner of the terrain grid corresponding to the object model is respectively represented by normal0, normal1, normal2 and normal3, the grid relative position is (LocalPos.x, localPos.y), the first initial vertex normal direction n1 is obtained through normal0 (1-localpos.x) +normal 1 x localpos.x, the second initial vertex normal direction n2 is obtained through normal2 (1-localpos.x) +normal3 x localpos.x, and the normal direction of the model vertex of the object model is obtained through n0 (1-localpos.y) +n1 x localpos.y according to the first initial vertex normal direction n1 and the second initial vertex normal direction n 2.
And d3, obtaining offset data of the model vertex of the object model relative to the vertex normal direction according to the vertex normal direction of the model vertex of the object model.
Further, in some embodiments, the vertex height of the model vertex and the vertex normal direction of the model vertex of the object model may be multiplied by a preset control coefficient to obtain offset data of the model vertex of the object model relative to the vertex normal direction. For example, the model vertex height of the model vertex may be multiplied by the vertex normal direction of the model vertex of the object model, and then multiplied by the preset control coefficient to obtain the offset data of the model vertex of the object model with respect to the vertex normal direction.
Further, in some embodiments, an initial normal direction of a model vertex of the object model may be obtained according to step d1, and the initial normal direction of the model vertex of the object model may be compared with a vertex normal direction of the model vertex of the object model, so as to obtain offset data of the model vertex of the object model with respect to the vertex normal direction.
And d4, adjusting the object model according to the offset data, the vertex height and the ground bulge height to obtain a target object model.
Further, in some embodiments, the model vertices of the object model may be stretched according to the vertex heights of the model vertices to obtain an intermediate object model, the vertex heights of the model vertices of the intermediate object model may be adjusted according to the ground bump heights of the model vertices to obtain an initial target object model, and the model vertices of the initial target object model may be shifted according to the shift data to obtain the target object model.
Further, in some embodiments, the offset data may offset model vertices of the object model to obtain an offset object model, stretch the model vertices of the offset object model according to the vertex heights of the model vertices to obtain an intermediate object model, and adjust the vertex heights of the model vertices of the intermediate object model according to the ground bump heights of the model vertices to obtain the target object model.
And d5, rendering the target object model.
Further, in some embodiments, after the target object model is obtained, the target object model is rendered according to a preset normal map and a preset color map.
In some embodiments of the present application, considering that a call of a graphics rendering interface is performed once for rendering one object model, performance consumption may be increased, so that after obtaining the target object model, batch rendering may be performed on multiple target object models. For example, static batch rendering, dynamic batch rendering, instance batch rendering, or the like is performed on the plurality of target object models.
In some embodiments of the present application, there may be an object model that does not need to be rendered, such as a land level, a shielding area, etc., so after determining an object model corresponding to each terrain mesh, the object model that does not need to be rendered in the object models corresponding to all terrain meshes is removed, the removed object model is rendered according to steps 231 to 232 described above,
further, in some embodiments, if the object model corresponding to each terrain mesh is determined and removed, the processing efficiency may be reduced, based on this, according to the position information of the terrain mesh, the embodiment of the application combines the object models corresponding to the terrain meshes adjacent to the position information into an initial object model cluster, screens a plurality of initial object model clusters according to the vertex position information of the bounding box formed by each initial object model cluster, and obtains an object model cluster, and renders the object model in each object model cluster according to the steps 231 to 232. The bounding box formed by the initial object model cluster refers to a three-dimensional model drawn by the maximum value and the minimum value of the initial object model cluster in the x direction, the maximum value and the minimum value in the y direction and the maximum value and the minimum value in the z direction in a world coordinate system.
Specifically, the method for determining the object model cluster includes:
(1) And grouping object models corresponding to the terrain grids according to the preset area range and the position information of the terrain grids to obtain a plurality of initial object model clusters.
(2) And determining bounding boxes of the initial object model clusters and vertex position information of the bounding boxes.
(3) And screening the plurality of initial object clusters according to the vertex position information of the bounding boxes of the initial object clusters to obtain the object model clusters with the vertex position information meeting the preset position requirement.
(4) And rendering the object model in each object model cluster according to the grid point height map and the ground height map.
The preset area range may be a preset number of terrain meshes, for example, object models corresponding to 4*4 terrain meshes adjacent to each other in the terrain meshes included in the terrain to be rendered may be combined into an initial object model cluster. Or, the object models belonging to the same model in the object models corresponding to each adjacent 4*4 terrain grids in the terrain grids included in the terrain to be rendered are combined into an initial object model cluster, wherein the object models belonging to the same model refers to that the object models in the terrain grids can be mutually converted, and two object models shown in a diagram (a) in fig. 4 and a diagram (b) in fig. 4 are the same model.
Optionally, for each initial object model cluster, bounding boxes of the initial object model cluster may be obtained by merging bounding boxes of object models in the initial object model cluster.
Wherein the vertex position information of the bounding box refers to world coordinates of corner points of the bounding box in a world coordinate system,
the preset position requirement may be that all vertices on the bounding box are inside a preset view cone.
Optionally, vertex position information of bounding boxes of each initial object model cluster may be input into a preset model to obtain a first value of each initial object model cluster, a second value of each initial object model cluster is obtained according to position information of a center point of the bounding box of each initial object model cluster, and for each initial object model cluster, whether the initial object model cluster meets a preset position requirement is determined according to a difference value between the first value and the second value of the initial object model cluster.
The method includes obtaining a second value according to position information origin of a center point of a bounding box of an initial object model cluster through a x+b x origin y+c origin z+d, determining that the initial object model cluster does not meet a preset position requirement according to vertex position information (a, B, C) of the bounding box of each initial object model cluster and a size box of the bounding box, obtaining a first value through abs (a) abs (box extension x) +abs (B) abs (box extension y) +abs (C) abs (box extension z), determining that the initial object model cluster does not meet the preset position requirement if the second value-first value >0 indicates that vertices on the bounding box are not inside a preset view cone, and determining that the initial object model cluster meets the preset position requirement if the second value-first value indicates that vertices on the bounding box are inside the preset view cone.
The following describes apparatus embodiments of the present application that may be used to perform the methods of the above-described embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments described above in the present application.
Fig. 10 is a block diagram of a rendering apparatus of a terrain model according to an embodiment of the present application, and as shown in fig. 10, the rendering apparatus of a terrain model includes:
an acquisition module 11, configured to acquire terrain mesh data of a terrain to be rendered; the terrain grid data comprises terrain grids of the terrain to be rendered, grid point heights corresponding to grid points of the terrain grids and ground bump heights;
the matching module 12 is configured to obtain an object model corresponding to each terrain grid according to the height of each grid point corresponding to each grid point of each terrain grid;
the rendering module 13 renders the object model corresponding to each terrain mesh according to the height of the grid point and the height of the position corresponding to each grid point of each terrain mesh.
Further, in some embodiments of the present application, the matching module 12 is configured to:
aiming at each terrain grid, determining the height grade corresponding to each grid point of the terrain grid according to the height of the grid point corresponding to each grid point of the terrain grid; the height grade represents the height difference type of each grid point of the terrain grid, and the height grade comprises a first-order height, a second-order height, a third-order height and a fourth-order height;
Encoding the height grade corresponding to each grid point of the terrain grid to obtain the height code of the terrain grid;
obtaining an object model matched with the terrain grid according to the height code of the terrain grid and a preset dictionary; the preset dictionary comprises a plurality of preset height codes and preset object models corresponding to the height codes.
Further, in some embodiments of the present application, the matching module 12 is configured to:
determining the target height of each grid point of the terrain grid according to the grid point height corresponding to each grid point of the terrain grid;
sequencing the target heights of all grid points of the terrain grid to obtain a sequencing result of the target heights of all grid points of the terrain grid;
and according to the sequencing result of the target heights of the grid points of the terrain grid, obtaining the height grade corresponding to the grid points of the terrain grid.
Further, in some embodiments of the present application, the matching module 12 is configured to:
determining the minimum grid point height in the grid point heights corresponding to all grid points of the terrain grid;
and obtaining the target height of each grid point of the terrain grid according to the difference value between the grid point height corresponding to each grid point of the terrain grid and the minimum grid point height.
Further, in some embodiments of the present application, the rendering module 13 is configured to:
according to the grid point height corresponding to each grid point of each terrain grid, a grid point height map of the terrain to be rendered is obtained, and according to the ground bump height corresponding to each grid point of each terrain grid, a ground height map of the terrain to be rendered is obtained; the terrain grids of the terrain to be rendered are respectively in one-to-one correspondence with the pixel points in the grid point height map and the pixel points in the ground height map, the color channel of each pixel point in the grid point height map is used for storing the grid point heights of all grid points of the corresponding terrain grids, and the color channel of each pixel point in the ground height map is used for storing the ground bump heights of all grid points of the corresponding terrain grids;
and (3) invoking the GPU, and rendering an object model corresponding to each terrain grid according to the grid point height map and the ground height map.
Further, in some embodiments of the present application, the rendering module 13 is configured to:
grouping object models corresponding to all terrain grids according to a preset area range and position information of all terrain grids to obtain a plurality of initial object model clusters;
determining bounding boxes of the initial object model clusters and vertex position information of the bounding boxes;
Screening the plurality of initial object clusters according to the vertex position information of the bounding boxes of the initial object clusters to obtain object model clusters with the vertex position information meeting the preset position requirement;
and rendering the object models in each object model cluster according to the grid point height map and the ground height map.
Further, in some embodiments of the present application, the rendering module 13 is configured to:
aiming at each object model, obtaining target position information of a terrain grid corresponding to the object model in the terrain to be rendered according to position information of a preset anchor point of the object model, position information of a starting point of the terrain to be rendered and the size of the terrain to be rendered;
according to the target position information, the grid point heights of all grid points of the terrain grid corresponding to the object model are obtained from the grid point height map, and the ground elevation heights of all grid points of the terrain grid corresponding to the object model are obtained from the ground height map;
obtaining the vertex height of the model vertex of the object model according to the grid point height of each grid point of the terrain grid corresponding to the object model, and obtaining the ground bulge height of the model vertex of the object model according to the ground bulge height of each grid point of the terrain grid corresponding to the object model;
And rendering the object model according to the ground elevation height of the model vertexes and the vertex height.
Further, in some embodiments of the present application, the rendering module 13 is configured to:
obtaining the grid relative position of the model vertex of the object model in the terrain grid corresponding to the object model according to the position information of the model vertex, the target position information of the terrain grid 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 grid corresponding to the object model;
and obtaining the ground elevation height of the model vertex according to the relative positions of the grids and the ground elevation height of each grid point of the terrain grid corresponding to the object model.
Further, in some embodiments of the present application, the rendering module 13 is configured to:
determining the normal direction of each grid point of the terrain grid corresponding to the object model;
linear interpolation is carried out on the normal direction according to the grid relative position, and the vertex normal direction of the model vertex of the object model is obtained;
obtaining offset data of the model vertex of the object model in the vertex normal direction according to the vertex normal direction of the model vertex of the object model;
adjusting the model vertexes of the object model according to the offset data, and adjusting the heights of the object model according to the vertexes of the model vertexes and the ground uplift heights to obtain a target object model;
Rendering the target object model.
Further, in some embodiments of the present application, the rendering module 13 is configured to:
determining the height grade corresponding to each grid point of the terrain grid corresponding to the object model according to the grid point height of each grid point of the terrain grid corresponding to the object model;
determining a target height grade matched with the vertex height grade in the height grade according to the vertex height grade of the model vertex corresponding to the object model;
and determining the vertex height of the model vertex corresponding to the object model according to the grid point height of each grid point corresponding to the target height level.
Fig. 11 is a schematic structural view of an electronic device according to an embodiment of the present application. The electronic device may be a server, but may also be other devices that may be used to perform the rendering method of the terrain model provided in the present application.
As shown in fig. 11, the apparatus may include a memory 20, a processor 30, and a communication unit 40, wherein the memory 20 stores a rendering program of a terrain model executable by the processor 30, and when the electronic apparatus 100 is operated, the processor 30 and the memory 20 communicate with each other through a bus, the processor 30 executes the rendering program of the terrain model, and executes a rendering method of the terrain model.
The memory 20, the processor 30 and the communication unit 40 are electrically connected directly or indirectly to each other to realize signal transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The rendering program of the terrain model is stored in a software function in the memory 20. The processor 30 is configured to execute executable modules (e.g., software functional modules or computer programs included in a rendering program of a terrain model) stored in the memory 20.
The Memory 20 may be, but is not limited to, a random access Memory (Random Access Memory, RAM), a Read Only Memory (ROM), a programmable Read Only Memory (Programmable Read-Only Memory, PROM), an erasable Read Only Memory (Erasable Programmable Read-Only Memory, EPROM), an electrically erasable Read Only Memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
Optionally, the processor 30 is configured to perform one or more of the functions described in this embodiment. Alternatively, the 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 (Central Processing Unit, CPU), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), special instruction set processor (Application Specific Instruction-setProcessor, ASIP), graphics processing unit (Graphics Processing Unit, GPU), physical processing unit (Physics Processing Unit, PPU), digital signal processor (Digital Signal Processor, DSP), field programmable gate array (Field Programmable Gate Array, FPGA), programmable logic device (Programmable Logic Device, PLD), controller, microcontroller unit, reduced instruction set computer (ReducedInstruction Set Computing, RISC), microprocessor, or the like, or any combination thereof. When the processor 30 executes the above-described rendering method of the terrain model, the CPU can implement the rendering of the terrain model by calling the GPU.
For ease of illustration, only one processor is depicted in the electronic device 100. It should be noted, however, that the electronic device 100 in the present embodiment may also include a plurality of processors, and thus the steps performed by one processor described in the present embodiment may also be performed jointly by a plurality of processors or performed separately. For example, if the processor of the server performs step a and step B, it should be understood that step a and step B may also be performed by two different processors together or performed separately in one processor. For example, the processor performs step a, the second processor performs step B, or the processor and the second processor together perform steps a and B.
In this embodiment, the memory 20 is used for storing a program, and the processor 30 is used for executing the program after receiving an execution instruction. The method of defining a flow disclosed in any embodiment of the present invention may be applied to the processor 30, or implemented by the processor 30.
The communication unit 40 is used for establishing a communication connection between the electronic device 100 and other devices through a network, and for transceiving data through the network.
Further, in some embodiments of the present application, the network may be any type of wired or wireless network, or a combination thereof. By way of example only, the network may include a wired network, a wireless network, a fiber optic network, a telecommunications network, an intranet, the Internet, a local area network (Local Area Network, LAN), a wide area network (Wide Area Network, WAN), a wireless local area network (Wireless Local Area Networks, WLAN), a metropolitan area network (Metropolitan Area Network, MAN), a wide area network (Wide Area Network, WAN), a public switched telephone network (Public Switched Telephone Network, PSTN), a Bluetooth network, a ZigBee network, a near field communication (Near Field Communication, NFC) network, or the like, or any combination thereof.
In this embodiment, the electronic device 100 may be, but is not limited to, a notebook computer, a mobile terminal, a personal computer, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook, a personal digital assistant (personal digital assistant, PDA), and the like, and the embodiment does not limit the specific type of the electronic device.
Although not shown, the electronic device 100 may further include a display unit or the like, which is not described herein. In particular, in this embodiment, the electronic device 100 loads executable files corresponding to the processes of one or more application programs into the memory 20 according to the following instructions, and the processor 30 executes the application programs stored in the memory 20, so as to implement various functions, as follows:
obtaining terrain grid data of the terrain to be rendered; the terrain grid data comprises terrain grids of the terrain to be rendered, grid point heights corresponding to grid points of the terrain grids and ground bump heights;
obtaining an object model corresponding to each terrain grid according to the grid height corresponding to each grid point of each terrain grid;
and rendering the object model corresponding to each terrain grid according to the grid point height corresponding to each grid point of each terrain grid and the ground bump height.
According to an aspect of embodiments of the present application, there is provided a computer readable storage medium having stored thereon computer readable instructions which, when executed by a processor, implement a method of rendering a terrain model as in any of the method embodiments above. For example, the computer readable instructions may perform the steps of:
obtaining terrain grid data of the terrain to be rendered; the terrain grid data comprises terrain grids of the terrain to be rendered, grid point heights corresponding to grid points of the terrain grids and ground bump heights;
obtaining an object model corresponding to each terrain grid according to the grid height corresponding to each grid point of each terrain grid;
and rendering the object model corresponding to each terrain grid according to the grid point height corresponding to each grid point of each terrain grid and the ground bump height.
It should be noted that, the computer readable medium shown in the embodiments of the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium may be, for example, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-Only Memory (ROM), an erasable programmable read-Only Memory (Erasable Programmable Read Only Memory, EPROM), flash Memory, an optical fiber, a portable compact disc read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. Where each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It should be noted that although in the above detailed description several modules or units of a device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functions of two or more modules or units described above may be embodied in one module or unit, in accordance with embodiments of the present application. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or may be implemented in software in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a usb disk, a mobile hard disk, etc.) or on a network, and includes several instructions to cause a computing device (may be a personal computer, a server, a touch terminal, or a network device, etc.) to perform the method according to the embodiments of the present application.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains.
It is to be understood that the present application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (13)

1. A method of rendering a terrain model, the method comprising:
obtaining terrain grid data of the terrain to be rendered; the terrain grid data comprise terrain grids of the terrain to be rendered, grid point heights corresponding to grid points of the terrain grids and ground bump heights;
obtaining an object model corresponding to each terrain grid according to the grid height corresponding to the grid point of each terrain grid;
and rendering the object model corresponding to each terrain grid according to the grid height corresponding to the grid point of each terrain grid and the ground bump height.
2. The rendering method according to claim 1, wherein the obtaining the object model corresponding to each of the terrain meshes according to the height of the lattice point corresponding to each of the lattice points of each of the terrain meshes includes:
determining the height grade corresponding to each grid point of the terrain grid according to the height of the grid point corresponding to each grid point of the terrain grid; the height grade characterizes the height difference type of each grid point of the terrain grid, and comprises a first-order height, a second-order height, a third-order height and a fourth-order height;
Encoding the height grade corresponding to each grid point of the terrain grid to obtain the height code of the terrain grid;
obtaining an object model matched with the terrain grid according to the height code of the terrain grid and a preset dictionary; the preset dictionary comprises a plurality of preset height codes and preset object models corresponding to the height codes.
3. The rendering method according to claim 2, wherein determining the height level corresponding to each grid point of the terrain grid according to the grid point height corresponding to each grid point of the terrain grid comprises:
determining the target height of each grid point of the terrain grid according to the grid point height corresponding to each grid point of the terrain grid;
sequencing the target heights of all grid points of the terrain grid to obtain sequencing results of the target heights of all grid points of the terrain grid;
and obtaining the height grade corresponding to each grid point of the terrain grid according to the sequencing result of the target heights of each grid point of the terrain grid.
4. A rendering method according to claim 3, wherein the determining the target height of each grid point of the terrain grid according to the grid point height corresponding to each grid point of the terrain grid comprises:
Determining the minimum grid point height in the grid point heights corresponding to all the grid points of the terrain grid;
and obtaining the target height of each grid point of the terrain grid according to the difference value between the grid point height corresponding to each grid point of the terrain grid and the minimum grid point height.
5. The rendering method according to claim 1, wherein the rendering the object model corresponding to each of the terrain meshes according to the height of the grid point corresponding to each of the grid points of each of the terrain meshes and the height of the ground bump, comprises:
obtaining a grid point height map of the terrain to be rendered according to the grid point heights corresponding to the grid points of the terrain grids;
obtaining a ground height map of the terrain to be rendered according to the ground bump height corresponding to each grid point of each terrain grid; the terrain grids of the terrain to be rendered are respectively in one-to-one correspondence with the pixel points in the grid point height map and the pixel points in the ground height map, the color channel of each pixel point in the grid point height map is used for storing the grid point heights of the grid points of the corresponding terrain grids, and the color channel of each pixel point in the ground height map is used for storing the ground uplift heights of the grid points of the corresponding terrain grids;
And (3) invoking the GPU, and rendering the object model corresponding to each terrain grid according to the grid point height map and the ground height map.
6. The rendering method according to claim 5, wherein said rendering the object model corresponding to each of the terrain meshes according to the grid point height map and the ground height map includes:
grouping object models corresponding to the terrain grids according to a preset area range and position information of the terrain grids to obtain a plurality of initial object model clusters;
determining bounding boxes of the initial object model clusters and vertex position information of the bounding boxes;
screening the plurality of initial object clusters according to the vertex position information of the bounding boxes of each initial object model cluster to obtain an object model cluster with the vertex position information meeting the preset position requirement;
and rendering the object model in each object model cluster according to the grid point height map and the ground height map.
7. The rendering method according to claim 5 or 6, wherein said rendering the object model corresponding to each of the terrain meshes from the grid point height map and the ground height map includes:
For each object model, obtaining target position information of a terrain grid corresponding to the object model in the terrain to be rendered according to position information of a preset anchor point of the object model, position information of a starting point of the terrain to be rendered and the size of the terrain to be rendered;
according to the target position information, the grid point heights of all grid points of the terrain grid corresponding to the object model are obtained from the grid point height map, and the ground elevation heights of all grid points of the terrain grid corresponding to the object model are obtained from the ground height map;
obtaining the vertex height of the model vertex of the object model according to the grid point height of each grid point of the terrain grid corresponding to the object model, and obtaining the ground bulge height of the model vertex of the object model according to the ground bulge height of each grid point of the terrain grid corresponding to the object model;
and rendering the object model according to the ground elevation height and the vertex height of the model vertex.
8. The rendering method according to claim 7, wherein the obtaining the ground elevation of the model vertex of the object model from the ground elevation of each grid point of the terrain grid corresponding to the object model includes:
Obtaining the grid relative position of the model vertex of the object model in the terrain grid corresponding to the object model according to the position information of the model vertex, the target position information of the terrain grid 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 grid corresponding to the object model;
and obtaining the ground elevation height of the model vertex according to the relative positions of the grids and the ground elevation height of each grid point of the terrain grid corresponding to the object model.
9. The rendering method according to claim 8, wherein the rendering the object model according to the ground elevation height and the vertex height of the model vertices includes:
determining the normal direction of each grid point of the terrain grid corresponding to the object model;
performing linear interpolation on each normal direction according to the grid relative positions to obtain a vertex normal direction of a model vertex of the object model;
obtaining offset data of the model vertex of the object model relative to the vertex normal direction according to the vertex normal direction of the model vertex of the object model;
According to the offset data, the vertex height and the ground bump height, the object model is adjusted to obtain a target object model;
rendering the target object model.
10. The rendering method according to claim 7, wherein the obtaining the vertex height of the model vertex of the object model according to the real lattice point height of each lattice point of the terrain mesh corresponding to the object model includes:
determining the height grade corresponding to each grid point of the terrain grid corresponding to the object model according to the actual grid point height of each grid point of the terrain grid corresponding to the object model;
determining a target height grade matched with the vertex height grade in the height grade according to the vertex height grade of the model vertex corresponding to the object model;
and determining the vertex height of the model vertex corresponding to the object model according to the real grid point height of the grid point corresponding to the target height level.
11. A rendering device for a terrain model, the device comprising:
the acquisition module is used for acquiring terrain grid data of the terrain to be rendered; the terrain grid data comprises terrain grids of the terrain to be rendered, and grid point heights and ground bump heights corresponding to grid points of the terrain grids;
The matching module is used for obtaining an object model corresponding to each terrain grid according to the grid height corresponding to each grid point of each terrain grid;
and the rendering module is used for rendering the object model corresponding to each terrain grid according to the grid point height corresponding to each grid point of each terrain grid and the ground bump height.
12. An electronic device, comprising:
a processor;
a memory having stored thereon computer readable instructions which, when executed by the processor, implement the method of any of claims 1 to 10.
13. A computer readable storage medium having computer readable instructions stored thereon, which when executed by a processor, implement the method of any of claims 1 to 10.
CN202310356546.XA 2023-03-30 2023-03-30 Rendering method and device of terrain model, electronic equipment and readable storage medium Pending CN116402932A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310356546.XA CN116402932A (en) 2023-03-30 2023-03-30 Rendering method and device of terrain model, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310356546.XA CN116402932A (en) 2023-03-30 2023-03-30 Rendering method and device of terrain model, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN116402932A true CN116402932A (en) 2023-07-07

Family

ID=87017409

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310356546.XA Pending CN116402932A (en) 2023-03-30 2023-03-30 Rendering method and device of terrain model, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN116402932A (en)

Similar Documents

Publication Publication Date Title
CN113178014B (en) Scene model rendering method and device, electronic equipment and storage medium
US11830143B2 (en) Tessellation method using recursive sub-division of triangles
CA2814226C (en) Triangle mesh compression
US20100289799A1 (en) Method, system, and computer program product for efficient ray tracing of micropolygon geometry
Haber et al. Smooth approximation and rendering of large scattered data sets
US10614178B2 (en) Scalable and precise fitting of NURBS surfaces to large-size mesh representations
US8456470B2 (en) Lighting environment simulation system and method
CN103559374A (en) Method for subdividing surface split type curved surfaces on multi-submesh model
CN108305314A (en) Computing system and method for handling graph data
CN117178297A (en) Micro-grid for structured geometry of computer graphics
CN115222806B (en) Polygon processing method, device, equipment and computer readable storage medium
CN106127850A (en) The three-dimensional visualization method of a kind of mobile terminal indoor and outdoor integration and device
WO2022161319A1 (en) Shadow mapping processing method and apparatus, and device, computer-readable storage medium and program product
CN115546371A (en) Point cloud optimization method and system, electronic device and storage medium
CN108986210B (en) Method and device for reconstructing three-dimensional scene
Chen et al. An improved texture-related vertex clustering algorithm for model simplification
CN112233241B (en) Method and device for generating height map of virtual scene terrain and storage medium
CN109697748A (en) Model compression processing method, model pinup picture processing method device, storage medium
CN112597260A (en) Visualization method and device for air quality mode forecast data
KR20160068204A (en) Data processing method for mesh geometry and computer readable storage medium of recording the same
CN116402932A (en) Rendering method and device of terrain model, electronic equipment and readable storage medium
CN114170394B (en) Method and device for optimizing display of massive inclined data on Web end
Lee et al. Bimodal vertex splitting: Acceleration of quadtree triangulation for terrain rendering
CN115035231A (en) Shadow baking method, shadow baking device, electronic apparatus, and storage medium
CN112730743A (en) Interaction method and device for air quality mode forecast data

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination