GPU-based terrain contour line and elevation marking efficient display method and system

By directly generating contour lines and elevation labels during the GPU fragment processing stage, the problem of low rendering efficiency in existing technologies is solved, and real-time, efficient display and interactive stability of 3D terrain scenes are achieved.

CN121767527APending Publication Date: 2026-03-31CHINA RAILWAY ERYUAN ENGINEERING GROUP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-12
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing technologies for 3D terrain visualization have low real-time rendering efficiency for contour lines and elevation labels, making it difficult to meet the real-time and stability requirements of large-scale scenes. In particular, when adjusting contour intervals, zooming the viewpoint, or updating terrain data, a large amount of CPU computation and resource consumption are required.

Method used

By directly determining the contour line display attributes and elevation label values ​​during the GPU fragment processing stage, CPU preprocessing is reduced, enabling real-time generation and fusion output of contour lines and elevation labels, thereby reducing data transmission volume and computational overhead.

Benefits of technology

It enables real-time dynamic display of contour lines and elevation labels, improving the rendering efficiency and smoothness of large-scale 3D terrain scenes, and ensuring adaptive line width and consistent label perspective.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121767527A_ABST
    Figure CN121767527A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer graphics, in particular to a terrain contour line and elevation marking efficient display method and system based on a GPU (Graphics Processing Unit). Comprising the steps that in the terrain rendering process of a GPU, a terrain elevation value serves as fragment-level rendering input and is transmitted to a fragment processing stage; in the segment processing stage, determining a contour line display attribute of a segment based on the terrain elevation value and a preset contour line parameter to generate a contour line display result, and determining a corresponding elevation labeling value based on the terrain elevation value to generate a labeling display result; and carrying out fusion output on the contour line display result and the annotation display result on a GPU (Graphic Processing Unit) to obtain a rendered image containing the terrain contour line and the elevation annotation. According to the method, the contour lines and the elevation marks are generated and fused in real time at the GPU slice element level, and the contour lines and the marks of the contour lines can be efficiently and dynamically displayed in a large-scale three-dimensional terrain in a line width / mark adaptive and consistent mode without CPU preprocessing and manual configuration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer graphics technology, and in particular to a GPU-based method and system for efficiently displaying terrain contour lines and elevation labels. Background Technology

[0002] In computer graphics and 3D terrain visualization, contour lines and their elevation labels are crucial for representing terrain features. Current technologies typically rely on the CPU to extract contour lines from digital elevation models or terrain meshes, generating numerous vector polylines, which are then uploaded to the GPU for rendering. When contour intervals are adjusted, the viewpoint is zoomed, or terrain data is updated, contour lines often need to be recalculated and reconstructed on the CPU, increasing the data processing burden, slowing down interactive responses, and making it difficult to meet the requirements of real-time rendering.

[0003] In elevation annotation, existing methods typically determine the annotation location and calculate the annotation value on the CPU side, generating corresponding textured text or vector font data, which is then rendered by the GPU. This process not only requires additional texture construction and video memory usage, but also necessitates regenerating text resources when the annotation content or display scale changes. Even some systems with a degree of automation still rely on manually setting annotation points, manually adjusting annotation avoidance rules, or maintaining multiple sets of text resources at different scaling levels, resulting in low overall efficiency.

[0004] With the continuous increase in the scale of 3D terrain data and the growing demand for real-time interaction, traditional CPU-based preprocessing solutions have revealed significant bottlenecks in areas such as dynamic contour line generation, visual consistency of line width, and automatic updating of elevation labels. These bottlenecks include high computational costs, large resource consumption, complex rendering processes, and difficulty in maintaining stable frame rates and real-time performance in large-scale scenes. Therefore, how to directly complete contour line determination, line width adaptation, elevation label generation, and final rendering output within the GPU, reducing CPU intervention, decreasing data transfer volume, and improving overall rendering efficiency, has become a pressing technical problem to be solved in this field. Summary of the Invention

[0005] This application aims to address at least one of the technical problems existing in the prior art. This application provides a GPU-based method for efficient display of terrain contour lines and elevation annotations. It can perform real-time contour line determination and elevation annotation generation on 3D terrain data, achieving a terrain contour line display effect that maintains high efficiency, high consistency, and high real-time performance even in large-scale scenes. During 3D terrain rendering, the contour line display attributes and annotation display attributes can be determined based on the terrain elevation value corresponding to the fragment. By synchronously completing contour line generation, annotation value determination, and digital annotation drawing during the GPU fragment processing stage, a data generation process without CPU preprocessing is achieved. This ensures smooth, dynamic, and adaptive contour line and elevation annotation display effects even with changes in viewpoint, contour interval adjustment, or terrain resolution.

[0006] In a first aspect, embodiments of this application provide a method for efficiently displaying terrain contour lines and elevation labels based on a GPU, the method including: During the GPU rendering of terrain, the terrain elevation value is passed as fragment-level rendering input to the fragment processing stage. In the fragment processing stage, the contour display attributes of the fragment are determined based on the terrain elevation value and the preset contour line parameters to generate contour display results, and at the same time, the corresponding elevation label value is determined based on the terrain elevation value to generate label display results. The contour line display results and the annotation display results are fused and output on the GPU to obtain a rendered image containing terrain contour lines and elevation annotations.

