A three-dimensional terrain slope rendering method and device, electronic equipment and storage medium

By rendering 3D terrain data twice using the GPU—first a normal rendering, then a slope rendering—the problem of low efficiency in terrain slope rendering in 3D animation is solved, improving both rendering quality and efficiency.

CN115457180BActive Publication Date: 2026-04-28PCI TECH GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PCI TECH GRP CO LTD
Filing Date
2022-09-22
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In existing technologies, 3D animation rendering suffers from low efficiency, especially when dynamically loading and rendering terrain slopes in 3D scenes, where CPU computation efficiency is low.

Method used

The GPU is used for two rendering processes. First, the data to be rendered is rendered using the normal rendering method to obtain the first rendering result. Then, the first rendering result is rendered using the slope rendering method to calculate the slope of each pixel. Finally, the data is rendered to the screen.

Benefits of technology

It improves the efficiency of rendering 3D terrain slope, enhances the rendering effect of 3D animation, and is simple to implement, easy to popularize, and widely applicable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115457180B_ABST
    Figure CN115457180B_ABST
Patent Text Reader

Abstract

The application discloses a three-dimensional terrain slope rendering method and device, electronic equipment and a storage medium. The method is applied to a graphic processing unit (GPU), and comprises the following steps: obtaining current view angle rendering data; rendering the current view angle rendering data according to a first rendering mode to obtain a first rendering result of the current view angle rendering data; rendering the first rendering result according to a second rendering mode to obtain a second rendering result of the current view angle rendering data; wherein the first rendering mode is a normal rendering mode; the second rendering mode is a slope rendering mode; and rendering the current view angle rendering data to a screen based on the second rendering result. The embodiment of the application can effectively improve the rendering efficiency of the three-dimensional terrain, thereby improving the three-dimensional animation rendering effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a three-dimensional terrain slope rendering method, apparatus, electronic device, and storage medium. Background Technology

[0002] Image rendering technologies can be broadly divided into two categories: real-time rendering, which is frequently used in 3D games, and offline rendering, which is widely used in animation and film production. The former has to compromise on image quality to ensure rendering speed, while the latter can pursue realism without regard to cost.

[0003] The goals of 3D animation rendering are twofold: firstly, to achieve highly realistic animation effects; and secondly, to provide good interactivity during the rendering process, thus achieving real-time rendering. Although current PCs possess abundant storage resources, fast processors, and powerful graphics processing chips, real-time rendering of 3D animations featuring large-scale characters remains a challenging problem. Mainstream geospatial analysis software such as ArcGIS typically uses the CPU to calculate slope information. However, this method suffers from inefficiency because it requires dynamically loading and rendering terrain slopes within a 3D scene. Summary of the Invention

[0004] This application provides a three-dimensional terrain slope rendering method, apparatus, electronic device, and storage medium, which can effectively improve the rendering efficiency of three-dimensional terrain, thereby enhancing the rendering effect of three-dimensional animation.

[0005] In a first aspect, embodiments of this application provide a three-dimensional terrain slope rendering method, applied to a graphics processing unit (GPU), the method comprising:

[0006] Get the data to be rendered from the current viewpoint;

[0007] The data to be rendered from the current viewpoint is rendered according to the first rendering method to obtain the first rendering result of the data to be rendered from the current viewpoint.

[0008] The first rendering result is rendered according to the second rendering method to obtain the second rendering result of the data to be rendered from the current viewpoint; wherein, the first rendering method is the normal rendering method; and the second rendering method is the slope rendering method.

[0009] Based on the second rendering result, the data to be rendered from the current viewpoint is rendered onto the screen.

[0010] Secondly, embodiments of this application also provide a three-dimensional terrain slope rendering device, the device comprising: an acquisition module, a first rendering module, a second rendering module, and a display module; wherein,

[0011] The acquisition module is used to acquire the data to be rendered from the current viewpoint;

[0012] The first rendering module is used to render the data to be rendered from the current viewpoint according to the first rendering method, and obtain the first rendering result of the data to be rendered from the current viewpoint;

[0013] The second rendering module is used to render the first rendering result according to the second rendering method to obtain the second rendering result of the data to be rendered from the current viewpoint; wherein, the first rendering method is the normal rendering method; and the second rendering method is the slope rendering method.

