A real-time global illumination processing method and system

By deploying a lighting probe network and cube maps in a virtual scene, optimizing the sampling sample set, and using spherical harmonic function encoding, the problem of insufficient lighting processing efficiency and accuracy in existing technologies is solved, and real-time global lighting processing with dynamic response and natural lighting effects is achieved.

CN120876706BActive Publication Date: 2025-12-05SHANGHAI WANJIAN NETWORK TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511375694.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2025-12-05
Estimated Expiration
2045-09-25

AI Technical Summary

Technical Problem

Existing real-time global illumination processing technology struggles to balance processing efficiency and computational accuracy, cannot dynamically respond to changes in light sources or objects, and produces unnatural lighting effects. Furthermore, the strategy of blending direct and indirect light lacks adaptability, leading to abrupt changes in the lighting of the rendered image.

Method used

A network of light probes is deployed in the virtual scene to generate a cube map to store the initial radiance information. Rays are emitted from the light probes to obtain sampling samples. The sampling sample set is optimized and encoded into a two-dimensional texture. The radiance value is dynamically updated by combining the spherical harmonic function for integration and encoding. During real-time rendering, the irradiance coefficient of the neighboring light probes is interpolated.

Benefits of technology

It improves the efficiency of lighting calculation, dynamically responds to changes in light sources and objects, reduces unnecessary calculations, ensures spatial continuity and natural transition effects of lighting, and meets the requirements of high-fidelity real-time rendering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120876706B_ABST
    Figure CN120876706B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of image processing, and specifically discloses a real-time global illumination processing method and system, wherein a light probe network is arranged in a virtual scene; a preset number of rays are emitted from each light probe position, and the intersection of the rays and the surface of an object or the sky is taken as a sampling sample, and the sampling sample set is optimized; the radiance value of the sampling sample is dynamically updated based on the current light source information; and the radiance value is integrated and coded by a spherical harmonic function to generate an irradiance coefficient; the technical scheme of the light probe network combined with the sampling sample set can significantly improve the processing efficiency while ensuring the illumination calculation accuracy, the radiance value is integrated and coded by a multi-order spherical harmonic function to generate an irradiance coefficient, the spatial continuity of the illumination is ensured, the realism and adaptability of the global illumination are improved, and the demand for high-fidelity real-time rendering in the fields of games, virtual reality and the like is met.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, in particular to a real-time global illumination processing method and system. BACKGROUND

[0002] Real-time global illumination processing is a core technology in computer graphics for achieving realistic rendering of virtual scenes. Its goal is to accurately calculate the combined effects of direct light (light directly illuminating the surface of an object) and indirect light (light reaching the target point after being reflected or scattered by the surface of an object) while ensuring the rendering frame rate. In virtual scenes, global illumination effects directly affect the realism of the picture, such as the soft spot on the ground reflected by the wall under the sun, the mutual reflection between furniture in an indoor environment, etc., all of which rely on global illumination calculation to present.

[0003] However, existing real-time global illumination processing techniques have the following problems in practical applications: First, it is difficult to balance processing efficiency and calculation accuracy. For example, although the method based on ray tracing can accurately calculate global illumination, the amount of calculation is extremely large, making it difficult to meet the frame rate requirements of real-time rendering. While the method based on baking light maps is more efficient, it cannot dynamically respond to changes in the position and state of light sources or objects, and lacks flexibility. Second, the generation and update strategy of sampling samples is not optimized, which can lead to waste of computing resources due to redundant sampling samples, or the illumination effect lags behind the scene changes due to delayed sampling sample updates. Third, the rendering picture may have sudden changes in illumination, affecting visual continuity. In addition, the fusion strategy of direct light and indirect light lacks dynamic adaptability, making it difficult to present natural illumination transition effects in different brightness scenes. SUMMARY

[0004] The main purpose of the present application is to provide a real-time global illumination processing method and system to solve the technical problems raised in the background art.

[0005] The present application proposes a real-time global illumination processing method, comprising:

[0006] arranging a network of illumination probes in the virtual scene, wherein each illumination probe generates a cube map centered on it, and the cube map stores the initial radiance information of the scene;

[0007] Based on the initial radiance information, a predetermined number of rays are emitted from each illumination probe position, and the intersection of the rays with the surface of an object or the sky is taken as a sampling sample, and a set of sampling samples is generated, wherein each sampling sample records the corresponding radiance value, position, normal and material properties;

[0008] optimizing the set of sampling samples, including merging spatially close sampling samples and encoding the sampling sample data into a two-dimensional texture;

[0009] acquiring current light source information, and dynamically updating the radiance values of the sampling samples based on the current light source information;

[0010] integrating and encoding the radiance values by spherical harmonics to generate irradiance coefficients for each of the sampling sample sets covered by the light probes;

[0011] During real-time rendering, irradiance coefficients of neighboring light probes around a visible pixel on the surface of the three-dimensional model are interpolated according to the spatial position of the visible pixel, and the indirect light diffuse contribution is calculated by substituting the irradiance coefficients and the material properties corresponding to the visible pixel into a diffuse reflection physical model, and the final pixel light color is obtained by superimposing the direct light result.

[0012] Preferably, based on the radiance information of the cube map, a preset number of rays are emitted from each of the light probe positions, and the intersection points of the rays and the object surface or the sky are taken as sampling samples to generate a sampling sample set, and the step of generating the sampling sample set comprises:

[0013] Based on uniformly distributed random numbers, rays of each of the light probes are emitted by a spherical uniform sampling function;

[0014] Acquiring three-dimensional model data, and determining the positions of the intersection points of the rays and the object surface or the sky according to the vertex positions, triangle patch indexes and collision box information in the three-dimensional model data:

[0015] If the intersection point corresponds to the object surface, the normal vector of the triangle patch is interpolated by coordinates to serve as the normal of the sampling sample, and the albedo corresponding to the triangle patch is extracted from the three-dimensional model data to serve as the material property of the sampling sample;

[0016] If the intersection point corresponds to the sky, the sampling sample is marked with a sky mask;

[0017] According to the direction vector of the ray, the face index and the UV coordinate of the cube map are determined, bilinear interpolation is performed on the initial radiance information of a plurality of pixels adjacent to the direction in the cube map, and the result is taken as the radiance value of the sampling sample;

[0018] All the sampling samples generated by the light probes are collected to form a sampling sample set containing the positions, normals, material properties and radiance values of the sampling samples.

[0019] Preferably, the step of optimizing the sampling sample set comprises:

[0020] All the sampling samples are traversed, and the position distance and the normal vector dot product of any two of the sampling samples are calculated, and a redundant sampling sample pair with a position distance less than a first threshold value and a normal vector dot product greater than a second threshold value is screened out.

[0021] Discarding the redundant sampling samples, and only keeping the representative sampling samples;

[0022] Mapping the albedo RGB channel of the representative sampling samples to the RGB channel of the two-dimensional texture; storing the x component and y component of the normal vector in the texture Alpha channel after normalization; embedding the sign bit of the z component of the normal vector in the lowest bit of the albedo R channel; mapping the position information of the sampling samples to the texture U and V coordinates respectively through spherical coordinate conversion, normalizing and compressing, and storing independently in the lower half area of the texture;

[0023] Storing the index of the representative sampling samples as uint in two ushort encodings, completing the merging processing and two-dimensional texture storage.

[0024] Preferably, the step of obtaining current light source information and dynamically updating the radiance value of the sampling sample based on the current light source information comprises:

[0025] Obtaining the type, position and attenuation radius in the current light source information; for a directional light source, all sampling samples in its coverage range are included in the update range; for a point light source, the update range is determined with the position of the point light source as the center and the attenuation radius as the reference, and the sampling samples located in the update range are screened out;

[0026] For the sampling samples in the coverage range of the directional light source, the direct light contribution of the directional light source to the sampling sample is calculated;

[0027] For the sampling samples in the update range of the point light source, the direct light contribution of the point light source to the sampling sample is calculated;

[0028] For the object surface sampling sample, the initial radiance value of the sampling sample and the indirect light radiance value calculated in the previous frame are obtained, the contribution value of the indirect light radiance value is extracted according to a preset proportion, the sum of the initial radiance value, the direct light radiance value of the directional light source and the point light source is combined, the fusion weight is determined according to the state of the light source, and the final radiance value of the object surface sampling sample is calculated by weighted calculation;

[0029] For the sky sampling sample, the initial sky radiance value of the sampling sample and the real-time calculated sky light color value are obtained, and the final radiance value of the sky sampling sample is obtained by weighting according to the fusion weight which changes dynamically with time.

[0030] Preferably, the step of obtaining current light source information and dynamically updating the radiance value of the sampling sample based on the current light source information further comprises:

[0031] Based on the rendering frame rate, all sampling samples are divided into multiple calculation units with balanced task quantity according to the coverage area of the illumination probe;

[0032] The update priorities are assigned in ascending order of spatial distance between the computing units and the camera;

[0033] The number of the computing units updated in each frame is dynamically associated with the frame rate, and the radiance values of the selected computing units are processed by parallel computing, and the historical radiance value data of the unselected computing units is reused;

[0034] When the change of the light source state exceeds a preset value, the computing units in the range affected by the changed light source are immediately marked as high priorities, and are forced to be included in the computing queue in the next frame;

[0035] Meanwhile, the number of the computing units updated in each frame is dynamically adjusted by a negative feedback mechanism based on the deviation between the computing time and the target frame time to achieve load balancing.

[0036] Preferably, for each of the sampling sample sets covered by the light probes, the step of integrating and encoding the radiance values by spherical harmonics to generate the irradiance coefficients comprises:

[0037] The sampling samples are screened based on the predetermined spatial coverage of the light probes, and when the number of the covered sampling samples is insufficient, the sampling samples are supplemented from adjacent light probes and distance-dependent weight attenuation is applied;

[0038] For each light probe, the radiance values of the sampling samples in the coverage range thereof are projected and integrated by multi-order spherical harmonics to calculate the irradiance coefficients.

[0039] The irradiance coefficients are stored in a storage medium in a floating-point texture format according to the three-dimensional spatial distribution, and the difference threshold of the irradiance coefficients of adjacent light probes is constrained by spatial filtering processing.

[0040] Preferably, during real-time rendering, according to the spatial position of the visible pixels on the surface of the three-dimensional model, the irradiance coefficients of the adjacent light probes around the visible pixels are interpolated, the indirect light diffuse contribution is calculated by substituting the diffuse reflection physical model combined with the material properties corresponding to the visible pixels, and the final pixel light color is obtained after superimposing the direct light result.

