A method, apparatus, device and medium for rendering a to-be-rendered object

By processing chunked rendering data in parallel on the GPU, the CPU processing bottleneck is solved, enabling efficient rendering of complex scenes and improving the performance and scalability of the rendering system.

CN121304886BActive Publication Date: 2026-04-24HUNAN TACHYON CULTURE & TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUNAN TACHYON CULTURE & TECHNOLOGY CO LTD
Filing Date
2025-12-12
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

In traditional graphics rendering pipelines, the CPU's handling of a large number of rendering instances and state synchronization leads to performance bottlenecks, severely limiting rendering efficiency and scene scale.

Method used

The CPU divides the rendering data into blocks and sends them to the GPU storage buffer, and then uses compute shader threads to process them in parallel, including visibility filtering and detail level control, to achieve parallel rendering on the GPU side.

Benefits of technology

It reduces communication overhead between the CPU and GPU, avoids CPU bottlenecks, significantly improves the throughput and scalability of the rendering system, enables smooth rendering of complex scenes, and provides a higher quality visual experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121304886B_ABST
    Figure CN121304886B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of computer graphics rendering, and particularly relates to a method and device for rendering a to-be-rendered object, equipment and medium. The method comprises: obtaining, by a CPU, rendering item data corresponding to each of one or more rendering items, obtaining data blocks by dividing the rendering item data corresponding to each of the one or more rendering items according to a preset rule, and saving the data blocks to a storage buffer of a GPU; generating, by the CPU, scheduling information for the data blocks; starting, according to the scheduling information, a plurality of computing shader threads on the GPU to perform parallel processing on the plurality of data blocks to generate rendering data of the rendering items corresponding to the plurality of data blocks; and rendering, by the GPU, the corresponding rendering items using the rendering data in the storage buffer. The scheme uses a computing shader to implement a GPU-driven rendering pipeline, thereby reducing the load of the CPU and greatly improving the rendering efficiency of large-scale scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer graphics rendering technology, specifically to a method, apparatus, device, and medium for rendering an object to be rendered. Background Technology

[0002] In traditional graphics rendering pipelines, the CPU (Central Processing Unit) handles the vast majority of scene management and rendering preparation, including but not limited to: traversing the scene graph to determine the set of potentially visible objects, performing frustum culling and occlusion culling, calculating the appropriate Level of Detail (LOD) for objects, organizing the rendering state, and preparing and submitting each draw call command. Faced with the massive number of rendering instances in modern applications (such as tens of thousands of vegetation, buildings, or particles), the logic that the CPU needs to process increases significantly. The large number of draw calls and the accompanying state synchronization and verification overhead between the CPU and the GPU quickly make single-threaded or limited multi-threaded CPUs the performance bottleneck of the rendering pipeline, severely restricting rendering efficiency and scene scale. Summary of the Invention

[0003] To address the problems in the related technologies, embodiments of this disclosure provide a method, apparatus, device, and medium for rendering an object to be rendered.

[0004] In a first aspect, this disclosure provides a method for rendering an object to be rendered, the object to be rendered including one or more rendering items, the method comprising:

[0005] The CPU obtains the rendering item data corresponding to each of the one or more rendering items, divides the rendering item data corresponding to each of the one or more rendering items into blocks according to a preset rule to obtain data blocks, and saves the data blocks to the storage buffer of the GPU. The rendering item data is used to generate rendering data for rendering the corresponding rendering item, and the data blocks include rendering item data of at least one rendering item.

[0006] The CPU generates scheduling information for the data blocks. The scheduling information includes the storage location information of the data blocks in the storage buffer and the scheduling grid size information required to process the data blocks. The scheduling grid includes at least one thread group, and the thread group includes at least one compute shader thread.

[0007] According to the scheduling information, multiple compute shader threads are started on the GPU to process multiple data blocks in parallel, so as to generate rendering data for the rendering items corresponding to the multiple data blocks, and the rendering data is stored in the GPU's storage buffer.

[0008] The GPU uses the rendering data in the storage buffer to render the corresponding rendering items.

[0009] According to embodiments of this disclosure, the step of starting multiple compute shader threads on the GPU to process multiple data blocks in parallel based on the scheduling information includes:

[0010] The CPU issues indirect scheduling instructions to the GPU.

[0011] The GPU responds to the indirect scheduling instruction by reading the scheduling information of the multiple data blocks. Based on the scheduling grid size information required to process the data blocks in the scheduling information, the GPU starts a corresponding number of compute shader threads for each of the multiple data blocks. The multiple compute shader threads started for the multiple data blocks read the rendering item data of the corresponding data block from the storage buffer according to the scheduling information of the corresponding data block and process the rendering item data in parallel to generate the rendering data of the rendering items of the multiple data blocks.

[0012] According to embodiments of this disclosure, the scheduling grid size information required for processing the data block includes any one or more of the following: the size of the scheduling grid required for processing the data block, the number of rendering items corresponding to the data block, the type of rendering items corresponding to the data block, and the number of rendering items.

[0013] The scheduling grid size in the scheduling information of the data block is determined based on the number of rendering items corresponding to the data block; or

[0014] The scheduling grid size in the scheduling information of the data block is determined based on the type and number of rendering items corresponding to the data block.

[0015] According to embodiments of this disclosure, the processing performed by the compute shader thread on the data block includes visibility filtering of the data block.

[0016] According to embodiments of this disclosure, the visibility filtering includes local culling based on a frustum or occlusion query.

[0017] According to embodiments of this disclosure, the processing performed by the GPU on the data blocks includes performing detail-level control on the data blocks.

[0018] According to embodiments of this disclosure, the level-of-detail control includes performing LOD calculations and selections on the rendering item data of terrain tiles.

[0019] According to embodiments of this disclosure, performing LOD calculation and selection on the rendered item data of terrain tiles includes:

[0020] Create the root node of an N-ary tree and store the node data of the root node, where N is an integer greater than or equal to 2;

[0021] Starting from the root node of the N-ary tree, traverse level by level, performing the following operations for each traversed node: If the current node's traversal state is untraversed, determine whether the current node needs to be subdivided based on its LOD level and the terrain data corresponding to the current node; if the current node needs to be subdivided, generate N child nodes for the current node, save the node data of the child nodes, and the LOD level of the child nodes = the LOD level of the current node + 1; if the current node does not need to be subdivided, treat the current node as a leaf node.

[0022] The LOD removal operation is performed based on the leaf nodes of the N-ary tree.

[0023] The node data includes the terrain region represented by the current node, the terrain data corresponding to the current node, the LOD level of the current node, and the traversal status of the current node.

[0024] According to an embodiment of this disclosure, N=4.

[0025] According to embodiments of this disclosure, a node structure is used to store the node data, and the node structure includes the following fields:

[0026] The spatial extent field is used to define the terrain region represented by the node;

[0027] The data reference field is used to associate the terrain data corresponding to the node;

[0028] The LOD level field is used to store the LOD level of a node;

[0029] The traversal status field is used to store the traversal status of a node.

