Simulation scene rendering optimization method

Through viewport culling and texture cache management, the bottleneck of rendering performance of complex dynamic simulation scenes is solved, and efficient rendering performance and response speed are achieved.

CN120198562APending Publication Date: 2025-06-24THE 20TH RESEARCH INSTITUTE OF CHINA ELECTRONICS TECHNOLOGY GROUP CORP
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510269504.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-07
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

The rendering performance of complex dynamic simulation scenarios is dragged down by data redundancy and repeated calculations, and traditional rendering methods face performance bottlenecks.

Method used

By establishing a mapping relationship between computer screen coordinates and simulation scene coordinates, viewport culling and texture cache management are implemented to reduce unnecessary calculations and data transmission.

Benefits of technology

The system performance of simulated scene rendering is significantly optimized, the processing load and data transmission of hardware units are reduced, and the response speed is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198562A_ABST
    Figure CN120198562A_ABST
Patent Text Reader

Abstract

The invention provides a simulation scene rendering optimization method, which comprises the following steps of: establishing a mapping relation between computer screen coordinates and simulation scene coordinates, calculating a simulation scene space region corresponding to a screen viewport before each time of scene loading, and removing scene elements outside the viewport to obtain a simulation scene space region; and the texture cache information of the existing scene is managed to delay release. When a new scene is switched, firstly, the viewport is continuously used for judgment and elimination, and in addition, the resource information in the texture buffer area is called, so that the amount of information sent into the GPU every time is reduced, and the rendering efficiency is improved. According to the method, the processing load of each hardware unit of the computer is reduced, the data transmission quantity among the hardware units is reduced, the system performance of simulation scene rendering is obviously optimized, and the response speed is improved. Therefore, the GPU burden is reduced, and the rendering efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer graphics processing, and particularly to a method for optimizing graphics rendering. Background Art

[0002] Nowadays, fields such as virtual reality, game development, autonomous driving simulation, and virtual training are booming. Among them, the visual rendering of simulation scenarios is one of the core technologies. The purpose is to use computer graphics technology to generate realistic virtual scenarios to meet different application requirements.

[0003] However, as the complexity of simulation scenarios continues to increase, including geometric details, texture accuracy, and real-time dynamic changes in the scenarios, complex simulation scenarios cause the computer to process a large amount of graphic coordinate data and texture information, which poses higher requirements for data processing capabilities. In addition, data redundancy and repeated calculations in large-scale simulation scenarios will also significantly drag down performance, and traditional rendering methods face performance bottlenecks.

[0004] Therefore, the present invention proposes a rendering optimization method for simulation scenarios. By means of viewport culling and texture buffer management, it reduces the ineffective calculations of the computer and improves the utilization rate of hardware resources, thereby effectively supporting the real-time rendering of complex dynamic scenarios.

[0005] In computer graphics, a texture is usually a two-dimensional image or program-generated data used to describe the attributes of two-dimensional and three-dimensional graphic surfaces, such as color, details, roughness, etc. By mapping the texture onto the surface of two- and three-dimensional graphics, simple geometric shapes can obtain richer details and a more realistic sense without increasing geometric complexity.

[0006] And for the mapping of texture information to primitives and the rendering and display on a computer monitor, the whole process involves data transmission between different hardware in a computer system, as Figure 1 shown.

[0007] First, as a non-volatile storage device, a hard disk can retain data even when powered off. Therefore, local image resources are often initially stored on the computer's hard disk. Under the control of the CPU (Central Processing Unit), the hard disk controller transfers the image resources to the memory through the bus and stores them in a two-dimensional pixel matrix. Then, using a graphics API (Application Programming Interface), such as the glTexImage2D function in OpenGL, the image data is uploaded to the video memory of the GPU (Graphics Processing Unit) through the PCIe bus under the management of the operating system and the graphics card driver. After that, the GPU uses the stream processors to execute the content in the shader in parallel, calculates the final content for each pixel. In this process, the parallel architecture of the GPU can process tens of thousands of pixels at once and store the processed content in the frame buffer of the GPU. Finally, the display controller reads the data from the frame buffer and transmits it to the display through interfaces such as HDMI for display.