[0007] According to some embodiments of this application, determining the contour display attributes of fragments in the fragment processing stage includes: The modulus of the primary curve is obtained by performing a modulus operation on the terrain elevation value and contour interval of the current fragment, and the modulus of the secondary curve is obtained by performing a modulus operation on the terrain elevation value and primary contour interval of the current fragment. Wherein, the first curve modulus is the result of taking the modulus of the current fragment elevation value and the contour interval, and the calculated curve modulus is the result of taking the modulus of the current fragment elevation value and the main contour interval.

[0008] According to some embodiments of this application, the main contour interval is set to a preset multiple of the contour interval, and the preset multiple is five, so that every five first curves correspond to one calculation curve.

[0009] According to some embodiments of this application, determining the contour display attributes of fragments in the fragment processing stage further includes: Calculate the rate of change of the current fragment elevation value in the first and second directions of screen space, and take the larger of the two as the rate of change of the fragment's neighborhood elevation. Multiply the elevation change rate by the preset contour line pixel width to obtain the elevation tolerance corresponding to the line width; When the magnitude of the first curve is not greater than the elevation tolerance, the current fragment is determined to belong to the first curve display area; when the magnitude of the calculated curve is not greater than the elevation tolerance, the current fragment is determined to belong to the calculated curve display area.

[0010] According to some embodiments of this application, the generation of contour display results in the fragment processing stage includes: Assign the first curve color to fragments belonging to the first curve display area and output visible transparency; Assign the curve color to the fragments belonging to the curve display area and output visible transparency; Output invisible transparency for fragments that are not part of the contour display area; The color of the first curve is different from the color of the calculation curve.

[0011] According to some embodiments of this application, the generation of annotation display results in the fragment processing stage includes: The screen space is divided into regular grid subspaces according to a preset number of rows and columns, and the center point of each grid subspace is determined as a candidate location for elevation labeling. Only at candidate elevation labels, when the fragments at the candidate position meet the condition of being close to the first curve or the count curve, an elevation label value consistent with the corresponding contour line is generated.

[0012] According to some embodiments of this application, the generation of annotation display results further includes: Pre-configure digital bitmaps with fixed pixel sizes for natural numbers 0 to 9, and encode the pixel positions that need to be lit in each digital bitmap as the corresponding digital bitmap encoding values; The elevation label value is decomposed bitwise to obtain each digit, and the target digit is determined based on the relative text coordinates of the current fragment at the label candidate position. Bitwise operations are performed based on the digital bitmap encoding value of the target bit and the pixel index of the bitmap corresponding to the current fragment. When the bitwise operation result indicates that the pixel is a lit pixel, the digital stroke color is output; otherwise, the opacity remains invisible.

[0013] Secondly, embodiments of this application provide a GPU-based high-efficiency display system for terrain contour lines and elevation markings, the system including: The input module is used to obtain terrain elevation values ​​during the GPU rendering process and pass the terrain elevation values ​​as fragment-level rendering input to the fragment processing stage. The processing module is used to determine the contour display attributes of the fragment based on the terrain elevation value and the preset contour parameters during the fragment processing stage, generate contour display results, and simultaneously generate annotation display results based on the terrain elevation value. The output module is used to fuse the contour line display results and the label display results on the GPU to obtain a rendered image containing terrain contour lines and elevation labels.

[0014] According to some embodiments of this application, the fragment processing module is configured as follows: The modulus of the primary curve is obtained by performing a modulus operation on the terrain elevation value and contour interval of the current fragment, and the modulus of the secondary curve is obtained by performing a modulus operation on the terrain elevation value and primary contour interval of the current fragment. Calculate the rate of change of the current fragment elevation value in the first and second directions of the screen space and take the larger one as the elevation change rate. Multiply the elevation change rate by the contour line pixel width to obtain the elevation tolerance corresponding to the line width. The first curve display result is output when the first curve modulus is not greater than the elevation tolerance, and the calculated curve display result is output when the calculated curve modulus is not greater than the elevation tolerance.

[0015] According to some embodiments of this application, the fragment processing module is further configured to: The screen space is divided into regular grid subspaces, and the center point of each subspace is used as the candidate location for elevation labeling. At the candidate elevation labeling location, the elevation labeling value is determined when the fragment meets the condition of being close to the first curve or the calculation curve; Bitwise operations are performed based on the preset natural number bitmap encoding and the pixel index of the fragment bitmap to generate the annotation display result corresponding to the elevation annotation value.

[0016] The efficient display method and system for terrain contour lines and elevation labels based on GPU according to the present invention has at least the following beneficial effects: The efficient display method and system for terrain contour lines and elevation labels based on GPU according to the present invention has at least the following beneficial effects: The GPU-based method for efficient display of terrain contour lines and elevation labels in this application first transmits terrain elevation values ​​to the fragment processing stage as fragment-level input during the GPU terrain rendering process. Then, in the fragment processing stage, the contour line display attributes of the fragment are directly determined based on the fragment elevation values ​​and preset contour line parameters, and contour line display results and elevation label display results are generated simultaneously. Finally, the contour line display results and label display results are fused and output on the GPU side to obtain a rendered image containing terrain contour lines and elevation labels. By decentralizing contour line determination, line width adaptation, and label value generation and digital drawing to the GPU fragment level and completing them all at once, real-time dynamic display is achieved without pre-extracting contour line vectors and pre-generating text resources on the CPU side. This significantly reduces CPU computation and CPU-GPU data transfer overhead, improves rendering efficiency and interactive smoothness in large-scale 3D terrain scenes, and ensures the adaptive consistency of contour line width and labels with changes in viewpoint, scale, and contour interval.