[0014] The display module is used to render the current viewpoint data to be rendered onto the screen based on the second rendering result.

[0015] Thirdly, embodiments of this application provide an electronic device, including:

[0016] One or more processors;

[0017] Memory, used to store one or more programs.

[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the three-dimensional terrain slope rendering method described in any embodiment of this application.

[0019] Fourthly, embodiments of this application provide a storage medium storing a computer program that, when executed by a processor, implements the three-dimensional terrain slope rendering method described in any embodiment of this application.

[0020] This application proposes a method, apparatus, electronic device, and storage medium for rendering three-dimensional terrain slope. First, it acquires data to be rendered from the current viewpoint. Then, it renders the data according to a first rendering method to obtain a first rendering result. Next, it renders the first rendering result according to a second rendering method to obtain a second rendering result. The first rendering method is a normal rendering method; the second rendering method is a slope rendering method. Finally, based on the second rendering result, the data to be rendered from the current viewpoint is rendered onto the screen. In other words, in this application's technical solution, the GPU can perform two renderings of the data to be rendered from the current viewpoint, calculating the slope of each pixel to complete the final rendering of the data. In existing technologies, mainstream geospatial analysis software such as ArcGIS typically uses the CPU to calculate slope information; however, in 3D scenes, the terrain slope needs to be dynamically loaded and rendered, and using the CPU for calculation results in low efficiency. Therefore, compared with the prior art, the three-dimensional terrain slope rendering method, apparatus, electronic device and storage medium proposed in the embodiments of this application can effectively improve the efficiency of three-dimensional terrain slope rendering, thereby improving the three-dimensional animation rendering effect; moreover, the technical solution of the embodiments of this application is simple and convenient to implement, easy to popularize, and has a wider range of applications. Attached Figure Description

[0021] Figure 1 A schematic diagram of the first process of the three-dimensional terrain slope rendering method provided in the embodiments of this application;

[0022] Figure 2 A schematic diagram of the second process of the three-dimensional terrain slope rendering method provided in the embodiments of this application;

[0023] Figure 3 A schematic diagram of the third process of the three-dimensional terrain slope rendering method provided in the embodiments of this application;

[0024] Figure 4 This is a schematic diagram of the structure of the three-dimensional terrain slope rendering device provided in the embodiments of this application;

[0025] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0026] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present application, not the entire structure.

[0027] Example 1

[0028] Figure 1 This is a first flowchart illustrating a three-dimensional terrain slope rendering method provided in an embodiment of this application. This method can be executed by a three-dimensional terrain slope rendering device or electronic device, which can be implemented in software and / or hardware, and can be integrated into any smart device with network communication capabilities. Figure 1 As shown, the three-dimensional terrain slope rendering method may include the following steps:

[0029] S101. Obtain the data to be rendered from the current viewpoint.

[0030] In this step, the electronic device can obtain the data to be rendered from the current viewpoint through the GPU. Specifically, the electronic device can load the virtual camera for the current viewpoint through the GPU, crop out data that is not within the camera's field of view, and what remains is the data to be rendered from the current viewpoint.

[0031] S102. Render the data to be rendered in the current view according to the first rendering method to obtain the first rendering result of the data to be rendered in the current view.

[0032] In this step, the electronic device can use the GPU to render the data to be rendered from the current viewpoint according to the first rendering method, and obtain the first rendering result of the data to be rendered from the current viewpoint. Specifically, in the embodiment of this application, the first rendering follows the normal rendering process, but the depth cache result is rendered to the texture (Render to texture, or RTT for short); then the second rendering is performed, and the depth cache result is transmitted as input to the fragment shader.

[0033] S103. Render the first rendering result according to the second rendering method to obtain the second rendering result of the data to be rendered from the current viewpoint; wherein, the first rendering method is the normal rendering method; and the second rendering method is the slope rendering method.

[0034] In a specific embodiment of this application, the electronic device can render the first rendering result according to a second rendering method to obtain a second rendering result of the data to be rendered from the current viewpoint; wherein, the first rendering method is a normal rendering method; and the second rendering method is a slope rendering method. Specifically, the electronic device can first extract a pixel from the first rendering result as the current first pixel; and select two pixels from the neighboring points of the current first pixel as the current second pixel and the current third pixel respectively; wherein, the current first pixel, the current second pixel, and the current third pixel are not on a straight line; then calculate the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel; then calculate the slope corresponding to the current first pixel based on the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel; repeat the above operation until the slope corresponding to each pixel is calculated; finally, render the first rendering result according to the slope corresponding to each pixel to obtain a second rendering result of the data to be rendered from the current viewpoint.