[0008] For the entire above process, since modern CPU processors and operating systems support asynchronous I / O technology, for the process of reading texture resources from the hard disk into the memory, a multi-threaded concurrent execution method is often used to improve efficiency. However, for the process of data transfer from the memory to the video memory of the GPU, most simulation systems cannot achieve full parallelization. The new generation of graphics APIs, such as Vulkan and DirectX 12, solve this problem by adopting asynchronous transmission and more fine-grained display control.

[0009] Although the new generation of graphics APIs allows developers to manually optimize data transfer and task scheduling, and can execute data transfer tasks and subsequent rendering tasks in parallel. However, full parallelization is still limited by the hardware bandwidth and bus architecture. Since the memory and the video memory of the GPU are physically separated, when large-scale data transfer is required, the transmission rate of the PCIe bus will still become the bottleneck of the entire data transfer process.

[0010] In addition, due to the low level of abstraction of the new generation of graphics APIs, they have high complexity, high development thresholds and development costs, which prolongs the entire development cycle. Moreover, most current simulation systems have a low application rate for them, and it is difficult to re-port.

[0011] Therefore, at the level of the simulation system itself, the present invention proposes a performance optimization method. Under the current software and hardware conditions, by performing viewport culling on the simulation scene and managing the texture resources through caching, the amount of data transferred from memory to the GPU video memory each time is optimized and reduced, thereby reducing the processing load of the hardware unit and the amount of information transmitted by each bus. Moreover, the technical method is applicable to the vast majority of simulation systems. Summary of the Invention

[0012] In order to overcome the deficiencies of the prior art, the present invention provides a method for optimizing the rendering of a simulation scene.

[0013] The present invention first establishes a mapping relationship between the computer screen coordinates and the simulation scene coordinates. Before each scene is loaded, the spatial area of the simulation scene corresponding to the screen viewport is calculated, the scene elements outside the viewport are culled, and the texture cache information of the existing scene is managed to delay the release. When switching to a new scene, first continue to use the viewport for judgment and culling. In addition, the resource information already in the texture buffer is retrieved, thereby reducing the amount of information sent to the GPU each time and improving the rendering efficiency. The method flow is as Figure 2 shown.

[0014] The specific steps of the technical solution adopted by the present invention to solve its technical problems are as follows:

[0015] Step 1: Establish a coordinate mapping relationship;

[0016] Step 2: Viewport culling;

[0017] For the scene elements within the rendering window range, they are processed according to the graphics rendering process of vertex shading and fragment shading, and finally output to the frame buffer; while for the scene elements outside the screen viewport, they are culled, and the geometric information or texture information of the scene element is no longer transmitted to the GPU to reduce unnecessary computational overhead;

[0018] Step 3: Texture cache management

[0019] In computer programming, Map and List are two data structures. Map uses a key-value storage method and efficiently retrieves the corresponding value (value) through the key (key); List uses an ordered storage structure and supports direct access to elements through indexes;

[0020] Use Map and List to store the texture resources and their index information of the scene elements within the current rendering viewport range; through a matching retrieval mechanism, reuse the existing texture resources using the result of viewport culling when the viewport is switched, and at the same time perform delayed release and unloading on the texture resources that are no longer visible, reducing the amount of data transferred from the CPU memory to the GPU video memory, thereby improving the rendering efficiency.

[0021] The specific steps of step 1 are as follows:

[0022] To establish the mapping relationship between computer screen coordinates and simulation scene coordinates, first, the Mercator projection transformation is used to convert the longitude and latitude coordinates of the Earth's surface, which is approximately a three-dimensional sphere in the real world, into longitude and latitude coordinates in a two-dimensional plane. The Mercator projection transformation method is shown in formula (1):

[0023]