[0017] The GPU-based high-efficiency display system for terrain contour lines and elevation labels in this embodiment first obtains and transmits terrain elevation values ​​to the fragment processing stage in the terrain rendering pipeline via an input module. Then, at the fragment level, a processing module determines contour line display attributes, generates contour line display results, and determines and generates elevation label values ​​and display results based on the elevation values ​​and contour line parameters. Finally, an output module fuses the contour line display results and label display results on the GPU, ultimately outputting a terrain rendering image containing contour lines and elevation labels. By modularly completing the synchronous generation and fusion display of contour lines and labels within the GPU, real-time response to interactive operations such as contour interval adjustment, view distance scaling, and terrain resolution changes is achieved. This results in reduced system resource consumption, reduced manual parameter configuration and repetitive data construction, and improved real-time performance, stability, and engineering usability of 3D terrain contour line and elevation label display.

[0018] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing this application. Attached Figure Description

[0019] Figure 1 This is a flowchart illustrating the steps of the GPU-based method for efficiently displaying terrain contour lines and elevation labels in Embodiment 1 of this application. Figure 2 This is a flowchart illustrating the steps of the GPU-based terrain contour line and elevation label display method in Embodiment 2 of this application. Figure 3 This is a schematic diagram of the contour line generation method in Embodiment 2 of this application; Figure 4This is a schematic diagram of the 4*5 bitmap encoding method and encoding value of natural numbers 0 to 9 in Embodiment 2 of this application; Figure 5 This is a schematic diagram of the elevation marking location calculation method in Embodiment 2 of this application; Figure 6 This is a schematic diagram of the digital text display method of Embodiment 2 of this application; Figure 7 This is a schematic diagram of the contour line labeling display method in Embodiment 2 of this application. Detailed Implementation

[0020] The present application will now be described in further detail with reference to experimental examples and specific embodiments. However, this should not be construed as limiting the scope of the subject matter of the present application to the following embodiments. All technologies implemented based on the content of the present application fall within the scope of protection of the present application.

[0021] Unless otherwise specified, the use of terms such as "upper," "lower," "left," "right," "center," "inner," "outer," and "side" to indicate orientation or positional relationships in the description of specific embodiments of this application is based on the orientation or positional relationships shown in the accompanying drawings, or the orientation or positional relationship in which the product / equipment / device is usually placed during use. These terms are merely for the purpose of facilitating the description of the solution in this application or simplifying the description in specific embodiments, and for enabling those skilled in the art to quickly understand the solution, and do not indicate or imply that a particular device / component / element must have a specific orientation, or be constructed and operated in a specific positional relationship, and therefore should not be construed as a limitation of this application.

[0022] In the description of the embodiments of this application, technical terms such as "first" and "second" only distinguish one entity or operation from another, and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary or secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.

[0023] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0024] Example 1 During the research process, the applicant discovered that when using the traditional method of pre-extracting contour lines and generating vector line features using the CPU, followed by GPU rendering, achieving real-time dynamic display of contour lines and their elevation labels in a 3D terrain scene while maintaining smooth interaction requires repeated recalculation of contour lines, generation of label weights, and re-uploading of vector / texture data whenever the contour interval is adjusted, the viewpoint is zoomed, or the terrain resolution changes. This necessitates relying solely on high-frequency CPU calculations and manual parameter adjustments to maintain the display effect. When solving practical engineering problems, to achieve the technical objective of automatically updating contour lines and labels with changes in viewpoint, maintaining visually consistent line widths, and controlling system load under large-scale, high-resolution terrain conditions, existing technologies cannot meet the comprehensive requirements for real-time performance, automation, and rendering efficiency. Therefore, after researching this problem, the applicant proposed a GPU-based method for efficient display of terrain contour lines and elevation labels. Addressing the technical issues of traditional contour line / label generation relying on CPU preprocessing, incurring high update costs, and struggling to respond in real time, the method achieves real-time rendering of contour lines and elevation labels without CPU-side pre-generation or tedious manual adjustments. This reduces computational and transmission overhead, improves the display efficiency of large-scale 3D terrain scenes, and enhances interactive stability.

[0025] Please refer to Figure 1 , Figure 1 This diagram illustrates the steps of a GPU-based method for efficiently displaying terrain contour lines and elevation labels, as provided in an embodiment of this application. The method may include: During the GPU rendering of terrain, the terrain elevation value is passed as fragment-level rendering input to the fragment processing stage. In the fragment processing stage, the contour display attributes of the fragment are determined based on the terrain elevation value and the preset contour line parameters to generate contour display results, and at the same time, the corresponding elevation label value is determined based on the terrain elevation value to generate label display results. The contour line display results and the annotation display results are fused and output on the GPU to obtain a rendered image containing terrain contour lines and elevation annotations.

[0026] In some specific embodiments, the method may further include: When rendering 3D terrain using a GPU, the terrain elevation value is first used as fragment-level rendering input, passed from the vertex processing stage to the fragment processing stage. This allows each fragment to directly access its corresponding terrain elevation information during rendering. In the fragment processing stage, based on the fragment's terrain elevation value and preset contour line parameters, it is determined whether the fragment belongs to a contour line display area, and the corresponding contour line display result is generated. Simultaneously, based on the fragment's terrain elevation value, the corresponding elevation label value is determined, thus generating the elevation label display result. Finally, the contour line display result and the label display result are fused and output on the GPU to obtain a complete terrain rendering image containing both contour lines and elevation labels.