[0030] According to embodiments of this disclosure, determining whether the current node needs further subdivision based on the LOD level of the current node and the terrain data corresponding to the current node includes:

[0031] Based on the LOD level of the current node, the relative distance between the current node and the camera, and the degree of terrain height change in the terrain data corresponding to the current node, the subdivided requirement value of the node is calculated;

[0032] The subdivision requirement value is compared with a preset subdivision threshold, and the current node is determined to be subdivided based on the comparison result.

[0033] The subdivided demand value increases as the distance between the node and the camera decreases, increases as the degree of change in terrain height in the terrain data corresponding to the node increases, and decreases as the LOD level of the node decreases.

[0034] According to embodiments of this disclosure, calculating the subdivided requirement value of a node based on the LOD level of the current node, the relative distance between the current node and the camera, and the degree of terrain height variation in the terrain data corresponding to the current node includes:

[0035] Calculate the normalized distance value between the current node and the camera based on the relative distance between the current node and the camera;

[0036] Calculate the ruggedness value of the current node based on the terrain height data in the terrain data corresponding to the current node;

[0037] The normalized distance value, ruggedness value, and current node LOD level are input into the subdivision evaluation function to calculate the subdivision requirement value.

[0038] The subdivision evaluation function satisfies the following relationship:

[0039] The subdivided demand value is inversely proportional to the normalized distance value, directly proportional to the ruggedness value, and inversely proportional to the LOD level of the current node.

[0040] According to embodiments of this disclosure, the step of traversing the N-ary tree level by level starting from the root node includes:

[0041] For any level below the root node, the nodes in that level are traversed in parallel by the compute shader thread. After traversing all the nodes in that level, the traversal of the next level is then performed.

[0042] According to embodiments of this disclosure, it further includes:

[0043] Calculate the LOD level difference between each leaf node and each of its neighboring nodes, wherein the terrain regions corresponding to the neighboring nodes of the leaf node are adjacent to the terrain regions corresponding to the leaf node.

[0044] Based on the LOD level difference, the positions of vertices located at the edges of the terrain regions represented by the corresponding leaf nodes are adjusted to achieve seamless integration between adjacent terrain regions.

[0045] According to embodiments of this disclosure, calculating the LOD level difference between each leaf node and each of its neighboring nodes includes, for each leaf node, using compute shader threads in parallel to calculate the LOD level difference between the leaf node and each of its neighboring nodes.

[0046] The step of adjusting the position of vertices located at the edge of the terrain region represented by the corresponding leaf node according to the LOD level difference includes using a compute shader thread in parallel to adjust the position of vertices located at the edge of the terrain region represented by the leaf node according to the LOD level difference between the leaf node and each of its neighboring nodes.

[0047] According to embodiments of this disclosure, the rendering item includes one or more of the following: terrain tiles, mesh instances, renderable instances, and particle system components.

[0048] According to an embodiment of this disclosure, rendering a corresponding rendering item using rendering data in the storage buffer via the GPU includes: issuing one or more indirect draw call instructions to the GPU via the CPU; the GPU responding to the indirect draw call instructions reading from the storage buffer and submitting the rendering data to the rendering pipeline; wherein rendering data corresponding to the same type of rendering item is merged and submitted in the same indirect draw call.

[0049] Secondly, this disclosure provides an apparatus for rendering an object to be rendered, the object to be rendered including one or more rendering items, the apparatus comprising:

[0050] The data allocation module is configured to obtain the rendering item data corresponding to each of the one or more rendering items through the CPU, divide the rendering item data corresponding to each of the one or more rendering items into blocks according to a preset rule to obtain data blocks, and save the data blocks to the storage buffer of the GPU. The rendering item data is used to generate rendering data for rendering the corresponding rendering item, and the data blocks include rendering item data of at least one rendering item.

[0051] The scheduling information generation module is configured to generate scheduling information for the data blocks via the CPU. The scheduling information includes the storage location information of the data blocks in the storage buffer and the scheduling grid size information required to process the data blocks. The scheduling grid includes at least one thread group, and the thread group includes at least one compute shader thread.

[0052] The parallel processing module is configured to start multiple compute shader threads on the GPU according to the scheduling information to perform parallel processing on multiple data blocks, so as to generate rendering data of rendering items corresponding to the multiple data blocks, and save the rendering data in the GPU's storage buffer.

[0053] The rendering execution module is configured to render the corresponding rendering items using the rendering data in the storage buffer via the GPU.

[0054] According to embodiments of this disclosure, the processing performed by the GPU on the data blocks includes performing detail-level control on the data blocks.

[0055] According to embodiments of this disclosure, the level-of-detail control includes performing LOD calculations and selections on the rendering item data of terrain tiles.

[0056] According to embodiments of this disclosure, performing LOD calculation and selection on the rendered item data of terrain tiles includes:

[0057] Create the root node of an N-ary tree and store the node data of the root node, where N is an integer greater than or equal to 2;

[0058] Starting from the root node of the N-ary tree, traverse level by level, performing the following operations for each traversed node: If the current node's traversal state is untraversed, determine whether the current node needs to be subdivided based on its LOD level and the terrain data corresponding to the current node; if the current node needs to be subdivided, generate N child nodes for the current node, save the node data of the child nodes, and the LOD level of the child nodes = the LOD level of the current node + 1; if the current node does not need to be subdivided, treat the current node as a leaf node.

[0059] The LOD removal operation is performed based on the leaf nodes of the N-ary tree.

[0060] The node data includes the terrain region represented by the current node, the terrain data corresponding to the current node, the LOD level of the current node, and the traversal status of the current node.

[0061] According to embodiments of this disclosure, it further includes:

[0062] The LOD level difference calculation module is configured to calculate the LOD level difference between each leaf node and each of its neighboring nodes, wherein the terrain regions corresponding to the neighboring nodes of the leaf node are adjacent to the terrain regions corresponding to the leaf node.

[0063] The vertex position adjustment module is configured to adjust the position of vertices located at the edge of the terrain region represented by the corresponding leaf node according to the LOD level difference, so as to achieve seamless connection between adjacent terrain regions.

[0064] Thirdly, embodiments of this disclosure provide an electronic device including a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method as described in the first aspect.

[0065] Fourthly, this disclosure provides a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the method described in the first aspect.