[0024] In formula (1), X world is the longitude value in the two-dimensional plane after the Mercator projection transformation, Y world is the latitude value in the two-dimensional plane after the Mercator projection transformation, Lon is the longitude value corresponding to the element on the three-dimensional Earth's surface, Lat is the latitude value; R is the radius of the Earth;

[0025] The calculated longitude and latitude coordinates of the element in the two-dimensional plane are converted into NDC (Normalized Device Coordinates) through the standard transformation process in computer graphics, as shown in formula (2);

[0026] ndc = projectionMatrix * viewMatrix * worldPosition (2)

[0027] In the formula, worldPosition is the two-dimensional plane coordinates obtained by the Mercator projection transformation; viewMatrix is the viewport transformation matrix, which is used to map the plane coordinates to the pixel space of the rendering window; projectionMatrix is the projection transformation matrix, which is used to convert the coordinates from the view space to the NDC space; ndc is the NDC coordinates obtained by the element transformation;

[0028] Finally, the NDC coordinates are converted into screen coordinates according to formula (3). The screen coordinates are in pixels, and the range is determined by the resolution of the monitor and the size of the rendering window;

[0029]

[0030] Among them, X screen is the horizontal pixel coordinate value corresponding to the element on the screen, Y screen is the vertical pixel coordinate value corresponding to the element on the screen, screenWidth is the width value of the current rendering window, and screenHeight is the height value of the current rendering window;

[0031] So far, the mapping relationship from the longitude and latitude coordinates of the three-dimensional sphere to the two-dimensional screen coordinates of the computer is established, and the conversion from the screen coordinates to the longitude and latitude coordinates of the sphere is completed by the inverse transformation.

[0032] The NDC is a normalized coordinate system used in computer graphics, and the coordinate range is normalized to between [-1, 1], including the view transformation (converting the coordinates in the scene space to the view space) and the projection transformation (converting the points in the view space to the NDC space).

[0033] The determination method for culling in step 2 is as follows:

[0034] Based on the mapping relationship between the longitude and latitude coordinates of the three-dimensional sphere and the screen coordinates established in step 1, the coordinates of the upper left corner (0, 0) and the lower right corner (screenWidth, screenHeight) of the rendering window are converted into the simulation scene coordinates, and it is judged whether each element in the scene is within the current rendering range through formula (4), so as to cull the elements outside the range:

[0035]

[0036] In formula (4), P is the coordinate point corresponding to the scene element, C is the scene coordinate range of the entire rendering window, x min and y min respectively represent the longitude value and the latitude value corresponding to the upper left corner of the rendering window, x max and y max respectively represent the longitude value and the latitude value corresponding to the lower right corner of the rendering window.

[0037] The specific process of step 3 is as follows:

[0038] Step 3.1: Texture resource loading;

[0039] When the scene is initialized or the viewport is updated, determine the set of currently visible scene elements; then, only load the texture resources for the currently visible scene elements. The texture resources are stored on the disk in the form of image files (such as PNG, DDS, etc.) or pre-generated by the program. In the present invention, a multi-threaded asynchronous loading method is adopted to read the texture image data in parallel into the CPU memory to reduce the main thread blockage and improve the loading efficiency.

[0040] During the loading process, define a unique index number for the element according to the spatial position information or the unique identifier (such as object ID, hierarchical structure, etc.) of the scene element; then, define an unLoadedImageMap (Map type) to store the mapping between the scene element index and the corresponding texture data; and define a loadedIndexList (List type) to store the indexes of all the loaded scene elements within the current viewport range;

[0041] Step 3.2: Upload texture data to the GPU

[0042] Use the graphics API to upload the texture data loaded into the CPU memory to the GPU video memory for efficient access during rendering. In the present invention, the texture data loaded into the memory is extracted from the unLoadedImageMap and sequentially uploaded to the texture buffer of the GPU through the graphics API; after the upload is completed, the graphics API returns the corresponding texture object ID (Texture ID) for subsequent texture binding and rendering operations;

[0043] Define hasLoadedTextureMap (Map type) to store the index of the scene element and the texture object ID of the element in the texture buffer. Through hasLoadedTextureMap, quickly retrieve and bind the corresponding texture resources during rendering to avoid repeated loading, thereby improving the utilization rate of GPU resources;