[0027] When determining the contour display attributes of a fragment, the first curve modulus is obtained by performing a modulo operation between the current fragment's terrain elevation value and the contour interval, and the count curve modulus is obtained by performing a modulo operation between the current fragment's terrain elevation value and the main contour interval. The first curve modulus is the result of the modulo operation between the current fragment's elevation value and the contour interval, and the count curve modulus is the result of the modulo operation between the current fragment's elevation value and the main contour interval. The modulo results are used to characterize the elevation position of the current fragment within the corresponding contour interval period. In this embodiment, the main contour interval is set to five times the contour interval, so that every five first curves correspond to one count curve.

[0028] Furthermore, to determine whether a fragment falls within the contour line display area, the rate of change of the fragment's elevation value in the first and second directions of the screen space is calculated, and the larger of the two is taken as the elevation change rate of the fragment's neighborhood. This rate of change is then multiplied by a preset contour line pixel width to obtain the elevation tolerance corresponding to the line width. When the magnitude of the first curve is not greater than this elevation tolerance, the fragment is determined to belong to the first curve display area; when the magnitude of the calculated curve is not greater than this elevation tolerance, the fragment is determined to belong to the calculated curve display area.

[0029] When generating contour display results, fragments belonging to the first curve display area are assigned the first curve color and output visible transparency, fragments belonging to the count curve display area are assigned the count curve color and output visible transparency, and fragments not belonging to any contour display area are output invisible transparency. The first curve color and the count curve color are different from each other.

[0030] When generating the annotation display results, the screen space is divided into regular grid subspaces according to a preset number of rows and columns, and the center point of each grid subspace is used as the candidate position for elevation annotation. Only when the fragment at a candidate position meets the condition of being close to the first curve or the calculated curve based on the fragment elevation value, an elevation annotation value consistent with the corresponding contour line is generated.

[0031] To render digital annotations at the GPU fragment stage, this embodiment pre-configures a fixed-pixel-size digital bitmap for each natural number from 0 to 9, and encodes the pixel positions to be illuminated in the digital bitmap into corresponding digital bitmap encoding values. The generated elevation annotation values ​​are decomposed bitwise to obtain each digit, and the target digit is determined based on the relative text coordinates of the current fragment at the annotation candidate position. Then, bitwise operations are performed between the target digit's digital bitmap encoding value and the pixel index of the current fragment in the digital bitmap. If the bitwise operation result indicates that the pixel is one to be illuminated, the digital stroke color is output; otherwise, the transparency remains invisible, thus completing the rendering of elevation annotation numbers at the fragment level.

[0032] Through the above steps, this embodiment realizes the completion of contour line determination, line width adaptation, annotation value determination and digital annotation drawing in the GPU in one go, and merges the two types of display results for output, thereby obtaining real-time, efficient and dynamically adaptive contour line and elevation annotation rendering effects in terrain scenes.

[0033] It should be noted that the description of fragment-level processing in the embodiments of this invention mainly uses the fragment shader in the graphics rendering pipeline as an example for illustration, to explain the basic processing flow of contour line determination, elevation annotation generation, and digital stroke drawing at the fragment level on the GPU. Those skilled in the art will understand that fragment-level parallel processing is not limited to implementation in the form of a fragment shader. Without departing from the technical solution of this invention, general GPU parallel computing frameworks such as GPU compute shaders, CUDA, OpenCL, Metal, or Vulkan can also be used. By constructing a parallel thread grid that corresponds one-to-one with the fragment positions in screen space, the same pixel-by-pixel calculation and display result generation of fragment elevation values ​​and contour line parameters can be performed. All of the above different GPU implementation methods can complete the fragment-level parallel processing logic required by this invention and do not affect the overall concept and technical effects of this invention.

[0034] The GPU-based method for efficient display of terrain contour lines and elevation labels provided in this application can be applied to many technical fields, such as 3D terrain visualization, geographic information systems (GIS), digital twin cities, vehicle navigation and simulation training, engineering survey and mapping visualization, including large-scale DEM / DSM terrain rendering, integrated display of urban terrain and facilities, terrain deformation visualization in disaster monitoring scenarios, and terrain representation in virtual simulation environments. In the above implementation, when rendering and displaying 3D terrain data in real time, the terrain elevation value can be passed as a fragment-level input to the fragment processing stage in the GPU rendering pipeline. Within the same fragment processing stage, the contour line display attribute determination and elevation label value generation can be completed simultaneously based on the elevation value and contour line parameters. Furthermore, the label text can be directly drawn at the fragment level using digital bitmap encoding. By fusing the contour line display result and the label display result at the GPU, dynamic display can be achieved without pre-extracting contour line vectors from the CPU or manually configuring label resources. This reduces computation and data transmission overhead, improves the real-time interactivity of large-scale terrain scenes, and ensures the consistency of contour line width and label with adaptive viewpoint / scale.