[0035] S104. Render the data to be rendered from the current viewpoint onto the screen based on the second rendering result.

[0036] The 3D terrain slope rendering method proposed in this application first acquires the data to be rendered from the current viewpoint; then, it renders the data according to a first rendering method to obtain a first rendering result; next, it renders the first rendering result according to a second rendering method to obtain a second rendering result; wherein, the first rendering method is a normal rendering method; the second rendering method is a slope rendering method; finally, the data to be rendered from the current viewpoint is rendered onto the screen based on the second rendering result. In other words, in the technical solution of this application, the GPU can perform two renderings on the data to be rendered from the current viewpoint to calculate the slope of each pixel, thereby completing the final rendering of the data to be rendered from the current viewpoint. In the prior art, mainstream geospatial analysis software such as ArcGIS typically uses the CPU to calculate slope information; in 3D scenes, the terrain slope needs to be dynamically loaded and rendered, and using the CPU for calculation is inefficient. Therefore, compared with the prior art, the 3D terrain slope rendering method proposed in this application can effectively improve the efficiency of 3D terrain slope rendering, thereby improving the 3D animation rendering effect; furthermore, the technical solution of this application is simple and convenient to implement, easy to popularize, and has a wider range of applications.

[0037] Example 2

[0038] Figure 2This is a schematic diagram of the second process of the three-dimensional terrain slope rendering method provided in this application embodiment. Further optimizations and extensions are possible based on the above technical solution, and it can be combined with the various optional implementation methods described above. For example... Figure 2 As shown, the three-dimensional terrain slope rendering method may include the following steps:

[0039] S201. Obtain the data to be rendered from the current viewpoint.

[0040] S202. Render the data to be rendered in the current view according to the first rendering method to obtain the first rendering result of the data to be rendered in the current view.

[0041] S203. Extract a pixel from the first rendering result as the current first pixel; and select two pixels from the neighboring points of the current first pixel as the current second pixel and the current third pixel respectively; wherein the current first pixel, the current second pixel, and the current third pixel are not on a straight line.

[0042] In this step, the electronic device can extract a pixel from the first rendering result using the GPU as the current first pixel; and select two pixels from the neighboring points of the current first pixel as the current second pixel and the current third pixel, respectively; wherein the current first pixel, the current second pixel, and the current third pixel are not on a straight line. Specifically, the electronic device can extract one pixel from the first rendering result one by one using the GPU as the current first pixel, and then select the pixel above the current first pixel as the current second pixel; and select the pixel to the right of the current first pixel as the current third pixel. Optionally, if there is no pixel above or to the right of the current first pixel, the pixel below the current first pixel can be selected as the current second pixel; and the pixel to the left of the current first pixel can be selected as the current third pixel.

[0043] S204. Calculate the world coordinates of the current first pixel, the current second pixel, and the current third pixel.

[0044] In this step, the electronic device can use the GPU to calculate the world coordinates of the current first pixel, the current second pixel, and the current third pixel. Specifically, the electronic device can first obtain the texture coordinates of the current first pixel, the current second pixel, and the current third pixel from the first rendering result using the GPU; then, based on the texture coordinates of the current first pixel, the current second pixel, and the current third pixel, calculate the depth values ​​of the current first pixel, the current second pixel, and the current third pixel, respectively; and finally, based on the texture coordinates of the current first pixel, the current second pixel, and the current third pixel, as well as the depth values ​​of the current first pixel, the current second pixel, and the current third pixel, calculate the world coordinates of the current first pixel, the current second pixel, and the current third pixel. For example, assuming the texture coordinates of the current first pixel are (u1, v1); assuming the depth value of the current first pixel is depth1; then this step can input the texture coordinates (u1, v1) and the depth value depth1 of the current first pixel into the pre-built interface function pt3d = Depth3D(depth, u, v) that converts depth to 3D coordinates; and calculate the world coordinates of the previous first pixel based on this function.