[0044] Step 3.3: Incremental update during viewport transformation

[0045] When the viewport is translated, rotated, or scaled, causing changes in the visible scene elements, the system needs to incrementally update the texture resources and reuse the existing textures as much as possible while loading the texture resources of the newly entered viewport; at this time, by judging whether each element in the new scene has been loaded, that is: if the element index exists in hasLoadedTextureMap, it means that the texture has been uploaded to the GPU, and directly use the corresponding Texture ID for binding and rendering; if the index does not exist in hasLoadedTextureMap, it means that the element is the content newly entered the viewport, and its texture resources need to be loaded in the manner of Step 3.1 and Step 3.2 and stored in hasLoadedTextureMap;

[0046] Step 3.4: Dynamic release of texture resources

[0047] To avoid GPU video memory overflow caused by frequent viewport switching, it is necessary to release and recycle the texture resources that are no longer visible. The present invention adopts an index-based comparison strategy to ensure that only the textures required by the current viewport are stored in hasLoadedTextureMap;

[0048] By comparing the keys of loadedIndexList and hasLoadedTextureMap, find the scene elements that do not belong to the current viewport, obtain their Texture ID through hasLoadedTextureMap, call the graphics API to release the corresponding GPU video memory resources, and remove the corresponding entries from hasLoadedTextureMap.

[0049] An electronic device, comprising: one or more processors; a memory; one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method as described above.

[0050] A computer-readable storage medium stores program code, and the program code can be called by a processor to execute the method as described above.

[0051] The beneficial effect of the present invention lies in a new simulation scene rendering optimization method. By adopting viewport culling and on-demand loading and dynamic unloading of texture buffers in the scene, the processing load of each hardware unit of the computer is reduced, and the data transmission volume between hardware units is reduced, significantly optimizing the system performance of simulation scene rendering and improving the response speed. This solution realizes efficient texture loading and management and optimizes the use of GPU resources through three links: coordinate mapping, viewport culling, and texture cache management. First, a screen coordinate mapping is established based on the spatial position information of scene elements to ensure accurate positioning of visible elements; then, the mapping relationship is used for viewport culling to determine which elements need to load or reuse existing textures; finally, texture cache management relies on the results of viewport culling, reuses the loaded textures, loads new textures entering the viewport on demand, and releases texture resources that are no longer visible. Thereby reducing the GPU burden and improving the rendering efficiency. Description of the Drawings

[0052] Figure 1 It is a flowchart of texture information transmission.

[0053] Figure 2 Flowchart of optimized graphic rendering.

[0054] Figure 3 Schematic diagram of the viewport culling method.

[0055] Figure 4 Schematic diagram of screen space transformation.

[0056] Figure 5 Real-time rendering diagram of the simulation scene. Detailed Embodiments

[0057] The present invention will be further described below with reference to the drawings and embodiments.

[0058] The present invention first establishes a mapping relationship between the computer screen coordinates and the simulation scene coordinates. Before each scene loading, it calculates the simulation scene space area corresponding to the screen viewport, eliminates the scene elements outside the viewport, and manages the texture cache information of the existing scene to delay the release. When switching to a new scene, it first continues to use the viewport for judgment and elimination. In addition, it retrieves the resource information already in the texture buffer, thereby reducing the amount of information sent to the GPU each time and improving the rendering efficiency. The method flow is as Figure 2 shown.

[0059] The specific technical solution is as follows:

[0060] (1) Establish a coordinate mapping relationship

[0061] To establish the mapping relationship between the computer screen coordinates and the simulation scene coordinates, considering that in various simulation systems, the elements in the scene usually define their coordinate positions in space in the form of longitude and latitude. Therefore, first, the Mercator projection transformation is adopted to convert the longitude and latitude coordinates of the earth's surface, which is approximately a three-dimensional sphere in the real world, into longitude and latitude coordinates in a two-dimensional plane. The Mercator projection transformation method is as shown in formula (1).

