A method for rendering large quantities of vector data based on shadow mapping
By parsing vector tiles into geometric data and building them into mesh data, combined with Unreal Engine's depth map calculation and post-processing rendering technology, the calculation cost and rendering quality cannot be balanced when rendering large-batch vector data in the existing technology is solved. The problem is to achieve efficient and accurate rendering effect.
Patent Information
- Application Number
- CN202411541538.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-10-31
AI Technical Summary
In the prior art, when rendering large batches of vector data, the calculation cost and rendering quality cannot be balanced.
Using a large-batch vector data rendering method based on shadow mapping, the vector tiles are parsed into geometric data, constructed into mesh data, and the depth value of each pixel is calculated using Unreal Engine, written into the virtual texture, and post-processing. Render.
It reduces the use of computing resources, improves rendering efficiency, and realizes efficient rendering of large-scale vector data, ensures the accuracy and consistency of map display, and avoids problems such as suspension and mold penetration.
Smart Images

Figure CN119048707B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of three-dimensional rendering, and in particular to a large-volume vector data rendering method based on shadow mapping. Background Art
[0002] Rendering vector data to three-dimensional terrain refers to mapping two-dimensional vector data to a three-dimensional terrain model. It is often used in geographic information systems (GIS), 3D visualization, and virtual environment modeling to display the shape of real geographic features in three-dimensional space.
[0003] There are currently three common methods for rendering vector data into 3D terrain:
[0004] 1. Rasterization: rasterize vector data to a texture, and then merge this texture with the terrain texture. Rasterization is the simplest and most effective solution in current technology. Its advantages are that there is no additional vertex overhead and the calculation cost is low; its disadvantages are that the vector edge and accuracy will be affected by the size of the rasterized texture, resulting in aliasing, and dislocation due to the terrain detail level.
[0005] 2. Geometric rendering method: interpolate and encrypt a part of points between two vertices of vector data, and intersect these points through rays to calculate the height of the terrain, and then use the vector vertex data with height to build mesh data and render it as an independent model. The advantages of the geometric rendering method are simple implementation and the best interactive effect; the disadvantages are that the complexity of the terrain may cause suspension and penetration, and interpolation causes the number of vertices to increase exponentially, consuming a lot of computing resources.
[0006] 3. Volumetric shadow method: The orthographic projection area of the two-dimensional vector on the terrain surface is used as the final area of vector rendering. The vector data needs to be constructed into a two-dimensional grid first, then stretched up and down into a shadow body, and then each pixel is calculated pixel by pixel whether it is in the shadow body, and the pixels in the shadow body are stored in the template buffer. Finally, in the post-processing process, the specified pixel area is rendered according to the value of the template buffer. The advantage of the volumetric shadow method is that it can achieve pixel-level accuracy, can fit perfectly on the terrain surface, and is not affected by the level of detail and undulation of the terrain; the disadvantage is that the shadow body generates additional vertices and memory usage, and the pixel-by-pixel judgment of whether it is in the shadow body generates a lot of algorithm overhead.
[0007] In summary, existing vector data rendering methods cannot achieve a balance between computational cost and rendering quality when rendering large quantities of vector data. Summary of the invention
[0008] Therefore, the technical problem to be solved by the present invention is to overcome the problem in the prior art that the computational cost and the rendering quality cannot be balanced when rendering large quantities of vector data.
[0009] In order to solve the above technical problems, the present invention provides a method for rendering large quantities of vector data based on shadow mapping, comprising:
[0010] Publish vector data as vector tile map services;
[0011] Requesting a vector tile map service in the Unreal Engine to obtain binary data of the vector tile; parsing the binary data of the vector tile into geometric data, and converting the coordinate system of the geometric data into the Unreal Engine coordinate system; constructing the geometric data converted into the Unreal Engine coordinate system into mesh data;
[0012] Use the Unreal Engine to calculate the depth value of each pixel of the mesh data and write it into the virtual texture;
[0013] Post-process rendering based on the depth value of each pixel in the virtual texture.
[0014] Preferably, the vector data is published as a vector tile map service using Geoserver software.
[0015] Preferably, the use of Geoserver software to publish vector data as a vector tile map service includes:
[0016] Get the vector shp data that needs to be rendered, create a new workspace in Geoserver, create a new data source, and import the vector shp data into the Geoserver storage warehouse;
[0017] Create a new layer on the Geoserver layer page, and select the vector shp data imported from the storage warehouse to add to the layer;
[0018] In the Tile Caching options for each layer, select the tile format as mapbox-vector-tile and set the layer information;
[0019] Save the layer and publish it as a vector tile map service.
[0020] Preferably, the vector tile map service includes TMS or WMTS.
[0021] Preferably, requesting the vector tile map service in the Unreal Engine to obtain binary data of the vector tile includes:
[0022] Import the Cesium For Unreal plugin into the Unreal Engine, and add the Vector Overlay Provider for vector tile resolution to the raster resolution architecture of the Cesium For Unreal plugin to access the vector tile map service;
[0023] Get the camera view matrix in real time, and use the Cesium For Unreal plug-in to calculate the current map level and vector tile row and column numbers based on the camera view matrix;
[0024] The vector tile row and column numbers are passed to the Vector Overlay Provider, and spliced into a URL address for requesting a vector tile map service. The vector tile map service is requested according to the URL address to obtain the binary data of the vector tile.
[0025] Preferably, parsing the binary data of the vector tile into geometric data and converting the coordinate system of the geometric data into the Unreal Engine coordinate system includes:
[0026] Add a VectorLoader class to load binary data of vector tiles, use the gdal library or pbr library to parse the binary data of each vector tile, and return the parsed result as geometric data;
[0027] Converts the coordinate system of the geometry data to the Unreal Engine coordinate system.
[0028] Preferably, constructing the geometric data converted to the Unreal Engine coordinate system into mesh data comprises:
[0029] Based on UMeshComponent and FVectorMeshSceneProxy classes, scene rendering commands are passed when constructing mesh data;
[0030] A CreateMesh() function is constructed for merging the geometric data of all vector tiles into one mesh data, wherein the input of the CreateMesh() function is the geometric data and the output is the mesh data; the geometric data is constructed into the mesh data using the CreateMesh() function.
[0031] Preferably, the step of calculating the depth value of each pixel of the mesh data by using the Unreal Engine and writing the depth value into the virtual texture comprises:
[0032] Calculate the depth value of each pixel of the mesh data at a preset viewing angle in a parallel projection scene, including:
[0033] Get the depth value of each pixel of the mesh data and construct a depth map of the mesh data;
[0034] The projection coordinates of each pixel are calculated through the orthogonal projection matrix, and it is determined whether the depth of each pixel is clipped under the preset viewing angle; if the depth of the current pixel is not clipped, the depth value of the current pixel is updated to 1, otherwise it is updated to 0;
[0035] Creates a virtual texture and writes the updated depth value for each pixel in the mesh data to the virtual texture.
[0036] Preferably, the calculating of the depth value of each pixel of the mesh volume data at a preset viewing angle in the parallel projection scene includes:
[0037] Build the CustomDepthRenderPass file, which inherits the CustomRenderPass function of Unreal Engine 5.4 and is used to calculate the depth value of each pixel of the mesh data at a preset viewing angle in a parallel projection scene.
[0038] Preferably, the post-processing rendering based on the depth value of each pixel in the virtual texture includes:
[0039] Set the parameters of the post-processing material;
[0040] The depth values of all pixels in the virtual texture are judged. If the depth value of the current pixel is 1, the pixel corresponding to the current pixel is rendered based on the post-processing material, otherwise no processing is performed.
[0041] The above technical solution of the present invention has the following beneficial effects compared with the prior art:
[0042] The method for rendering large quantities of vector data based on shadow mapping described in the present invention parses vector tiles into geometric data, then merges the geometric data into mesh data, uses Unreal Engine to render the mesh data, determines the shadow part of the object in the scene by generating a depth map, applies the shadow mapping technology to the rendering of electronic map vector data, and directly renders the depth value under the current camera. The depth map generated by the present invention is independent of the scene complexity and the amount of vector data. Compared with the method of geometric rendering and volume shadow, it does not generate additional vertex data, nor does it need to determine whether it is located in the shadow pixel by pixel, which reduces the occupation of computing resources, not only improves the rendering efficiency, realizes the rendering of large quantities of vector data, and effectively uses the depth map to project the vector data onto the terrain surface, ensuring the accuracy and consistency of the map display, avoiding problems such as suspension and penetration, and providing a strong guarantee for the efficient operation of the geographic information system. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:
[0044] Figure 1 It is a flow chart of a method for rendering large quantities of vector data based on shadow mapping of the present invention;
[0045] Figure 2It is a flowchart for vector data analysis;
[0046] Figure 3 It is a flowchart for performing rendering based on geometric data;
[0047] Figure 4 This is the core code diagram of UVectorMeshComponent;
[0048] Figure 5 This is an example diagram of the electronic map effect output by the method of the present invention. DETAILED DESCRIPTION
[0049] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0050] Reference Figure 1 As shown, the present invention provides a method for rendering large quantities of vector data based on shadow mapping, and the specific steps include:
[0051] S1. Use Geoserver software to publish vector data as vector tile map services.
[0052] S1-1. Get the vector shp data that needs to be rendered, create a new workspace in Geoserver, create a new data source, and import the vector shp data into the Geoserver storage warehouse.
[0053] S1-2. Create a new layer on the layer page of Geoserver and select the vector shp data imported from the storage warehouse to add to the layer.
[0054] S1-3. In the Tile Caching option of each layer, select the tile format as mapbox-vector-tile and set the layer information, including the coordinate system, range, etc.
[0055] S1-4. Save the layer and publish it as a vector tile map service.
[0056] Preferably, the vector tile map service includes TMS or WMTS.
[0057] S2. Request a vector tile map service in Unreal Engine (UE) to obtain binary data of the vector tile; parse the binary data of the vector tile into geometric data, and then construct the geometric data into mesh data.
[0058] S2-1. Import the Cesium For Unreal plug-in into the Unreal Engine, and add the Vector Overlay Provider for vector tile resolution to the raster resolution architecture of the Cesium For Unreal plug-in to access the vector tile map service.
[0059] S2-2. Based on the quadtree and camera view matrix of the Cesium framework, calculate the row and column numbers of the vector tiles that need to be loaded and hidden at the current map level in the Unreal Engine.
[0060] S2-3. Pass the vector tile row and column numbers to the Vector Overlay Provider, concatenate them into a URL address for requesting the vector tile map service, request the vector tile map service, and obtain the binary data of the vector tile.
[0061] Taking WMTS as an example, the URL address for requesting WMTS is: http: / / baseURL / zoom / tileX / tileY.png, where zoom represents the level number, tileX represents the vector tile column number, and tileY represents the vector tile row number.
[0062] S2-4. Parse the binary data of each vector tile into geometric data. The specific method is as follows:
[0063] Add a VectorLoader class to load the binary data of vector tiles, use the gdal library or pbr library to parse the binary data of each vector tile, and return the parsed result as a custom tile structure FVectorData, that is, geometric data.
[0064] Converts the coordinate system of the geometry data to the Unreal Engine coordinate system.
[0065] S2-5. Use the geometric data converted to the Unreal Engine coordinate system to construct mesh data.
[0066] Based on UMeshComponent and FVectorMeshSceneProxy, a new C++ class UVectorMeshComponent is created. The core code of UVectorMeshComponent is referenced Figure 4 As shown, commands are used to pass scene rendering when building mesh data.
[0067] Construct the CreateMesh() function to merge the geometric data of all vector tiles into one mesh data. The CreateMesh() function extracts the coordinates of polygons, line segments, and points in the geometric data by parsing, constructs the corresponding vertex and index arrays for each geometry, and then uses the vertex and index arrays of all geometries to generate mesh data.
[0068] The purpose of merging the geometric data of vector tiles into one mesh data is to make the rendering of the entire vector occupy only one rendering batch, thereby improving rendering efficiency.
[0069] The input of the CreateMesh() function is the tile structure FVectorData, and the output is mesh data.
[0070] S3. Use the Unreal Engine to calculate the depth value of each pixel of the mesh data and write it into the virtual texture.
[0071] S3-1. Calculate the depth value of each pixel of the mesh data at a preset viewing angle in a parallel projection scene, including:
[0072] Get the depth value of each pixel of the mesh data and construct a depth map of the mesh data;
[0073] The projection coordinates of each pixel are calculated through the orthogonal projection matrix, and it is determined whether the depth of each pixel is clipped under the preset viewing angle; if the depth of the current pixel is not clipped, the depth value of the current pixel is updated to 1, otherwise it is updated to 0.
[0074] At different preset angles, the pixels blocked in the mesh data are different, that is, the pixels clipped by depth are different. Therefore, when the preset angle changes, the depth value of each pixel in the mesh data needs to be recalculated, the depth value in the virtual texture needs to be updated, and post-processing rendering needs to be performed again.
[0075] Specifically, at the current viewing angle, if the projection coordinates of multiple pixels in the grid data are the same, depth clipping occurs. The depth values of multiple pixels with the same projection coordinates are determined, and the pixel with the smallest depth value can be displayed. The remaining pixels with larger depth values will be blocked by the pixel with the smallest depth value. Therefore, the depth value of the pixel with the smallest depth value is updated to 1, and the depth values of the remaining pixels are updated to 0.
[0076] Preferably, this embodiment constructs a CustomDepthRenderPass file in the Unreal Engine, which inherits the new function CustomRenderPass of the Unreal Engine 5.4. The CustomDepthRenderPass file is used to calculate the depth value of each pixel of the mesh data at a preset viewing angle in a parallel projection scene.
[0077] The code of the CustomDepthRenderPass file is as follows:
[0078] FString DebugName = TEXT("CustomDepthRenderPass");
[0079] FCustomRenderPassBase::ERenderMode RenderMode =FCustomRenderPassBase::ERenderMode::DepthPass;
[0080] FCustomRenderPassBase::ERenderOutput RenderOutput =FCustomRenderPassBase::ERenderOutput::SceneDepth;
[0081] FTestCustomRenderPass* CustomPass = new FTestCustomRenderPass(DebugName, RenderMode, RenderOutput, RenderTarget);
[0082] PassInput.CustomRenderPass = CustomPass;
[0083] FSceneInterface* Scene = GWorld->GetWorld()->Scene;
[0084] Scene->CustomRenderPassRendererInputs.Add(PassInput);
[0085] The CustomDepthRenderPass file is directly calculated in the main rendering pipeline, which saves a rendering pipeline compared to the traditional scene depth capture solution and greatly optimizes the efficiency of scene depth capture.
[0086] S3-2. Create a virtual texture and write the depth value of each pixel in the mesh data into the virtual texture.
[0087] S4. Perform post-processing rendering based on the depth value of each pixel in the virtual texture.
[0088] S4-1. Create post-processing materials.
[0089] S4-2. Set the parameters of post-processing materials, including color and line width.
[0090] S4-3, judging the depth values of all pixels in the virtual texture, if the depth value of the current pixel is 1, rendering the pixel corresponding to the current pixel based on the post-processing material, otherwise no processing is performed.
[0091] Since post-processing rendering is done after scene rendering, it effectively avoids the problem of flickering caused by scene re-rendering due to post-processing material modifications.
[0092] The electronic map effect example diagram output by the method of the present invention is shown in FIG. Figure 5 shown.
[0093] Compared with the prior art, the present invention has the following beneficial effects:
[0094] 1. The present invention parses vector tiles into geometric data, then merges the geometric data into mesh data, uses Unreal Engine to render the mesh data, determines the shadow part of the object in the scene by generating a depth map, applies Shadow Mapping technology to the rendering of electronic map vector data, and directly renders the depth value under the current camera. The depth map generated by the present invention is independent of the scene complexity and the amount of vector data. Compared with the method of geometric rendering and volume shadow, it does not generate additional vertex data, nor does it need to determine whether it is in the shadow pixel by pixel, which reduces the occupation of computing resources, not only improves the rendering efficiency, but also realizes the rendering of large quantities of vector data, and effectively uses the depth map to project the vector data onto the terrain surface, ensuring the accuracy and consistency of the map display, avoiding problems such as suspension and penetration, and providing a strong guarantee for the efficient operation of the geographic information system.
[0095] 2. The present invention uses the virtual texture technology of the Unreal Engine to optimize shadow mapping, which solves the bottleneck that the rendering quality of traditional shadow mapping technology is limited by the size of the depth map texture, and significantly improves the rendering quality compared to the traditional effect.
[0096] 3. The present invention uses Unreal Engine to realize scene rendering while constructing mesh data, and then uses post-processing technology to edit the rendering effect by setting post-processing materials. Since post-processing rendering is performed after scene rendering, it effectively avoids the problem of flickering caused by re-rendering of scenes due to modification of layers and element materials.
[0097] 4. The rendering method of the present invention has good scalability. It can not only be applied to the rendering of vector data, but also be combined with other geographic information system functions, such as spatial analysis, map interaction, etc., to provide users with richer and more comprehensive geographic information services. In addition, most three-dimensional engines support shadow mapping technology, so the present invention also has good scalability in other engines.
[0098] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0099] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0100] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0101] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0102] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. A method for rendering large quantities of vector data based on shadow mapping, characterized in that: include: Publish vector data as vector tile map services; Request the vector tile map service in Unreal Engine to obtain the binary data of the vector tile; Parse the binary data of the vector tile into geometric data and convert the coordinate system of the geometric data to the Unreal Engine coordinate system; Construct the geometric data converted to the Unreal Engine coordinate system into mesh data; Use the Unreal Engine to calculate the depth value of each pixel of the mesh data and write it to the virtual texture, including: Calculate the depth value of each pixel of the mesh data at a preset viewing angle in a parallel projection scene, including: Get the depth value of each pixel of the mesh data and construct a depth map of the mesh data; The projection coordinates of each pixel are calculated through the orthogonal projection matrix, and it is determined whether the depth of each pixel is clipped under the preset viewing angle; if the depth of the current pixel is not clipped, the depth value of the current pixel is updated to 1, otherwise it is updated to 0; Create a virtual texture and write the updated depth value of each pixel in the mesh data to the virtual texture; Post-processing rendering based on the depth value of each pixel in the virtual texture, including: Create post-processing materials; Set the parameters of the post-processing material; The depth values of all pixels in the virtual texture are judged. If the depth value of the current pixel is 1, the pixel corresponding to the current pixel is rendered based on the post-processing material, otherwise no processing is performed.
2. The method for rendering large quantities of vector data based on shadow mapping according to claim 1, characterized in that: Use Geoserver software to publish vector data as vector tile map services.
3. The method for rendering large quantities of vector data based on shadow mapping according to claim 2, characterized in that: The use of Geoserver software to publish vector data as vector tile map services includes: Get the vector shp data that needs to be rendered, create a new workspace in Geoserver, create a new data source, and import the vector shp data into the Geoserver storage warehouse; Create a new layer on the Geoserver layer page, and select the vector shp data imported from the storage warehouse to add to the layer; In the Tile Caching options for each layer, select the tile format as mapbox-vector-tile and set the layer information; After saving the layer, publish it as a vector tile map service.
4. The method for rendering large quantities of vector data based on shadow mapping according to claim 3, characterized in that: The vector tile map service includes TMS or WMTS.
5. The method for rendering large quantities of vector data based on shadow mapping according to claim 1, characterized in that: The requesting of the vector tile map service in the Unreal Engine to obtain the binary data of the vector tile includes: Import the Cesium For Unreal plugin into the Unreal Engine, and add the Vector Overlay Provider for vector tile resolution to the raster resolution architecture of the Cesium For Unreal plugin to access the vector tile map service; Get the camera view matrix in real time, and use the Cesium For Unreal plug-in to calculate the current map level and vector tile row and column numbers based on the camera view matrix; The vector tile row and column numbers are passed to the Vector Overlay Provider, and spliced into a URL address for requesting a vector tile map service. The vector tile map service is requested according to the URL address to obtain the binary data of the vector tile.
6. The method for rendering large quantities of vector data based on shadow mapping according to claim 1, characterized in that: Parse the binary data of the vector tile into geometric data and convert the coordinate system of the geometric data to the Unreal Engine coordinate system, including: Add a VectorLoader class to load binary data of vector tiles, use the gdal library or pbr library to parse the binary data of each vector tile, and return the parsed result as geometric data; Converts the coordinate system of the geometry data to the Unreal Engine coordinate system.
7. The method for rendering large quantities of vector data based on shadow mapping according to claim 1, characterized in that: The step of constructing the geometric data converted to the Unreal Engine coordinate system into mesh data includes: Based on UMeshComponent and FVectorMeshSceneProxy classes, scene rendering commands are passed when constructing mesh data; A CreateMesh() function is constructed for merging the geometric data of all vector tiles into one mesh data, wherein the input of the CreateMesh() function is the geometric data and the output is the mesh data; the geometric data is constructed into the mesh data using the CreateMesh() function.
8. The method for rendering large quantities of vector data based on shadow mapping according to claim 1, characterized in that: The step of calculating the depth value of each pixel of the mesh data at a preset viewing angle in the parallel projection scene includes: Build the CustomDepthRenderPass file, which inherits the CustomRenderPass function of Unreal Engine 5.4 and is used to calculate the depth value of each pixel of the mesh data at a preset viewing angle in a parallel projection scene.
Citation Information
Patent Citations
Shadow rendering method and device, terminal and storage medium
CN109993823A
Image reconstruction method, system and equipment and computer readable storage medium
CN111669564A