[0045] S205. Based on the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel, calculate the slope corresponding to the current first pixel; repeat the above operation until the slope corresponding to each pixel is calculated.

[0046] In this step, the electronic device can use the GPU to calculate the slope corresponding to the current first pixel based on the world coordinates of the current first pixel, the current second pixel, and the current third pixel; repeating the above operation until the slope corresponding to each pixel is calculated. Specifically, the electronic device can first use the GPU to calculate the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel based on their world coordinates; then calculate the perpendicular line from the origin to the current first pixel based on its world coordinates; and finally calculate the slope corresponding to the current first pixel based on the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel, and the perpendicular line from the origin to the current first pixel.

[0047] S206. Render the first rendering result according to the slope corresponding to each pixel to obtain the second rendering result of the data to be rendered from the current viewpoint.

[0048] S207. Render the data to be rendered from the current viewpoint onto the screen based on the second rendering result.

[0049] The 3D terrain slope rendering method proposed in this application first acquires the data to be rendered from the current viewpoint; then, it renders the data according to a first rendering method to obtain a first rendering result; next, it renders the first rendering result according to a second rendering method to obtain a second rendering result; wherein, the first rendering method is a normal rendering method; the second rendering method is a slope rendering method; finally, the data to be rendered from the current viewpoint is rendered onto the screen based on the second rendering result. In other words, in the technical solution of this application, the GPU can perform two renderings on the data to be rendered from the current viewpoint to calculate the slope of each pixel, thereby completing the final rendering of the data to be rendered from the current viewpoint. In the prior art, mainstream geospatial analysis software such as ArcGIS typically uses the CPU to calculate slope information; in 3D scenes, the terrain slope needs to be dynamically loaded and rendered, and using the CPU for calculation is inefficient. Therefore, compared with the prior art, the 3D terrain slope rendering method proposed in this application can effectively improve the efficiency of 3D terrain slope rendering, thereby improving the 3D animation rendering effect; furthermore, the technical solution of this application is simple and convenient to implement, easy to popularize, and has a wider range of applications.

[0050] Example 3

[0051] Figure 3 This is a schematic diagram of the third process of the three-dimensional terrain slope rendering method provided in this application embodiment. Further optimizations and extensions can be made based on the above technical solution, and it can be combined with the various optional implementation methods described above. For example... Figure 3 As shown, the three-dimensional terrain slope rendering method may include the following steps:

[0052] S301. Obtain the data to be rendered from the current viewpoint.

[0053] S302. Render the data to be rendered in the current view according to the first rendering method to obtain the first rendering result of the data to be rendered in the current view.

[0054] S303. Extract a pixel from the first rendering result as the current first pixel; and select two pixels from the neighboring points of the current first pixel as the current second pixel and the current third pixel respectively; wherein the current first pixel, the current second pixel, and the current third pixel are not on a straight line.

[0055] S304. Obtain the texture coordinates of the current first pixel, the current second pixel, and the current third pixel from the first rendering result.

[0056] In this step, the electronic device can obtain the texture coordinates of the current first pixel, the current second pixel, and the current third pixel from the first rendering result via the GPU. Specifically, the texture coordinates of the current first pixel can be represented as (u1, v1); the texture coordinates of the current second pixel can be represented as (u2, v2); and the texture coordinates of the current third pixel can be represented as (u3, v3).

[0057] S305. Based on the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel, calculate the depth values ​​of the current first pixel, the current second pixel, and the current third pixel, respectively.

[0058] In this step, the electronic device can use the GPU to calculate the depth values ​​of the current first pixel, the current second pixel, and the current third pixel based on their texture coordinates. Specifically, the depth value of the current first pixel can be represented as depth1; the depth value of the current second pixel can be represented as depth2; and the depth value of the current third pixel can be represented as depth3. For example, the electronic device can use the GPU to input the texture coordinates (u1, v1) of the current first pixel into a pre-built function depth = Texture2D(depthBuffer, u, v), which calculates the depth value of the current first pixel; where depthBuffer is the depth buffer texture; and u and v are the texture coordinates of the pixels.

[0059] S306. Based on the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel, as well as the depth values ​​of the current first pixel, the current second pixel, and the current third pixel, calculate the world coordinates of the current first pixel, the current second pixel, and the current third pixel.