[0062]

[0063] In formula (1), Lon is the longitude value corresponding to the element on the three-dimensional earth's surface, Lat is the latitude value; R is the radius of the earth; X world is the longitude value in the two-dimensional plane after the Mercator projection transformation, and Y world is the latitude value after the transformation.

[0064] Next, the calculated longitude and latitude coordinates of the element in the two-dimensional plane are converted into NDC (Normalized Device Coordinates) through the standard transformation process in computer graphics, as shown in formula (2). NDC is a standardized coordinate system used in computer graphics, and its coordinate range is normalized to between [-1, 1]. Specifically, this process usually includes a view transformation (converting the coordinates in the scene space to the view space) and a projection transformation (converting the points in the view space to the NDC space).

[0065] ndc = projectionMatrix * viewMatrix * worldPosition (2)

[0066] Where worldPosition is the two-dimensional plane coordinates obtained by Mercator projection transformation; viewMatrix is the viewport transformation matrix used to map the plane coordinates to the pixel space of the rendering window; projectionMatrix is the projection transformation matrix used to convert the coordinates from the view space to the NDC space; ndc is the NDC coordinates obtained by element transformation.

[0067] Finally, convert the NDC coordinates to screen coordinates according to formula (3). The screen coordinates are in pixels, and the range is determined by the resolution of the monitor and the size of the rendering window.

[0068]

[0069] Among them, screenWidth is the width value of the current rendering window, and screenHeight is its height value; X screen is the horizontal pixel coordinate value corresponding to the element on the screen, and Y screen is the vertical pixel coordinate value.

[0070] So far, the mapping relationship from three-dimensional spherical longitude and latitude coordinates to computer two-dimensional screen coordinates has been established, and the conversion from screen coordinates to spherical longitude and latitude coordinates can be completed by inverse transformation.

[0071] (2) Viewport culling

[0072] Based on the mapping relationship between three-dimensional spherical longitude and latitude coordinates and screen coordinates established in step (1), convert the upper-left corner coordinates (0, 0) and lower-right corner coordinates (screenWidth, screenHeight) of the rendering window into simulation scene coordinates, and judge whether each element in the scene is within the current rendering range through formula (4), so as to cull the elements outside the range.

[0073]

[0074] In the formula, P is the coordinate point corresponding to the scene element, C is the scene coordinate range of the entire rendering window, x min and y min respectively represent the longitude and latitude values corresponding to the upper left corner of the rendering window, x max and y max respectively represent the longitude and latitude values corresponding to the lower right corner of the rendering window. For the scene elements within the rendering window range, they are processed according to the standard processes of graphics rendering such as vertex shading and fragment shading, and finally output to the frame buffer. For the scene elements not within the screen viewport range, they are culled, and their geometric information (such as vertex coordinates, index data, etc.) or texture information is no longer transmitted to the GPU to reduce unnecessary computational overhead. Specifically as Figure 3 shown.

[0075] (3) Texture cache management

[0076] In computer programming, Map and List are two common data structures. Map stores data in key-value pairs and enables efficient retrieval of the corresponding value through the key; List stores data in an ordered structure and supports direct access to elements through indices.

[0077] In this solution, Map and List are used to store the texture resources and their index information of the scene elements within the current rendering viewport range. Through a matching retrieval mechanism, when the viewport is switched, the existing texture resources are reused as much as possible using the results of viewport culling. At the same time, the texture resources that are no longer visible are delayed released and unloaded, reducing the amount of data transferred from CPU memory to GPU video memory, thereby improving the rendering efficiency. The specific process is as follows:

[0078] 3.1) Texture resource loading

[0079] When the scene is initialized or the viewport is updated, the set of currently visible scene elements is determined. Then, only the texture resources of these scene elements are loaded. These resources are usually stored on disk in image file formats (such as PNG, DDS, etc.) or pre-generated by the program. This solution uses a multi-threaded asynchronous loading method to parallelly read the texture image data into CPU memory to reduce main thread blocking and improve the loading efficiency.