[0041] The multiple light probes adjacent to the visible pixels on the surface of the three-dimensional model are selected by spatial index retrieval;

[0042] The effective light probes are selected within a limited maximum retrieval radius range, and the inverse distance square weighting algorithm is applied for coefficient interpolation;

[0043] The interpolated irradiance coefficients are substituted into the diffuse reflection model combined with the material properties corresponding to the visible pixels to calculate the indirect light diffuse contribution value;

[0044] The direct light result is obtained, the direct light result is mixed with the indirect light diffuse reflection contribution value according to a scene brightness change setting to generate a final pixel light color by mixing a mixing ratio.

[0045] The application further provides a real-time global illumination processing method system, comprising:

[0046] A probe initialization module is configured to arrange a light probe network in a virtual scene, wherein each light probe generates a cube map centered on the light probe, and the cube map stores initial radiance information of the scene.

[0047] A sampling sample generation module is configured to emit a preset number of rays from each light probe position based on the initial radiance information, take an intersection of the rays with an object surface or the sky as a sampling sample, and generate a sampling sample set, wherein each sampling sample records a corresponding radiance value, position, normal and material attribute.

[0048] A sampling sample optimization module is configured to perform optimization processing on the sampling sample set, including merging spatially close sampling samples and encoding the sampling sample data into a two-dimensional texture.

[0049] A dynamic light update module is configured to obtain current light source information, and dynamically update the radiance value of the sampling sample based on the current light source information.

[0050] A spherical harmonic light encoding module is configured to integrate and encode the radiance value by using a spherical harmonic function for each sampling sample set covered by the light probe to generate an irradiance coefficient.

[0051] A real-time light rendering module is configured to, during real-time rendering, interpolate the irradiance coefficient of a neighboring light probe around a visible pixel of a three-dimensional model surface according to the spatial position of the visible pixel, combine the material attribute corresponding to the visible pixel, substitute into a diffuse reflection physical model to calculate an indirect light diffuse reflection contribution, and obtain a final pixel light color after superimposing a direct light result.

[0052] The application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the real-time global illumination processing method when executing the computer program.

[0053] The application further provides a computer readable storage medium storing a computer program, wherein the computer program implements the steps of the real-time global illumination processing method when executed by a processor.

[0054] The beneficial effects of the present application are: the technical scheme of the present application combines the light probe network with the cube map to sample the sample set, which significantly improves the processing efficiency while ensuring the accuracy of light calculation, reduces the real-time calculation amount through the pre-calculated initial radiance information, and effectively balances the contradiction between accuracy and real-time based on the dynamic updating mechanism to respond to the state changes of the light source and the object.

[0055] And through the optimization processing of the sampling sample set, the invalid calculation is reduced, the data access efficiency is improved, and the waste of resources is avoided; the frame updating strategy combined with the priority mechanism ensures the timely updating of the sampling sample of the key area, and solves the problem of lagging updating of the sampling sample.

[0056] Moreover, the radiance value is integrated and coded to generate the irradiance coefficient by using the multi-order spherical harmonic function, and the coefficient difference of adjacent light probes is constrained through spatial filtering processing, which ensures the spatial continuity of the light and avoids the light mutation of the rendered picture; the interpolation algorithm based on the inverse distance square weighting further improves the spatial smoothness of the irradiance coefficient, and enhances the visual coherence.

[0057] And the fusion ratio of direct light and indirect light is dynamically adjusted based on the scene brightness, so that the lighting effect can be naturally transitioned in different brightness environments, improving the realism and adaptability of global lighting, and meeting the demand for high-fidelity real-time rendering in the fields of games, virtual reality and the like. BRIEF DESCRIPTION OF DRAWINGS

[0058] Figure 1 It is a method flowchart of an embodiment of the present application.

[0059] Figure 2 It is a system structure schematic diagram of an embodiment of the present application.

[0060] The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings. DETAILED DESCRIPTION

[0061] 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] As shown in the figure, the present application provides a real-time global lighting processing method, comprising: Figure 1 S1, arranging a light probe network in a virtual scene, wherein each light probe generates a cube map centered on it, and the cube map stores the initial radiance information of the scene;

[0063]

[0064] ​S2, based on the initial radiance information (using the stable and constant light radiance in the scene), a preset number of rays are emitted from each of the light probe positions, the intersection of the rays with the object surface or the sky is taken as a sampling sample, and a sampling sample set is generated, wherein each sampling sample records a corresponding radiance value, position, normal and material attribute;

[0065] S3, the sampling sample set is optimized, including merging the sampling samples that are close in space and encoding the sampling sample data into a two-dimensional texture;

[0066] S4, obtaining current light source information, and dynamically updating the radiance value of the sampling sample based on the current light source information;

[0067] S5, for each of the sampling sample sets covered by the light probe, the radiance value is integrated and encoded to generate an irradiance coefficient through a spherical harmonic function;

[0068] S6, during real-time rendering, according to the spatial position of the visible pixels on the surface of the three-dimensional model, the irradiance coefficients of the neighboring light probes around the visible pixels are interpolated, and the indirect light diffuse contribution is calculated by substituting the diffuse reflection physical model combined with the material attribute corresponding to the visible pixels, and the final pixel light color is obtained after superimposing the direct light result.

[0069] As described above in steps S1-S6, the present application arranges a light probe network in a virtual scene and generates a cube map storing initial radiance information, generates a sampling sample set based on the information, optimizes the sampling sample set, dynamically updates the radiance value of the sampling sample in combination with the current light source information, and generates an irradiance coefficient of the light probe through spherical harmonic function integration and encoding. Finally, during real-time rendering, the indirect light contribution is calculated by interpolating the irradiance coefficient, and the direct light is superimposed, thereby realizing efficient processing of real-time global illumination in a virtual scene, to meet the dual requirements of real-time and accuracy of global illumination in a virtual scene.

[0070] Since global illumination involves the combined action of direct light and indirect light in the scene, indirect light is formed by reflection or scattering of object surfaces, and its propagation path is complex, making it extremely challenging to accurately and in real time calculate global illumination in a virtual scene. Traditional real-time rendering methods are difficult to balance accuracy and performance. For example, although ray tracing can accurately calculate global illumination, the amount of calculation is extremely large, making it difficult to meet the frame rate requirements of real-time rendering. The method of baking light map can pre-calculate illumination information, but cannot cope with dynamic changes of light sources or objects in the scene, and lacks flexibility. The present application is aimed at these problems and proposes a solution combining light probe, sampling sample and spherical harmonic function encoding technology, which aims to significantly improve the real-time performance of global illumination under the premise of ensuring a certain illumination calculation accuracy through a step-by-step processing flow.

[0071] Specifically, the S1 step of "arranging a light probe network in a virtual scene, wherein each light probe generates a cube map centered on it, and the cube map stores initial radiance information of the scene", the technical implementation is to arrange a plurality of light probes in the virtual scene according to the complexity of the scene and the accuracy requirement, and these light probes are like "observation points" in the scene. Each light probe emits a ray in six directions around it (±X, ±Y, ±Z), collects the radiance information in each direction and generates a cube map. The initial radiance information stored in the cube map mainly comes from the stable and unchanged light contribution in the scene, such as the reflected light on the surface of static objects and the sky light. These information can be pre-calculated by offline rendering, such as sampling the three-dimensional model of the material albedo and pre-computing the light map for the object surface area, and calling the atmospheric scattering model to calculate the radiance value at different elevation angles for the sky area. The significance of this step of the present application is to provide basic data for subsequent light calculation. By distributing the light probes, the complex three-dimensional scene is divided into multiple local areas, and the light information of each area is collected and characterized by the corresponding light probe, thereby reducing the complexity of global light calculation. For example, in an indoor scene containing multiple static objects, by arranging light probes at different positions in the room, the cube map of each probe can store the initial radiance of the surface reflection of the walls, furniture, etc. in its surrounding area, providing a starting point for subsequent calculation of the light in the area.

[0072] The S2 step of "based on the initial radiance information (using the stable and unchanged light radiance in the scene), emitting a preset number of rays from each light probe position, taking the intersection of the rays with the object surface or the sky as a sampling sample, and generating a sampling sample set, wherein each sampling sample records the corresponding radiance value, position, normal and material attribute". The significance of this step of the present application is to further obtain more detailed local light-related data in the scene based on the initial radiance information collected by the light probe. The sampling sample is equivalent to a "sampling point" in the scene, which records the light, geometry and material information at a specific position, providing a specific calculation object for subsequent dynamic update of radiance and calculation of irradiance coefficient. For example, the ray emitted from the light probe intersects with the surface of a red sofa, and the intersection point as a sampling sample records the radiance, the position of the sofa surface, the normal direction and the albedo of the red cloth, etc. These information is crucial for accurately calculating the light change of this point under dynamic light source.

[0073] S3 step "optimizing the sampling sample set, including merging spatially close sampling samples and encoding the sampling sample data into a two-dimensional texture". The significance of this step of the present application is to reduce the amount of data and improve the efficiency of subsequent processing. Since a large number of spatially close and similar attribute redundant sampling samples may be generated during the sampling process, these sampling samples will increase the computational burden and have limited effect on the result improvement, and the data can be simplified by merging the redundant sampling samples; and the sampling sample data is encoded into a two-dimensional texture, which can utilize the efficient processing capability of GPU for texture to speed up the subsequent radiance update and lighting calculation process. For example, a plurality of sampling samples are densely distributed on a plane, and the difference between their positions and attributes is small, and after optimization processing, a few representative sampling samples are merged, which reduces the amount of data and does not significantly affect the accuracy of lighting calculation.

[0074] S4 step "obtaining current light source information, and dynamically updating the radiance value of the sampling sample based on the current light source information", the significance of this step of the present application is that the radiance value of the sampling sample can reflect the dynamic changes of the light source in the scene in real time, thereby ensuring the timeliness of global lighting calculation. Since the light source in the scene may move, change intensity or switch state, these changes will directly affect the lighting of the object surface, and by dynamically updating the radiance value of the sampling sample, the subsequent irradiance coefficient calculation and real-time rendering can be based on the latest lighting state, thereby presenting an accurate dynamic lighting effect. For example, when a point light source in the scene is moved, the radiance values of the sampling samples around it will be recalculated to reflect the changes in lighting intensity and color caused by the change in light source position.