[0035] Example 2 As a further optimization of the preceding embodiments, this application provides a specific implementation of a GPU-based method for efficiently displaying terrain contour lines and elevation labels, such as... Figure 2 As shown, the main steps include: S1: Pass terrain elevation values ​​to fragment shaders in the vertex shader. First, the elevation values ​​of the terrain mesh are obtained during the vertex shading stage, and these elevations are passed as interpolation values ​​to the fragment shader. This allows the GPU to directly access the precise elevation data of the current fragment during per-fragment rendering. In this way, all subsequent contour line calculations can be completed on the fly at the fragment level, without CPU preprocessing or loading additional contour line vector data.

[0036] S2: As Figure 3 Draw contour lines as shown. Figure 3 A schematic diagram of contour line generation. S2.1 Elevation Modulus Calculation Based on the preset contour spacing, the modulus distanceToContour of the current fragment's elevation relative to the first curve and the modulus distanceToMainContour relative to 5 times the contour spacing (counting curves) are calculated. The modulus represents the "remaining amount" of the current fragment in the contour spacing period, and its physical meaning is the distance of the fragment from the corresponding contour line on the elevation axis.

[0037] S2.2 Calculation of Elevation Change Rate and Linear Tolerance Using GLSL's dFdx, dFdy, and max, we obtain the partial derivatives of the current fragment's elevation in the X and Y directions of screen space, and take the maximum of these two values ​​to characterize the "maximum elevation change rate" near the fragment. Multiplying this maximum change rate by the screen pixel width of the contour line (contourWidth) yields the maximum possible change in the fragment's elevation within a contourWidth pixel range (contourWidthDeltaHeight). This amount can be considered as the "height tolerance" after mapping the contour line width to the elevation domain.

[0038] S2.3 Contour Type Determination When distanceToContour > contourWidthDeltaHeight, it means the fragment does not fall within the screen bandwidth of the first curve; when distanceToContour ≤ contourWidthDeltaHeight, it means the fragment belongs to the display area of ​​the first curve; when distanceToMainContour ≤ contourWidthDeltaHeight, it means the fragment belongs to the display area of ​​the main curve. Through these judgments, it is possible to determine in real-time within the GPU whether any fragment falls on a contour line position based solely on its elevation value.

[0039] S2.4 Contour Coloring The final color of the contour line is set according to the contour type to which the fragment belongs: the primary contour is displayed in green, the secondary contour is displayed in red; non-contour areas remain transparent or the background color. At this point, contour rendering is complete, without requiring any CPU-generated vector contours or texture sampling.

[0040] S3: Draw contour line labels S3.1 Annotation Position Calculation (10×10 Subspace of Screen) like Figure 5 As shown, Figure 5 This diagram illustrates the method for calculating elevation annotation locations. The current viewport screen space is evenly divided into 10×10 sub-regions. For each fragment, its sub-region is determined based on its screen coordinates, and the coordinates of the center point of that sub-region are calculated. This center point serves as a candidate location for elevation annotations, used to subsequently determine whether annotation text needs to be drawn.

[0041] S3.2 Labeled Area Recognition (Based on Elevation Tolerance) Referring to the method in S2.2, with 50 pixels as a larger tolerance range, calculate contourLabelAreaDeltaHeight, which represents the amount of elevation change that may occur within the text display height range.

[0042] If distanceToContour ≤ contourWidthDeltaHeight, then this subspace is the location for the first curve label; if distanceToMainContour ≤ contourWidthDeltaHeight, then this subspace is the location for the second curve label. This determination ensures that the label location falls accurately near the contour line without offset or misalignment.

[0043] S3.3 4×5 bitmap encoding of digits 0–9 like Figure 4 As shown, Figure 4 This is a schematic diagram illustrating the encoding method and encoding values ​​for natural numbers 0 to 9 using a 4*5 bitmap. Specifically, this embodiment uses a 4-column × 5-row bitmap to represent the natural numbers 0 to 9, where the encoding values ​​are as follows: Bitmap 0 encoding value = 2 0 +2 1 +2 2 +2 5 +2 6 +2 8 +2 10 +2 12 +2 14 +2 16 +2 17 +2 18 =480599 Bit Figure 1 Encoded value = 2 1 +2 5 +2 9 +2 13 +2 17 =139810 Bit Figure 2 Encoded value = 2 0 +2 1 +2 2 +2 4 +2 8 +2 9 +2 10 +2 14 +2 16 +2 17 +2 18 =476951 Bit Figure 3 Encoded value = 2 0 +2 1 +2 2 +2 6 +2 8 +2 9 +2 10 +2 14 +216 +2 17 +2 18 =476999 Bit Figure 4 Encoded value = 2 2 +2 6 +2 8 +2 9 +2 10 +2 12 +2 14 +2 16 +2 18 =350020 Bit Figure 5 Encoded value = 2 0 +2 1 +2 2 +2 6 +2 8 +2 9 +2 10 +2 16 +2 17 +2 18 =464711 Bit Figure 6 Encoded value = 2 0 +2 1 +2 2 +2 4 +2 6 +2 8 +2 9 +2 10 +2 12 +2 16 +2 17 +2 18 ==464727 Bit Figure 7 Encoded value = 2 2 +2 6 +2 10 +2 14 +2 16 +2 17 +2 18 =476228 Bitmap 8 encoding value = 2 0 +2 1 +2 2 +2 4 +2 6 +2 8 +2 9 +2 10 +2 12 +2 14 +2 16 +2 17 +2 18 =481111 Bitmap 9 encoding value = 2 0 +2 1 +2 2 +2 6 +2 8 +2 9 +2 10 +2 12 +2 14 +2 16 +2 17 +2 18 =481095 By mapping each bitmap pixel that needs to be lit to a binary bit, and summing all the lit bits, a unique integer code is obtained. For example, the number "1" occupies the 1st, 5th, 9th, 13th, and 17th pixel positions in the bitmap, and the corresponding binary powers are summed to obtain the code value 139810.