[0080] During the loading process, a unique index number is defined for each element based on its spatial position information or unique identifier (such as object ID, hierarchical structure, etc.). Then, an unLoadedImageMap (of type Map) is defined to store the scene element index and the corresponding texture data; and a loadedIndexList (of type List) is defined to store the indices of all the loaded scene elements within the current viewport range.

[0081] 3.2) Uploading texture data to the GPU

[0082] The texture data loaded into CPU memory is uploaded to the GPU video memory using the graphics API for efficient access during rendering. In this solution, the texture data that has been loaded into memory is extracted from the unLoadedImageMap and uploaded to the texture buffer of the GPU sequentially through the graphics API. After the upload is complete, the graphics API returns the corresponding texture object ID (Texture ID) for subsequent texture binding and rendering operations.

[0083] Define hasLoadedTextureMap (Map type) to store the index of scene elements and the texture object ID of these elements in the texture buffer. Through hasLoadedTextureMap, the corresponding texture resources can be quickly retrieved and bound during rendering, avoiding repeated loading and thus improving the utilization rate of GPU resources.

[0084] 3.3) Incremental update during viewport transformation

[0085] When the viewport undergoes translation, rotation, or scaling, resulting in changes to the visible scene elements, as Figure 4 shown, the system needs to incrementally update the texture resources, reuse the existing textures as much as possible, and load the texture resources that newly enter the viewport. At this time, by judging whether each element in the new scene has been loaded, that is: if the element index exists in hasLoadedTextureMap, it means that the texture has been uploaded to the GPU, and the corresponding Texture ID is directly used for binding and rendering; if the index does not exist in hasLoadedTextureMap, it means that the element is new to the viewport, and its texture resources need to be loaded in the manner of steps 1) and 2) and stored in hasLoadedTextureMap.

[0086] 3.4) Dynamic release of texture resources

[0087] To avoid GPU video memory overflow caused by frequent viewport switching, it is necessary to release and recycle the texture resources that are no longer visible. The present invention adopts an index-based comparison strategy to ensure that only the textures required by the current viewport are stored in hasLoadedTextureMap.

[0088] By comparing the keys of loadedIndexList and hasLoadedTextureMap, find the scene elements that do not belong to the current viewport, obtain their Texture ID through hasLoadedTextureMap, call the graphics API to release the corresponding GPU video memory resources, and remove the corresponding entries from hasLoadedTextureMap.

[0089] The present invention realizes efficient texture loading and management and optimizes the use of GPU resources through three links: coordinate mapping, viewport culling, and texture cache management. First, establish a screen coordinate mapping based on the spatial position information of scene elements to ensure accurate positioning of visible elements; then, use the mapping relationship for viewport culling to judge which elements need to load or reuse existing textures; finally, the texture cache management relies on the results of viewport culling, reuses the loaded textures, loads new textures entering the viewport as needed, and releases the texture resources that are no longer visible. Thereby reducing the GPU burden and improving the rendering efficiency.

[0090] Experimental verification

[0091] Based on the above technical methods, the method of the present invention is experimentally verified to verify the effectiveness of the method. Generally, there are two intuitive ways to reflect the rendering efficiency of a simulation system. One is whether there is a relatively obvious "drag feeling" when dragging instantaneously during scene roaming for viewport movement; the other is whether there are obvious frame drops when the viewport is fixed and elements in the scene change in real time. Therefore, the present invention conducts experimental verification based on the above two aspects.

[0092] (1) By building the same scene, the same viewport dragging experiment is performed on the system before and after optimization. Under each scene, record the instantaneous time consumption of loading new element information when dragging the scene viewport 10 times, and calculate the average value of the 10 time consumptions. The experimental results are shown in Table 1.

[0093] Table 1 Instantaneous dragging time consumption test

[0094]

[0095] It can be seen that for the optimized simulation system, the instantaneous dragging time consumption during scene roaming is significantly reduced, significantly reducing the "drag feeling" of viewport movement. Especially when there are more scene elements, the optimization effect is more significant.