[0066] According to the technical solution provided in this disclosure, the CPU acquires rendering item data corresponding to one or more rendering items, divides the rendering item data corresponding to one or more rendering items into data blocks according to a preset rule, and saves the data blocks to the GPU's storage buffer. The rendering item data is used to generate rendering data for rendering the corresponding rendering item, and each data block includes rendering item data for at least one rendering item. The CPU generates scheduling information for the data blocks, including the storage location information of the data blocks in the storage buffer and the scheduling grid size information required to process the data blocks. The scheduling grid includes at least one thread group, and each thread group includes at least one compute shader thread. Multiple compute shader threads are started on the GPU according to the scheduling information to process multiple data blocks in parallel, generating rendering data for the rendering items corresponding to the multiple data blocks. The rendering data is saved in the GPU's storage buffer. The GPU uses the rendering data in the storage buffer to render the corresponding rendering item. This disclosure transfers core rendering preparation tasks, such as scene management, visibility culling, and detail level calculation and selection, which were originally executed serially by the CPU, to the GPU for parallel execution through compute shaders. This frees the CPU from the heavy burden of per-frame scene processing, allowing the GPU to directly process render item data blocks organized in contiguous buffers in a highly parallel manner. This significantly reduces communication overhead and synchronization wait between the CPU and GPU, and effectively avoids CPU bottlenecks caused by a large number of draw calls. By adopting a data block-based scheduling mechanism and a "one thread, one render item" parallel processing model, this disclosure enables the system to efficiently handle ultra-large-scale scenes and massive instance rendering, significantly improving the overall throughput and scalability of the rendering system. It can smoothly render extremely complex scenes and ultimately brings users a higher quality and more immersive visual experience.

[0067] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0068] Other features, objects, and advantages of this disclosure will become more apparent from the following detailed description of non-limiting embodiments, taken in conjunction with the accompanying drawings. In the drawings:

[0069] Figure 1 A flowchart illustrating a method for rendering an object to be rendered according to an embodiment of the present disclosure;

[0070] Figure 2 A schematic diagram of quadtree management according to an embodiment of the present disclosure is shown;

[0071] Figure 3 A structural block diagram of an apparatus for rendering an object to be rendered according to an embodiment of the present disclosure is shown.

[0072] Figure 4 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown;

[0073] Figure 5 A schematic diagram of the structure of a computer system suitable for implementing the method according to embodiments of the present disclosure is shown. Detailed Implementation

[0074] In the following, exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings to enable those skilled in the art to readily implement them. Furthermore, for clarity, portions unrelated to the description of exemplary embodiments have been omitted from the drawings.

[0075] In this disclosure, it should be understood that terms such as “comprising” or “having” are intended to indicate the presence of features, figures, steps, behaviors, components, parts or combinations thereof disclosed in this specification, and are not intended to exclude the possibility of the presence or addition of one or more other features, figures, steps, behaviors, components, parts or combinations thereof.

[0076] It should also be noted that, unless otherwise specified, the embodiments and features described in this disclosure can be combined with each other. This disclosure will now be described in detail with reference to the accompanying drawings and embodiments.

[0077] As mentioned earlier, in modern real-time graphics rendering applications, such as game engines and virtual reality systems, handling large-scale scene rendering remains a significant performance bottleneck. Taking terrain rendering as an example, traditional rendering pipelines typically employ a CPU-based preprocessing workflow: first, the CPU traverses the scene graph to determine potential visible objects; then, frustum culling and level of detail (LOD) calculations are performed; finally, the processed data is transferred to the GPU in batches for rendering. This architecture places a large number of computationally intensive tasks on the CPU, which has limited processing power, creating a significant performance bottleneck.

[0078] Specifically, traditional solutions face multiple technical limitations: quadtree traversal and LOD evaluation, as core algorithms for terrain rendering, have serial execution characteristics that make it difficult to fully utilize the parallel potential of multi-core CPUs; as the camera's viewing angle changes dynamically, the CPU needs to frequently reconstruct the vertex buffer, resulting in continuous memory allocation and data transfer; a large number of independent terrain tiles lead to a surge in the number of draw calls, and the state switching of the GPU when rendering different objects further reduces pipeline efficiency. These factors together cause the system bus bandwidth to be occupied by a large amount of redundant data, and the GPU often needs to wait for the CPU to complete preprocessing work, resulting in low hardware resource utilization.

[0079] To address the aforementioned problems, this disclosure provides a method, apparatus, device, and medium for rendering objects, achieving parallel processing throughout the entire process from scene management to final rendering through computational shaders, aiming to build an efficient and smooth large-scale scene rendering solution. For ease of understanding, the technical solution of this disclosure is described below through specific embodiments.

[0080] Figure 1 A flowchart illustrating a method for rendering an object to be rendered according to an embodiment of the present disclosure is provided. Figure 1 As shown, in the method for rendering an object to be rendered, the object to be rendered includes one or more rendering items, and the method includes the following steps S101-S104:

[0081] In step S101, the CPU obtains the rendering item data corresponding to each of the one or more rendering items, divides the rendering item data corresponding to each of the one or more rendering items into blocks according to a preset rule to obtain data blocks, and saves the data blocks to the storage buffer of the GPU. The rendering item data is used to generate rendering data for rendering the corresponding rendering item, and the data blocks include rendering item data of at least one rendering item.

[0082] In step S102, the CPU generates scheduling information for the data block. The scheduling information includes the storage location information of the data block in the storage buffer and the scheduling grid size information required to process the data block. The scheduling grid includes at least one thread group, and the thread group includes at least one compute shader thread.

[0083] In step S103, multiple compute shader threads are started on the GPU according to the scheduling information to process multiple data blocks in parallel, so as to generate rendering data of the rendering items corresponding to the multiple data blocks, and the rendering data is stored in the GPU's storage buffer.

[0084] In step S104, the GPU uses the rendering data in the storage buffer to render the corresponding rendering item.

[0085] For example, in step S101 of the embodiment using the game engine rendering pipeline, the rendering item data has different data structures depending on the type of the rendering item.

[0086] For example, when the rendering item is a terrain tile, the rendering item data includes height map data, normal data, and terrain control map data; when the rendering item is a mesh instance, the rendering item data includes vertex data, normal data, and world transformation matrix data; when the rendering item is a particle system component, the rendering item data includes particle position data, particle velocity data, and particle lifecycle data.

[0087] The segmentation according to preset rules includes any one or more of the following segmentation methods: segmenting according to the type of rendering item, organizing rendering items of the same type in the same data segment; segmenting according to spatial location, organizing rendering items in adjacent spatial areas in the same data segment; segmenting according to material properties, organizing rendering items using the same material properties in the same data segment.

[0088] According to embodiments of this disclosure, the rendering item includes one or more of the following: terrain tiles, mesh instances, renderable instances, and particle system components.

[0089] According to embodiments of this disclosure, the storage buffer is a Shader Storage Buffer Object (SSBO) or an Unordered Access View (UAV), and the data blocks are stored in the storage buffer with a contiguous memory layout, wherein the rendering item data within the same data block is stored in order according to a preset data structure.

[0090] By using the block-splitting method based on preset rules, the consistency of rendering items within the same data block in terms of type and spatial distribution is ensured, thus establishing an effective data organization foundation for subsequent parallel processing on the GPU.

[0091] According to an embodiment of this disclosure, in step S102, scheduling information is generated for the data block by the CPU. The scheduling information includes the storage location information of the data block in the storage buffer and the scheduling grid size information required to process the data block. The scheduling grid includes at least one thread group, and the thread group includes at least one compute shader thread.