[0060] In this step, the electronic device can use the GPU to calculate the world coordinates of the current first pixel, the current second pixel, and the current third pixel based on their texture coordinates, depth values, and depth values. For example, assuming the texture coordinates of the current first pixel are (u1, v1) and its depth value is depth1, this step can input the texture coordinates (u1, v1) and depth value (depth1) of the current first pixel into a pre-built interface function pt3d = Depth3D(depth, u, v) to convert depth to 3D coordinates; based on this function, the world coordinates of the current first pixel can be calculated.

[0061] S307. Based on the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel, calculate the slope corresponding to the current first pixel; repeat the above operation until the slope corresponding to each pixel is calculated.

[0062] In this step, the electronic device can use the GPU to calculate the slope corresponding to the current first pixel based on the world coordinates of the current first pixel, the current second pixel, and the current third pixel; this operation is repeated until the slope corresponding to each pixel is calculated. Specifically, the electronic device can first calculate the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel based on their world coordinates; then calculate the perpendicular line from the origin to the current first pixel based on its world coordinates; and finally calculate the slope corresponding to the current first pixel based on the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel, and the perpendicular line from the origin to the current first pixel. For example, assuming the world coordinates of the current first pixel are pt3d1; the world coordinates of the current second pixel are pt3d2; and the world coordinates of the current third pixel are pt3d3, this step can calculate the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel using the following formula: normal = normalize(Cross(pt3d2-pt3d1, (pt3d3-pt3d1)); where normalize represents the normalization operation; Cross represents the cross product operation; pt3d2-pt3d1... 3d1 represents the vector pt3d1 pointing to pt3d2; pt3d3-pt3d1 represents the vector pt3d1 pointing to pt3d3. Further, the perpendicular calculation formula in this embodiment is: z_dir = mormalize(pt3d1); Additionally, the slope calculation formula in this embodiment is: Slope = Acos(Abs(DOT(mormal, z_dir))); where Acos represents the inverse cosine function; Abs represents the absolute value operation; DOT represents the vector dot product; and Slope represents the calculated slope.

[0063] S308. Render the first rendering result according to the slope corresponding to each pixel to obtain the second rendering result of the data to be rendered from the current viewpoint.

[0064] S309. Render the data to be rendered from the current viewpoint onto the screen based on the second rendering result.

[0065] The 3D terrain slope rendering method proposed in this application first acquires the data to be rendered from the current viewpoint; then, it renders the data according to a first rendering method to obtain a first rendering result; next, it renders the first rendering result according to a second rendering method to obtain a second rendering result; wherein, the first rendering method is a normal rendering method; the second rendering method is a slope rendering method; finally, the data to be rendered from the current viewpoint is rendered onto the screen based on the second rendering result. In other words, in the technical solution of this application, the GPU can perform two renderings on the data to be rendered from the current viewpoint to calculate the slope of each pixel, thereby completing the final rendering of the data to be rendered from the current viewpoint. In the prior art, mainstream geospatial analysis software such as ArcGIS typically uses the CPU to calculate slope information; in 3D scenes, the terrain slope needs to be dynamically loaded and rendered, and using the CPU for calculation is inefficient. Therefore, compared with the prior art, the 3D terrain slope rendering method proposed in this application can effectively improve the efficiency of 3D terrain slope rendering, thereby improving the 3D animation rendering effect; furthermore, the technical solution of this application is simple and convenient to implement, easy to popularize, and has a wider range of applications.

[0066] Example 4

[0067] Figure 4 This is a schematic diagram of the structure of the three-dimensional terrain slope rendering device provided in an embodiment of this application. Figure 4 As shown, the three-dimensional terrain slope rendering device includes: an acquisition module 401, a first rendering module 402, a second rendering module 403, and a display module 404; wherein,

[0068] The acquisition module 401 is used to acquire the data to be rendered from the current viewpoint;

[0069] The first rendering module 402 is used to render the data to be rendered in the current view according to the first rendering method, and obtain the first rendering result of the data to be rendered in the current view.

[0070] The second rendering module 403 is used to render the first rendering result according to the second rendering method to obtain the second rendering result of the data to be rendered from the current viewpoint; wherein, the first rendering method is a normal rendering method; and the second rendering method is a slope rendering method.

[0071] The display module 404 is used to render the current viewpoint data to be rendered onto the screen based on the second rendering result.

[0072] Furthermore, the second rendering module 403 is specifically used to extract a pixel from the first rendering result as the current first pixel; and select two pixels from the neighboring points of the current first pixel as the current second pixel and the current third pixel, respectively; wherein the current first pixel, the current second pixel, and the current third pixel are not on a straight line; calculate the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel; calculate the slope corresponding to the current first pixel based on the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel; repeat the above operations until the slope corresponding to each pixel is calculated; and render the first rendering result according to the slope corresponding to each pixel to obtain the second rendering result of the data to be rendered from the current viewpoint.

[0073] Furthermore, the second rendering module 403 is specifically used to obtain the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel in the first rendering result; calculate the depth value of the current first pixel, the depth value of the current second pixel, and the depth value of the current third pixel based on the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel; and calculate the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel based on the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel, as well as the depth values ​​of the current first pixel, the depth values ​​of the current second pixel, and the depth values ​​of the current third pixel.

[0074] Furthermore, the second rendering module 403 is specifically used to calculate the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel based on the world coordinates of the current first pixel, the current second pixel, and the current third pixel; calculate the perpendicular line from the origin to the current first pixel based on the world coordinates of the current first pixel; and calculate the slope corresponding to the current first pixel based on the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel, and the perpendicular line from the origin to the current first pixel.

[0075] Furthermore, the second rendering module 403 is specifically used to calculate the vector pointing from the current first pixel to the current second pixel and the vector pointing from the current first pixel to the current third pixel; and to calculate the normal of the plane determined by the current first pixel, the current second pixel and the current third pixel based on the vector pointing from the current first pixel to the current second pixel and the vector pointing from the current first pixel to the current third pixel.

[0076] The aforementioned three-dimensional terrain slope rendering device can execute the method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in this embodiment can be found in the three-dimensional terrain slope rendering method provided in any embodiment of this application.

[0077] Example 5

[0078] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present application is shown. Figure 5 The electronic device 12 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0079] like Figure 5 As shown, the electronic device 12 is represented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, system memory 28, and bus 18 connecting different system components (including system memory 28 and processing unit 16).