[0075] S5 step "integrating and encoding the radiance value by spherical harmonics to generate irradiance coefficients for each sampling sample set covered by the light probe", the significance of this step of the present application is to compress and encode the radiance information of the sampling sample, so as to be efficiently used for subsequent real-time rendering. Spherical harmonics can represent complex radiance distribution with a small number of coefficients, and by integrating the radiance value of the sampling sample, the irradiance coefficients of the area covered by the light probe are obtained, which can approximately represent the lighting environment of the area, and provide key data for fast calculation of indirect light contribution in real-time rendering. For example, there are a plurality of sampling samples in the area covered by a light probe, and after integration and encoding by spherical harmonics, a set of irradiance coefficients is obtained, which represents the overall lighting condition of the area, and the set of coefficients can be directly used to calculate the indirect lighting of the object surface in the area in real-time rendering.

[0076] S6, in real-time rendering, according to the spatial position of the visible pixel on the surface of the three-dimensional model, interpolating the irradiance coefficients of the surrounding adjacent light probes, combining the material properties corresponding to the visible pixel, substituting into the diffuse reflection physical model to calculate the indirect light diffuse reflection contribution, superimposing the direct light result to obtain the final pixel light color, the meaning of the step of the application is to apply the irradiance coefficients calculated in the previous step to the actual rendering process, and generate a global light effect with realistic feeling. By interpolating the irradiance coefficients of the adjacent light probes, the light environment information suitable for the position of each visible pixel can be provided, the indirect light contribution is calculated combined with the material properties, and the direct light is superimposed, and finally the pixel color considering the direct light and the indirect light is obtained, so that the rendered virtual scene is more realistic and credible. For example, when rendering a visible pixel on the surface of an object, the indirect light received by the pixel is calculated by interpolating the irradiance coefficients of several light probes around the pixel combined with the material albedo of the object surface, and then the direct light irradiation effect is superimposed to obtain the final color of the pixel, and rich lighting details are presented.

[0077] Through the above steps, the application can realize efficient and accurate real-time global illumination processing in a virtual scene, which not only overcomes the shortcomings of traditional methods in real-time and flexibility, but also ensures the accuracy and efficiency of light calculation through the optimization design of each step, so that the rendering effect of the virtual scene is more realistic, and the demand for real-time global illumination in the fields of games, virtual reality and the like can be better met.

[0078] In an embodiment of the application, based on the radiance information of the cube map, a preset number of rays are emitted from each of the light probe positions, and the intersection of the rays with the object surface or the sky is taken as a sampling sample to generate a sampling sample set, and the step includes:

[0079] S21, based on the uniform distribution random number, the rays of each of the light probes are emitted through a spherical uniform sampling function;

[0080] S22, three-dimensional model data is acquired, and the position of the intersection of the rays with the object surface or the sky is determined according to the vertex position, the triangular facet index and the collision box information in the three-dimensional model data:

[0081] If the intersection corresponds to the object surface, the normal vector of the triangular facet is taken as the normal of the sampling sample through coordinate interpolation, and the albedo corresponding to the triangular facet is extracted from the three-dimensional model data as the material property of the sampling sample;

[0082] If the intersection corresponds to the sky, the sampling sample is marked with a sky mask;

[0083] S23, determining a face index and UV coordinate of the cube map according to the ray direction vector, performing bilinear interpolation on initial radiance information of several pixels adjacent to the direction in the cube map, and taking the result as a radiance value of the sampling sample;

[0084] S24, collecting sampling samples generated by all light probes to form a sampling sample set containing positions, normals, material properties and radiance values of each sampling sample.

[0085] As described in steps S21-S24, based on the initial radiance information stored in the cube map generated by the light probe, the present application obtains the intersection with the object surface or the sky as the sampling sample by emitting uniformly distributed rays from the light probe, accurately records the radiance value, position, normal and material property of the sampling sample, and finally forms a complete sampling sample set, providing high-quality basic data for subsequent radiance dynamic update and irradiance coefficient calculation.

[0086] Since the core of global illumination is to accurately calculate the direct light and indirect light radiation received by each point in the scene, and radiance is a physical quantity describing the intensity and color of light in a certain direction, its distribution in space directly determines the accuracy of the illumination calculation. Although the cube map can store the initial radiance information around the light probe, it is a global representation of the spatial direction and cannot reflect the local radiance characteristics of different positions in the scene (such as different points on the object surface and different areas in the sky). Therefore, it is necessary to convert the "macro" information of the cube map into "micro" point information through sampling samples. The sampling sample as an "observation point" of a specific position in the scene, its recorded position, normal (reflecting the surface orientation), material property (such as albedo, reflecting the surface reflection ability) and radiance value together constitute the complete characteristics of the light environment at that point, solving the problem of insufficient representation of the cube map in local details and providing accurate calculation objects for the subsequent step of dynamically adjusting the radiance combined with real-time light sources.

[0087] Specifically: first, "based on uniformly distributed random numbers, emit rays of each light probe through a spherical uniform sampling function", the technical implementation is to generate azimuth angle φ=2πu and polar angle θ=arccos(1-2v) by using two uniformly distributed random numbers u and v in the range of (0, 1) through the spherical coordinate conversion formula, and then convert the two angles into a three-dimensional ray direction vector (x=sinθcosφ, y=sinθsinφ, z=cosθ), ensuring that the rays are uniformly distributed on the spherical surface centered on the light probe. This uniformity avoids the bias of the sampling direction, for example, in a spherical space, whether the direction is towards the object or towards the sky, an equal number of rays can be obtained, ensuring that the subsequent sampling samples can cover all areas of the scene and provide comprehensive raw data for radiance calculation.

[0088] Next, the process involves "acquiring 3D model data and determining the intersection point of the ray with the object surface or the sky based on the vertex positions, triangle facet indices, and collision box information in the 3D model data." This 3D model data comes from the model file loaded in the scene and includes the vertex coordinates of each object, the triangle facet indices constituting the surface (recording which vertices make up each facet), and simplified collision box information (such as AABB axis-aligned bounding boxes). During the determination, objects that might intersect are first filtered through a fast intersection detection of the ray and collision boxes. If the ray does not intersect with any object's collision box, the intersection point is directly determined to be the sky. If they intersect, the triangle facet indices are used, and the Möller-Trumbore algorithm is used to calculate the intersection point coordinates of the ray and the specific triangle facet, improving the efficiency and accuracy of intersection point determination. For example, for a cube in the scene, the ray first checks the cube's collision box; if it intersects, the intersection point with a triangle facet on a certain face of the cube is further calculated, avoiding the time-consuming problem of checking all triangle facets in the scene one by one.

[0089] Then, "if the intersection point corresponds to the surface of an object, the vertex normal vector of the triangular facet is interpolated using coordinate interpolation as the normal of the sampled sample, and the albedo corresponding to the triangular facet is extracted from the 3D model data as the material attribute of the sampled sample." The vertex normal vector interpolation is based on the barycentric coordinates of the intersection point within the triangular facet. This interpolation method accurately reflects the normal changes at different positions on the triangular surface, avoiding normal errors caused by treating the entire facet as a plane. The albedo comes from the material file associated with the triangular facet in the 3D model data. For example, if a facet belongs to the "red fabric" material, its albedo RGB value is extracted from the material's attributes, ensuring that the material attributes of the sampled sample are consistent with the actual surface, providing accurate parameters for subsequent calculations of light reflection contributions. For instance, the normal at the edge of a triangular facet of a curved object will differ from that at the center through interpolation, better reflecting the true orientation of the curved surface.

[0090] The purpose of the operation "if the intersection point corresponds to the sky, then mark the sample with a sky mask" is to distinguish between sky samples and object surface samples in the sample set, because the emissivity calculation logic of the two is different. Sky samples do not involve the reflection of the object material, and their emissivity is mainly affected by changes in sky light. A special weighting formula will be used during subsequent dynamic updates. Object surface samples, on the other hand, need to combine material albedo and light source contribution. This marking ensures that subsequent steps can process the two types of samples separately and avoid confusion.

[0091] Next, "determine the face index and UV coordinate of the cube map according to the ray direction vector, perform bilinear interpolation on the initial radiance information of several pixels adjacent to the direction in the cube map, and take the result as the radiance value of the sampling sample", where the face index determination is determined by comparing the absolute values of the x, y, z components of the ray direction vector, for example, if |x| is the maximum and x is positive, then the corresponding +X face of the cube map; the UV coordinate is obtained by normalizing the other two components of the direction vector, for example, the UV coordinate of the +X face is converted from (the normalized value of y / z). Bilinear interpolation is a weighted calculation of the 4 pixels (discrete) around the UV coordinate, and the weight is determined by the distance between the UV coordinate and the center of the pixel. The closer the distance, the greater the weight. In this way, the discrete pixel radiance is converted into continuous ray direction radiance, avoiding the radiance jump caused by the pixel boundary. For example, the ray direction points to a certain position of the +X face, and the UV coordinate falls between two pixels. By interpolating the radiance of the two pixels and the other two adjacent pixels, a more accurate sampling sample radiance value is obtained, so that the initial radiance of the sampling sample is seamlessly connected with the storage information of the cube map.

[0092] Finally, "collect all the sampling samples generated by the light probes to form a sampling sample set containing the position, normal, material attribute and radiance value of each sampling sample", this step is to integrate the dispersed sampling samples into a structured data set. The position information is used to judge whether the sampling sample is within the coverage of the light probe in the subsequent step, the normal and material attribute are used for reflection calculation when dynamically updating the radiance, and the radiance value is used as the initial value for subsequent adjustment. The formation of the sampling sample set enables the subsequent steps to be processed based on complete and unified data structures, for example, when merging sampling samples close in space, the position information in the sampling sample set needs to be called for distance calculation, ensuring the data continuity of the entire method flow.

[0093] Through the above steps, the accurate conversion from the macroscopic radiance information of the cube map to the micro sampling sample is realized, and the technical features directly improve the uniformity of the sampling, the accuracy of the sampling sample attribute and the precision of the radiance value. A high-quality data foundation is laid for subsequent real-time calculation of global illumination, which not only solves the bias and roughness problems of traditional sampling methods, but also ensures that the sampling sample information can truly reflect the physical characteristics of the scene by combining three-dimensional model data and interpolation algorithm.

[0094] In one embodiment of the present application, the step of optimizing the sampling sample set comprises:

[0095] S31, traverse all the sampling samples, and calculate the position distance and normal vector dot product of any two sampling samples, and screen out redundant sampling sample pairs whose position distance is less than a first threshold and whose normal vector dot product is greater than a second threshold;

[0096] S32, discard the normal vector reverse and repeated sampling samples in the redundant sampling sample pair, and only keep the representative sampling sample;