[0092] For example, the scheduling information is organized into a scheduling information table on the CPU side. Subsequently, the CPU creates and initializes a dedicated parameter buffer in the GPU's video memory using graphics APIs (such as Vulkan's vkCreateBuffer and vkCmdUpdateBuffer, or DirectX 12's CreateCommittedResource and CopyBufferRegion), and transfers the scheduling information table to it. For each data block, the scheduling information specifically includes: the starting offset of the data block in the storage buffer, the number of rendering items contained in the data block, and the number of thread groups in the scheduling grid in the X, Y, and Z dimensions required to process the data block.

[0093] The method for determining the scheduling grid size varies depending on the characteristics of the data blocks and processing requirements:

[0094] For terrain truncation, the scheduling grid size is determined based on the number of terrain nodes to be processed contained in the truncation. The scheduling grid is configured to distribute computing threads in the X and Y dimensions, and the size of the Z dimension is set to 1, forming a logical two-dimensional grid layout to match the distribution characteristics of terrain data on the plane.

[0095] For a grid instance, the scheduling grid size is calculated based on the number of instances and a fixed thread group capacity. Specifically, the number of thread groups in the X dimension of the scheduling grid is calculated as ceil(number of instances / thread group capacity), where ceil is the floor function. For example, if a data block contains 150 grid instances and the thread group capacity is set to 64 threads, then the required number of thread groups is ceil(150 / 64) = 3, meaning the scheduling grid size is (3, 1, 1), and a total of 3 × 64 = 192 threads are started, with the first 150 threads working effectively. This scheduling grid ensures that each grid instance is processed by an independent compute shader thread.

[0096] For particle system components, the dimensional layout of the scheduling grid is determined based on the organization of particle data or the required processing mode. When the particle system does not involve interactions between particles and the particle data is organized in the form of a linear list, a one-dimensional grid layout is used. When the particle system needs to interact based on spatial neighborhood, particles are assigned to a two-dimensional spatial grid for management. In this case, a two-dimensional grid layout is used so that threads correspond to spatial grid cells.

[0097] According to embodiments of this disclosure, the step of launching multiple compute shader threads on the GPU to process multiple data blocks in parallel based on the scheduling information includes:

[0098] The CPU issues an indirect scheduling instruction to the GPU; the GPU responds to the indirect scheduling instruction by reading the scheduling information of the multiple data blocks, and according to the scheduling grid size information required to process the data blocks in the scheduling information, starts a corresponding number of compute shader threads for each of the multiple data blocks. The multiple compute shader threads started for the multiple data blocks read the rendering item data of the corresponding data block from the storage buffer according to the scheduling information of the corresponding data block and process the rendering item data in parallel to generate the rendering data of the rendering items of the multiple data blocks.

[0099] For example, the indirect scheduling instruction is the DispatchIndirect command. The CPU triggers the parallel computing process by submitting this command to the GPU's command queue, without specifying a particular number of thread groups, which is read in real time by the GPU from the parameter buffer.

[0100] On the GPU side, after responding to the indirect scheduling instruction, the command processor performs the following operations: reads the scheduling information of the data block to be processed from the parameter buffer; parses the scheduling grid size in the scheduling information, i.e., the number of thread groups in the three dimensions of X, Y, and Z; creates a corresponding thread group grid on the GPU according to the scheduling grid size, wherein each thread group contains a predetermined number of compute shader threads; and all started compute shader threads execute the same compute shader program in parallel.

[0101] Each compute shader thread obtains its globally unique identifier in the thread grid through a system-built-in variable. Based on this identifier and the starting offset in the scheduling information, the thread can accurately locate the position of the specific render item data it is responsible for processing in the storage buffer.

[0102] According to embodiments of this disclosure, the scheduling grid size information required for processing the data block includes any one or more of the following: the size of the scheduling grid required for processing the data block, the number of rendering items corresponding to the data block, the type and number of rendering items corresponding to the data block; the scheduling grid size in the scheduling information of the data block is determined based on the number of rendering items corresponding to the data block; or the scheduling grid size in the scheduling information of the data block is determined based on the type and number of rendering items corresponding to the data block.

[0103] For example, the method for determining the scheduling grid size is specifically limited according to the type of rendering item: when the determination of the scheduling grid size is based solely on the number of rendering items corresponding to the data chunk, the number of thread groups in the X dimension of the scheduling grid is configured to the minimum value required to accommodate all rendering items, and the number of thread groups in the Y and Z dimensions is fixed at 1. This rule ensures that the number of allocated compute shader threads matches the number of rendering items to be processed; when the determination of the scheduling grid size is based on both the type and number of rendering items corresponding to the data chunk, the system predefines corresponding thread group configuration rules for each type of rendering item. Specifically, for terrain chunks, based on the characteristics of their two-dimensional spatial data, a configuration in which thread groups are evenly distributed in both the X and Y dimensions is adopted; for particle system components, based on whether the organization of their particle data in memory is a linear structure, thread groups are selected to be distributed in one or two dimensions. This discriminative rule optimizes the efficiency of GPU parallel computing by adapting to the inherent data structure and processing logic of different types of rendering items.

[0104] According to an embodiment of this disclosure, in step S103, multiple compute shader threads are started on the GPU according to the scheduling information to process multiple data blocks in parallel, so as to generate rendering data for rendering items corresponding to the multiple data blocks, and the rendering data is stored in the GPU's storage buffer.

[0105] For example, step S103 is the core computational stage of the GPU-driven rendering pipeline. After the indirect scheduling instruction is triggered, the GPU, based on the scheduling information in the parameter buffer, starts a corresponding size of compute shader thread group for each data block. All threads execute the predetermined compute shader program in parallel to process the allocated rendering item data. Each compute shader thread obtains its globally unique identifier in the thread grid through a system built-in variable, and combines it with the starting offset of the storage buffer obtained from the scheduling information to accurately locate and read the specific rendering item data it is responsible for processing.

[0106] According to embodiments of this disclosure, the processing performed by the compute shader thread on the data block includes visibility filtering of the data block.

[0107] For example, the visibility filtering is executed in parallel by compute shader threads. Each thread processes one or more render items and determines their visibility by calculating the intersection relationship between the spatial bounding volume of the render item and the camera's view frustum. For invisible render items, the thread marks them as culled. The visibility filtering also includes delayed culling based on hardware occlusion queries, which determines whether a render item is occluded by querying the depth information of previous frames.

[0108] According to embodiments of this disclosure, the processing performed by the GPU on the data blocks includes performing detail-level control on the data blocks.

[0109] According to embodiments of this disclosure, the level-of-detail control includes performing LOD calculations and selections on the rendering item data of terrain tiles.