[0044] This encoding method allows for the rapid retrieval of bitmap information for any number using a lookup table within the shader.

[0045] S3.4 as Figure 6 The diagram shows the drawing of numerical text. Figure 6 A schematic diagram of a method for displaying digital text. (1) For the current fragment, subtract its screen coordinates from the numerical annotation position vNumberPos, and divide by the font size vFontSize to obtain the normalized position vTextCoords of the fragment within the numerical region. The font size must be proportional to the 4×5 bitmap, such as 5×4, 10×8, etc.

[0046] (2) If vTextCoords is not in the range of 0–1, it means that the fragment does not belong to the numeric region and is skipped directly.

[0047] (3) Calculate the decimal number of the current elevation label value and obtain the maximum bit index fBiggestIndex by rounding down by log10(fValue).

[0048] (4) Round vTextCoords.x to get fDigitIndex, which is used to determine which number of the label value the fragment falls into.

[0049] (5) If fDigitIndex>fBiggestIndex, then the fragment does not belong to the valid digit region.

[0050] (6) Obtain the corresponding numeric character based on fDigitIndex, and obtain its bitmap encoding fDigitBin through the numeric encoding function. For example, the bitmap encoding of the number "5" is 464711.

[0051] (7) Calculate the pixel index of the fragment in the 4×5 bitmap based on the decimal part of vTextCoords. For example, based on the proportional position of vTextCoords in the horizontal and vertical directions, map it to the column index and row index of the bitmap and combine them to obtain the pixel index value. For example, in the example, when vTextCoords=(0.52,0.44), the corresponding bitmap pixel index is 10, indicating that the current fragment is at the 10th pixel position in the digital bitmap.

[0052] (8) Perform a bitwise AND operation between the bitmap encoding fDigitBin and the binary bits corresponding to the fragment pixel index. If the result is greater than 0, it means that the text stroke corresponding to the fragment should be lit up and displayed; otherwise, it should not be displayed. For example, when the target number is "5" and fDigitBin is 464711, perform a bitwise AND operation between it and the binary weight corresponding to the 10th pixel. If the resulting binary result is not zero, it is determined that the 10th pixel should be lit up in the bitmap of the number "5", and the color of the number stroke is output at the fragment position.

[0053] S4: As Figure 7 As shown, Figure 7 This is a schematic diagram of contour line labeling display. The final elevation labels are drawn at the labeled locations and blended with the contour line results. After completing the digital rendering, the digital fragments obtained in S3.4 are mixed with the contour fragments in S2: if the current fragment belongs to both the contour area and the digital stroke area, the digital color (usually the same as or more conspicuous as the contour color) is used first, and the transparency is increased to make it clearly visible; if it is a normal contour area, its original color is kept; the background rendering of non-contour areas remains unchanged.

[0054] It should be noted that the solution described in this application is not simply a matter of transferring traditional contour line annotation algorithms to the GPU. Instead, it leverages the characteristics of GPU fragment-level parallel rendering to comprehensively design the processing order and data flow for contour line determination, elevation annotation value determination, and digital annotation drawing. By directly utilizing the terrain elevation value, contour line parameters, and screen space change rate corresponding to the fragment in the same fragment processing stage to determine the contour line display attributes and generate the annotation display results, and then performing result fusion on the GPU, this solution reduces the construction and maintenance of intermediate data such as contour line vectors and text textures on the CPU side, thereby reducing the frequency and amount of data interaction between the CPU and GPU. For large-scale, high-resolution 3D terrain scenes, this solution can achieve real-time dynamic display of contour lines and elevation annotations with lower system overhead without changing existing hardware conditions. This "fragment-level integrated processing + omitting intermediate primitives" processing mode is substantially different from the traditional division of labor where the CPU performs preprocessing and the GPU only performs simple rendering, and brings about actual engineering performance improvements.

[0055] Through the above hybrid strategy, the embodiments of this application realize the unified display of contour lines and elevation labels based on GPU. The label values ​​can be automatically updated with changes in contour distance and viewpoint, without the need for CPU to pre-generate textures or vector objects, which greatly reduces system overhead and improves rendering efficiency.

[0056] This application uses GPU rendering of 3D terrain as an example for illustration. By passing terrain elevation values ​​to the fragment processing stage and simultaneously generating contour line and elevation label display results during fragment processing, real-time rendering of large-scale terrain contour lines and labels is achieved. Other GPU-based graphics rendering methods (such as computational shader-based, multi-channel rendering pipeline-based, or GPU general-purpose computing-based schemes) for generating contour lines and labels can also follow the same processing flow as in this embodiment. The core logic in this application's embodiments is all completed at the fragment level, therefore there are no strict limitations on specific rendering APIs, shader languages, or graphics frameworks.