[0097] S33, map the albedo RGB channel of the representative sampling sample to the RGB channel of the two-dimensional texture; the x component and the y component of the normal vector are stored in the texture Alpha channel after normalization, and the z component of the normal vector is embedded in the lowest bit of the albedo R channel; the sampling sample position information is mapped to the texture U and V coordinates respectively through spherical coordinate conversion and normalized compression, and is independently stored in the lower half area of the texture;

[0098] S34, store the index of the representative sampling sample as uint in two ushort encodings, complete the merging processing and two-dimensional texture storage.

[0099] As described in the above steps S31-S34, the present application optimizes the generated sampling sample set, merges the spatially close redundant sampling samples, encodes the sampling sample data into two-dimensional texture, reduces the data amount to improve the subsequent processing efficiency, and at the same time guarantees the integrity and efficient accessibility of the sampling sample information, provides simplified and structured data support for real-time global illumination calculation.

[0100] Although the sampling sample set contains rich local illumination information in the scene, due to the intensity of ray sampling or the existence of a large number of similar surfaces in the scene, it is inevitable to produce redundant sampling samples with similar spatial positions and attributes (such as normal and material) during the generation process. These redundant sampling samples not only occupy additional storage resources, but also increase unnecessary calculation in the subsequent steps of radiance update and irradiance coefficient calculation, which reduces the overall processing efficiency. In addition, if the data format of the sampling sample is not unified or not suitable for hardware acceleration, it will also affect the processing speed of the data by the GPU and other hardware. Therefore, it is necessary to solve the problems of sampling sample redundancy and data format adaptation through optimization processing, to improve the real-time performance of the whole method on the premise of ensuring that the accuracy of illumination calculation is not significantly affected.

[0101] The traditional method directly retains all sampling samples, even if two sampling samples almost coincide in space and have consistent attributes, it will also repeat storage and calculation, causing waste of computing power; and in data storage, if an unstructured format such as array is used, GPU is difficult to efficiently read in parallel processing, affecting the processing speed. And the present application sets a threshold to screen redundant sampling samples and encodes the data into two-dimensional texture, which specifically solves these problems, not only reduces the data amount, but also adapts to the texture processing advantage of GPU, improves the efficiency of the whole process.

[0102] Specifically: first, "traverse all sampling samples, and calculate the position distance and normal vector dot product of any two sampling samples, and screen out the redundant sampling sample pairs whose position distance is less than the first threshold and whose normal vector dot product is greater than the second threshold", wherein the position distance is calculated by the Euclidean distance formula of the coordinates of two points in three-dimensional space; the normal vector dot product is a1·a2=|a1||a2|cosθ (θ is the angle between two normal vectors), and since the normal vector has been normalized, the dot product result is cosθ. The first threshold is set according to the scene accuracy requirement, for example, it is set to 0.1 meters in a scene with high accuracy requirement, to ensure that sampling samples that are too close are considered redundant; the second threshold is set to 0.9 (corresponding to an angle of about 25 degrees), to ensure that sampling samples with similar surface orientations are considered redundant. Through this double screening, pairs of sampling samples with close spatial positions and similar surface orientations can be accurately identified. For example, two sampling samples that are closely adjacent on a plane have very small position distances and almost identical normal vectors, and will be screened as a pair of redundant sampling samples.

[0103] Next, "discard the sampling samples with reverse normal vectors and repeated sampling samples in the redundant sampling sample pairs, and only keep the representative sampling samples", where "sampling samples with reverse normal vectors" refer to sampling samples with normal vector dot products less than 0 (angle greater than 90 degrees), which may belong to the front and back of an object (such as the two sides of a thin plate), and should not be combined even if they are close in position; "repeated sampling samples" refer to sampling samples that are identical in position and attributes, and only one of them needs to be kept. The representative sampling samples usually are the sampling samples that are closer to the center of the region or more typical in attributes among the redundant sampling sample pairs, for example, the sampling sample that is in the middle position is selected as the representative among multiple redundant sampling samples, so that the lighting information of the region can be preserved to the greatest extent, and the number of sampling samples can be effectively reduced. This step significantly reduces the data amount of the sampling sample set by removing redundancies, for example, 600 sampling samples may be kept after screening from the original 1000 sampling samples, which can save about 40% of the computing power in subsequent calculations.

[0104] Then, the albedos of the representative sampling samples are mapped to the RGB channels of a two-dimensional texture, the x and y components of the normal vectors are normalized and stored in the alpha channel of the texture, and the sign bit of the z component of the normal vector is embedded in the lowest bit of the R channel of the albedo. The position information of the sampling samples is converted into spherical coordinates and then mapped to the U and V coordinates of the texture and normalized and compressed, and is independently stored in the lower half of the texture.

[0105] Finally, the indexes of the representative sampling samples are stored as uint in two ushorts to complete the merging and two-dimensional texture storage. The index coding is to establish the correspondence between the position of the sampling sample in the texture and the original sampling sample information. Each ushort can store an index value of 0-65535, and two ushorts combined into uint can cover more sampling samples to ensure the uniqueness of the index. After the sampling sample data is encoded into a two-dimensional texture, the GPU can efficiently read the sampling sample information by using the texture cache and the parallel texture access mechanism. For example, when updating the radiance, the multi-thread of the GPU can simultaneously access the sampling sample data at different positions in the texture, and the processing speed is 2-3 times faster than accessing an array format. At the same time, the texture storage makes the data structure more compact and saves memory space. For example, the albedo, normal vector, and position information originally stored in multiple arrays can now be integrated into a texture, which is convenient for management and transmission.

[0106] The above steps realize the optimization and efficient storage of the sampling sample set, and the technical features directly bring two effects: first, by merging redundant sampling samples, the data amount is reduced, and the computational burden of subsequent steps is reduced; second, the sampling sample data is encoded into a two-dimensional texture, which fully utilizes the hardware advantages of the GPU and improves the efficiency of data access and processing. These optimizations enable real-time global illumination processing to meet higher frame rate requirements while ensuring accuracy, especially suitable for games, virtual reality, and other scenes with strict real-time requirements.

[0107] In one embodiment of the present invention, the step of obtaining current light source information and dynamically updating the emissivity value of the sampled sample based on the current light source information includes:

[0108] S41, obtain the type, location and attenuation radius from the current light source information; for directional light sources, include all sampled samples within their coverage area into the update range; for point light sources, determine the update range of the radius with the point light source location as the center and its attenuation radius as the reference, and filter out the sampled samples within the update range.

[0109] S42, for the sampled sample within the coverage area of ​​the directional light source, calculate the direct light contribution of the directional light source to the sampled sample, the formula is as follows: ;

[0110] In the formula, This represents the direct light contribution of the directional light source to the sampled sample. This represents the albedo of the sampled specimens within the coverage area of ​​the directional light source. This represents the result of multiplying the intensity of a directional light source by its color. This represents the dot product (i.e., the cosine of the angle) between the normal of the sampled sample within the coverage area of ​​the directional light source and the direction vector of the light source. It is a non-negative value to ensure that only the front is illuminated. This represents the shadow attenuation coefficient calculated using the exponential shadow mapping algorithm (values ​​range from 0 to 1, where 1 indicates full illumination and 0 indicates full shadow).

[0111] S43, for the sampled samples within the update range of the point light source, calculate the direct light contribution of the point light source to that sampled sample, using the following formula: ;