[0080] Bus 18 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. For example, these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0081] Electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0082] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used to read and write non-removable, non-volatile magnetic media (… Figure 5 Not shown; usually referred to as a "hard drive"). Although Figure 5 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this application.

[0083] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods described in the embodiments of this application.

[0084] Electronic device 12 can also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), and with one or more devices that enable a user to interact with electronic device 12, and / or with any device that enables electronic device 12 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 22. Furthermore, electronic device 12 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with other modules of electronic device 12 via bus 18. It should be understood that, although... Figure 5 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0085] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the three-dimensional terrain slope rendering method provided in the embodiments of this application.

[0086] Example 6

[0087] This application provides a computer storage medium.

[0088] The computer-readable storage medium of this application embodiment can be any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. For example, a computer-readable storage medium can be—but is not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device to perform various functional applications and data processing, such as implementing the three-dimensional terrain slope rendering method provided in the embodiments of this application.

[0089] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.

[0090] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including—but not limited to—wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.

[0091] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0092] Note that the above are merely preferred embodiments and the technical principles employed in this application. Those skilled in the art will understand that this application is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of this application. Therefore, although this application has been described in detail through the above embodiments, this application is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of this application, the scope of which is determined by the scope of the appended claims.

Claims

1. A method for rendering three-dimensional terrain slope, characterized in that, Applied to a graphics processing unit (GPU), the method includes: Get the data to be rendered from the current viewpoint; The data to be rendered from the current viewpoint is rendered according to the first rendering method to obtain the first rendering result of the data to be rendered from the current viewpoint. The first rendering result is rendered according to the second rendering method to obtain the second rendering result of the data to be rendered from the current viewpoint; wherein, the first rendering method is the normal rendering method; and the second rendering method is the slope rendering method. Based on the second rendering result, render the current viewpoint data to be rendered onto the screen; The step of rendering the first rendering result according to the second rendering method to obtain the second rendering result of the data to be rendered from the current viewpoint includes: Extract a pixel from the first rendering result as the current first pixel; and select two pixels from the neighboring points of the current first pixel as the current second pixel and the current third pixel respectively; wherein the current first pixel, the current second pixel, and the current third pixel are not on a straight line; Calculate the world coordinates of the current first pixel, the current second pixel, and the current third pixel; Based on the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel, calculate the slope corresponding to the current first pixel; traverse each pixel in the first rendering result, take each as the current first pixel, and for each current first pixel, repeat the steps of selecting the current second pixel and the current third pixel, calculating the world coordinates, and calculating the slope, until the slope corresponding to all pixels is obtained; The first rendering result is rendered based on the slope corresponding to each pixel to obtain the second rendering result of the data to be rendered from the current viewpoint.