[0057] This embodiment also exhibits scalability at different stages of the technical solution. For example, in the terrain data input stage, in addition to inputting elevation values ​​using a grid terrain method, regular grid DEM data, elevation maps obtained by rasterizing point cloud data, or elevation fields generated in real time by terrain generation algorithms can also be used. As long as the elevation values ​​corresponding to the fragments can be obtained at the fragment stage, this method can be applied for contour line and label display. In the contour line determination stage, although this embodiment uses contour interval and principal contour interval as the basis for fragment determination, other forms of elevation classification strategies or contour line parameter integration methods can also be used without violating the technical solution of this invention, as long as the processing flow of calculating contour line display attributes based on elevation at the fragment level remains consistent. In the label generation stage, although this embodiment exemplarily uses a regular grid to divide the screen space to determine the candidate positions of labels, other mechanisms for determining display candidate positions, such as those based on screen space segmentation, terrain geometric feature points, or view adaptive point selection strategies, can also refer to the overall logic of this method to complete the determination and display of elevation labels.

[0058] The GPU fragment-level contour and elevation label generation method designed in this embodiment is equally applicable in various application fields. For example, in standard GIS scenarios, this method can be directly used for DEM terrain browsing and analysis; in digital twin city or virtual simulation training scenarios, this method can be used for real-time terrain background rendering to improve scene rendering efficiency; in lightweight platforms such as vehicle navigation, outdoor robot positioning, and mobile device terrain visualization, the fragment-level rendering mechanism of this invention can reduce CPU involvement and maintain a stable frame rate under limited computing resources; in disaster monitoring, engineering survey, or surveying visualization, this method can present contour features corresponding to elevation changes in real time, improving analysis efficiency. Although the data scale, rendering framework, and display requirements differ in these scenarios, since this invention directly generates contour lines and labels based on fragment-level elevation calculation, this method can be used to achieve efficient contour and elevation label display in all these scenarios.

[0059] In summary, the embodiments of this application are based on a holistic method for determining contour lines, generating annotation values, digital drawing, and fusion rendering at the fragment level using a GPU. This method can be flexibly adjusted according to different data sources, different rendering stages, and the needs of different application fields. However, all replacement methods should remain within the technical framework of generating contour lines and elevation annotations based on elevation values ​​and completing fusion display at the fragment processing stage.

[0060] Example 3 The following describes an embodiment of a GPU-based high-efficiency display system for terrain contour lines and elevation labels, in conjunction with the technical solution of the present invention. The system in this embodiment mainly includes an input module, a processing module, and an output module. These modules work collaboratively to achieve real-time generation and rendering of contour lines and elevation labels within the GPU.

[0061] In one embodiment, the system includes an input module for acquiring the elevation values ​​of each vertex or pixel in the terrain data during GPU terrain rendering, and passing these elevation values ​​as fragment-level rendering input to the fragment processing stage. In this way, the GPU can directly access the elevation information corresponding to the current fragment when executing the fragment shading procedure, providing basic data for subsequent contour line determination and annotation generation.

[0062] The system also includes a processing module, which determines the contour display attributes of a segment based on terrain elevation values ​​and preset contour parameters during the segment processing stage, and generates contour display results. Simultaneously, the processing module also generates corresponding elevation label display results based on the segment elevation values, enabling contour lines and labels to be generated synchronously at the same segment stage, avoiding the overhead of CPU-side preprocessing and data reconstruction.

[0063] In a preferred embodiment, the processing module is configured to: obtain the initial curve modulus and the calculated curve modulus by performing modulo operations on the current fragment elevation value with the contour interval and the main contour interval, respectively, to characterize the modulo result of the fragment elevation value relative to the contour interval; further, the processing module also calculates the rate of change of the fragment elevation value in two orthogonal directions in screen space, takes the larger of the two as the fragment elevation change rate, and multiplies it by a preset contour pixel linewidth to obtain the elevation tolerance corresponding to the linewidth. When the initial curve modulus is not greater than the elevation tolerance, the processing module outputs the display result of the initial curve; when the calculated curve modulus is not greater than the elevation tolerance, it outputs the display result of the calculated curve. In this way, the system can maintain the screen linewidth consistency of the contour lines under different scaling scales and ensure the stability and real-time performance of contour rendering.

[0064] In another embodiment, the processing module is also configured to generate elevation annotation values. The processing module divides the screen space into regular grid subspaces and uses the center point of each subspace as candidate elevation annotation locations. When a fragment at a candidate location meets the condition of being close to the first curve or the counting curve determined based on the fragment's elevation value, the processing module determines that the candidate location needs to generate a corresponding elevation annotation value. Subsequently, the processing module performs digital decomposition on the elevation annotation value according to a preset natural number bitmap encoding rule and performs bitwise operations based on the pixel index of the fragment in the bitmap to generate the corresponding digital annotation display result. In this way, digital annotations can be drawn pixel-by-pixel at the GPU fragment level, eliminating the need for the CPU to construct text textures, thereby reducing storage and transmission overhead.

[0065] The system also includes an output module, which is used to fuse the contour line display results and annotation display results generated by the processing module on the GPU and output the final rendered image. The fused output can ensure the consistency of digital annotations and contour lines in spatial position, color representation and transparency processing, and finally obtain a complete rendered image containing terrain contour lines and elevation annotations, achieving real-time, continuous and efficient terrain expression effects.

[0066] In summary, the system in this embodiment completes the entire process of elevation input, fragment-level contour line and annotation generation, and final fusion output within the GPU, effectively avoiding the performance bottlenecks caused by CPU preprocessing, text texture generation, and repeated data transmission, thereby achieving efficient visualization of contour lines and elevation annotations in large-scale 3D terrain.