[0112] In the formula, This represents the direct light contribution of a point light source to the sampled sample. This represents the albedo of the sampled samples within the update range of the point light source. Indicates the distance from the sampled sample to the point light source ( (Reflecting distance attenuation) This represents the result of multiplying the intensity of a point light source by its color. This represents the dot product (i.e., the cosine of the angle) between the normal of the sampled sample within the update range of the point light source and the direction vector of the light source. It is a non-negative value to ensure that only the front is illuminated. This represents the shadow decay coefficient calculated using the exponential shadow mapping algorithm.

[0113] S44, for the object surface sampling sample, the initial emissivity value of the sampling sample is obtained, and the indirect light emissivity value calculated in the previous frame is obtained, the contribution value of the indirect light emissivity value is extracted according to the preset proportion, the initial emissivity value, the sum of the direct light emissivity values of the directional light source and the point light source are combined, the fusion weight is determined according to the light source state, and the final emissivity value of the object surface sampling sample is calculated by weighted calculation, and the formula is: ;

[0114] In the formula, The final emissivity value of the object surface sampling sample is represented, The fusion weight determined according to the light source state is represented, The initial emissivity value of the object surface sampling sample (from the cube map) is represented, The indirect light emissivity value of the previous frame is represented, The contribution value of the indirect light emissivity value (here, 0.2 is taken as an example, and the indirect light emissivity value is multiplied by 0.2 to avoid high energy accumulation).

[0115] S45, for the sky sampling sample, the initial sky emissivity value of the sampling sample is obtained, and the sky light color value calculated in real time is obtained, the final emissivity value of the sky sampling sample is obtained according to the fusion weight dynamically changing with time, and the formula is: ;

[0116] In the formula, The final emissivity value of the sky sampling sample is represented, The fusion weight dynamically changing with time is represented, The initial emissivity value of the sky sampling sample (from the cube map) is represented, The sky light color value calculated in real time is represented.

[0117] As described above, according to the steps S41-S45, the present application obtains the current light source information, determines the update range of the sampling sample according to the light source type (directional light source or point light source), calculates the direct light contribution of different light sources to the sampling sample respectively, combines the initial emissivity of the sampling sample, the indirect light emissivity of the previous frame and other information, dynamically updates the emissivity value of the sampling sample through the weighted fusion mechanism, optimizes the update process by using the frame strategy, so that the emissivity of the sampling sample can reflect the light source change in real time, and provides accurate dynamic data support for subsequent irradiance coefficient calculation.

[0118] Since the radiance as a key physical quantity describing the propagation of light in space, its value will change with the state of the light source (such as position, intensity, type) - the movement of the light source will cause the change of the illumination direction and distance, the intensity adjustment will directly affect the energy output of the light, and the illumination range and attenuation characteristics of different types of light sources (such as directional light source and point light source) are also different. Therefore, to realize real-time global illumination, the radiance value of the sampling sample must follow the change of the light source state, otherwise the lighting effect calculated based on the outdated radiance will be out of touch with the actual scene. For example, when a point light source in the scene moves, the light intensity received by the sampling samples around it will change, and if the radiance is not updated, the area corresponding to these sampling samples will show the wrong brightness. The present application is to dynamically update the mechanism to make the radiance of the sampling sample always match the current light source state, solving the problem that the static radiance cannot adapt to the dynamic change of the light source.

[0119] Specifically: first, "obtain the type, position and attenuation radius in the current light source information; for directional light source, all sampling samples in its coverage range are included in the update range; for point light source, the update range is determined with the position of the point light source as the center and its attenuation radius as the reference, and the sampling samples located in the update range are selected". The light source information here comes from the light source management module maintained in real time in the scene, which will record the type identification of each light source (such as directional light source marked as "DirLight", point light source marked as "PointLight"), three-dimensional space coordinates (position coordinates of point light source, direction vector of directional light source can be derived from position) and attenuation parameters (attenuation radius of point light source, usually preset by art personnel according to the influence range of light source, such as indoor light attenuation radius set to 5 meters, outdoor searchlight set to 20 meters). Directional light source has the characteristic of parallel light, theoretically the illumination range is not limited by distance, so all sampling samples are included in the update range (in actual application, scene boundary clipping can be used to avoid invalid calculation of sampling samples outside the scene); the update range of point light source is based on the attenuation radius, for example, when the attenuation radius is R, the update range radius is set to R, because the light intensity of point light source decays with the square of the distance, and the light intensity beyond the attenuation radius can be ignored, in this way the calculation amount can be greatly reduced.

[0120] Then, "for the sampling samples in the coverage range of the directional light source, calculate the direct light contribution of the directional light source to the sampling sample", the formula is . Wherein albedo of the sampling samples in the coverage range of the directional light source, from the material property (extracted from the material file of the three-dimensional model), used to describe the reflection ratio of the sampling sample surface to light; is the product of intensity and color of the directional light source, where intensity is determined by the "brightness" parameter of the light source, and color is determined by the "color temperature" or "RGB value" parameter of the light source, both multiplied to get the radiance intensity of the light source; is the dot product of the sample sample normal and the light source direction vector, which is the cosine of the angle, and its physical meaning is the degree of agreement between the surface orientation and the light source direction. The larger the dot product, the more the surface is directly facing the light source, and the more light it receives. The max function ensures that only the front is illuminated (0 when the dot product is less than 0, to avoid the back being incorrectly illuminated); is the shadow attenuation coefficient calculated by the Exponential Shadow Mapping algorithm (ESM), which compares the sample sample depth with the depth value of the light source view volume depth buffer, and calculates the attenuation with an exponential function, with a value between 0 and 1. 1 indicates full illumination, and 0 indicates full shadow. Compared with traditional shadow mapping, it can reduce shadow aliasing.

[0121] Then, "update the sample samples in the range for the point light source, and calculate the direct light contribution of the point light source to the sample sample", the formula is . This formula adds a distance attenuation term (d is the straight-line distance from the sample sample to the point light source, calculated by the Euclidean distance formula between two points) to the directional light source formula , because the intensity of the point light source follows the inverse square law, the farther the distance, the faster the light intensity decays; the shadow coefficient is calculated using the Percentage Closer Filtering algorithm (PCF), which samples multiple pixels around the corresponding position of the sample sample on the shadow map, calculates the average value of the shadow coverage rate as the attenuation coefficient, and can generate softer soft shadows compared to ESM.

[0122] For the object surface sample, "get the initial radiance value of the sample sample and the indirect light radiance value calculated in the previous frame, extract the contribution value of the indirect light radiance value according to the preset proportion, combine the initial radiance value, the sum of the direct light radiance values of the directional light source and the point light source, determine the fusion weight according to the light source state, and calculate the final radiance value of the object surface sample by weighted calculation", the formula is . Where, is the initial radiance obtained from the cube map (from the pre-computed results of the scene static lighting); is the indirect light radiance calculated by the subsequent steps in the previous frame (stored in the history data of the sample sample), and the preset proportion of 0.2 is to avoid the accumulation of indirect light energy being too high in multiple frame iterations (indirect light is essentially multiple reflections of light, and excessive accumulation will cause the scene to be too bright); is the fusion weight, which is dynamically adjusted according to the light source state - when the light source is stationary , the smaller value is taken, at which time the initial radiance and the proportion of historical indirect light are higher, ensuring the stability of the radiance; when the light source moves Take the larger value, so that the newly calculated direct light and indirect light contribution quickly dominates, to ensure that the radiance can respond to the light source changes in time. For example, when the light source suddenly moves, =0.8, the final radiance of the sampling sample is mainly determined by the new direct light and indirect light, which can be updated within 1-2 frames to avoid visual delay; while the light source is stationary, =0.3, the radiance changes smoothly, reducing flicker.

[0123] For the sky sampling sample, "obtain the initial sky radiance value of the sampling sample and the real-time calculated sky light color value, and obtain the final radiance value of the sky sampling sample according to the dynamically changing fusion weight", the formula is . The initial sky radiance obtained in the previous step (from the pre-calculated sky box data); the initial sky radiance is the real-time calculated sky light color by the atmospheric scattering model (such as the Henyey-Greenstein model), which calculates the sky light color in different directions according to the solar elevation angle, atmospheric composition and other parameters (such as orange-red near the sun at sunrise, light blue in the upper air); is a dynamically changing fusion weight (range 0.1-0.5), which is determined by the time elapsed speed, for example, in the fast time lapse effect Take 0.5 to make the sky light change quickly, while in normal time flow Take 0.1 to ensure smooth transition. For example, from day to dusk, the solar elevation angle decreases, from blue to orange-red, slowly increases with time, so that the final radiance of the sky sampling sample is smoothly transitioned, showing a natural sky light change effect and avoiding color mutation.

[0124] Through the above steps, the dynamic update of the radiance of the sampling sample is realized, the optimized update range of the sampling sample according to the light source type reduces invalid calculation, the direct light formula designed based on physical law ensures the accuracy, and the dynamic weight fusion balances the response speed and stability. These technical features together ensure that the sampling sample can always provide accurate radiance data in the scene where the light source changes dynamically, laying a reliable foundation for subsequent global light calculation.

[0125] In an embodiment of the present application, the step of obtaining the current light source information and dynamically updating the radiance value of the sampling sample based on the current light source information further comprises:

[0126] S46, based on the rendering frame rate, all sampling samples are divided into multiple task-balanced computing units according to the illumination probe coverage area;

[0127] S47, assigning an update priority to each of the calculation units according to a distance between the calculation unit and the camera in ascending order;

[0128] S48, selecting a number of the calculation units associated with a rendering frame rate for each frame, processing radiation values of the selected calculation units and reusing historical radiation values of the unselected calculation units;

[0129] S49, when a change in a light source state is detected and exceeds a preset value, marking the calculation units in a range affected by the changed light source as high-priority calculation units and forcing the calculation units to be included in a calculation queue in a next frame;

[0130] S410, dynamically adjusting the number of the calculation units updated for each frame to achieve load balancing through a negative feedback mechanism based on a deviation between a calculation time consumption and a target frame time.

[0131] As described in steps S46-S410, the application divides the sampling samples into calculation units based on a rendering frame rate, assigns update tasks according to priorities, dynamically adjusts the number of calculation units updated for each frame, and triggers a forced update mechanism and a load balancing strategy when a light source state changes, thereby achieving efficient scheduling of the sampling sample radiation rate update process, ensuring timely updating of radiation rate data in key areas while ensuring real-time performance, and providing stable and timely input for subsequent lighting calculation.

[0132] Since the radiation rate update of the sampling samples consumes certain calculation resources, and real-time rendering scenes have strict requirements on frame rate (e.g., 30 FPS or 60 FPS, corresponding to a maximum allowed time consumption of about 33 ms or 16 ms per frame), when the number of sampling samples is large (e.g., tens of thousands or even hundreds of thousands), if all the sampling samples are updated every frame, the calculation amount will far exceed the hardware processing capacity, resulting in a sharp decrease in frame rate or even freezing. Conversely, if the update is not timely, especially when the light source changes, the lighting effect will lag behind the scene state, affecting the realism. Therefore, a refined task scheduling mechanism is needed to balance the calculation resources and update requirements - both to control the calculation time consumption per frame and to ensure that key sampling samples (e.g., those near the camera or in the range affected by the light source change) are updated first. This is one of the core challenges in achieving real-time global lighting.

[0133] Traditional methods are difficult to maintain stable frame rate when handling such calculation scheduling, and important sampling samples in the camera view may be updated with a lag due to queuing. In addition, when the light source changes suddenly, the application cannot quickly trigger the update of related sampling samples, resulting in a synchronization problem between the lighting effect and the light source state. The application solves these problems by dynamically dividing calculation units, prioritizing based on distance, adjusting the number of updates associated with frame rate, and triggering a forced update mechanism when the light source changes, thereby ensuring stable frame rate and improving the timeliness and relevance of the update.

[0134] Specifically: first, "all sampling samples are divided into multiple task-balanced computing units according to the coverage area of the illumination probe based on the rendering frame rate". The rendering frame rate here is the target frame rate of the current scene (such as 60FPS set by the user), and the sampling samples are divided according to the coverage area of the illumination probe because the coverage range of each illumination probe is relatively independent (such as a spherical area centered on the illumination probe), and the sampling samples in the same area have stronger relevance in updating tasks, which is convenient for batch processing. Task-balanced means that each computing unit contains approximately the same number of sampling samples (with a difference of no more than 10%), for example, when the total number of sampling samples is 10000 and the target frame rate is 30FPS, it may be divided into 4 units (about 2500 sampling samples per unit), ensuring that the calculation time of each unit is similar (such as 5ms per unit), avoiding the situation that a unit has too many sampling samples, resulting in excessive single-frame time consumption. This division method breaks down the huge update task into manageable sub-tasks, laying the foundation for frame-by-frame processing, and at the same time, using the spatial distribution characteristics of the illumination probe, the update calculation of the sampling samples in the unit can share part of the data (such as the influence parameters of the light source on the region), indirectly improving the calculation efficiency.

[0135] Next, "update priority is assigned according to the ascending order of the spatial distance between the computing unit and the camera". The distance between the computing unit and the camera is determined by the Euclidean distance from the center of the unit (such as the average position of all sampling samples in the unit) to the camera position, and the smaller the distance, the higher the priority. This is because the sampling samples in the camera's field of view correspond to the visual focus of the user's current attention, and the timeliness of their radiance rate update directly affects the picture perception; while the areas far from the camera, even if the update is delayed, the user is difficult to detect. For example, in a large indoor scene, when the camera is in the living room, the computing units in the living room and nearby have the highest priority and will be updated first, while the units in the bedroom, kitchen and other distant places will be updated later. This strategy can maximize the improvement of visual effects under limited computing resources.

[0136] Then, "select and render the number of updated calculation units dynamically associated with the frame rate per frame, and update the radiance value of the selected calculation unit and reuse the historical radiance value data of the unselected calculation unit through parallel computing processing". The association between the number of updated calculation units K and the rendering frame rate follows the principle of K≈total number of units M / rendering frame rate. For example, when M=4 and the rendering frame rate=30FPS, K=1 (4 / 30≈0.13, rounded up to 1), that is, one unit is updated per frame, and four frames complete a full update, ensuring that all units can be updated within a reasonable period. Parallel computing is achieved through multi-threading of GPU, and each thread handles the radiance update of one sampling sample (such as direct light contribution calculation, weighted fusion, etc. in weight 4). The parallel architecture of GPU enables it to handle hundreds of sampling samples simultaneously, greatly reducing the update time of a single unit. Unselected units reuse the radiance value of the last frame, although the data is not the latest, but due to the short update period (such as 4 frames per round) and the priority mechanism that ensures priority update in key areas, there will be no obvious delay in vision. For example, a certain unit is not selected in the first frame, and the radiance value of the 0th frame is reused. It is selected and updated in the second frame, with only one frame interval, and the radiance change is small, so the picture transition is natural.

[0137] When "detecting that the light source state change exceeds the preset value, immediately marking the calculation units within the influence range of the changed light source as high priority, and forcing them into the calculation queue in the next frame". The preset value of the light source state change includes: light source switch state switching (such as from off to on), intensity adjustment amount exceeding 15% (such as from 1.0 to 1.2), position moving distance exceeding the preset step (such as 0.5 meters), these thresholds are determined through experiments, which can avoid unnecessary forced update due to small changes, and ensure that significant changes are captured in time. The determination of the influence range of the changed light source: the influence range of the directional light source is the calculation unit covered by its illumination direction; the influence range of the point light source is the calculation unit within the area centered at its position with a decay radius of 1.5 times the radius (slightly larger than the normal update range, to ensure that the edge area can also be covered). The units marked as high priority will skip the normal queue and be forced to update in the next frame, for example, if a point light source suddenly moves 1 meter, the surrounding 3 calculation units are marked, and they will be processed first in the next frame, regardless of whether they are due for update, to ensure that the sampling samples in these units can quickly reflect the radiance change after the light source moves, avoiding the disjointed phenomenon that the light source has moved but the lighting effect has not changed.

[0138] Meanwhile, the number of the calculation units updated per frame is dynamically adjusted through a negative feedback mechanism to achieve load balancing based on the deviation between the calculation time and the target frame time. The target frame time is 1 / render frame rate (e.g. 16 ms for 60 FPS), and the calculation time is obtained in real time through a performance monitoring tool (e.g. GPU timer). When the calculation time of 3 consecutive frames exceeds the target frame time (e.g. reaches 20 ms), it indicates that the current K value is too large, and the K value needs to be increased (by 1 each time) until the calculation time decreases to below the target value. If the calculation time of 5 consecutive frames is less than 70% of the target frame time (e.g. 11.2 ms for 70% of 16 ms, and the actual calculation time is 9 ms), it indicates that there are surplus calculation resources, and the K value can be reduced (by 1 each time, and the minimum is 1) to avoid resource waste. This negative feedback mechanism enables the system to adapt to hardware performance fluctuations or scene complexity changes. For example, when multiple light sources are suddenly added to the scene, causing the update time of a single unit to increase, the system will automatically reduce the K value (e.g. from 2 to 1) to ensure that the single-frame calculation time does not exceed the standard. When the light sources are reduced, the K value will be increased to speed up the full update cycle.

[0139] Through the above steps, the present application constructs a self-adaptive calculation scheduling mechanism, which dynamically divides the calculation units to achieve balanced allocation of tasks, the priority sorting based on distance ensures timely update of the visual key area, the K value associated with the frame rate balances the update efficiency and real-time performance, the forced update mechanism when the light source changes ensures the synchronization of lighting effects and scene state, and the negative feedback load balancing strategy enables the system to stably operate under various hardware and scene conditions. These technical features work together to enable the radiance update of the sampling sample to meet the frame rate requirements of real-time rendering and accurately respond to scene changes, providing stable and timely basic data for subsequent irradiance coefficient calculation and real-time rendering, directly improving the reliability and adaptability of real-time global illumination processing.

[0140] In an embodiment of the present application, for each set of sampling samples covered by the light probe, the step of generating irradiance coefficients by integrating and encoding the radiance values through spherical harmonics includes:

[0141] S51, based on the predetermined spatial coverage range of the light probe, the sampling samples are screened, and when the number of covered sampling samples is insufficient, the sampling samples are supplemented from adjacent light probes and distance-related weight attenuation is applied.

[0142] S52, for each light probe, the radiance values of the sampling samples in its coverage range are projected and integrated on the sphere through multi-order spherical harmonics to calculate the irradiance coefficients, and the formula is: ;

[0143] In the formula, represents the order irradiance coefficient, represents irradiance conversion coefficient (is the conversion factor of spherical harmonics from radiance to irradiance), represents the total amount of spherical solid angle (unit: steradian), which is used to normalize the discrete sampled radiance value to the full spatial range, represents the total number of sampling samples participating in the calculation, that is, the number of effective sampling samples in the coverage range of the illumination probe (including supplementary sampling samples), represents the final radiance value of the updated sampling sample, represents the spherical harmonic function value of the corresponding direction of the sampling sample, which is a mathematical function describing the weight of the direction in the spherical harmonic function, represents the polar angle of the sampling sample relative to the illumination probe (the angle between the Z axis of the space coordinate system where the illumination probe is located), represents the azimuth angle of the sampling sample relative to the illumination probe (the rotation angle around the Z axis of the space coordinate system where the illumination probe is located).

[0144] S53, store the irradiance coefficient in the storage medium in floating-point texture format according to the three-dimensional space distribution, and constrain the difference threshold of the irradiance coefficient of adjacent illumination probes through spatial filtering processing.

[0145] As described in the above steps S51-S53, for each set of sampling samples covered by the illumination probe, the present application uses multi-order spherical harmonic functions to perform spherical projection integral calculation on the radiance values of the sampling samples by screening the sampling samples, supplementing the sampling samples and applying weights, generates and stores and optimizes the irradiance coefficient, and compresses the dispersed sampling sample radiance information into a compact coefficient form, thereby providing efficient and accurate illumination environment description data for fast calculation of indirect light contribution in real-time rendering.

[0146] Since irradiance is the total energy of all directional incident light received at a certain point, it is the core parameter for calculating the reflection of indirect light on the surface of an object. The radiance of a single sampling sample only reflects the light intensity in a specific direction, while the illumination probe needs to represent the overall lighting environment in its coverage area, that is, the radiance distribution in each direction. Directly storing the radiance data of all sampling samples will occupy a large amount of memory, and it is difficult to quickly reuse in real-time rendering. As a kind of orthogonal basis function on the sphere, spherical harmonics can decompose complex radiance distribution into a small number of coefficients (i.e. irradiance coefficients), realizing efficient compression and reconstruction of data, which is like using Fourier series to decompose complex waveforms, and a small number of harmonic components can approximately restore the original signal. Therefore, integral coding of sampling sample radiance by spherical harmonics is a key means to balance between accuracy and efficiency, which solves the problem of efficient characterization of radiance distribution.

[0147] The application solves these problems by screening and supplementing sampling samples, adopting multi-order spherical harmonic function integration, and spatial filtering optimization, thereby ensuring the accuracy of the irradiance coefficient and improving the usability of the irradiance coefficient in real-time rendering.

[0148] Specifically, first, the sampling samples are screened based on the predetermined spatial coverage of the light probe, and when the number of the sampling samples is insufficient, the sampling samples are supplemented from adjacent light probes and distance-related weight attenuation is applied. The predetermined spatial coverage of the light probe is usually a sphere (for example, a sphere with a radius of 3-5 meters, which is set according to the scene accuracy requirement) centered on the position of the light probe. When the sampling samples are screened, the distance between the position of the sampling sample and the light probe is calculated, and the sampling samples with a distance less than the radius are retained. If the number of the sampling samples after screening is lower than a preset threshold (for example, 32), the sampling samples are supplemented from the coverage of the three nearest adjacent light probes - these adjacent probes are obtained through precomputed spatial indexing (for example, neighbor query based on a grid), and the weight of the supplemented sampling samples decreases linearly with the increase of the distance from the current probe (for example, the weight is 1 when the distance d=0, and the weight is 0 when d=2 meters), so as to ensure that the influence of the supplemented sampling samples decreases with the distance and avoid introducing irrelevant regional light interference. For example, if there are only 20 sampling samples (lower than the threshold of 32) in the coverage of a light probe, 4 sampling samples are introduced from each of the three adjacent probes, and the weights of 0.8, 0.5 and 0.3 are given according to the distance, so as to supplement the number of sampling samples and ensure the data correlation.

[0149] Then, for each light probe, the irradiance coefficient is calculated by performing spherical projection integration on the radiance values of the sampling samples in the coverage of the light probe using multi-order spherical harmonic functions, and the formula is The design of the formula is based on the integration characteristics of the spherical harmonic functions: the multi-order spherical harmonic functions usually adopt three orders (l=0, 1, 2), and there are 9 base functions (m from -l to l), which can capture the changes in the light direction more finely than the low-order functions. is the irradiance conversion coefficient (for example, =3.1415), ( =2.0943), ( =0.7853)), which is used to convert the radiance integration result into irradiance; is the total solid angle of the sphere, which is used to normalize the radiance of the discrete sampling samples to the whole space; and N is the total number of the sampling samples participating in the calculation (including the supplemented sampling samples, and the supplemented sampling samples need to be multiplied by the weight); is the final radiance value of the sampling sample after updating; is the spherical harmonic base function, which is calculated according to the polar angle (an angle with the Z axis) and the azimuth angle (determining the rotation angle around the Z axis) determines the weight of the direction in the spherical harmonic space. The integration process is to sum up the product of the radiance of all sampling samples and the corresponding basis function value, and then multiply by the normalization coefficient to obtain the irradiance coefficient of each order and index. For example, for the basis function of l=0, m=0 (corresponding to omnidirectional light), the integration result reflects the average light intensity received by the region, and the coefficient of l=1, m=0 reflects the light deviation along the Z axis direction. The coefficients of multiple orders together constitute a complete description of the lighting environment.