[0096] (2) Build a total of 3000 elements in the scene and make them move randomly in real time within a specified area, as Figure 5 shown.

[0097] By adjusting the viewport, the number of elements in the screen space is changed, and the average value of the time consumption of 10 single-frame renderings is recorded. The experimental results are shown in Table 2.

[0098] Table 2 Comparison of the number of elements in the viewport and the time consumption of single-frame rendering

[0099]

[0100] The present invention first establishes a mapping relationship between computer screen coordinates and simulation scene coordinates, and proposes a rendering optimization method based on viewport culling to cull redundant content in the simulation scene.

[0101] The present invention proposes a management method for texture buffers to support the on-demand loading and dynamic unloading of texture resources.

[0102] Through a new simulation scene rendering optimization method, the present invention adopts viewport culling and on-demand loading and dynamic unloading of texture buffers in the scene, reducing the processing load of each hardware unit of the computer and the data transmission volume between hardware units, significantly optimizing the system performance of simulation scene rendering and improving the response speed.

Claims

1. A simulation scene rendering optimization method, characterized in that The steps include: Step 1: Establish coordinate mapping relationship; Step 2: Viewport culling; For scene elements within the rendering window, they are processed according to the graphics rendering process of vertex shading and fragment shading, and finally output to the frame buffer; Scene elements that are not within the screen viewport are culled, and the geometric information or texture information of the scene elements is no longer transmitted to the GPU to reduce unnecessary computing overhead; Step 3: Texture cache management In computer programming, Map and List are two data structures. Map uses key-value pairs to store data and efficiently retrieves corresponding values ​​through keys. List uses an ordered storage structure and supports direct access to elements through indexes. Map and List are used to store the texture resources and index information of the scene elements within the current rendering viewport. Through the matching retrieval mechanism, the existing texture resources are reused using the results of viewport culling when the viewport is switched. At the same time, delayed release and unloading of texture resources that are no longer visible are performed to reduce the amount of data transferred from CPU memory to GPU video memory, thereby improving rendering efficiency.

2. The simulation scene rendering optimization method according to claim 1, characterized in that: The specific steps of step 1 are: In order to establish the mapping relationship between the computer screen coordinates and the simulation scene coordinates, the Mercator projection transformation is first used to convert the longitude and latitude coordinates of the earth surface, which is approximately a three-dimensional sphere in the real world, into the longitude and latitude coordinates on a two-dimensional plane. The Mercator projection transformation method is shown in formula (1): In formula (1), X world is the longitude value in the two-dimensional plane after Mercator projection transformation, Y world The latitude value in the two-dimensional plane after Mercator projection transformation, Lon is the longitude value corresponding to the element on the three-dimensional earth surface, Lat is the latitude value; R is the radius of the earth; The calculated two-dimensional plane latitude and longitude coordinates of the element are converted into normalized device coordinates NDC through the standard transformation process in graphics, as shown in formula (2); ndc=projectionMatrix*viewMatrix*worldPosition(2) Where worldPosition is the two-dimensional plane coordinate obtained by Mercator projection transformation; viewMatrix is ​​the viewport transformation matrix, which is used to map the plane coordinate to the pixel space of the rendering window; projectionMatrix is ​​the projection transformation matrix, which is used to transform coordinates from view space to NDC space; ndc is the NDC coordinate obtained by element transformation; Finally, the NDC coordinates are converted to screen coordinates according to formula (3). The screen coordinates are in pixels, and the range is determined by the resolution of the display and the size of the rendering window. Among them, X screen Y is the horizontal pixel coordinate value of the element on the screen. screen is the vertical pixel coordinate value corresponding to the element on the screen, screenWidth is the width value of the current rendering window, and screenHeight is the height value of the current rendering window; At this point, a mapping relationship from three-dimensional spherical longitude and latitude coordinates to two-dimensional computer screen coordinates is established, and the conversion from screen coordinates to spherical longitude and latitude coordinates is completed by inverse transformation.