[0110] According to embodiments of this disclosure, the LOD calculation and selection of the rendering item data for terrain tiles includes: creating the root node of an N-ary tree and saving the node data of the root node, where N is an integer greater than or equal to 2; traversing layer by layer from the root node of the N-ary tree, and performing the following operations for each traversed node: if the traversal state of the current node is untraversed, determining whether the current node needs to be subdivided based on the LOD level of the current node and the terrain data corresponding to the current node; if the current node needs to be subdivided, generating N child nodes of the current node, saving the node data of the child nodes, where the LOD level of the child nodes = the LOD level of the current node + 1; if the current node does not need to be subdivided, treating the current node as a leaf node; and performing LOD culling operations based on the leaf nodes of the N-ary tree, wherein the node data includes the terrain region represented by the current node, the terrain data corresponding to the current node, the LOD level of the current node, and the traversal state of the current node.

[0111] According to embodiments of this disclosure, N=4. However, those skilled in the art will understand that the technical solutions of this disclosure are also applicable to other values ​​where N is not less than 2.

[0112] For example, Figure 2 This diagram illustrates quadtree management according to an embodiment of the present disclosure. Taking the quadtree management of an embodiment of the present disclosure as an example, the process of performing LOD calculation and selection on the rendering item data of terrain tiles is implemented in a fully parallel quadtree management manner through the GPU computing shader. The step of creating the root node specifically includes: creating the root node in the initialization phase, defining the terrain region in the node data as an axis-aligned bounding box of the entire terrain range, the terrain data referencing the global height map and normal map, initializing the LOD level to 0, and marking the traversal state as untraversed. The step of traversing layer by layer from the root node is implemented through multiple indirect scheduling to achieve layered processing, with each scheduling corresponding to the calculation of one LOD level. During the processing of each layer, the computing shader processes the current layer node list in parallel. For each current node, it is determined whether the traversal state of the current node is untraversed. If so, the evaluation algorithm that determines whether the current node needs to be subdivided based on the LOD level of the current node and the terrain data corresponding to the current node is executed.

[0113] For a current node that needs to be subdivided, the operation of generating four child nodes of the current node is performed. The terrain region of the child node is obtained by dividing the parent node region into four equal parts, and the LOD level of the child node is set to the LOD level of the current node + 1. For a current node that does not need to be subdivided, the operation of making the current node a leaf node is performed.

[0114] The step of performing LOD culling on the leaf nodes of the N-ary tree is completed by performing parallel frustum culling on the final list of leaf nodes. The terrain data organization method of the quadtree structure is adapted to the two-dimensional grid characteristics of terrain data, which facilitates efficient parallel processing of the computation shader.

[0115] According to embodiments of this disclosure, a node structure is used to store the node data. The node structure includes the following fields: a spatial range field, used to define the terrain region represented by the node; a data reference field, used to associate the terrain data corresponding to the node; a LOD level field, used to store the LOD level of the node; and a traversal status field, used to store the traversal status of the node.

[0116] For example, the node structure is organized and stored in the GPU storage buffer as a linear array. Specifically, the spatial extent field is implemented using two float3 type vectors to store the minimum and maximum angular coordinates of the terrain region, respectively; the data reference field is implemented using uint type indexes to associate with terrain data blocks stored in a unified buffer; the LOD level field is stored using int type variables; the traversal status field is encoded using uint type variables, where a value of 0 indicates that it has not been traversed, a value of 1 indicates that it needs to be subdivided, and a value of 2 indicates that it is a leaf node; or, the traversal status field is encoded using uint type variables, where a value of 0 indicates that it needs to be subdivided, and a value of 1 indicates that it is a leaf node.

[0117] In a specific implementation, the layout of a single node structure in memory is as follows: [min_x, min_y, min_z, max_x, max_y, max_z, data_index, lod_level, traverse_state];

[0118] min_x, min_y, and min_z form a float3 type vector min_bound, which represents the minimum vertex coordinates of the terrain region axis-aligned bounding box in the spatial extent field;

[0119] max_x, max_y, and max_z form a float3 type vector max_bound, which represents the maximum vertex coordinates of the terrain region axis-aligned bounding box in the spatial extent field.

[0120] The data_index is a variable of type uint, representing the index identifier of the terrain data in the global buffer within the data reference field;

[0121] lod_level is an integer variable representing the detail level value of the node in the LOD level field;

[0122] The traverse_state is a variable of type uint, representing the current processing state encoding of the node in the traversal state field;

[0123] Here, `min_bound` and `max_bound` together define the spatial extent of the terrain region, `data_index` implements the association reference with the terrain data, `lod_level` records the detailed level of the node in the quadtree structure, and `traverse_state` controls the traversal process of the node through state coding. All fields are stored with 4-byte boundary alignment to ensure the memory alignment requirements of the computation shader.

[0124] According to embodiments of this disclosure, determining whether a current node needs subdivision based on its LOD level and the terrain data corresponding to the current node includes: calculating a subdivision requirement value for the node based on its LOD level, the relative distance between the current node and the camera, and the degree of terrain height variation in the terrain data corresponding to the current node; comparing the subdivision requirement value with a preset subdivision threshold, and determining whether the current node needs subdivision based on the comparison result; wherein the subdivision requirement value increases as the distance between the node and the camera decreases, increases as the degree of terrain height variation in the terrain data corresponding to the node increases, and decreases as the LOD level of the node decreases.

[0125] According to embodiments of this disclosure, calculating the subdivision requirement value of a node based on the LOD level of the current node, the relative distance between the current node and the camera, and the degree of terrain height variation in the terrain data corresponding to the current node includes: calculating a normalized distance value between the current node and the camera based on the relative distance between the current node and the camera; calculating a ruggedness value of the current node based on the terrain height data in the terrain data corresponding to the current node; and inputting the normalized distance value, the ruggedness value, and the LOD level of the current node into a subdivision evaluation function to calculate the subdivision requirement value; wherein the subdivision evaluation function satisfies the following relationship: the subdivision requirement value is inversely proportional to the normalized distance value, directly proportional to the ruggedness value, and inversely proportional to the LOD level of the current node.

[0126] In the embodiments of this disclosure, the calculation of the subdivided demand value is affected by three factors: the distance factor is reflected by the normalized distance from the node center to the camera position; the terrain complexity is quantified by the ruggedness value calculated by the standard deviation or range of the height map data within the node area; and the LOD level is used as an attenuation factor.

[0127] The detailed demand value is inversely proportional to the distance, directly proportional to the ruggedness, and inversely proportional to the LOD level. The final value is obtained by weighted summation and then compared with the preset threshold.

[0128] For example, the formula for segmenting demand values ​​is:

[0129] ;

[0130] in, To further refine the demand values, This is the distance weighting coefficient. This is the ruggedness weighting coefficient. For detail weighting coefficients, This represents the ruggedness value of the current node. The current node's LOD level;

[0131] The normalized distance value represents the relative distance between the current node and the camera, and is calculated as follows:

[0132] ;

[0133] in, This represents the actual distance from the current node center to the camera. The closest visible distance, This represents the furthest visible distance.

[0134] According to embodiments of this disclosure, the step of traversing the N-ary tree level by level starting from the root node includes:

[0135] For any level below the root node, the nodes in that level are traversed in parallel by the compute shader thread. After traversing all the nodes in that level, the traversal of the next level is then performed.