2. The method according to claim 1, characterized in that, Calculating the world coordinates of the current first pixel, the current second pixel, and the current third pixel includes: The texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel are obtained from the first rendering result. Based on the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel, the depth values ​​of the current first pixel, the current second pixel, and the current third pixel are calculated respectively. Based on the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel, as well as the depth values ​​of the current first pixel, the current second pixel, and the current third pixel, calculate the world coordinates of the current first pixel, the current second pixel, and the current third pixel.

3. The method according to claim 1, characterized in that, Based on the world coordinates of the current first pixel, the current second pixel, and the current third pixel, the slope corresponding to the current first pixel is calculated, including: Calculate the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel based on the world coordinates of the current first pixel, the current second pixel, and the current third pixel. Calculate the perpendicular line from the origin to the current first pixel based on the world coordinates of the current first pixel; The slope corresponding to the current first pixel is calculated based on the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel, and the perpendicular line from the origin to the current first pixel.

4. The method according to claim 3, characterized in that, Based on the world coordinates of the current first pixel, the current second pixel, and the current third pixel, calculate the normal to the plane determined by the current first pixel, the current second pixel, and the current third pixel, including: Calculate the vector pointing from the current first pixel to the current second pixel and the vector pointing from the current first pixel to the current third pixel; Calculate the normal of the plane determined by the current first pixel, the current second pixel, and the current third pixel based on the vector pointing from the current first pixel to the current second pixel and the vector pointing from the current first pixel to the current third pixel.

5. A three-dimensional terrain slope rendering device, characterized in that, The device includes: an acquisition module, a first rendering module, a second rendering module, and a display module; wherein, The acquisition module is used to acquire the data to be rendered from the current viewpoint; The first rendering module is used to render the data to be rendered from the current viewpoint according to the first rendering method, and obtain the first rendering result of the data to be rendered from the current viewpoint; The second rendering module is used to render the first rendering result according to the second rendering method to obtain the second rendering result of the data to be rendered from the current viewpoint; wherein, the first rendering method is the normal rendering method; and the second rendering method is the slope rendering method. The display module is used to render the current viewpoint data to be rendered onto the screen based on the second rendering result; The second rendering module is specifically used to extract a pixel from the first rendering result as the current first pixel; and select two pixels from the neighboring points of the current first pixel as the current second pixel and the current third pixel, respectively; wherein the current first pixel, the current second pixel, and the current third pixel are not on a straight line; calculate the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel; calculate the slope corresponding to the current first pixel based on the world coordinates of the current first pixel, the world coordinates of the current second pixel, and the world coordinates of the current third pixel; traverse each pixel in the first rendering result, and use each pixel as the current first pixel, and for each current first pixel, repeat the steps of selecting the current second pixel and the current third pixel, calculating the world coordinates, and calculating the slope, until the slope corresponding to all pixels is obtained; render the first rendering result according to the slope corresponding to each pixel to obtain the second rendering result of the data to be rendered from the current viewpoint.

6. The apparatus according to claim 5, characterized in that, The second rendering module is specifically used to obtain the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel from the first rendering result; and to calculate the depth value of the current first pixel, the depth value of the current second pixel, and the depth value of the current third pixel based on the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel, respectively. Based on the texture coordinates of the current first pixel, the texture coordinates of the current second pixel, and the texture coordinates of the current third pixel, as well as the depth values ​​of the current first pixel, the current second pixel, and the current third pixel, calculate the world coordinates of the current first pixel, the current second pixel, and the current third pixel.

7. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the three-dimensional terrain slope rendering method as described in any one of claims 1 to 4.

8. A storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the three-dimensional terrain slope rendering method as described in any one of claims 1 to 4.