Lighting rendering method of game scene and electronic device
By determining the voxelization processing area and setting the processing priority based on the observation point on mobile devices, and using the main thread to distribute asynchronous tasks to background threads for parallel processing, the problem of low resource consumption and efficiency of global illumination technology on mobile devices is solved, and real-time updates and stable rendering of lighting effects are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-06
- Publication Date
- 2026-04-10
AI Technical Summary
Voxel-based global illumination technology consumes a lot of resources on mobile devices, has low computational efficiency, and cannot dynamically adjust processing priorities, resulting in unstable frame rates and delayed or distorted lighting effects.
By observing points to determine the voxelization processing area, dividing voxel blocks and setting processing priorities, and using the main thread to distribute asynchronous tasks to background threads for parallel processing, memory usage is reduced and GPU utilization is improved.
It reduces computational complexity, ensures that lighting effects in the center of the player's field of view are updated in real time, avoids screen lag or distortion, and improves the efficiency and stability of lighting rendering on mobile devices.
Smart Images

Figure CN121073748B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of global illumination, in particular to a game scene illumination rendering method and an electronic device. BACKGROUND
[0002] The voxel-based global illumination (VXGI) technology stores illumination and material information in each voxel by voxelizing a 3D grid, and then calculates indirect illumination by using ray tracing or cone tracing algorithm.
[0003] However, the voxel-based global illumination technology adopts a full-scene voxelization processing mode, which needs to maintain voxel data of the entire game scene regardless of the current view angle, resulting in huge consumption of device resources and difficulty in efficient operation on mobile terminals. In terms of computing architecture, voxelization processing is executed synchronously by the main thread, which easily causes the main thread to be busy, leading to unstable application frame rate. The voxelization processing adopts a mode of processing voxel blocks one by one, so that GPU resources cannot be fully utilized and the computing efficiency is low. Moreover, the processing order of voxel blocks is fixed and cannot be dynamically adjusted according to the visual importance of the scene. In terms of data processing path, the 3D grid of the game scene needs to be converted into voxels, which not only has the problem of precision loss but also increases the computational complexity and prolongs the processing time. SUMMARY
[0004] To solve the above problems, the embodiments of the present application propose a game scene illumination rendering method and an electronic device, which are aimed at determining a voxelization processing area based on an observation point, and only need to voxelize the scene within a limited range around the observation point, so as to greatly reduce the computational complexity and reduce the memory resource occupation. By distributing tasks through the main thread and executing voxelization processing in parallel by multiple background threads, the utilization of GPU can be improved and the main thread can be prevented from being blocked. By determining the processing priority of voxel blocks, voxel blocks that have a greater impact on the picture effect can be processed preferentially, so as to ensure real-time updating of the illumination effect in the center area of the player's field of view and avoid delay or distortion in the key area of the picture.
[0005] To achieve the above purpose, a first aspect of the embodiments of the present application proposes a game scene illumination rendering method applied to a mobile terminal, which comprises the following steps:
[0006] determining a voxelization processing area corresponding to the current frame according to the three-dimensional coordinates of the observation point in the current frame of the three-dimensional game scene and the performance level of the mobile terminal device;
[0007] dividing the voxelization processing area corresponding to the current frame into a plurality of voxel blocks with a fixed size, and creating a voxel block management list, wherein the voxel block management list includes all voxel blocks in the voxelization processing area corresponding to the current frame;
[0008] determine a processing priority of each to-be-processed voxel block in the voxel block management list based on a picture display effect, and generate a to-be-processed queue in an order according to the processing priority, wherein the to-be-processed voxel block is a voxel block carrying a to-be-processed state mark;
[0009] The main thread creates a corresponding asynchronous task object for each to-be-processed voxel block in the to-be-processed queue, and submits each asynchronous task object to a background processing queue, wherein the asynchronous task object contains voxel block coordinate information, game scene original data reference, texture resource pointer and state mark information;
[0010] A plurality of background threads obtain asynchronous task objects of to-be-processed voxel blocks from the background processing queue through a lock-free queue, and perform voxelization processing on the to-be-processed voxel blocks in parallel according to the asynchronous task objects, and then submit voxelization processing results to an upload queue, wherein one to-be-processed voxel block corresponds to one voxelization processing result;
[0011] The main thread obtains a preset number of voxelization processing results from the upload queue in batches, and uploads the batch of obtained voxelization processing results to a global voxel texture for light rendering of a current frame.
[0012] In an embodiment of the present application, the determination of the voxelization processing region according to the observation point three-dimensional coordinate of the current frame in the three-dimensional game scene and the performance level of the mobile terminal device comprises:
[0013] aligning the observation point three-dimensional coordinate of the current frame in the three-dimensional game scene to the grid center point according to a mobile threshold to obtain normalized coordinates of the observation point;
[0014] determining a range parameter of voxelization processing according to the performance level of the mobile terminal device;
[0015] taking the normalized coordinates of the observation point as the center and calculating a voxelization processing region boundary according to the determined range parameter of voxelization processing to obtain a voxelization processing region corresponding to the current frame.
[0016] In an embodiment of the present application, the determination of the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect comprises:
[0017] calculating a geometric center point of each to-be-processed voxel block in the voxel block management list;
[0018] calculating a Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point;
[0019] determine a processing priority of each to-be-processed voxel block in the voxel block management list according to a Euclidean distance square of a geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point, wherein the smaller the Euclidean distance square of the geometric center point of the to-be-processed voxel block and the observation point, the higher the corresponding processing priority is;
[0020] Alternatively, the processing priority of each to-be-processed voxel block in the voxel block management list is determined according to the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point, the importance of each to-be-processed voxel block in the three-dimensional game scene, and the change frequency of each to-be-processed voxel block in the three-dimensional game scene.
[0021] In an embodiment of the present application, the background thread acquires the asynchronous task object of the to-be-processed voxel block from the background processing queue through the lock-free queue, and after voxelization processing is performed on the to-be-processed voxel block according to the asynchronous task object, submits the voxelization processing result to the upload queue, comprising:
[0022] The background thread acquires the asynchronous task object of the to-be-processed voxel block from the background processing queue through the lock-free queue;
[0023] According to the voxel block coordinate information and the texture resource pointer, a corresponding three-dimensional texture object group is allocated from a texture resource pool, and the three-dimensional texture object group includes a color texture object and an opacity texture object;
[0024] According to the allocated three-dimensional texture object group and the game scene original data reference, corresponding game scene original data is read, and the game scene original data is converted into voxel texture data;
[0025] According to the voxel texture data, a 3-level Mip mapping relationship is generated;
[0026] The voxel texture data containing the 3-level Mip mapping relationship is submitted to the upload queue as a voxelization processing result.
[0027] In an embodiment of the present application, after the illumination rendering of the previous frame is completed, the method further comprises:
[0028] Detecting whether the three-dimensional coordinates of the observation point, the game content, and the game light environment in the three-dimensional game scene of the current frame change;
[0029] If the viewpoint three-dimensional coordinate in the three-dimensional game scene of the current frame changes, or the game content changes, or the game light environment changes, a to-be-processed voxel block corresponding to the current frame is identified to update the voxel block management list, wherein the to-be-processed voxel block corresponding to the current frame includes a voxel block in which the illumination information changes and a newly added voxel block.
[0030] After the voxel block management list is updated, the step of determining the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect and sorting the to-be-processed queue according to the processing priority is returned.
[0031] If the viewpoint three-dimensional coordinate in the three-dimensional game scene of the current frame does not change, and the game content does not change, and the game light environment does not change, the voxelization data of the previous frame is reused to perform the illumination rendering of the current frame.
[0032] In an embodiment of the present application, the method further comprises:
[0033] According to the performance level of the mobile terminal device, a predetermined number of three-dimensional texture object groups are created to build a texture resource pool, wherein one three-dimensional texture object group includes one color texture object and one opacity texture object.
[0034] A dynamic allocation algorithm is used to allocate the three-dimensional texture object groups in the texture resource pool to corresponding background threads, and the texture data content in the three-dimensional texture object groups is cleared and recycled after being used by the background threads, for reuse by the next background thread.
[0035] In an embodiment of the present application, the method further comprises:
[0036] A first cache unit and a second cache unit are built, the first cache unit is used to cache the voxelization processing result data corresponding to the current frame, and the second cache unit is used to cache the voxelization processing result data that can be used in the future period of time.
[0037] Based on the historical moving track of the viewpoint in multiple continuous frames in the three-dimensional game scene, the moving trend of the viewpoint in the future period of time is predicted.
[0038] According to the predicted moving trend of the viewpoint in the future period of time, the changed voxelization processing region is predicted.
[0039] Based on the changed voxelization processing region, the to-be-processed voxel block is identified.
[0040] The to-be-processed voxel block is voxelized, and the voxelization processing result is stored in the second cache unit.
[0041] In an embodiment of the present application, the method further comprises:
[0042] determining the number of blocks of to-be-processed voxels that the background thread can simultaneously process according to the performance level of the mobile terminal device;
[0043] determining the number of voxelization processing results that the main thread can batch acquire from the upload queue according to the performance level of the mobile terminal device.
[0044] In an embodiment of the present application, the method further comprises:
[0045] monitoring the frame rate and GPU occupancy rate of the mobile terminal device in real time;
[0046] dynamically adjusting the number of background threads for parallel processing and the voxelization precision according to the monitoring result.
[0047] To achieve the above object, a second aspect of the embodiments of the present application proposes an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of the first aspect of the embodiments of the present application when executing the computer program.
[0048] In the technical solution provided in this application embodiment, the voxelization processing area corresponding to the current frame is determined based on the 3D coordinates of the observation point in the current frame of the 3D game scene and the performance level of the mobile device. This voxelization processing area is then divided into several fixed-size voxel blocks. Since the voxelization processing area can be determined based on the observation point, only a limited area around the observation point needs to be voxelized, significantly reducing computational complexity and memory consumption. Next, the processing priority of each voxel block in the voxel block management list is determined based on the display effect, and a processing queue is generated according to the processing priority. This allows for priority processing of voxel blocks that have a greater impact on the display effect, ensuring that the lighting effect in the center area of the player's field of vision is updated in real time and avoiding delays or distortions in key areas of the screen. During voxelization, the main thread creates an asynchronous task object for each voxel block in the processing queue and submits these objects to the background processing queue. Multiple background threads then retrieve the asynchronous task objects for each voxel block from the background processing queue using a lock-free queue. They perform voxelization on the voxel blocks in parallel according to these asynchronous task objects and submit the results to the upload queue. Each voxel block corresponds to one voxelization result. This approach, where the main thread distributes tasks and multiple background threads execute voxelization in parallel, improves GPU utilization and avoids main thread blocking. Finally, the main thread retrieves a preset number of voxelization results in batches from the upload queue and uploads these batch results to the global voxel texture for lighting rendering of the current frame. This batch upload of voxelization results reduces GPU data transfer frequency and overhead.
[0049] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0050] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0051] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the principles of this application.
[0052] Figure 1 This is a flowchart of a lighting rendering method for a game scene provided in an embodiment of this application.
[0053] Figure 2 This is a flowchart of the steps for determining the voxelization processing area corresponding to the current frame based on the three-dimensional coordinates of the observation point of the current frame in the three-dimensional game scene and the performance level of the mobile device, according to an embodiment of this application.
[0054] Figure 3 is a step flowchart provided by an embodiment of the present application for determining the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect.
[0055] Figure 4 is another step flowchart provided by an embodiment of the present application for determining the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect.
[0056] Figure 5 is a step flowchart provided by an embodiment of the present application for the background thread to acquire the asynchronous task object of the to-be-processed voxel block from the background processing queue through the lock-free queue, and after voxelization processing is performed on the to-be-processed voxel block according to the asynchronous task object, the voxelization processing result is submitted to the uploading queue.
[0057] Figure 6 is another flowchart of the light rendering method of the game scene provided by an embodiment of the present application.
[0058] Figure 7 is a step flowchart provided by an embodiment of the present application for identifying the voxel block that needs to be updated based on the change type, so as to update the voxel block management list.
[0059] Figure 8 is a step flowchart provided by an embodiment of the present application for being executed after the multi-frame light rendering is completed.
[0060] Figure 9 is a hardware structure schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0061] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.
[0062] It should be noted that although the functional modules are divided in the device schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a manner different from the module division in the device or the order in the flowchart. The terms "first", "second", and the like in the specification and claims and the above-described drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.
[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.
[0064] Global Illumination (GI) is a key technology in the field of computer graphics, which can simulate the multiple reflection, refraction and scattering process of light in the scene, and then generate indirect lighting, ambient occlusion, color penetration (color bleeding) and soft shadow, etc. The highly realistic lighting effects. Implementing global illumination on mobile devices not only faces unique challenges such as limited hardware performance, but also brings important opportunities to improve the visual experience of mobile 3D graphics applications.
[0065] Traditional lighting models only focus on the calculation of direct lighting, while global illumination technology further considers the multiple bounce process of light between scene surfaces, accurately simulating the light propagation law in the real world. This technology can significantly enhance the realism and immersion of 3D scenes, and has become one of the core visual effects pursued by current game engines and various graphics applications.
[0066] The voxel-based global illumination technology stores lighting and material information in each voxel by voxelizing the 3D grid, and then calculates indirect lighting using ray tracing or cone tracing algorithms.
[0067] However, the voxel-based global illumination technology adopts a full-scene voxelization processing mode, regardless of the current viewing angle, it needs to maintain the voxel data of the entire game scene, resulting in huge device resource consumption, making it difficult to run efficiently on mobile devices. In terms of computing architecture, voxelization processing is executed synchronously by the main thread, which can easily cause the main thread to be busy, leading to unstable application frame rate; it adopts a mode of processing each voxel block, and GPU resources cannot be fully utilized, resulting in low computing efficiency; and the processing order of the voxel block is fixed, and the processing priority cannot be dynamically adjusted according to the visual importance of the scene; in terms of data processing path, it needs to convert the 3D grid of the game scene into voxels first, which not only has precision loss problems, but also increases the computational complexity and prolongs the processing time.
[0068] Therefore, the embodiment of the present application proposes a lighting rendering method for a game scene, which determines the voxelization processing area based on the observation point, only needs to voxelize the scene within a limited range around the observation point, can greatly reduce the computational complexity and reduce the memory resource occupation; by distributing tasks through the main thread, multiple background threads perform voxelization processing in parallel, which can improve the utilization of GPU and avoid blocking the main thread; by determining the processing priority of the voxel block, the voxel block with greater impact on the screen effect can be processed preferentially, ensuring that the lighting effect of the center area of the player's field of view is updated in real time, and avoiding delays or distortions in the key areas of the screen.
[0069] Reference Figure 1 , Figure 1is a flowchart of a light rendering method of a game scene provided by an embodiment of the present application, applied to a mobile terminal device, including but not limited to steps S110 to S160.
[0070] In step S110, a voxelization processing region corresponding to a current frame is determined according to a viewpoint three-dimensional coordinate of the current frame in a three-dimensional game scene and a performance level of the mobile terminal device.
[0071] In the embodiment of the present application, considering that the existing voxel-based global illumination technology adopts a full-scene voxelization processing mode, the voxel data of the full scene needs to be maintained regardless of the current view position, which leads to huge consumption of device resources and makes it difficult to efficiently run on a mobile terminal. To this end, the embodiment of the present application determines a voxelization processing region centered on a viewpoint, so that only the scene within a limited range around the viewpoint is voxelized, which can greatly reduce the computational complexity, reduce the memory resource occupation, and make the application of VXGI technology on a mobile terminal possible.
[0072] Referring to Figure 2 , Figure 2 is a step flowchart for determining a voxelization processing region corresponding to a current frame according to a viewpoint three-dimensional coordinate of the current frame in a three-dimensional game scene and a performance level of a mobile terminal device, provided by an embodiment of the present application, including but not limited to steps S210 to S230.
[0073] In step S210, the viewpoint three-dimensional coordinate of the current frame in the three-dimensional game scene is rounded to the grid center point according to a mobile threshold to obtain a normalized coordinate of the viewpoint.
[0074] In the embodiment of the present application, the viewpoint three-dimensional coordinate of the current frame in the three-dimensional game scene is first converted into a normalized coordinate of the viewpoint, that is, the standardization processing of the viewpoint coordinate is realized through space discretization. Specifically, the continuous three-dimensional coordinate space is divided into fixed-size grid units (such as 16x16x16 voxel units), and the viewpoint coordinate is forced to align to the nearest grid center point through rounding operation. The specific calculation method is as follows:
[0075] .
[0076] Taking the three-dimensional coordinate of the viewpoint as (150.5, 64.2, -230.8) and the mobile threshold as 16 for example, the normalized coordinate is calculated as follows:
[0077] .
[0078] The final normalized coordinate of the viewpoint is (144, 64, -240). In this way, the conversion from floating-point coordinates to discrete grid coordinates can be realized. The normalized coordinate of the viewpoint as a unified reference can greatly reduce the calculation amount in subsequent voxelization processing.
[0079] In step S220, the range parameter of the voxelization processing is determined according to the performance level of the mobile terminal device.
[0080] In the embodiment of the present application, considering that the GPU / CPU performance of different mobile terminal devices is different, the calculation load and hardware capability are also different. In this regard, the device GPU / CPU computing power can be matched to automatically adjust the voxelization calculation range, so that the mobile terminal devices of different performance levels can maintain a stable frame rate, and the low-end device can be prevented from causing lag due to overloading. Specifically, for a high-performance mobile terminal device, the determined range parameter is: horizontal radius = 8 voxel blocks, vertical radius = 4 voxel blocks. This means that the observation point is taken as the center, each extends 8 voxel blocks in the X and Z axis directions (a total of 16 voxel blocks in width), covering 256 voxel units in the horizontal direction (8x2x16); each extends 4 voxel blocks in the Y axis direction (a total of 8 voxel blocks in height), covering 128 voxel units in the vertical direction (4x2x16). For a medium-performance mobile terminal device, the determined range parameter is: horizontal radius = 6 voxel blocks, vertical radius = 3 voxel blocks. This means that the observation point is taken as the center, each extends 6 voxel blocks in the X and Z axis directions (a total of 12 voxel blocks in width), covering 192 voxel units in the horizontal direction (6x2x16); each extends 3 voxel blocks in the Y axis direction (a total of 6 voxel blocks in height), covering 96 voxel units in the vertical direction (3x2x16). For a low-performance mobile terminal device, the determined range parameter is: horizontal radius = 4 voxel blocks, vertical radius = 2 voxel blocks. This means that the observation point is taken as the center, each extends 4 voxel blocks in the X and Z axis directions (a total of 8 voxel blocks in width), covering 128 voxel units in the horizontal direction (4x2x16); each extends 2 voxel blocks in the Y axis direction (a total of 4 voxel blocks in height), covering 64 voxel units in the vertical direction (2x2x16).
[0081] For a low-performance mobile terminal device, the embodiment of the present application can reduce the memory access amount by about 60% by reducing the corresponding processing range, thereby relieving the bandwidth bottleneck.
[0082] In step S230, the voxelization processing region boundary is calculated based on the normalized coordinates of the observation point as the center and the determined range parameter of the voxelization processing, to obtain the voxelization processing region corresponding to the current frame.
[0083] In the embodiment of the present application, after the three-dimensional coordinates of the observation point are converted into normalized coordinates and the range parameter of the voxelization processing is determined based on the performance of the mobile terminal device, the three-dimensional region boundary of the voxelization processing can be calculated based on the normalized coordinates as the center and the determined range parameter. The specific calculation method is as follows:
[0084] MinBoundaryPoint = normalized coordinates - (horizontal radius x 16, vertical radius x 16, horizontal radius x 16);
[0085] MaxBoundaryPoint = normalized coordinates + (horizontal radius x 16, vertical radius x 16, horizontal radius x 16).
[0086] Exemplarily, the observed point normalized coordinates are (144, 64, -240), the horizontal radius of the medium-performance device = 6 voxel blocks, and the vertical radius = 3 voxel blocks, then:
[0087] MinBoundaryPoint = (144 - 96, 64 - 48, -240 - 96) = (48, 16, -336);
[0088] MaxBoundaryPoint = (144 + 96, 64 + 48, -240 + 96) = (240, 112, -144);
[0089] The finally formed stereoscopic processing region (i.e., the voxelized processing region corresponding to the current frame) is a cuboid with a width of 192, a height of 96, and a depth of 192.
[0090] In the embodiments of the present application, by dynamically managing the voxelized processing region, the scene voxelization in a limited range centered on the observation point is processed, which can significantly reduce the computational complexity and memory occupation; in combination with the performance grade of the mobile terminal device, the processing range parameters are adaptively adjusted, which can realize accurate resource allocation; by the normalized coordinate alignment and boundary calculation algorithm, the voxel blocks and the coordinate grid can be accurately matched, which not only avoids the resource waste in the traditional scheme of full-scene processing, but also guarantees the visual continuity through the dynamic region boundary management mechanism, thereby laying a foundation for the efficient operation of real-time global illumination under the limited hardware performance of the mobile terminal.
[0091] In some embodiments, considering that the existing voxel-based global illumination technology adopts a full-scene voxelization processing mode, the voxel data of the full scene needs to be maintained, which leads to huge consumption of device resources and makes it difficult to efficiently operate on the mobile terminal. The consumption of device resources can also be reduced by the following scheme:
[0092] The three-dimensional game world is recursively divided into space by an octree data structure, that is, the three-dimensional space in the game scene is recursively divided into 8 subcubes (nodes), each node can be further subdivided or store data. It is especially suitable for processing sparsely distributed scene objects. When voxelization processing is performed, only the nodes containing objects are voxelized, and the empty area is automatically cropped, which can reduce 60%-80% of invalid calculation and significantly reduce the memory occupation.
[0093] By detecting the view frustum space range (composed of near / far clipping planes and four side planes) of the rendering camera in real time, the visible area can be accurately focused. When voxelizing, only the scene within the view frustum needs to be voxelized, which can reduce the calculation amount by 70%-90% compared with global processing, especially suitable for first-person perspective and other directional observation scenes.
[0094] By dynamically adjusting the voxelization precision, the performance and vision are balanced. Specifically, the scene is divided into multiple detail areas, such as 0.1m 3 high-precision voxels to support shadow, collision, and other detail rendering; 0.1m 3 resolution is retained for main geometric features; and 1m 3 low-precision voxels only maintain the volume outline. Smooth switching is achieved through octree spatial partitioning and distance field LOD transition algorithms (such as spherical harmonic function interpolation), combined with double-precision buffer pool and progressive blending technology to avoid picture abrupt changes. It is especially suitable for open-world games, building BIM visualization, and other scenes that require dynamic loading.
[0095] In step S120, the voxelization processing area corresponding to the current frame is divided into a plurality of voxel blocks of fixed size, and a voxel block management list is created, which includes all voxel blocks in the voxelization processing area corresponding to the current frame.
[0096] In the embodiments of the present application, after determining the corresponding voxelization processing area based on the three-dimensional coordinates of the observation point in the current frame in the three-dimensional game scene, the voxelization processing area corresponding to the current frame needs to be further divided into a plurality of voxel blocks of fixed size, and a voxel block management list is created. Each voxel block has a fixed size of 16x16x16 voxel units, each voxel unit corresponds to a 1x1x1 space unit in the game scene, and the voxel blocks are aligned in multiples of 16 in the world coordinate system of the game scene to ensure accurate matching of the voxel block boundaries and the coordinate grid, facilitating subsequent data processing and management. Specifically, the world coordinates in the three-dimensional game scene can be converted into voxel block unit coordinates to convert the three-dimensional voxelization processing area into a voxel block unit coordinate range. For example, the world coordinates can be converted into voxel block unit coordinates by the following formula to realize the mapping from the world space to the voxel block unit space:
[0097] Voxel block unit X = floor(world coordinate X / 16);
[0098] Voxel block unit Y = floor(world coordinate Y / 16);
[0099] Voxel block unit Z = floor(world coordinate Z / 16);
[0100] For example, if the boundary of the voxelized processing region in the world coordinate system is (48, 16, -336) to (240, 112, -144) determined based on the observation point, the coordinate range of the voxel block unit is calculated as follows:
[0101] Minimum voxel block unit X = floor(48 / 16) = 3;
[0102] Minimum voxel block unit Y = floor(16 / 16) = 1;
[0103] Minimum voxel block unit Z = floor(-336 / 16) = -21;
[0104] Maximum voxel block unit X = floor(240 / 16) = 15;
[0105] Maximum voxel block unit Y = floor(112 / 16) = 7;
[0106] Maximum voxel block unit Z = floor(-144 / 16) = -9;
[0107] Therefore, the coordinate range of the voxel block unit is (3, 1, -21) to (15, 7, -9).
[0108] Using the nested loop algorithm, all voxel blocks in the coordinate range of the voxel block unit are traversed, and corresponding voxel block objects are created and added to the management array to generate a voxel block management list. Taking the coordinate range of the voxel block unit (3, 1, -21) to (15, 7, -9) as an example, the total number of voxel block objects in the management array can be obtained by calculating the number of voxel blocks in each coordinate axis direction:
[0109] X direction: 15-3+1 = 13 voxel blocks;
[0110] Y direction: 7-1+1 = 7 voxel blocks;
[0111] Z direction: -9-(-21)+1 = 13 voxel blocks;
[0112] A total of 13x7x13 = 1183 voxel blocks.
[0113] In some embodiments, to facilitate quick lookup and access to the voxel block objects in the management array, a mapping relationship between the voxel block unit coordinates and the array indexes can also be established by the following formulas:
[0114] Relative X = voxel block X - minimum voxel block X;
[0115] Relative Y = voxel block Y - minimum voxel block Y;
[0116] Relative Z = voxel block Z - minimum voxel block Z;
[0117] Array Index = Relative Z x (X Range x Y Range) + Relative Y x X Range + Relative X.
[0118] For example, the index of the voxel block (5, 3, -15) in the management array is calculated, where the minimum voxel block X = 3, the minimum voxel block Y = 1, the minimum voxel block Z = -21, X Range = 13, Y Range = 7, then:
[0119] Relative X = 5 - 3 = 2;
[0120] Relative Y = 3 - 1 = 2;
[0121] Relative Z = -15 - (-21) = 6;
[0122] The calculated array index = 6 x (13 x 7) + 2 x 13 + 2 = 6 x 91 + 26 + 2 = 546 + 26 + 2 = 574.
[0123] The embodiments of the present application can calculate the index corresponding to each voxel block by nested loop traversal of the generated voxel block management list and in combination with the coordinate-index mapping algorithm, and can improve data access efficiency.
[0124] In step S130, the processing priority of each to-be-processed voxel block in the voxel block management list is determined based on the picture display effect, and a to-be-processed queue is generated by sorting according to the processing priority, wherein the to-be-processed voxel block is a voxel block carrying a to-be-processed state mark.
[0125] In the embodiments of the present application, considering the existing voxel-based global lighting technology, the voxel blocks are processed in a fixed order, which cannot dynamically adjust the processing priority of the voxel blocks according to the scene visual importance, thereby easily leading to the problem that the computing resources cannot be dynamically allocated according to the scene visual importance, causing the problems of unbalanced computing resource allocation and insufficient perspective quality. For example, a low-detail area far away may consume the same amount of calculation as a high-detail area near, causing invalid rendering overhead. When the camera moves quickly, objects near may appear light flickering or detail loss due to not being processed in time.
[0126] Based on this, the embodiments of the present application determine the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect, such as determining the processing priority of each to-be-processed voxel block by analyzing the screen space coverage, the line-of-sight distance, the dynamic attention degree and other visual key factors of the voxel block in real time, and generating a to-be-processed queue in the order of the processing priority. That is, the calculated processing priority of each voxel block can be used to intelligently allocate computing resources, so that the nearby high-detail area and the dynamic object are given priority processing, thereby improving the rendering efficiency while ensuring the picture quality. At the same time, it can also effectively reduce the invalid calculation of the distant low-value area, reduce the memory bandwidth consumption, and significantly improve the lighting stability during fast view angle switching, avoiding the phenomenon of picture flickering or trailing.
[0127] Referring to Figure 3 , Figure 3 is a step flowchart provided by an embodiment of the present application for determining the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect, including but not limited to steps S310 to S330.
[0128] Step S310, calculating the geometric center point of each to-be-processed voxel block in the voxel block management list;
[0129] Step S320, calculating the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point;
[0130] Step S330, determining the processing priority of each to-be-processed voxel block in the voxel block management list according to the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point, wherein the smaller the Euclidean distance square of the geometric center point of the to-be-processed voxel block and the observation point, the higher the corresponding processing priority.
[0131] In the embodiments of the present application, the geometric center point of each to-be-processed voxel block in the voxel block management list is calculated first, such as calculating the geometric center point of the to-be-processed voxel block by the following formula:
[0132] The voxel block center point coordinate = voxel block coordinate x 16 + (8, 8, 8).
[0133] Exemplarily, taking the voxel block coordinate (5, 3, -15) as an example, the corresponding center point coordinate is calculated as follows:
[0134] The center point X coordinate = 5 x 16 + 8 = 88;
[0135] The center point Y coordinate = 3 x 16 + 8 = 56;
[0136] The center point Z coordinate = -15 x 16 + 8 = -232;
[0137] Therefore, the geometric center point coordinate of the voxel block coordinate (5, 3, -15) is (88, 56, -232).
[0138] Next, the Euclidean distance square of the geometric center point of the voxel block to be processed and the observation point is calculated, and the voxel blocks are arranged in ascending order according to the distance square value. The smaller the Euclidean distance square, the closer the voxel block is to the observation point, and the higher the priority. The larger the Euclidean distance square, the farther the voxel block is from the observation point, and the lower the priority. After determining the processing priority of the voxel block, the processing priority can be sorted to generate a to-be-processed queue, so that the subsequent voxelization processing can prioritize the voxel block closest to the observation point according to the sorting result, ensuring that the lighting effect of the key area of the picture is updated first.
[0139] In the embodiment of the application, the Euclidean distance square is used as the basis for sorting (instead of the traditional Euclidean distance), which can avoid the performance loss caused by the square root operation while preserving the accuracy of the distance relationship. By converting the voxel block coordinate into a 16-fold precision center point coordinate, stable distance calculation accuracy can be maintained in large scenes. At the same time, subsequent rendering can prioritize the voxel block closest to the observation point, effectively reducing the lighting update delay in the key area and reducing the invalid calculation of distant voxel blocks, thereby improving the overall rendering efficiency.
[0140] Reference Figure 4 , Figure 4 is another step flowchart provided by an embodiment of the application for determining the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect, including but not limited to steps S410 to S430.
[0141] Step S410, calculating the geometric center point of each to-be-processed voxel block in the voxel block management list;
[0142] Step S420, calculating the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point;
[0143] Step S430, determining the processing priority of each to-be-processed voxel block in the voxel block management list according to the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point, the importance of each to-be-processed voxel block in the three-dimensional game scene, and the change frequency of each to-be-processed voxel block in the three-dimensional game scene.
[0144] In the embodiments of the present application, it is considered that the voxel block with small Euclidean distance square is usually located near the observer, and its visual contribution is higher. According to the human visual characteristics, the details in the near place need higher resolution rendering, and the accuracy of the far area can be reduced. Prior processing of the voxel block in the near place can ensure more than 80% of the visual quality improvement. Secondly, in a three-dimensional game scene, the voxel block with high importance usually refers to the area that has a key influence on the game, visual performance or physical interaction. The voxel block with high importance (such as the player interaction area, dynamic object) needs real-time update of lighting, collision and other data, and through the prior processing, more than 70% of the computing resources can be concentrated in these key areas to avoid invalid calculation on low-value areas (such as the far static background). And the voxel block (i.e. the voxel block with high importance) in the important area (such as the 5-meter range around the character) usually needs higher accuracy to support detail rendering. Prior processing can ensure real-time update of lighting and shadow effects in these areas to avoid flickering or loss of details. The voxel block related to the core gameplay (such as destructible terrain, skill range) (i.e. the voxel block with high importance) needs to be updated at high frequency. For example, in the Minecraft game, the voxel block built / damaged by the player has the highest priority to ensure immediate response to interaction. Thirdly, in a three-dimensional game scene, the change frequency of the voxel block usually refers to the time interval or triggering condition of the voxel data being modified or updated in the scene. Such changes may be caused by player interaction (such as destruction / building), environmental dynamic effects (such as weather erosion) or procedural generation (such as terrain deformation). For example, in the Minecraft game, the player places / damages a block every time to trigger real-time update of local voxel data. The voxel block with high frequency changes usually corresponds to the dynamic interaction area in the scene (such as character movement, object destruction, etc.), which needs real-time update of rendering and physical state. By prioritizing these areas, invalid calculations can be reduced, and GPU / CPU resources can be concentrated in key areas.
[0145] Based on this, the embodiment of the present application first calculates the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point, then determines the importance of the voxel block in the three-dimensional game scene and the change frequency of the voxel block in the three-dimensional game scene, so as to determine the processing priority of each to-be-processed voxel block in the voxel block management list according to the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the observation point, the importance of each to-be-processed voxel block in the three-dimensional game scene, and the change frequency of each to-be-processed voxel block in the three-dimensional game scene. Specifically, the Euclidean distance square, the importance, and the change frequency can be assigned corresponding weight coefficients, and then weighted summation is performed to calculate the priority score corresponding to each voxel block, and then the voxel blocks are sorted based on the calculated priority scores to generate a to-be-processed queue in order of processing priority. Thus, the rendering system can accurately identify the visual key area, improve the processing priority of high-value voxel blocks, and reduce invalid calculations, thereby significantly improving the real-time performance of dynamic object lighting while maintaining stable frame rate. Compared with the traditional single distance sorting, the multi-dimensional evaluation mechanism makes the rendering resource allocation in complex scenes more consistent with the human eye visual characteristics, and is suitable for application scenarios with strict real-time requirements.
[0146] In some embodiments, after determining the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect and generating a to-be-processed queue in order of processing priority, a fixed time slice can also be assigned to each to-be-processed voxel block in the to-be-processed queue to limit each to-be-processed voxel block to complete the voxel calculation task within the fixed time slice, thereby ensuring consistent response time of each voxel block.
[0147] In step S140, the main thread creates a corresponding asynchronous task object for each to-be-processed voxel block in the to-be-processed queue, and submits each asynchronous task object to a background processing queue, wherein the asynchronous task object contains voxel block coordinate information, game scene original data reference, texture resource pointer, and state marking information.
[0148] In the embodiment of the present application, it is considered that the existing voxel-based global lighting technology voxelization calculation is executed in the main rendering thread, and the time consumption of each processing can reach several milliseconds to several tens of milliseconds. This will cause the main rendering thread to be blocked, causing the application frame rate to be reduced from 60 FPS to below 30 FPS, which seriously affects the user experience.
[0149] To this end, the embodiment of the present application separates the voxelization calculation from the main rendering thread by using asynchronous processing technology, and executes the voxelization calculation in parallel in the background thread, which can effectively avoid the blocking of the main thread and ensure stable application frame rate. That is, the main thread is responsible for identifying to-be-processed tasks and distributing them to the background thread, and the background thread executes the voxelization calculation tasks in parallel to generate and process voxel data.
[0150] Specifically, after generating the to-be-processed queue in the order of the processing priority, the main thread creates a corresponding asynchronous task object for each to-be-processed voxel block in the to-be-processed queue, wherein the asynchronous task object contains voxel block coordinate information, a game scene original data reference, a texture resource pointer, and state flag information. Then, the created asynchronous task object is submitted to a thread-safe background processing queue to ensure data safety during task distribution. After the main thread submits the task, the main thread immediately returns and continues to execute the normal rendering pipeline process without waiting for the voxelization calculation to complete, thereby avoiding blocking of the main thread.
[0151] In step S150, the plurality of background threads obtain the asynchronous task object of the to-be-processed voxel block from the background processing queue through the lock-free queue, and perform voxelization processing on the to-be-processed voxel block according to the asynchronous task object, and then submit the voxelization processing result to the upload queue, wherein one to-be-processed voxel block corresponds to one voxelization processing result.
[0152] In the process of creating the corresponding asynchronous task object for each to-be-processed voxel block in the to-be-processed queue by the main thread and submitting the asynchronous task object to the thread-safe background processing queue, in the embodiment of the application, the plurality of background threads obtain the asynchronous task object of the to-be-processed voxel block from the background processing queue in sequence through the lock-free queue, perform corresponding voxelization processing according to the obtained asynchronous task object, and then submit the voxelization processing result to the upload queue.
[0153] Reference Figure 5 , Figure 5 is a step flowchart of the background thread obtaining the asynchronous task object of the to-be-processed voxel block from the background processing queue through the lock-free queue, and performing voxelization processing on the to-be-processed voxel block according to the asynchronous task object, and then submitting the voxelization processing result to the upload queue, provided by an embodiment of the application, and includes but is not limited to steps S510 to S550.
[0154] In step S510, the background thread obtains the asynchronous task object of the to-be-processed voxel block from the background processing queue through the lock-free queue.
[0155] In step S520, a corresponding three-dimensional texture object group is allocated from the texture resource pool according to the voxel block coordinate information and the texture resource pointer, and the three-dimensional texture object group includes a color texture object and an opacity texture object.
[0156] In step S530, corresponding game scene original data is read according to the allocated three-dimensional texture object group and the game scene original data reference, and the game scene original data is converted into voxel texture data.
[0157] In step S540, a 3-level Mip mapping relationship is generated according to the voxel texture data.
[0158] Step S550, the voxel texture data containing the 3-level Mip mapping relationship is submitted to the upload queue as the voxelization processing result.
[0159] In the embodiment of the application, in the process of creating a corresponding asynchronous task object for each to-be-processed voxel block in the to-be-processed queue and submitting the asynchronous task object to the thread-safe background processing queue by the main thread, the plurality of background threads can sequentially obtain the asynchronous task objects of the to-be-processed voxel blocks from the background processing queue through the lock-free queue, and then allocate a corresponding group of three-dimensional texture objects from the texture resource pool according to the voxel block coordinate information and the texture resource pointer. The group of three-dimensional texture objects includes a color texture object and an opacity texture object. The color texture object has a size of 16x16x16 pixels, which is completely matched with the number of voxels of the voxel block. The color texture object has a format of RGBA8, that is, each color channel occupies 8 bits, a total of 32 bits, which ensures the accuracy of color data. The color texture object has a Mip level of 3 (16 3 ,8 3 ,4 3 ), which supports rendering requirements at different distances. The color texture object is used for storing the red component of the block light in the R channel, the green component of the block light in the G channel, the blue component of the block light in the B channel, and the sky light intensity of the block light in the A channel. Similarly, the opacity texture object has a size of 16x16x16 pixels, which is consistent with the number of voxels of the voxel block. The opacity texture object has a format of RGBA8, and the G, B, and A channels are reserved for subsequent functional expansion. The opacity texture object has a Mip level of 3, which is consistent with the color texture, and ensures that the rendering effect is matched. The opacity texture object is used for storing the opacity information of the block in the R channel, and the G, B, and A channels are temporarily reserved to provide expansion space for future functional upgrade (such as transparent effect optimization, special material support, etc.).
[0160] Then, according to the game scene original data reference, the game scene original data corresponding to the to-be-processed voxel block is directly read, so that based on the allocated group of three-dimensional texture objects and the corresponding game scene original data, the 16x16x16 voxels are sequentially converted and calculated to convert the game scene original data into voxel texture data. According to the voxel texture data, a 3-level Mip mapping relationship is generated, wherein the generated 3-level Mip mapping (16 3 →8 3 →4 3), which can adapt to the rendering requirements of different distances and improve the rendering efficiency of distant scenes. Specifically, to improve the rendering efficiency and visual effect of scenes at different distances, a 3-level Mip mapping relationship is generated, and a downsampling algorithm can be used to realize the conversion from high resolution to low resolution. Among them, by traversing each voxel of the low resolution Mip layer, the average calculation of the 8 adjacent voxel data in the corresponding region of the high resolution layer can generate Mip level 1 data. The same downsampling algorithm as Mip level 1 generation is used to generate Mip level 2 data with Mip level 1 data as input, ensuring the consistency and continuity of each level of Mip mapping. Through the generated 3-level Mip mapping (16 3 →8 3 →4 3 ), efficient conversion from game scene original data to rendering-ready voxel texture can be realized. Compared with the complex grid voxelization process in the traditional voxel-based global illumination technique, this method not only avoids precision loss, but also saves additional grid conversion calculation overhead, which can improve processing efficiency.
[0161] Finally, the voxel texture data containing the 3-level Mip mapping relationship is submitted to the upload queue as the voxelization processing result, waiting for the main thread to synchronize to the GPU. Finally, the processing state flag of the task object is updated, and the identifier corresponding to the voxel block is updated to the processing state identifier.
[0162] In the embodiments of the present application, the existing voxel-based global illumination technique needs to convert the 3D grid of the scene into voxels first. This process not only has precision loss problem, but also increases the calculation complexity and prolongs the processing time. The embodiments of the present application directly use the original voxel data of the game world, skipping the complex 3D grid voxelization stage. At the same time, an efficient data extraction and conversion algorithm is designed, which can simplify the data processing path while ensuring the original precision of the voxel data and improving the accuracy of the lighting calculation.
[0163] It should be noted that the embodiments of the present application also maintain three key state flags for each voxel block object to realize accurate management of the update state of the voxel block. Specifically, the processing state of the voxel block can include a to-be-processed state, a processing state and a completed processing state. After the background thread obtains the asynchronous task object of the to-be-processed voxel block from the background processing queue, the to-be-processed voxel block flag can be updated from the to-be-processed state flag to the processing state flag. When the background thread completes the voxelization processing of the to-be-processed voxel block and is synchronized and rendered by the main thread, the processing state flag can be updated to the completed processing state flag. In this way, the voxelization processing can be carried out in order, and data processing errors caused by state confusion can be avoided.
[0164] It should be noted that, to ensure data security and efficiency during parallel processing by multiple background threads, the number of voxel blocks that a background thread can process simultaneously can be determined based on the performance level of the mobile device. Furthermore, the number of background threads can be limited based on the performance level of the mobile device, such as a maximum of 2-4 background threads running simultaneously, to avoid resource contention and scheduling overhead caused by too many background threads. Additionally, embodiments of this application can employ a thread-safe queue data structure, using locking mechanisms or atomic operations to ensure that there is no data contention when multiple threads access the queue; each background thread independently processes different voxel block tasks, avoiding data interaction between threads and improving parallel processing efficiency.
[0165] In this embodiment, compared to the related technologies that process voxel blocks one by one, this application distributes tasks through the main thread and multiple background threads perform voxelization processing in parallel, which can improve GPU utilization and avoid main thread blocking.
[0166] In some embodiments, during system initialization, a preset number of 3D texture objects can be pre-created based on the performance level of the mobile device to construct a texture resource pool. For example, for high-performance devices, 20 groups of 3D texture objects can be pre-created, each containing one color texture object and one opacity texture object to meet resource requirements under high load scenarios. For medium-performance devices, 10 groups of 3D texture objects can be pre-created to achieve a balance between resource consumption and performance. For low-performance devices, 5 groups of 3D texture objects can be pre-created to reduce memory consumption and ensure smooth device operation.
[0167] When a background thread needs texture resources, it can first attempt to obtain an idle 3D texture object group from the texture resource pool. If an idle 3D texture object group exists in the texture resource pool, it is directly allocated to the requesting background thread and marked as occupied. If the texture resource pool is empty and the current texture resource usage does not exceed the device memory limit, a temporary 3D texture object group can be dynamically created and allocated to the requesting background thread. This embodiment can also record detailed information for each texture resource allocation (such as allocation time, thread using the resource, voxel block number, etc.) to monitor texture resource usage and optimize texture resource allocation strategies.
[0168] Additionally, after a background thread finishes using a 3D texture object group, it can check the completion status of the 3D texture object group to ensure that the data has been successfully uploaded to the global voxel texture. Then, the contents of the 3D texture object group are cleared to prevent residual data from affecting subsequent use. After clearing, the 3D texture object group is returned to the texture resource pool and marked as idle for reuse by other threads. This embodiment can also update the available quantity of the texture resource pool in real time, providing data support for resource allocation decisions.
[0169] In some embodiments, to support multiple background threads performing texture resource allocation and return operations simultaneously, a lock-free stack structure can be used to manage the texture resource pool. The lock-free stack ensures data consistency through atomic operations, avoiding the performance overhead of traditional mutex locks; multiple background threads can simultaneously and safely acquire or return texture resources to the stack, supporting high-concurrency access scenarios. The lock-free design ensures efficient execution of texture resource allocation and return operations, improving overall system performance.
[0170] In some embodiments, considering that the frame rate and GPU utilization of mobile devices change dynamically during game execution, the system can monitor these parameters in real time. Based on the monitoring results, the number of background threads and voxelization precision are dynamically adjusted, significantly improving game stability and efficiency. By providing real-time feedback on mobile device performance data, the system can intelligently allocate computing resources, reducing background threads or voxel precision to alleviate load when the frame rate drops, and improving rendering quality when performance is sufficient, thus balancing image quality and smoothness. This adaptive mechanism is particularly suitable for mobile devices, effectively avoiding overheating and stuttering, while optimizing battery life and ensuring a smoother, more stable gaming experience across different devices.
[0171] In step S160, the main thread retrieves a preset number of voxelization processing results from the upload queue in batches, and uploads the batch-retrieved voxel count results to the global voxel texture for lighting rendering of the current frame.
[0172] In this embodiment, after the background thread performs voxelization processing and submits the voxelization results to the upload queue, the main thread can synchronize the voxelization results of the background thread during the interval between completing the rendering task of the current frame. Specifically, the main thread first checks whether there are completed voxelization results in the upload queue. If so, it retrieves a preset number of voxelization results from the upload queue in batches and uploads the batch-retrieved voxelization results to the global voxel texture through the GPU compute shader for lighting rendering of the current frame. Then, the marker of the corresponding voxel block is updated to the processing completion status marker. At the same time, the used 3D texture object group is returned to the texture resource pool to achieve resource reuse. The entire synchronization process is executed during the main thread rendering interval, without blocking the rendering process of the current frame, thus ensuring a stable application frame rate.
[0173] It should be noted that, in some embodiments, the number of voxelization results that the main thread can obtain in batches from the upload queue can also be determined based on the performance level of the mobile device.
[0174] The embodiment of the application can efficiently complete the update of the voxel data under the premise of ensuring the stability of the frame rate through the cooperative work of the main thread and the background thread. The main thread processes the voxelization processing result in the upload queue in batches during the rendering gap, uses the GPU computing shader to realize efficient data transmission, and reduces the memory overhead through the reuse mechanism of the texture resource pool. This design avoids the blocking of the rendering pipeline and improves the resource utilization, and is particularly suitable for dynamic scenes that need to update the voxel data in real time, such as global illumination calculation or physical simulation applications.
[0175] In some embodiments, considering that the voxel blocks that need to be voxelized may change during the running of the game scene, but not all the illumination information of the voxel blocks changes, the traditional scheme updates all the voxel blocks without distinction, resulting in a large amount of invalid calculation and waste of device resources. In this regard, the embodiment of the application only updates the voxel blocks whose illumination information changes or the newly added voxel blocks, which can greatly improve the calculation efficiency.
[0176] Referring to Figure 6 , Figure 6 is another flowchart of the game scene illumination rendering method provided by an embodiment of the application, including but not limited to steps S610 to S6120.
[0177] In step S610, the voxelization processing region corresponding to the current frame is determined according to the three-dimensional coordinates of the observation point in the three-dimensional game scene and the performance level of the mobile terminal device.
[0178] In step S620, the voxelization processing region corresponding to the current frame is divided into a plurality of voxel blocks of a fixed size, and a voxel block management list is created, the voxel block management list including all the voxel blocks in the voxelization processing region corresponding to the current frame.
[0179] In step S630, the processing priority of each to-be-processed voxel block in the voxel block management list is determined based on the screen display effect, and the to-be-processed queue is generated by sorting according to the processing priority, wherein the to-be-processed voxel block is a voxel block carrying a to-be-processed state mark.
[0180] In step S640, the main thread creates a corresponding asynchronous task object for each to-be-processed voxel block in the to-be-processed queue, and submits each asynchronous task object to the background processing queue, wherein the asynchronous task object includes voxel block coordinate information, game scene original data reference, texture resource pointer and state mark information.
[0181] In step S650, the plurality of background threads obtain the asynchronous task objects of the to-be-processed voxel blocks from the background processing queue through the lock-free queue, and after performing voxelization processing on the to-be-processed voxel blocks in parallel according to the asynchronous task objects, submit the voxelization processing results to the upload queue, wherein one to-be-processed voxel block corresponds to one voxelization processing result.
[0182] In step S660, the main thread obtains a preset number of voxelization processing results from the upload queue in batches, and uploads the batch of obtained voxel number results to the global voxel texture to perform light rendering of the current frame.
[0183] In step S670, after completing the light rendering of the current frame, the next frame is updated as the current frame.
[0184] In step S680, it is detected whether the observation point three-dimensional coordinates in the three-dimensional game scene of the current frame change.
[0185] In step S690, if the observation point three-dimensional coordinates in the three-dimensional game scene of the current frame do not change, it is detected whether the game content in the three-dimensional game scene of the current frame changes.
[0186] In step S6100, if the game content in the three-dimensional game scene of the current frame does not change, it is detected whether the game light environment in the three-dimensional game scene of the current frame changes.
[0187] In step S6110, if the game light environment in the three-dimensional game scene of the current frame does not change, the voxelization data of the previous frame is reused to perform light rendering of the current frame.
[0188] In step S6120, if the three-dimensional coordinates in the three-dimensional game scene of the current frame change, or the game content changes, or the game light environment changes, the to-be-processed voxel block corresponding to the current frame is identified to update the voxel block management list, wherein the to-be-processed voxel block corresponding to the current frame includes a voxel block whose light information changes and a newly added voxel block; after updating the voxel block management list, returning to step S630.
[0189] In the embodiments of the present application, the voxel processing region is first determined based on the observation point coordinates and the mobile device performance, and then the voxel block sorting based on the visual priority is combined to ensure that the computing resources are focused on the key area of the picture. Secondly, through the parallel architecture of the main thread task distribution and the background thread lock-free queue, combined with the batch data upload of the GPU computing shader, the voxel data update is completed in the rendering gap, which can avoid frame rate fluctuations. After completing the lighting rendering of the previous frame, for the next frame of picture, the voxel blocks that need to be voxelized may change due to the change of the observation point position, or the change of the game content, or the change of the game light environment (such as from day to night). However, not all voxel blocks will change their lighting information. When performing the lighting rendering of the next frame, if it is detected that the observation point changes, or the game content changes, or the game light environment changes, the voxel blocks that need to be updated are identified based on the change type, including the voxel blocks whose lighting information changes and the newly added voxel blocks, so that only the voxel blocks whose lighting information changes and the newly added voxel blocks need to be voxelized in the lighting rendering of the next frame, and all voxel blocks do not need to be updated indiscriminately, which can greatly improve the computing efficiency.
[0190] Specifically, referring to Figure 7 , Figure 7 is a step flowchart provided by an embodiment of the present application for identifying the voxel blocks that need to be updated based on the change type to update the voxel block management list, including but not limited to steps S710 to S720.
[0191] Step S710, when the observation point changes cause the voxel processing region to change, the voxel processing region before and after the change is compared to obtain the newly added voxel blocks, the removed voxel blocks and the unchanged voxel blocks.
[0192] Step S720, the newly added voxel blocks are marked as to-be-processed and then included in the voxel block management list, and the removed voxel blocks are removed from the voxel block management list.
[0193] In the embodiments of the present application, when the observation point moves and causes the voxelization processing region to change, the voxel block to be processed can be updated according to the position in the new and old regions. Specifically, for the voxel block newly entering the voxelization processing region, the state of the voxel block is marked as a to-be-processed state. The reason is that the voxel block has not been in the voxelization processing region before, and lacks effective voxelization data, and needs to be recalculated to ensure the lighting effect of the new voxelization processing region. For the voxel block remaining in the voxelization processing region, the original state of the voxel block is maintained unchanged. If the voxel block has completed the voxelization processing before, the existing data is continued to be used; if the voxel block is still in a processing state, the processing is continued to be waited for completion to avoid repeated calculation. For the voxel block moving out of the voxelization processing region, any ongoing processing of the voxel block is immediately stopped, the texture resource allocated for the voxel block is released, and the voxel block is removed from the voxel block management list to recycle the device resource.
[0194] When the player operation causes the game content to change, the voxel block to be updated can be identified according to the change type. For example, the player performs a block placement or destruction operation, at this time, the world coordinates of the change are identified, and the voxel block coordinates affected by the operation are calculated according to the formula "affected voxel block coordinates = floor (change coordinates / 16)", then the corresponding voxel block is marked as a to-be-processed state, and is included in the voxel block management list to update the voxel block management list. If the light source (such as a torch, a light stone, etc.) in the game world changes, the influence range (usually 15 units of radius) of the change of the light source is calculated, and all voxel blocks in the influence range are traversed to identify the voxel block to be updated. After the voxel block to be updated is identified, the voxel block is marked as a to-be-processed state and included in the voxel block management list to update the voxel block management list. Exemplarily, if the player places a torch at the world coordinates (67, 45, -156), a light source change update is triggered, at this time, the affected voxel block X = floor (67 / 16) = 4; the affected voxel block Y = floor (45 / 16) = 2; the affected voxel block Z = floor (-156 / 16) = -10; therefore, it can be determined that the affected voxel block coordinates are (4, 2, -10), the voxel block is marked as a to-be-processed state and included in the voxel block management list to update the voxel block management list.
[0195] When the game's lighting environment changes—that is, as the game scene progresses and the environment changes periodically over time—a time-driven approach can be used to trigger voxel block updates. For example, if the game scene experiences a day-night cycle, meaning the sky's light intensity dynamically changes during the day-night cycle, all voxel blocks within the voxelization processing area must be marked as pending and added to the voxel block management list to update the list. This allows for recalculation of sky lighting information, ensuring the scene's lighting effects are synchronized with the day-night cycle. In other words, for periodic lighting environment changes (such as day-night cycles), the system automatically marks all voxel blocks within the current voxelization processing area as pending, triggering a global lighting recalculation to ensure scene lighting effects are synchronized with time changes. For dynamic light source effects in the game scene, such as flickering flames or flowing lava, relevant voxel blocks need to be periodically marked and updated. This involves periodically marking relevant voxel blocks as pending and adding them to the voxel block management list. If a tiered update strategy is adopted, high-frequency dynamic light sources (such as flames) are marked with relevant voxel blocks every 2 frames, while mid-frequency dynamic light sources (such as lava) are updated every 5 frames. By setting a reasonable update cycle, the continuity of dynamic light source effects can be maintained, while avoiding performance loss caused by excessively frequent updates.
[0196] It should be noted that, in this embodiment, after updating the voxel block management list, the processing priority of each voxel block to be processed in the voxel block management list needs to be re-determined based on the screen display effect. That is, after updating the voxel block management list, the priority of the voxel blocks to be processed in the voxel block management list needs to be adjusted in real time to ensure that the processing order always matches the current viewpoint, maintaining visual continuity and the best experience.
[0197] In some embodiments, after completing multi-frame lighting rendering, the movement trend of the observation point can be predicted in the future based on the historical movement trajectory of the observation point in multiple consecutive frames in the 3D game scene. Based on the prediction results, the area that may enter the viewpoint can be voxelized in advance.
[0198] Reference Figure 8 , Figure 8 This is a flowchart of the steps performed after multi-frame lighting rendering is completed, provided by an embodiment of this application, including but not limited to steps S810 to S850.
[0199] Step S810: Construct a first cache unit and a second cache unit. The first cache unit is used to cache the voxelization processing result data corresponding to the current frame, and the second cache unit is used to cache the voxelization processing result data that may be used in the future.
[0200] Step S820, predicting a moving trend of the observation point in a future period of time based on the observation point historical moving track of the plurality of continuous frames in the three-dimensional game scene;
[0201] Step S830, predicting a changed voxelization processing region according to the predicted moving trend of the observation point in the future period of time;
[0202] Step S840, identifying a voxel block to be processed based on the changed voxelization processing region;
[0203] Step S850, performing voxelization processing on the voxel block to be processed, and storing the voxelization processing result to the second cache unit.
[0204] In the embodiments of the present application, the first cache unit and the second cache unit can be constructed in advance, wherein the first cache unit is used to cache the voxelization processing result data corresponding to the current frame, and the second cache unit is used to cache the voxelization processing result data that can be used in a future period of time. Thus, after completing the multi-frame light rendering, the moving trend of the observation point in a future period of time can be predicted based on the observation point historical moving track of the plurality of continuous frames in the three-dimensional game scene, so that the changed voxelization processing region can be predicted according to the moving trend of the observation point in the future period of time. For example, the moving trend of the observation point in the next frame can be predicted based on the observation point historical moving track of the plurality of continuous frames in the three-dimensional game scene, so that the voxelization processing region of the next frame can be predicted. Then, based on the voxelization processing regions before and after the change, the voxel block that needs to be updated can be identified, the voxel block that needs to be updated is subjected to voxelization processing, and the voxelization processing result is stored to the second cache unit. Thus, when the light rendering of the next frame is performed, the voxelization processing result in the second cache unit can be directly obtained for light rendering, the voxelization calculation link can be skipped, the frame rate of the mobile terminal global light can be further improved, and the voxelization calculation overhead can be reduced, which is especially suitable for first-person perspective and other fast-moving scenes.
[0205] Please refer to Figure 9 , Figure 9 is a hardware structure schematic diagram of an electronic device provided by the embodiments of the present application, and the electronic device comprises:
[0206] The processor 901 can be implemented in a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute related programs to implement the technical solutions provided by the embodiments of the present application;
[0207] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM), etc. The memory 902 can store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present specification are implemented by software or firmware, the related program codes are stored in the memory 902 and are called and executed by the processor 901 to perform the method provided by the embodiments of the present application;
[0208] The input / output interface 903 is configured to realize information input and output.
[0209] The communication interface 904 is configured to realize the communication interaction between the device and other devices, and the communication can be realized by a wired manner (for example, a USB, a network cable, etc.) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, etc.).
[0210] The bus 905 is configured to transmit information between various components (for example, the processor 901, the memory 902, the input / output interface 903, and the communication interface 904) of the device.
[0211] The processor 901, the memory 902, the input / output interface 903, and the communication interface 904 are connected to each other through the bus 905 to realize the communication connection between the devices.
[0212] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, and the scope of the rights of the embodiments of the present application is not limited by this. Any modification, equivalent replacement, and improvement made by a person skilled in the art without departing from the scope and essence of the embodiments of the present application should be within the scope of the rights of the embodiments of the present application.
Claims
1. A lighting rendering method for a game scene, applied to mobile devices, characterized in that, The method comprises: determining a voxelization processing region corresponding to a current frame according to a viewpoint three-dimensional coordinate of the current frame in a three-dimensional game scene and a performance level of the mobile terminal device; dividing the voxelization processing region corresponding to the current frame into a plurality of voxel blocks of a fixed size, and creating a voxel block management list, the voxel block management list comprising all voxel blocks in the voxelization processing region corresponding to the current frame; determining a processing priority of each to-be-processed voxel block in the voxel block management list based on a picture display effect, and generating a to-be-processed queue by sorting according to the processing priority, wherein the to-be-processed voxel block is a voxel block carrying a to-be-processed state marker; the main thread creating a corresponding asynchronous task object for each to-be-processed voxel block in the to-be-processed queue, and submitting each asynchronous task object to a background processing queue, wherein the asynchronous task object comprises voxel block coordinate information, game scene original data reference, texture resource pointer and state marker information; a plurality of background threads obtaining asynchronous task objects of to-be-processed voxel blocks from the background processing queue through a lock-free queue, and submitting a voxelization processing result to an upload queue after performing voxelization processing on the to-be-processed voxel blocks in parallel according to the asynchronous task objects, wherein one to-be-processed voxel block corresponds to one voxelization processing result; the main thread batch-obtaining a preset number of voxelization processing results from the upload queue, and uploading the batch-obtained voxelization processing results to a global voxel texture for illumination rendering of the current frame; wherein determining the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect comprises: calculating a geometric center point of each to-be-processed voxel block in the voxel block management list; calculating a Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the viewpoint; determining the processing priority of each to-be-processed voxel block in the voxel block management list according to the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the viewpoint, wherein the smaller the Euclidean distance square of the geometric center point of the to-be-processed voxel block and the viewpoint, the higher the corresponding processing priority; or, determining the processing priority of each to-be-processed voxel block in the voxel block management list according to the Euclidean distance square of the geometric center point of each to-be-processed voxel block in the voxel block management list and the viewpoint, an importance degree of each to-be-processed voxel block in the three-dimensional game scene, and a change frequency of each to-be-processed voxel block in the three-dimensional game scene.
2. The method of claim 1, wherein, The determination of the voxelization processing region corresponding to the current frame according to the viewpoint three-dimensional coordinate of the current frame in the three-dimensional game scene and the performance level of the mobile terminal device comprises: aligning the viewpoint three-dimensional coordinate of the current frame in the three-dimensional game scene to a grid center point by rounding off according to a movement threshold to obtain a normalized viewpoint coordinate; determining a range parameter of voxelization processing according to the performance level of the mobile terminal device; Centering on the observation point normalized coordinate, and according to the determined voxelization processing range parameter, a voxelization processing region boundary is calculated to obtain a voxelization processing region corresponding to the current frame.
3. The method of claim 1, wherein, The background thread acquires the asynchronous task object of the to-be-processed voxel block from the background processing queue through the lock-free queue, and after performing voxelization processing on the to-be-processed voxel block according to the asynchronous task object, submits the voxelization processing result to the upload queue, including: The background thread acquires the asynchronous task object of the to-be-processed voxel block from the background processing queue through the lock-free queue; According to the voxel block coordinate information and the texture resource pointer, a corresponding three-dimensional texture object group is allocated from a texture resource pool, and the three-dimensional texture object group includes a color texture object and an opacity texture object; According to the allocated three-dimensional texture object group and the game scene original data reference, corresponding game scene original data is read, and the game scene original data is converted into voxel texture data; According to the voxel texture data, a 3-level Mip mapping relationship is generated; The voxel texture data containing the 3-level Mip mapping relationship is submitted to the upload queue as the voxelization processing result.
4. The method of claim 1, wherein, After completing the light rendering of the previous frame, the method further includes: Detecting whether the observation point three-dimensional coordinate changes, whether the game content changes, and whether the game light environment changes in the three-dimensional game scene of the current frame; If the observation point three-dimensional coordinate changes, or the game content changes, or the game light environment changes in the three-dimensional game scene of the current frame, a to-be-processed voxel block corresponding to the current frame is identified to update the voxel block management list, wherein the to-be-processed voxel block corresponding to the current frame includes a voxel block whose illumination information changes and a newly added voxel block; After updating the voxel block management list, returning to the step of determining the processing priority of each to-be-processed voxel block in the voxel block management list based on the picture display effect and sorting the to-be-processed queue according to the processing priority; If the observation point three-dimensional coordinate does not change, the game content does not change, and the game light environment does not change in the three-dimensional game scene of the current frame, the voxelization data of the previous frame is reused to perform the light rendering of the current frame.
5. The method of claim 1, wherein, The method further includes: According to the performance level of the mobile terminal device, a predetermined number of three-dimensional texture object groups are created to construct a texture resource pool, wherein one three-dimensional texture object group includes one color texture object and one opacity texture object; A dynamic allocation algorithm is used to allocate the three-dimensional texture object groups in the texture resource pool to corresponding background threads, and after the background threads are used, the texture data contents in the three-dimensional texture object groups are cleared and recycled for reuse by the next background thread.
6. The method of claim 1, wherein, The method further includes: A first cache unit and a second cache unit are constructed, the first cache unit is used to cache voxelization processing result data corresponding to the current frame, and the second cache unit is used to cache voxelization processing result data that may be used in the future period of time; predict a moving trend of the viewpoint in a future period of time based on the historical moving track of the viewpoint in the plurality of continuous frames in the three-dimensional game scene; predict a changed voxelization processing region according to the predicted moving trend of the viewpoint in the future period of time; identify a to-be-processed voxel block based on the changed voxelization processing region; perform voxelization processing on the to-be-processed voxel block, and store a voxelization processing result into the second cache unit.
7. The method of claim 1, wherein, The method further comprises: determining a number of to-be-processed voxel blocks that can be simultaneously processed by the background thread according to the performance level of the mobile terminal device; determining a number of voxelization processing results that can be batched from the upload queue by the main thread according to the performance level of the mobile terminal device.
8. The method of claim 1, wherein, The method further comprises: monitoring a frame rate and a GPU occupancy rate of the mobile terminal device in real time; dynamically adjusting a number of parallel processing background threads and a voxelization precision according to a monitoring result.
9. An electronic device, comprising: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method in any one of claims 1-8 when executing the computer program.
Citation Information
Patent Citations
Building concrete volume calculation method based on model voxelization
CN119129176A
3D GS model real-time processing method and device based on unreal engine
CN120635270A