[0136] For example, the layer-by-layer traversal is implemented through multiple indirect scheduling commands to achieve layered processing. Each indirect scheduling command corresponds to the processing of nodes at a LOD level, where the compute shader thread processes all nodes in the current level's node list in parallel. After processing all nodes at the current level, the generated list of child nodes is used as input for the next level, and a counter manages the updating of the node list until all nodes are marked as leaf nodes.

[0137] According to embodiments of this disclosure, the method further includes: calculating the LOD level difference between each leaf node and each of its adjacent nodes, wherein the terrain regions corresponding to the adjacent nodes of the leaf node are adjacent to the terrain regions corresponding to the leaf node; and adjusting the position of vertices located at the edge of the terrain region represented by the corresponding leaf node according to the LOD level difference, so as to achieve seamless connection between adjacent terrain regions.

[0138] For example, the calculation process of the LOD level difference is completed on the GPU through two consecutive compute shader channels. The steps include: processing all the finally determined leaf nodes in parallel through the first compute shader channel, and writing the corresponding LOD level value into the corresponding position of a two-dimensional image memory that matches the minimum terrain tile resolution according to the spatial range information of each finally determined leaf node, so that each element of the two-dimensional image memory accurately stores the LOD level of the minimum terrain tile it represents; processing each leaf node in parallel through the second compute shader channel, where each compute shader thread in the second compute shader channel processes one leaf node, and based on the LOD level value in the two-dimensional image memory, the compute shader thread reads the LOD levels of the adjacent nodes of its associated leaf node in the four spatial directions of east, south, west, and north, calculates the LOD level difference in each direction, and encodes the level difference information in the four directions into an integer value, which can be a four-digit integer. The calculation result is stored in the GPU memory.

[0139] According to an embodiment of this disclosure, adjusting the position of vertices located at the edge of the terrain region represented by the corresponding leaf node based on the LOD level difference includes using a compute shader thread in parallel to adjust the position of vertices located at the edge of the terrain region represented by the leaf node based on the LOD level difference between the leaf node and each of its adjacent nodes.

[0140] For example, the vertex position adjustment is performed during the vertex shader stage. For each vertex, the LOD level difference information of the leaf node where it is located is queried through its coordinates. When it is detected that the vertex is located on the edge and there is an LOD level difference, the position is offset according to the predefined stitching rules: for edge vertices in the east / west direction, its X coordinate is adjusted; for edge vertices in the south / north direction, its Z coordinate is adjusted.

[0141] The formula for calculating the offset is:

[0142]

[0143] in, The offset adjusted for the vertex position. This is the LOD level difference, which is the numerical difference between the current leaf node and its adjacent nodes in the LOD level field. The base tile size is the side length of the terrain tile at the finest LOD level. This is the value of the LOD level field of the current leaf node.

[0144] For example, storing the rendering data in the GPU's storage buffer further includes generating the drawing parameters required for indirect drawing.

[0145] After performing visibility filtering and detail level control processing, the compute shader organizes the final result to be submitted for rendering into indirect drawing commands. The commands contain a complete set of parameters defined by the graphics API specification, including the number of vertices, the number of instances, the starting index position, the base vertex position, and the starting instance position. The commands are written into a dedicated drawing parameter buffer to form a complete sequence of indirect drawing commands. The drawing parameter buffer and the storage buffer that stores the rendering data are independent of each other and together constitute the complete rendering output.

[0146] The stitching mechanism disclosed herein achieves geometric continuity between terrain blocks at different detail levels by using precise mathematical calculations and the parallel capabilities of the GPU, without CPU intervention. Its advantage lies in its ability to automatically correct vertex positions based on the real-time calculated LOD level difference. This not only eliminates visual defects such as T-shaped cracks caused by differences in mesh density, ensuring the integrity of the rendered image, but also avoids the synchronization wait and data transfer between the CPU and GPU in traditional methods, since all calculations are efficiently completed on the GPU. Ultimately, this improves visual quality while maintaining the optimized performance of the rendering pipeline.

[0147] In step S104, the GPU uses the rendering data in the storage buffer to render the corresponding rendering item.

[0148] According to an embodiment of this disclosure, rendering a corresponding rendering item using rendering data in the storage buffer via the GPU includes: issuing one or more indirect draw call instructions to the GPU via the CPU; the GPU responding to the indirect draw call instructions reading from the storage buffer and submitting the rendering data to the rendering pipeline; wherein rendering data corresponding to the same type of rendering item is merged and submitted in the same indirect draw call.

[0149] For example, the indirect drawing call instruction is a DrawIndirect instruction. The CPU triggers the rendering process by submitting the indirect drawing call instruction to the GPU's command queue without specifying specific drawing parameters. When the GPU responds to the indirect drawing call instruction, it reads the complete indirect drawing command from the drawing parameter buffer. The indirect drawing command contains a command structure defined by the graphics API specification, where the command parameters include the number of vertices, the number of instances, the starting index position, the base vertex position, and the starting instance position.

[0150] On the GPU side, after responding to the indirect drawing call instruction, the rendering pipeline performs the following operations: sequentially reads the drawing commands preset for each batch of rendering items of the same type from the drawing parameter buffer; binds the corresponding geometric data (vertex buffer, index buffer) and material resources according to the resource requirements corresponding to the drawing command; binds the corresponding rendering data (such as world transformation matrix, material parameters, etc.) generated by the computation shader in the storage buffer as shader resources; and performs drawing operations based on all bound resources, thus starting the complete processing flow of the graphics rendering pipeline.

[0151] The GPU organizes rendering items using the same vertex buffer, index buffer, shader program, and material state into a single drawing command by the compute shader. The drawing parameter buffer stores the drawing commands sequentially according to the rendering batch, allowing a single DrawIndirect call to trigger the GPU to continuously render all similar rendering items in the entire batch. This merges a large number of discrete drawing calls into a few efficient batch calls, significantly improving rendering efficiency while maintaining visual quality.

[0152] Figure 3 A structural block diagram of an apparatus for rendering an object to be rendered according to an embodiment of the present disclosure is shown.

[0153] like Figure 3As shown, the apparatus 200 for rendering the object to be rendered includes: a data allocation module 201, configured to obtain rendering item data corresponding to each of the one or more rendering items through the CPU, divide the rendering item data corresponding to each of the one or more rendering items into data blocks according to a preset rule, and save the data blocks to the storage buffer of the GPU, wherein the rendering item data is used to generate rendering data for rendering the corresponding rendering item, and the data block includes rendering item data of at least one rendering item; and a scheduling information generation module 202, configured to generate scheduling information for the data blocks through the CPU, wherein the scheduling information includes the... The data block storage location information in the storage buffer and the scheduling grid size information required to process the data block are specified. The scheduling grid includes at least one thread group, and the thread group includes at least one compute shader thread. The parallel processing module 203 is configured to start multiple compute shader threads on the GPU to perform parallel processing on multiple data blocks according to the scheduling information, so as to generate rendering data for rendering items corresponding to the multiple data blocks, and save the rendering data in the GPU's storage buffer. The rendering execution module 204 is configured to render the corresponding rendering items using the rendering data in the storage buffer through the GPU.