[0150] Finally, the irradiance coefficients are stored in a storage medium in a three-dimensional spatial distribution in a floating-point texture format, and the difference threshold of the irradiance coefficients of adjacent light probes is constrained through spatial filtering processing. Three-dimensional spatial distribution storage refers to storing the irradiance coefficients of the light probes in the scene according to the X, Y, Z coordinates of the light probes in the scene into the voxels of the three-dimensional texture. Each voxel contains 9 coefficients (corresponding to the third order spherical harmonic function), and a floating-point format such as RGBAHalf is used to support high dynamic range (HDR) lighting. Spatial filtering processing is to perform weighted averaging (such as 3x3x3 neighborhood filtering) on the same order coefficients of each light probe and its adjacent probes, so that the difference between the same order coefficients of adjacent probes does not exceed a preset threshold (such as 5%), for example, the l=0 coefficient of a certain probe is 100, and the coefficient of the adjacent probe needs to be in the range of 95-105, so as to avoid the occurrence of obvious light boundary on the surface of the object due to the sudden change of the coefficient during rendering. This storage method enables the GPU to quickly obtain the probe coefficients through texture sampling during real-time rendering, and the spatial filtering ensures the spatial continuity of the light, thereby improving the visual consistency of the picture.

[0151] Through the above steps, the present application realizes the conversion from the discrete sampling sample radiance to the compact irradiance coefficient. The sampling sample supplement mechanism guarantees the integration accuracy, the multi-order spherical harmonic function improves the richness of the light description, and the three-dimensional texture storage and spatial filtering optimize the access efficiency and spatial continuity of the coefficients. These technical features directly support the efficient calculation of indirect light in the real-time rendering stage. During rendering, only a small number of irradiance coefficient interpolation and reconstruction are required to quickly restore the lighting environment. Compared with directly using the original sampling sample radiance, the calculation and storage overhead is greatly reduced, and the smoothness of the lighting effect is improved through filtering processing. It is a key bridge connecting the sampling sample update and real-time rendering.