[0067] It should be understood that the various modules of the GPU-based terrain contour line and elevation labeling high-efficiency display system provided in the above embodiments are only illustrated by the division of functional modules in the above description. In practical applications, the above functions can be assigned to different functional modules as needed. That is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0068] The functional modules in the above embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of the embodiments of this application.

[0069] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects.

[0070] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0071] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A GPU-based method for efficiently displaying terrain contour lines and elevation labels, characterized in that, include: During the GPU rendering of terrain, the terrain elevation value is passed as fragment-level rendering input to the fragment processing stage. In the fragment processing stage, the contour display attributes of the fragment are determined based on the terrain elevation value and the preset contour line parameters to generate contour display results, and at the same time, the corresponding elevation label value is determined based on the terrain elevation value to generate label display results. The contour line display results and the annotation display results are fused and output on the GPU to obtain a rendered image containing terrain contour lines and elevation annotations.

2. The method according to claim 1, characterized in that, The determination of the contour display attributes of fragments in the fragment processing stage includes: The modulus of the primary curve is obtained by performing a modulus operation on the terrain elevation value and contour interval of the current fragment, and the modulus of the secondary curve is obtained by performing a modulus operation on the terrain elevation value and primary contour interval of the current fragment. Wherein, the first curve modulus is the result of taking the modulus of the current fragment elevation value and the contour interval, and the calculated curve modulus is the result of taking the modulus of the current fragment elevation value and the main contour interval.

3. The method according to claim 2, characterized in that, The main contour interval is set to a preset multiple of the contour interval, and the preset multiple is five, so that every five first curves correspond to one calculation curve.

4. The method according to claim 2, characterized in that, The determination of the contour display attributes of fragments in the fragment processing stage also includes: Calculate the rate of change of the current fragment elevation value in the first and second directions of screen space, and take the larger of the two as the rate of change of the fragment's neighborhood elevation. Multiply the elevation change rate by the preset contour line pixel width to obtain the elevation tolerance corresponding to the line width; When the magnitude of the first curve is not greater than the elevation tolerance, the current fragment is determined to belong to the first curve display area; when the magnitude of the calculated curve is not greater than the elevation tolerance, the current fragment is determined to belong to the calculated curve display area.

5. The method according to claim 1, characterized in that, The contour line display results generated in the fragment processing stage include: Assign the first curve color to fragments belonging to the first curve display area and output visible transparency; Assign the curve color to the fragments belonging to the curve display area and output visible transparency; Output invisible transparency for fragments that are not part of the contour display area; The color of the first curve is different from the color of the calculation curve.

6. The method according to claim 1, characterized in that, The annotation display results generated in the fragment processing stage include: The screen space is divided into regular grid subspaces according to a preset number of rows and columns, and the center point of each grid subspace is determined as a candidate location for elevation labeling. Only at candidate elevation labels, when the fragments at the candidate position meet the condition of being close to the first curve or the count curve, an elevation label value consistent with the corresponding contour line is generated.

7. The method according to claim 6, characterized in that, The generated annotation display results also include: Pre-configure digital bitmaps with fixed pixel sizes for natural numbers 0 to 9, and encode the pixel positions that need to be lit in each digital bitmap as the corresponding digital bitmap encoding values; The elevation label value is decomposed bitwise to obtain each digit, and the target digit is determined based on the relative text coordinates of the current fragment at the label candidate position. Bitwise operations are performed based on the digital bitmap encoding value of the target bit and the pixel index of the bitmap corresponding to the current fragment. When the bitwise operation result indicates that the pixel is a lit pixel, the digital stroke color is output; otherwise, the opacity remains invisible.

8. A GPU-based high-efficiency display system for terrain contour lines and elevation annotations, characterized in that, include: The input module is used to obtain terrain elevation values ​​during the GPU rendering process and pass the terrain elevation values ​​as fragment-level rendering input to the fragment processing stage. The processing module is used to determine the contour display attributes of the fragment based on the terrain elevation value and the preset contour parameters during the fragment processing stage, generate contour display results, and simultaneously generate annotation display results based on the terrain elevation value. The output module is used to fuse the contour line display results and the label display results on the GPU to obtain a rendered image containing terrain contour lines and elevation labels.

9. The system according to claim 8, characterized in that, The fragment processing module is configured as follows: The modulus of the primary curve is obtained by performing a modulus operation on the terrain elevation value and contour interval of the current fragment, and the modulus of the secondary curve is obtained by performing a modulus operation on the terrain elevation value and primary contour interval of the current fragment. Calculate the rate of change of the current fragment elevation value in the first and second directions of the screen space and take the larger one as the elevation change rate. Multiply the elevation change rate by the contour line pixel width to obtain the elevation tolerance corresponding to the line width. The first curve display result is output when the first curve modulus is not greater than the elevation tolerance, and the calculated curve display result is output when the calculated curve modulus is not greater than the elevation tolerance.

10. The system according to claim 8, characterized in that, The fragment processing module is also configured to: The screen space is divided into regular grid subspaces, and the center point of each subspace is used as the candidate location for elevation labeling. At the candidate elevation labeling location, the elevation labeling value is determined when the fragment meets the condition of being close to the first curve or the calculation curve; Bitwise operations are performed based on the preset natural number bitmap encoding and the pixel index of the fragment bitmap to generate the annotation display result corresponding to the elevation annotation value.