[0154] According to embodiments of this disclosure, the processing performed by the GPU on the data blocks includes performing detail-level control on the data blocks.

[0155] According to embodiments of this disclosure, the level-of-detail control includes performing LOD calculations and selections on the rendering item data of terrain tiles.

[0156] According to embodiments of this disclosure, the LOD calculation and selection of the rendering item data for terrain tiles includes: creating the root node of an N-ary tree and saving the node data of the root node, where N is an integer greater than or equal to 2; traversing layer by layer from the root node of the N-ary tree, and performing the following operations for each traversed node: if the traversal state of the current node is untraversed, determining whether the current node needs to be subdivided based on the LOD level of the current node and the terrain data corresponding to the current node; if the current node needs to be subdivided, generating N child nodes of the current node, saving the node data of the child nodes, where the LOD level of the child nodes = the LOD level of the current node + 1; if the current node does not need to be subdivided, treating the current node as a leaf node; and performing LOD culling operations based on the leaf nodes of the N-ary tree, wherein the node data includes the terrain region represented by the current node, the terrain data corresponding to the current node, the LOD level of the current node, and the traversal state of the current node.

[0157] According to embodiments of this disclosure, it further includes: a LOD level difference calculation module 205, configured to calculate the LOD level difference between each leaf node and each of its adjacent nodes, wherein the terrain regions corresponding to the adjacent nodes of the leaf node are adjacent to the terrain regions corresponding to the leaf node; and a vertex position adjustment module 206, configured to adjust the position of vertices located at the edge of the terrain region represented by the corresponding leaf node according to the LOD level difference, so as to achieve seamless connection between adjacent terrain regions.

[0158] This disclosure also discloses an electronic device. Figure 4 A structural block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0159] like Figure 4 As shown, the electronic device includes a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method according to embodiments of the present disclosure.

[0160] Figure 5 A schematic diagram of the structure of a computer system suitable for implementing the method according to embodiments of the present disclosure is shown.

[0161] like Figure 5 As shown, the computer system includes a processing unit that can execute various methods described above based on a program stored in a read-only memory (ROM) or a program loaded from a storage portion into a random access memory (RAM). The RAM also stores various programs and data required for the operation of the computer system. The processing unit, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.

[0162] The following components are connected to the I / O interface: input sections including keyboards, mice, etc.; output sections including cathode ray tubes (CRTs), liquid crystal displays (LCDs), and speakers; storage sections including hard disks; and communication sections including network interface cards such as LAN cards and modems. The communication section performs communication processes via a network such as the Internet. Drives are also connected to the I / O interface as needed. Removable media, such as disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on the drive as needed so that computer programs read from them can be installed into the storage section as required. The processing unit can be implemented as a CPU, GPU, TPU, FPGA, NPU, etc.

[0163] In particular, according to embodiments of this disclosure, the methods described above can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program containing program code for performing the methods described above. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium.

[0164] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0165] The units or modules described in the embodiments of this disclosure can be implemented in software or programmable hardware. The described units or modules can also be located in a processor, and the names of these units or modules do not necessarily constitute a limitation on the unit or module itself.

[0166] In another aspect, this disclosure also provides a computer-readable storage medium, which may be a computer-readable storage medium included in the electronic device or computer system described above; or it may be a standalone computer-readable storage medium not assembled into a device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to perform the methods described in this disclosure.

[0167] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

Claims

1. A method for rendering an object to be rendered, characterized in that, The object to be rendered includes one or more rendering items, and the method includes: The CPU obtains the rendering item data corresponding to each of the one or more rendering items, divides the rendering item data corresponding to each of the one or more rendering items into blocks according to a preset rule to obtain data blocks, and saves the data blocks to the storage buffer of the GPU. The rendering item data is used to generate rendering data for rendering the corresponding rendering item, and the data blocks include rendering item data of at least one rendering item. The CPU generates scheduling information for the data blocks. The scheduling information includes the storage location information of the data blocks in the storage buffer and the scheduling grid size information required to process the data blocks. The scheduling grid includes at least one thread group, and the thread group includes at least one compute shader thread. The scheduling grid size information includes the type and number of rendering items corresponding to the data blocks. The CPU issues an indirect scheduling instruction to the GPU, which is a DispatchIndirect command. In response to the indirect scheduling instruction, the GPU reads scheduling information for multiple data blocks from a parameter buffer. Based on the scheduling grid size information required to process the data blocks in the scheduling information, the GPU starts a corresponding number of compute shader threads for each of the multiple data blocks. The compute shader threads started for the multiple data blocks read the rendering item data of the corresponding data blocks from the storage buffer according to the scheduling information of the corresponding data blocks and process the rendering item data in parallel to generate rendering data for the rendering items of the multiple data blocks. The rendering data is then stored in the GPU's storage buffer. The GPU uses the rendering data in the storage buffer to render the corresponding rendering items.

2. The method according to claim 1, characterized in that: The scheduling grid size in the scheduling information of the data block is determined based on the number of rendering items corresponding to the data block; or The scheduling grid size in the scheduling information of the data block is determined based on the type and number of rendering items corresponding to the data block.

3. The method according to claim 1, characterized in that, The processing performed by the compute shader thread on the data chunks includes visibility filtering of the data chunks.

4. The method according to claim 3, characterized in that, The visibility filtering includes local culling based on frustum or occlusion queries.

5. The method according to claim 1, characterized in that, The processing performed by the GPU on the data blocks includes detailed level control of the data blocks.

6. The method according to claim 5, characterized in that, The detailed level control includes performing LOD calculations and selections on the rendering data of terrain tiles.

7. The method according to claim 6, characterized in that, The LOD calculation and selection of the rendering data for terrain tiles includes: Create the root node of an N-ary tree and store the node data of the root node, where N is an integer greater than or equal to 2; Starting from the root node of the N-ary tree, traverse level by level, performing the following operations for each traversed node: If the current node's traversal state is untraversed, determine whether the current node needs to be subdivided based on its LOD level and the terrain data corresponding to the current node; if the current node needs to be subdivided, generate N child nodes for the current node, save the node data of the child nodes, and the LOD level of the child nodes = the LOD level of the current node + 1; if the current node does not need to be subdivided, treat the current node as a leaf node. The LOD removal operation is performed based on the leaf nodes of the N-ary tree. The node data includes the terrain region represented by the current node, the terrain data corresponding to the current node, the LOD level of the current node, and the traversal status of the current node.

8. The method according to claim 7, characterized in that, N=4。 9. The method according to claim 7, characterized in that, The node data is stored using a node structure, which includes the following fields: The spatial extent field is used to define the terrain region represented by the node; The data reference field is used to associate the terrain data corresponding to the node; The LOD level field is used to store the LOD level of a node; The traversal status field is used to store the traversal status of the node. The traversal status includes three states: "not traversed", "enqueued and waiting to be subdivided", and "subdivided". The traversal status field is used to control the traversal process of the N-ary tree, avoiding repeated evaluation or omission of the same node.

