CN-121982176-A - Terrain rendering method, apparatus, electronic device and storage medium
Abstract
The method comprises the steps of constructing terrain grid data corresponding to a plurality of layers in an off-line mode, enabling the terrain grid data corresponding to the layers to be used for describing basic terrain and mountains in the basic terrain, conducting bidirectional grid vertex alignment processing between adjacent layers on the terrain grid data corresponding to the layers in the off-line mode to obtain multi-layer terrain grid data, and conducting on-line rendering on the basis of camera parameters and the multi-layer terrain grid data. The method and the device realize the compromise of high-precision terrain presentation and high-performance cross-view smooth scaling.
Inventors
- Wu Menzhen
Assignees
- 星臻科技(上海)有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251208
Claims (14)
- 1. A terrain rendering method, the method comprising: constructing terrain grid data corresponding to a plurality of layers in an off-line manner, wherein the terrain grid data corresponding to the layers are used for describing basic terrain and mountains in the basic terrain; performing bidirectional grid vertex alignment processing between adjacent layers on the terrain grid data corresponding to the multiple layers respectively in an off-line manner to obtain multi-layer terrain grid data; And performing online rendering based on camera parameters and the multi-level terrain mesh data.
- 2. The method according to claim 1, wherein the offline performing bidirectional mesh vertex alignment processing between adjacent layers on the terrain mesh data corresponding to the multiple layers respectively to obtain multi-layer terrain mesh data includes performing the following operations on the terrain mesh data of any two adjacent layers: inserting part of boundary vertexes of the first grid into corresponding positions of boundaries of the second grid to serve as new vertexes in the second grid; Determining a target vertex based on the vertex in the first grid and the vertex in the second grid, and deleting the target vertex in the first grid; the first grid refers to a grid indicated by the topographic grid data corresponding to the low level in the any two adjacent levels, and the second grid refers to a grid indicated by the topographic grid data corresponding to the high level in the any two adjacent levels.
- 3. The method of claim 2, wherein the determining a target vertex based on the vertices in the first mesh and the vertices in the second mesh comprises: Determining a mapping position of the vertex corresponding to any vertex in the first grid in the second grid, and determining two vertexes adjacent to the mapping position in the second grid as a first vertex and a second vertex respectively; Taking the height difference between the vertex and the first vertex as a first height difference, and taking the height difference between the vertex and the second vertex as a second height difference; and if the difference value of the first height difference and the second height difference is smaller than a preset threshold value, and the vertex, the first vertex and the second vertex have a collinear relationship, and the vertex is determined to be the target vertex.
- 4. The method according to claim 2, wherein the method further comprises: and taking the points in the outer contour boundary in the first grid as the vertexes of the first grid, and taking the points in the outer contour boundary in the second grid as the vertexes of the second grid.
- 5. The method of claim 1, wherein the constructing, offline, the terrain mesh data corresponding to each of the plurality of levels comprises: Performing terrain grid baking on the terrain elevation map based on the terrain elevation map to characterize basic terrain, so as to obtain a multi-resolution terrain grid; Placing a three-dimensional mountain model in a terrain scene and baking the scene, and synchronously loading the multi-resolution terrain grid and the three-dimensional mountain model in the scene baking process to obtain mixed data, wherein the mixed data comprises multi-resolution terrain grid data and a height map, and the multi-resolution terrain grid data comprises a mountain texture map; And obtaining terrain grid data corresponding to the multiple layers respectively based on the mixed data.
- 6. The method of claim 5, wherein the camera parameters include camera height, and wherein the online rendering based on the camera parameters and the multi-level terrain mesh data comprises: rendering a three-dimensional mountain model positioned in a visual field under the condition that the height of the camera is smaller than a preset height; Rendering target data located within a field of view, the target data from the multi-level terrain mesh data, and the target data including the mountain texture map, if the camera height is greater than or equal to the preset height.
- 7. The method of claim 6, wherein the rendering the target data located within the field of view comprises: Determining a hierarchy to be rendered based on the camera height; Extracting the target data in the view field from the multi-level terrain mesh data based on the level to be rendered, and extracting a map resource under a target level in the multi-level terrain mesh data based on the view field, wherein the target level is an upper level of the level to be rendered; Rendering the target data.
- 8. The method of claim 7, wherein the field of view is determined based on the camera height and camera position, the extracting the target data within the field of view in the multi-level terrain mesh data based on the level to be rendered comprising: Determining each of the layers to be rendered to the highest layer as a valid layer; Determining a plurality of grids under each effective level within the field of view; And taking data corresponding to grids under each effective level as the target data.
- 9. The method of claim 8, wherein the online rendering based on camera parameters and the multi-level terrain mesh data comprises: under the condition that the highest-level terrain grid data is determined to be loaded based on the camera parameters, synchronously loading the highest-level terrain grid data; Under the condition that the non-highest-level terrain mesh data are required to be loaded based on the camera parameters, asynchronous loading is carried out on the non-highest-level terrain mesh data; the highest-level terrain mesh data loaded last time is always reserved.
- 10. The method of claim 1, wherein the online rendering based on camera parameters and the multi-level terrain mesh data comprises: in the case where the condition of rendering from the high level to the low level is satisfied, if all fourth meshes corresponding to a third mesh are loaded, the fourth meshes are displayed at the same time, the third mesh is hidden, the third mesh is any mesh belonging to the high level in the field of view, the fourth mesh is a mesh in an adjacent low level, and the terrain range formed by the third mesh coincides with the terrain range formed by the fourth meshes.
- 11. A terrain rendering device, the device comprising: A base data construction module configured to perform off-line construction of terrain mesh data corresponding to a plurality of levels, respectively, the terrain mesh data corresponding to the plurality of levels being used to describe a base terrain and mountains in the base terrain; the vertex alignment module is configured to perform off-line bidirectional grid vertex alignment processing between adjacent layers on the terrain grid data corresponding to the multiple layers respectively to obtain multi-layer terrain grid data; and the rendering module is configured to perform online rendering based on camera parameters and the multi-level terrain mesh data.
- 12. An electronic device, comprising: A processor; A memory for storing the processor-executable instructions; Wherein the processor is configured to execute the instructions to implement a terrain rendering method as claimed in any of claims 1 to 10.
- 13. A computer readable storage medium, characterized in that the instructions in the computer readable storage medium, when executed by a processor of an electronic device, perform the terrain rendering method of any of claims 1 to 10.
- 14. A computer program product, characterized in that it comprises a computer program stored in a readable storage medium, from which at least one processor of a computer device reads and executes the computer program, causing the device to perform the terrain rendering method as claimed in any of claims 1 to 10.
Description
Terrain rendering method, apparatus, electronic device and storage medium Technical Field The disclosure relates to the field of computer technology, and in particular relates to a terrain rendering method, a terrain rendering device, electronic equipment and a storage medium. Background Limitations in hardware conditions become a major bottleneck in terrain rendering on mobile devices. Because the GPU has lower performance, complex graphic calculation tasks cannot be processed efficiently, and rendering effects are difficult to meet the requirement of high precision. At the same time, the limited memory resources also present a significant challenge to the loading and storage of terrain data. These factors act together to make it particularly difficult to implement functions that can both present high-precision terrain and support high-performance cross-view smooth scaling at the mobile end. At present, the related technology is difficult to realize the combination of high-precision terrain presentation and high-performance cross-view smooth scaling. Disclosure of Invention The present disclosure provides a terrain rendering method, apparatus, electronic device, and storage medium to solve the problems in the related art. The technical scheme of the present disclosure is as follows: according to a first aspect of embodiments of the present disclosure, there is provided a terrain rendering method, the method comprising: constructing terrain grid data corresponding to a plurality of layers in an off-line manner, wherein the terrain grid data corresponding to the layers are used for describing basic terrain and mountains in the basic terrain; performing bidirectional grid vertex alignment processing between adjacent layers on the terrain grid data corresponding to the multiple layers respectively in an off-line manner to obtain multi-layer terrain grid data; And performing online rendering based on camera parameters and the multi-level terrain mesh data. In an exemplary embodiment, the offline performs bidirectional mesh vertex alignment processing between adjacent layers on the terrain mesh data corresponding to the multiple layers respectively to obtain multi-layer terrain mesh data, and the method includes the following operations on the terrain mesh data of any two adjacent layers: inserting part of boundary vertexes of the first grid into corresponding positions of boundaries of the second grid to serve as new vertexes in the second grid; Determining a target vertex based on the vertex in the first grid and the vertex in the second grid, and deleting the target vertex in the first grid; the first grid refers to a grid indicated by the topographic grid data corresponding to the low level in the any two adjacent levels, and the second grid refers to a grid indicated by the topographic grid data corresponding to the high level in the any two adjacent levels. In an exemplary embodiment, the determining the target vertex based on the vertex in the first mesh and the vertex in the second mesh includes: Determining a mapping position of the vertex corresponding to any vertex in the first grid in the second grid, and determining two vertexes adjacent to the mapping position in the second grid as a first vertex and a second vertex respectively; Taking the height difference between the vertex and the first vertex as a first height difference, and taking the height difference between the vertex and the second vertex as a second height difference; and if the difference value of the first height difference and the second height difference is smaller than a preset threshold value, and the vertex, the first vertex and the second vertex have a collinear relationship, and the vertex is determined to be the target vertex. In an exemplary embodiment, the method further comprises: and taking the points in the outer contour boundary in the first grid as the vertexes of the first grid, and taking the points in the outer contour boundary in the second grid as the vertexes of the second grid. In an exemplary embodiment, the offline construction of the terrain mesh data corresponding to each of the plurality of levels includes: Performing terrain grid baking on the terrain elevation map based on the terrain elevation map to characterize basic terrain, so as to obtain a multi-resolution terrain grid; Placing a three-dimensional mountain model in a terrain scene and baking the scene, and synchronously loading the multi-resolution terrain grid and the three-dimensional mountain model in the scene baking process to obtain mixed data, wherein the mixed data comprises multi-resolution terrain grid data and a height map, and the multi-resolution terrain grid data comprises a mountain texture map; And obtaining terrain grid data corresponding to the multiple layers respectively based on the mixed data. In an exemplary embodiment, the camera parameters include camera height, and the online rendering based on the camera parameters and the