[0152] In an embodiment of the present application, during real-time rendering, according to the spatial position of the visible pixels on the surface of the three-dimensional model, the irradiance coefficients of the adjacent light probes around the visible pixels are interpolated, and the indirect light diffuse contribution is calculated by substituting the diffuse reflection physical model combined with the material properties corresponding to the visible pixels, and the final pixel light color is obtained after superimposing the direct light result.

[0153] S61, select multiple illumination probes adjacent to the visible pixels on the surface of the three-dimensional model by spatial index retrieval.

[0154] S62, within the limited maximum search radius, select effective illumination probes and apply the inverse distance squared weighted algorithm for coefficient interpolation. The weight calculation formula for each illumination probe is as follows: ;

[0155] In the formula, Indicates the first The weight of each illumination probe Indicates the visible pixels up to the 1st. The distance between each light probe This indicates the total number of neighboring illumination probes selected. Indicates the number of the adjacent illumination probes. Indicates the visible pixels up to the 1st. The distance between the light probes ( and (These represent different light probe indices). The interpolated irradiance coefficient is the sum of the products of the spherical harmonic coefficients of the same order of each light probe and their corresponding weights.

[0156] S63, combine the interpolated irradiance coefficient with the material properties corresponding to the visible pixels and substitute them into the diffuse reflection model to calculate the indirect light diffuse reflection contribution value, the formula is: ;

[0157] In the formula, This represents the indirect light diffuse reflection contribution value of visible pixels on the surface of a 3D model, which represents the indirect light intensity (including color information) received by that pixel from the surrounding environment. Indicates the visible pixels up to the 1st. The distance of each light probe to the visible pixel corresponds to the material albedo (RGB three-channel value), which describes the proportion of light reflected by the material and is a core material property that determines the intensity of indirect light reflection. The normalization coefficient in the diffuse reflection physical model, derived from Lambert's cosine law (the energy distribution characteristics of an ideal diffuse reflective surface), is used to ensure the conservation of light energy. This indicates the order of the spherical harmonic function (here, we take the order 0-2, corresponding to the third-order spherical harmonic function). The index of the spherical harmonic basis functions of the same order (ranging from -l to l) indicates that the calculation results of all third-order spherical harmonic basis functions are summed. Indicates the interpolated first... Rank The irradiance coefficients are spherical harmonic coefficients (a total of 9, corresponding to third-order spherical harmonic functions) obtained by interpolating the irradiance coefficients of neighboring illumination probes and applicable to the currently visible pixels. denotes the value of the spherical harmonic basis function corresponding to the normal of the visible pixel surface after interpolation, wherein is the normal vector of the pixel surface (this function represents the weight distribution of the normal direction in the spherical harmonic space).

[0158] S64, obtaining a direct lighting result, and mixing the direct lighting result and the indirect light diffuse reflection contribution value according to a scene brightness change setting to generate a final pixel lighting color.

[0159] As described in steps S61-S64, in the real-time rendering process, the present application retrieves the lighting probes around the visible pixel and interpolates the irradiance coefficients thereof, combines the material properties corresponding to the pixel, calculates the indirect light diffuse reflection contribution by using the diffuse reflection physical model, dynamically mixes the direct lighting result according to the scene brightness, and finally obtains the pixel lighting color conforming to the physical law and natural in vision, thereby realizing the real-time presentation of the global lighting effect in the virtual scene.

[0160] Since the color finally presented by the visible pixel on the object surface is the result of the joint action of direct light (direct illumination of the light source) and indirect light (environmental reflected light), the direct light can be calculated through the direct interaction of the light source and the pixel, while the indirect light is difficult to accurately solve in real time due to the involvement of complex multi-path reflection. The irradiance coefficient, as a compressed representation of the ambient lighting of the lighting probe, can provide the ambient lighting information of the pixel at the location thereof through interpolation, and then, in combination with the albedo (description of the surface reflection ability) of the material, the indirect light contribution can be calculated through the diffuse reflection model. Therefore, the core of the right 7 is to establish a mapping from the irradiance coefficient of the lighting probe to the final color of the pixel, to solve the problem of real-time calculation of indirect light, so that the rendering result contains both the highlight and dark contrast of direct lighting and also reflects the soft transition of environmental light, which conforms to the perception law of the human eye to the real world lighting.

[0161] The present application solves these problems by improving the accuracy of the coefficient through inverse distance square weighted interpolation, calculating the indirect light based on the physical diffuse reflection model, and dynamically mixing the lighting result according to the scene brightness, thereby significantly improving the realism of the lighting effect while ensuring real-time performance.

[0162] Specifically: first, "select multiple light probes adjacent to the visible pixels on the surface of the three-dimensional model through spatial index retrieval". The spatial index is a pre-constructed light probe spatial distribution data structure (such as a grid index or a kd tree), which can quickly locate the light probes around the visible pixels according to their spatial coordinates. The coordinates of the visible pixels come from the vertex shader output in the real-time rendering pipeline (the pixel position obtained after rasterization), and when retrieving, usually the four closest light probes are selected (the number can be adjusted according to the accuracy requirements), and the maximum retrieval radius (such as 8 meters) is used to limit the inclusion of invalid probes - if there are only two probes within 8 meters of the pixel, only these two are used, avoiding the introduction of irrelevant lighting information from probes that are too far away. For example, in an indoor scene, a pixel is located in the center of the room, and through spatial index, the four light probes at the corners of the room can be quickly found, which can accurately reflect the ambient lighting at the pixel's location.

[0163] Next, "select effective light probes within the range of the maximum retrieval radius and apply the inverse distance squared weighting algorithm for coefficient interpolation, where the weight calculation formula for each light probe is Effective light probes refer to probes that are less than the maximum retrieval radius from the pixel calculated by the Euclidean distance between the pixel coordinates and the light probe coordinates. The principle of inverse distance squared weighting is that the closer the probe is to the pixel, the greater the influence of the light on the pixel, and the higher the weight. For example, the distance from the pixel to the first probe is 2 meters, and the distance to the second probe is 4 meters, so the weight of the first probe is 1 / 2²=0.25, and the weight of the second probe is 1 / 4²=0.0625, the total weight sum is 0.3125, so the normalized weight of the first probe is 0.25 / 0.3125=0.8, and the second probe is 0.2, the interpolated irradiance coefficient is the first probe coefficient x 0.8 + the second probe coefficient x 0.2. This interpolation method ensures smooth transition of light from one probe to another, avoiding sudden changes in light at the probe boundary.

[0164] Then, "calculate the indirect light diffuse contribution value by substituting the interpolated irradiance coefficient and the pixel material albedo into the diffuse reflection model, the formula is This formula is based on the Lambert cosine law (ideal diffuse reflection model), where is the material albedo of the pixel (extracted from the material data of the three-dimensional model), is the normalized coefficient, which ensures energy conservation; represents the summation of the nine basis functions of the third-order spherical harmonics ( =0 to 2, from -l to l); is the interpolated irradiance coefficient (from the calculation result of the previous step); is the spherical harmonic basis function value corresponding to the pixel surface normal, describing the sensitivity of the normal direction to different spherical harmonic components.

[0165] Finally, "obtain the direct lighting result, mix the direct lighting result and the indirect light diffuse reflection contribution value according to the scene brightness change setting to generate a final pixel lighting color by mixing a mixing ratio". The direct lighting result comes from the light source calculation in the real-time rendering pipeline (such as shadow mapping of directional light, attenuation calculation of point light, etc.), which contains the intensity and color of the direct illumination of the light source; the scene brightness is obtained by statistics of the average brightness of all pixels in the current frame (such as using Mipmap to quickly calculate). The mixing ratio is dynamically adjusted according to the scene brightness, for example, when the scene brightness is high (such as sunny outdoor, average brightness > 1000 nit), the direct light proportion is high (such as 70%), and the indirect light proportion is low (30%), highlighting the direct effect of sunlight; when the scene brightness is low (such as indoor candlelight, average brightness < 200 nit), the proportion of indirect light is increased (such as 60%), and the proportion of direct light is reduced (40%), which reflects the soft lighting of ambient light; the intermediate brightness is linearly transitioned. For example, the direct lighting result of a certain pixel is 1.0, the indirect light contribution is 0.5, and the scene brightness is 500 nit (in the middle range), then the mixing ratio is direct light 55%, indirect light 45%, and the final color is 1.0*0.55 + 0.5*0.45 = 0.55 + 0.225 = 0.775, which takes into account the contribution of both kinds of lighting, making the picture look natural in different brightness environments.

[0166] Through the above steps, a complete calculation process from the illumination probe irradiance coefficient to the final color of the pixel is realized, the spatial index and inverse distance interpolation ensure the spatial continuity of the light, the physically-based diffuse reflection model guarantees the accuracy of the indirect light calculation, and the dynamic mixing ratio makes the lighting effect adapt to different brightness scenes. These technical features work together to make the real-time rendered virtual scene not only reflect the clear outline of direct light, but also present the soft transition of environmental reflection, which significantly improves the realism of global illumination under the premise of ensuring controllable rendering time per frame, directly meeting the needs of real-time high-fidelity rendering in the fields of games, virtual reality, etc.

[0167] As shown in Figure 2 The present application also provides a real-time global illumination processing method system, comprising:

[0168] A probe initialization module is used to arrange a light probe network in a virtual scene, wherein each light probe generates a cube map centered on it, and the cube map stores the initial radiance information of the scene;

[0169] The sampling sample generation module is configured to emit a preset number of rays from each of the light probe positions based on the initial radiance information, take the intersection of the rays with the object surface or the sky as a sampling sample, and generate a sampling sample set, wherein each sampling sample records a corresponding radiance value, position, normal, and material attribute;

[0170] The sampling sample optimization module is configured to perform optimization processing on the sampling sample set, including merging the sampling samples that are close in space and encoding the sampling sample data into a two-dimensional texture.

[0171] The dynamic light update module is configured to obtain current light source information and dynamically update the radiance value of the sampling sample based on the current light source information.

[0172] The spherical harmonic light encoding module is configured to integrate and encode the radiance value by using a spherical harmonic function for each of the sampling sample sets covered by the light probe to generate an irradiance coefficient.

[0173] The real-time light rendering module is configured to, when performing real-time rendering, interpolate the irradiance coefficient of the neighboring light probe around a visible pixel of a three-dimensional model surface according to the spatial position of the visible pixel, combine the material attribute corresponding to the visible pixel, substitute into a diffuse reflection physical model to calculate the diffuse reflection contribution of indirect light, and obtain the final pixel light color after superimposing the direct light result.

[0174] The application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and wherein the processor implements the steps of the real-time global light processing method when executing the computer program.

[0175] The application further provides a computer readable storage medium storing a computer program, wherein the computer program implements the steps of the real-time global light processing method when executed by a processor.

[0176] It should be noted that, in this document, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusion, so that processes, devices, articles, or methods including a series of elements not only include those elements, but also include other elements not explicitly listed, or inherent to such processes, devices, articles, or methods. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of another identical element in the process, device, article, or method including the element.

[0177] The above merely describes preferred embodiments of the present application, and is not intended to limit the patent scope of the present application, and any equivalent structure or equivalent process conversion made by using the content of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method of real-time global illumination processing, the method comprising: The method comprises the following steps: arranging a light probe network in a virtual scene, wherein each light probe generates a cube map centered on it, which stores the initial radiance information of the scene; based on the initial radiance information, a preset number of rays are emitted from each light probe position, the intersection of the rays with the object surface or the sky is taken as a sampling sample, and a sampling sample set is generated, wherein each sampling sample records the corresponding radiance value, position, normal and material attribute; optimizing the sampling sample set, including merging the sampling samples close in space and encoding the sampling sample data into a two-dimensional texture; obtaining current light source information, and dynamically updating the radiance value of the sampling sample based on the current light source information, including: based on the rendering frame rate, all sampling samples are divided into a plurality of task load balanced calculation units according to the light probe coverage area; the update priority is assigned in ascending order according to the spatial distance between the calculation unit and the camera; the number of calculation units to be updated is selected dynamically associated with the rendering frame rate every frame, and the radiance value of the selected calculation units is processed through parallel calculation, and the historical radiance value data of the unselected calculation units is reused; when it is detected that the light source state changes more than a preset value, the calculation units in the range of the changed light source are immediately marked as high priority, and are forced to be included in the calculation queue in the next frame; at the same time, based on the deviation between the calculation time consumption and the target frame time, the number of calculation units updated every frame is dynamically adjusted through a negative feedback mechanism to realize load balancing; for each sampling sample set covered by the light probe, the radiance value is integrated and encoded to generate irradiance coefficients through spherical harmonic functions; during real-time rendering, according to the spatial position of the visible pixels on the surface of the three-dimensional model, the irradiance coefficients of the adjacent light probes around the visible pixels are interpolated, combined with the material attributes corresponding to the visible pixels, substituted into the diffuse reflection physical model to calculate the indirect light diffuse reflection contribution, and the final pixel light color is obtained after superimposing the direct light result.

2. The method of claim 1, wherein, The step of generating a sampling sample set based on the radiance information of the cube map includes: based on a uniformly distributed random number, the rays of each light probe are emitted through a spherical uniform sampling function; obtaining three-dimensional model data, and determining the position of the intersection of the rays with the object surface or the sky according to the vertex position, triangle patch index and collision box information in the three-dimensional model data: if the intersection corresponds to an object surface, the normal vector of the triangle patch is interpolated through coordinate interpolation as the normal of the sampling sample, and the albedo corresponding to the triangle patch is extracted from the three-dimensional model data as the material attribute of the sampling sample; if the intersection corresponds to the sky, the sampling sample is marked with a sky mask; determining the face index and UV coordinates of the cube map according to the ray direction vector, performing bilinear interpolation on the initial radiance information of a plurality of pixels adjacent to the direction in the cube map, and taking the result as the radiance value of the sampling sample; Collecting all the sampling samples generated by the light probes to form a sampling sample set containing the position, normal, material attribute and radiance value of each sampling sample.

3. The method of claim 1, wherein, The optimization process of the sampling sample set comprises: Traversing all the sampling samples and calculating the position distance and normal vector dot product of any two sampling samples, and screening out redundant sampling sample pairs whose position distance is less than a first threshold and whose normal vector dot product is greater than a second threshold; Discarding the sampling samples with opposite normal vectors and keeping only the representative sampling samples; Mapping the albedo RGB channel of the representative sampling samples to the RGB channel of a two-dimensional texture, storing the normalized x and y components of the normal vector in the texture Alpha channel, embedding the sign bit of the z component of the normal vector in the lowest bit of the albedo R channel, and mapping the position information of the sampling samples to the U and V coordinates of the texture through spherical coordinate conversion and then normalizing and compressing the position information and storing it in the lower half of the texture; Storing the index of the representative sampling samples in uint and two ushort encodings to complete the merging and two-dimensional texture storage.

4. The method of claim 1, wherein, Obtaining the current light source information and dynamically updating the radiance value of the sampling sample based on the current light source information comprises: Obtaining the type, position and attenuation radius of the current light source information; for a directional light source, all sampling samples in its coverage range are included in the update range; for a point light source, the update range is determined based on the position of the point light source and its attenuation radius, and the sampling samples located in the update range are screened out; For the sampling samples in the coverage range of the directional light source, the direct light contribution of the directional light source to the sampling samples is calculated; For the sampling samples in the update range of the point light source, the direct light contribution of the point light source to the sampling samples is calculated; For the object surface sampling samples, the initial radiance value and the indirect light radiance value calculated in the previous frame of the sampling sample are obtained, the contribution value of the indirect light radiance value is extracted according to a preset proportion, the sum of the initial radiance value, the direct light radiance value of the directional light source and the direct light radiance value of the point light source is combined, the fusion weight is determined according to the state of the light source, and the final radiance value of the object surface sampling sample is calculated by weighted calculation. For the sky sampling samples, the initial sky radiance value and the real-time calculated sky light color value of the sampling sample are obtained, and the final radiance value of the sky sampling sample is obtained by weighting according to the fusion weight that changes dynamically with time.

5. The method of claim 1, wherein, For each sampling sample set covered by the light probe, the radiance value is integrated and encoded by spherical harmonics to generate the irradiance coefficient, which comprises: Screening the sampling samples based on the predetermined spatial coverage range of the light probe, and supplementing the sampling samples from the adjacent light probe and applying the distance-related weight attenuation when the number of covered sampling samples is insufficient; For each light probe, the radiance value of the sampling samples in its coverage range is projected and integrated by multi-order spherical harmonics to calculate the irradiance coefficient; Storing the irradiance coefficient in a floating-point texture format storage medium according to the three-dimensional spatial distribution, and constraining the difference threshold of the irradiance coefficient of adjacent light probes through spatial filtering processing.

6. The method of claim 1, wherein, The step of, in real-time rendering, interpolating irradiance coefficients of the light probes adjacent to a visible pixel on the surface of the three-dimensional model according to a spatial position of the visible pixel, combining material properties corresponding to the visible pixel, substituting into a diffuse reflection physical model to calculate indirect light diffuse reflection contribution, superimposing a direct light result to obtain a final pixel light color includes: Selecting a plurality of light probes adjacent to the visible pixel on the surface of the three-dimensional model through spatial index retrieval; Selecting effective light probes within a limited maximum retrieval radius range and applying an inverse distance square weighting algorithm for coefficient interpolation; Substituting the interpolated irradiance coefficients into a diffuse reflection model to calculate an indirect light diffuse reflection contribution value, in combination with material properties corresponding to the visible pixel; Obtaining a direct light result, mixing the direct light result and the indirect light diffuse reflection contribution value according to a scene brightness change setting to generate a final pixel light color.

7. A real-time global illumination processing method system for implementing the method of any one of claims 1 to 6, characterized in that, Comprise: A probe initialization module for arranging a light probe network in a virtual scene, wherein each light probe generates a cube map centered on it, and the cube map stores initial radiance information of the scene; A sampling sample generation module for emitting a preset number of rays from each light probe position based on the initial radiance information, taking the intersection of the rays with the surface of an object or the sky as a sampling sample, and generating a sampling sample set, wherein each sampling sample records a corresponding radiance value, position, normal, and material property; A sampling sample optimization module for optimizing the sampling sample set, including merging spatially adjacent sampling samples and encoding the sampling sample data into a two-dimensional texture; A dynamic light update module for obtaining current light source information and dynamically updating the radiance values of the sampling samples based on the current light source information; A spherical harmonic light encoding module for integrating and encoding the radiance values of each sampling sample set covered by the light probe through spherical harmonics to generate irradiance coefficients; A real-time indirect light rendering module for, in real-time rendering, interpolating irradiance coefficients of the light probes adjacent to a visible pixel on the surface of the three-dimensional model according to a spatial position of the visible pixel, combining material properties corresponding to the visible pixel, substituting into a diffuse reflection physical model to calculate indirect light diffuse reflection contribution, superimposing a direct light result to obtain a final pixel light color.

8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method of any one of claims 1 to 6.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Illumination sampling method in game, device and computer equipment

    CN111744183A

  • Global illumination method supporting day and night alternation and computer readable storage medium

    CN112884876A

  • 3D real-time rendering method and system and medium

    CN115393499A