10. The method according to claim 7, characterized in that, The step of determining whether the current node needs to be subdivided based on the LOD level of the current node and the terrain data corresponding to the current node includes: Calculate the normalized distance value between the current node and the camera based on the relative distance between the current node and the camera; Calculate the ruggedness value of the current node based on the terrain height data in the terrain data corresponding to the current node; The normalized distance value, ruggedness value, and current node LOD level are input into the subdivision evaluation function to calculate the subdivision demand value; wherein, the subdivision evaluation function satisfies the following relationship: the subdivision demand value is inversely proportional to the normalized distance value, directly proportional to the ruggedness value, and inversely proportional to the current node LOD level; The formula for segmenting demand values ​​is: ; in, To further refine the demand values, This is the distance weighting coefficient. This is the ruggedness weighting coefficient. For detail weighting coefficients, This represents the ruggedness value of the current node. The current node's LOD level; The normalized distance value represents the relative distance between the current node and the camera, and is calculated as follows: ; in, This represents the actual distance from the current node center to the camera. The closest visible distance, This represents the furthest visible distance. The subdivision requirement value is compared with a preset subdivision threshold, and the current node is determined to be subdivided based on the comparison result. The subdivided demand value increases as the distance between the node and the camera decreases, increases as the degree of change in terrain height in the terrain data corresponding to the node increases, and decreases as the LOD level of the node decreases.

11. The method according to claim 7, characterized in that, The step of traversing the N-ary tree level by level starting from the root node includes: For any level below the root node, the nodes in that level are traversed in parallel by the compute shader thread. After traversing all the nodes in that level, the traversal of the next level is then performed.

12. The method according to claim 7, characterized in that, Also includes: Calculate the LOD level difference between each leaf node and each of its neighboring nodes, wherein the terrain regions corresponding to the neighboring nodes of the leaf node are adjacent to the terrain regions corresponding to the leaf node. Based on the LOD level difference, the positions of vertices located at the edges of the terrain regions represented by the corresponding leaf nodes are adjusted to achieve seamless integration between adjacent terrain regions.

13. The method according to claim 12, characterized in that: The calculation of the LOD level difference between each leaf node and each of its neighboring nodes includes, for each leaf node, using a compute shader thread in parallel to calculate the LOD level difference between the leaf node and each of its neighboring nodes. The step of adjusting the position of vertices located at the edge of the terrain region represented by the corresponding leaf node according to the LOD level difference includes using a compute shader thread in parallel to adjust the position of vertices located at the edge of the terrain region represented by the leaf node according to the LOD level difference between the leaf node and each of its neighboring nodes.

14. The method according to claim 1, characterized in that, The rendering items include any one or more of the following: terrain tiles, mesh instances, renderable instances, and particle system components.

15. The method according to claim 1, characterized in that, The step of rendering the corresponding rendering item using the rendering data in the storage buffer via the GPU includes: issuing one or more indirect drawing call instructions to the GPU via the CPU; the GPU responding to the indirect drawing call instructions reads the rendering data from the storage buffer and submits it to the rendering pipeline; wherein, the rendering data corresponding to the same type of rendering item is merged and submitted in the same indirect drawing call; the indirect drawing call instructions include the number of vertices, the number of instances, the starting index position, the base vertex position, and the starting instance position.

16. An apparatus for rendering an object to be rendered, characterized in that, The object to be rendered includes one or more rendering items, and the apparatus includes: The data allocation module is configured to obtain the rendering item data corresponding to each of the one or more rendering items through the CPU, divide the rendering item data corresponding to each of the one or more rendering items into blocks according to a preset rule to obtain data blocks, and save the data blocks to the storage buffer of the GPU. The rendering item data is used to generate rendering data for rendering the corresponding rendering item, and the data blocks include rendering item data of at least one rendering item. The scheduling information generation module is configured to generate scheduling information for the data block via the CPU. The scheduling information includes the storage location information of the data block in the storage buffer and the scheduling grid size information required to process the data block. The scheduling grid includes at least one thread group, and the thread group includes at least one compute shader thread. The scheduling grid size information includes the type and number of rendering items corresponding to the data block. The parallel processing module is configured to issue an indirect scheduling instruction to the GPU via the CPU. The indirect scheduling instruction is a DispatchIndirect command. In response to the indirect scheduling instruction, the GPU reads scheduling information for multiple data blocks from a parameter buffer. Based on the scheduling grid size information required to process the data blocks in the scheduling information, the GPU starts a corresponding number of compute shader threads for each of the multiple data blocks. The compute shader threads started for the multiple data blocks read the rendering item data of the corresponding data blocks from the storage buffer according to the scheduling information of the corresponding data blocks and process the rendering item data in parallel to generate rendering data for the rendering items of the multiple data blocks. The rendering data is then stored in the GPU's storage buffer. The rendering execution module is configured to render the corresponding rendering items using the rendering data in the storage buffer via the GPU.

17. The apparatus according to claim 16, characterized in that, The processing performed by the GPU on the data blocks includes detailed level control of the data blocks.

18. The apparatus according to claim 17, characterized in that, The detailed level control includes performing LOD calculations and selections on the rendering data of terrain tiles.

19. The apparatus according to claim 18, characterized in that, The LOD calculation and selection of the rendering data for terrain tiles includes: Create the root node of an N-ary tree and store the node data of the root node, where N is an integer greater than or equal to 2; Starting from the root node of the N-ary tree, traverse level by level, performing the following operations for each traversed node: If the current node's traversal state is untraversed, determine whether the current node needs to be subdivided based on its LOD level and the terrain data corresponding to the current node; if the current node needs to be subdivided, generate N child nodes for the current node, save the node data of the child nodes, and the LOD level of the child nodes = the LOD level of the current node + 1; if the current node does not need to be subdivided, treat the current node as a leaf node. The LOD removal operation is performed based on the leaf nodes of the N-ary tree. The node data includes the terrain region represented by the current node, the terrain data corresponding to the current node, the LOD level of the current node, and the traversal status of the current node.

20. The apparatus according to claim 19, characterized in that, Also includes: The LOD level difference calculation module is configured to calculate the LOD level difference between each leaf node and each of its neighboring nodes, wherein the terrain regions corresponding to the neighboring nodes of the leaf node are adjacent to the terrain regions corresponding to the leaf node. The vertex position adjustment module is configured to adjust the position of vertices located at the edge of the terrain region represented by the corresponding leaf node according to the LOD level difference, so as to achieve seamless connection between adjacent terrain regions.

21. An electronic device, characterized in that, It includes a memory and a processor; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method of any one of claims 1-15.

22. A computer-readable storage medium having computer instructions stored thereon, characterized in that, When executed by a processor, the computer instructions implement the method of any one of claims 1-15.

Citation Information

Patent Citations

  • Scene rendering method and device and electronic equipment

    CN114494646A