3. The simulation scene rendering optimization method according to claim 2, characterized in that: The NDC is a standardized coordinate system used in computer graphics, and the coordinate range is normalized to [-1, 1], including view transformation and projection transformation.

4. The simulation scene rendering optimization method according to claim 2, characterized in that: The method for judging elimination in step 2 is: Based on the mapping relationship between the three-dimensional spherical latitude and longitude coordinates and the screen coordinates established in step 1, the upper left corner coordinates (0, 0) and the lower right corner coordinates (screenWidth, screenHeight) of the rendering window are converted into simulation scene coordinates, and formula (4) is used to determine whether each element in the scene is within the current rendering range, thereby eliminating elements outside the range: In formula (4), P is the coordinate point corresponding to the scene element, C is the scene coordinate range of the entire rendering window, and x min and min They represent the longitude and latitude values ​​corresponding to the upper left corner of the rendering window, respectively. max and max They respectively represent the longitude and latitude values ​​corresponding to the lower right corner of the rendering window.

5. The simulation scene rendering optimization method according to claim 4, characterized in that: The specific process of step 3 is as follows: Step 3.1: Texture resource loading; When the scene is initialized or the viewport is updated, the set of currently visible scene elements is determined; then, only the texture resources of the currently visible scene elements are loaded. The texture resources are stored on the disk as image files or pre-generated by the program. The texture image data is read in parallel to the CPU memory using multi-threaded asynchronous loading to reduce main thread blocking and improve loading efficiency. During the loading process, a unique index number is defined for the element according to the spatial position information or unique identifier of the scene element; then, an unLoadedImageMap is defined to store the scene element index and the corresponding texture data; and a loadedIndexList is defined to store all loaded scene element indexes within the current viewport range; Step 3.2: Upload texture data to GPU Use the graphics API to upload the texture data loaded into the CPU memory to the GPU memory for efficient access during rendering; extract the texture data loaded into the memory from the unLoadedImageMap, and upload it to the GPU's texture buffer in sequence through the graphics API; after the upload is completed, the graphics API returns the corresponding texture object ID (Texture ID) for subsequent texture binding and rendering operations; Define hasLoadedTextureMap to store the index of the scene element and the texture object ID of the element in the texture buffer. Through hasLoadedTextureMap, the corresponding texture resources can be quickly retrieved and bound during rendering to avoid repeated loading, thereby improving the utilization of GPU resources. Step 3.3: Incremental updates when the viewport changes When the viewport is translated, rotated or scaled, resulting in changes in visible scene elements, the system needs to incrementally update texture resources and reuse existing textures as much as possible, while loading texture resources that are newly entered into the viewport; at this time, it is determined whether each element in the new scene has been loaded, that is: if the element index exists in hasLoadedTextureMap, it means that the texture has been uploaded to the GPU, and the corresponding Texture ID is directly used for binding and rendering; if the index does not exist in hasLoadedTextureMap, it means that the element is new to the viewport, and its texture resources need to be loaded according to steps 3.1 and 3.2, and stored in hasLoadedTextureMap; Step 3.4: Dynamic release of texture resources In order to avoid GPU memory overflow caused by frequent viewport switching, it is necessary to release and recycle texture resources that are no longer visible; an index-based comparison strategy is adopted to ensure that hasLoadedTextureMap only stores textures required by the current viewport; By comparing the Key of loadedIndexList and hasLoadedTextureMap, find out the scene elements that do not belong to the current viewport, obtain their Texture ID through hasLoadedTextureMap, call the graphics API to release the corresponding GPU video memory resources, and remove the corresponding entries from hasLoadedTextureMap.

6. An electronic device, characterized in that: include: one or more processors; Memory; One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 5.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, and the program codes can be called by a processor to execute the method according to any one of claims 1 to 5.

Citation Information

Cited By

  • Method and system for dynamically adjusting display interface

    CN120431888A

  • Texture loading method based on three-dimensional engine, electronic equipment and storage medium

    CN120580333A

  • A three-dimensional engine-based texture loading method, electronic device and storage medium

    CN120580333B