Real-time global illumination processing method and system

By deploying a lighting probe network and cube maps in a virtual scene, generating and optimizing a sample set, and combining it with spherical harmonic functions for real-time lighting processing, the problem of insufficient efficiency and accuracy in existing technologies is solved, achieving efficient and dynamic global lighting effects.

CN120876706AActive Publication Date: 2025-10-31SHANGHAI WANJIAN NETWORK TECHNOLOGY CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202511375694.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2025-10-31
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. The strategy of blending direct and indirect light lacks adaptability, resulting in abrupt changes in lighting and poor visual coherence in 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 through 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 with integration and encoding. During real-time rendering, the irradiance coefficient is interpolated and the light color is calculated by combining the material properties.

Benefits of technology

It improves the efficiency of lighting calculation, dynamically responds to changes in light sources and objects, reduces invalid calculations, ensures the spatial continuity and natural transition of lighting, and enhances the realism and adaptability of virtual scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120876706A_ABST
    Figure CN120876706A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of image processing, and particularly discloses a real-time global illumination processing method and system, and the method comprises the steps: arranging an illumination probe network in a virtual scene; a preset number of rays are emitted from the position of each illumination probe, intersection points of the rays and the surface of an object or the sky serve as sampling samples, and the sampling sample set is optimized; dynamically updating the radiance value of the sampling sample based on the current light source information; the radiance value is integrated and coded through the spherical harmonic function to generate the irradiance coefficient, through the technical scheme that the illumination probe network is combined with the sampling sample set, the processing efficiency is remarkably improved while the illumination calculation precision is guaranteed, the multi-order spherical harmonic function is adopted to carry out integral coding on the radiance value to generate the irradiance coefficient, and the processing efficiency is improved. The spatial continuity of illumination is ensured; and the reality sense and adaptability of global illumination are improved, and the requirements for high-fidelity real-time rendering in the fields of games, virtual reality and the like are met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a real-time global illumination processing method and system. Background Technology

[0002] Real-time global illumination (GBI) 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 rays that directly illuminate the surface of an object) and indirect light (light rays that reach a target point after being reflected or scattered by the object's surface) in a scene while maintaining the rendering frame rate. In virtual scenes, GBI directly impacts the realism of the image. For example, the soft light spots reflected from a wall to the ground under sunlight, and the mutual reflections between furniture in an indoor environment, all rely on GBI calculations for rendering.

[0003] However, existing real-time global illumination processing technologies suffer from the following problems in practical applications: First, it is difficult to balance processing efficiency and computational accuracy. For example, while ray tracing-based methods can accurately calculate global illumination, the computational load is extremely large, making it difficult to meet the frame rate requirements of real-time rendering. On the other hand, while baking lightmaps is more efficient, it cannot dynamically respond to changes in the position and state of light sources or objects, resulting in insufficient flexibility. Second, the generation and updating strategies for sampling samples are not optimized enough, easily leading to redundant sampling samples that waste computational resources, or untimely updates to sampling samples that cause lighting effects to lag behind scene changes. Third, sudden changes in lighting in the rendered image can affect visual coherence. Furthermore, the fusion strategy of direct and indirect lighting lacks dynamic adaptability, making it difficult to present natural lighting transitions in scenes with different brightness levels. Summary of the Invention

[0004] The main objective of this invention is to provide a real-time global illumination processing method and system, which aims to solve the technical problems mentioned in the background art.

[0005] This invention proposes a real-time global illumination processing method, comprising: A network of light probes is deployed in a virtual scene, wherein each light probe generates a cube map centered on itself, and the cube map stores the initial emissivity information of the scene; Based on the initial emissivity information, a preset number of rays are emitted from each of the illumination probe positions. The intersections of the rays with the object surface or the sky are used as sampling samples, and a sampling sample set is generated. Each sampling sample records the corresponding emissivity value, position, normal, and material properties. The sample set is optimized by merging spatially similar sample samples and encoding the sample data into a two-dimensional texture. Obtain current light source information, and dynamically update the emissivity value of the sampled sample based on the current light source information; For each of the sampling sample sets covered by the illumination probe, the radiance value is integrated and encoded using a spherical harmonic function to generate an irradiance coefficient; During real-time rendering, based on the spatial position of visible pixels on the surface of the 3D model, the irradiance coefficient of the surrounding light probes is interpolated. Combined with the material properties corresponding to the visible pixels, the contribution of indirect light diffuse reflection is calculated by substituting into the diffuse reflection physical model. The final pixel lighting color is obtained by superimposing the direct lighting results.

[0006] Preferably, based on the emissivity information of the cube map, a predetermined number of rays are emitted from each of the illumination probe positions, and the intersections of the rays with the object surface or the sky are used as sampling samples to generate a sampling sample set, including: Based on uniformly distributed random numbers, rays are emitted from each of the illumination probes using a spherical uniform sampling function; Acquire 3D model data, and determine the position of the intersection point between the ray and the object surface or the sky based on the vertex positions, triangle patch indices, and collision box information in the 3D model data: If the intersection point corresponds to the surface of an object, the vertex normal vector of the triangle facet is used as the normal vector of the sampled sample by coordinate interpolation, and the albedo corresponding to the triangle facet is extracted from the three-dimensional model data as the material property of the sampled sample. If the intersection point corresponds to the sky, then the sky mask is used to mark the sampled data. The face index and UV coordinates of the cube map are determined based on the ray direction vector. Bilinear interpolation is performed on the initial radiance information of several pixels adjacent to the cube map in that direction, and the result is used as the radiance value of the sampled sample. Collect all the sampling samples generated by the illumination probes to form a sampling sample set containing the location, normal, material properties and emissivity value of each sampling sample.

[0007] Preferably, the step of optimizing the sample set includes: Traverse all sampled samples and calculate the positional distance and normal vector dot product of any two sampled samples, and filter out redundant sampled sample pairs whose positional distance is less than a first threshold and whose normal vector dot product is greater than a second threshold; Discard redundant sample samples with reversed normal vectors and duplicate sample samples, and retain only representative sample samples; The albedo RGB channels of representative samples are mapped to the RGB channels of a 2D texture; the x and y components of the normal vector are normalized and stored in the texture Alpha channel, and the sign bit of the z component of the normal vector is embedded in the least significant bit of the albedo R channel; the position information of the sampled samples is mapped to the texture U and V coordinates through spherical coordinate transformation and normalized and compressed, and stored independently in the lower half of the texture. The representative sample index is stored as two ushort codes in uint, and the merging process and two-dimensional textured storage are completed.

[0008] Preferably, the step of acquiring current light source information and dynamically updating the emissivity value of the sampled sample based on the current light source information includes: 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 in 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 this update range; 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; 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; For the object surface sampling sample, the initial emissivity value of the sampling sample and the indirect light emissivity value calculated from the previous frame are obtained. The contribution value of the indirect light emissivity value is extracted according to a preset ratio. Combined with the initial emissivity value and the sum of the direct light emissivity values ​​of the directional light source and the point light source, the fusion weight is determined according to the light source state, and the final emissivity value of the object surface sampling sample is obtained by weighted calculation. For the sky sample, the initial sky radiance value and the real-time calculated sky color value are obtained. The final radiance value of the sky sample is obtained by weighting the samples according to the fusion weight that changes dynamically over time.

[0009] Preferably, the step of acquiring current light source information and dynamically updating the emissivity value of the sampled sample based on the current light source information further includes: Based on the rendering frame rate, all sampled samples are divided into multiple computationally balanced units according to the coverage area of ​​the lighting probe; The update priority is assigned in ascending order based on the spatial distance between the computing unit and the camera; Each frame selects the number of computational units updated that are dynamically associated with the rendering frame rate, processes the emissivity value of the selected computational units through parallel computation, and reuses the historical emissivity value data of the unselected computational units. When a change in the state of a light source is detected to exceed a preset value, the calculation units within the range of the changed light source are immediately marked as high priority and forcibly included in the calculation queue in the next frame. Meanwhile, based on the deviation between the computation time and the target frame time, the number of computation units updated in each frame is dynamically adjusted through a negative feedback mechanism to achieve load balancing.

[0010] Preferably, the step of generating an irradiance coefficient by integrating and encoding the radiance values ​​using a spherical harmonic function for the sample set covered by each of the illumination probes includes: Samples are selected based on the predetermined spatial coverage of the illumination probes. When the number of covered samples is insufficient, samples are supplemented from adjacent illumination probes and distance-related weights are applied to attenuate the samples. For each illumination probe, the irradiance coefficient is calculated by spherical projection integral of the radiance values ​​of the sampled samples within its coverage area using a multi-order spherical harmonic function; The irradiance coefficients are stored in a floating-point texture format storage medium according to the three-dimensional spatial distribution, and the difference threshold of the irradiance coefficients of adjacent light probes is constrained by spatial filtering.

[0011] Preferably, during real-time rendering, the steps of interpolating the irradiance coefficients of the surrounding light probes based on the spatial position of visible pixels on the surface of the 3D model, combining the material properties corresponding to the visible pixels, substituting them into the diffuse reflection physical model to calculate the indirect light diffuse reflection contribution, and then superimposing the direct lighting results to obtain the final pixel lighting color include: Multiple illumination probes adjacent to visible pixels on the surface of the 3D model are selected by spatial index retrieval; Within a limited maximum search radius, effective illumination probes are selected and coefficients are interpolated using an inverse distance squared weighted algorithm. The interpolated irradiance coefficient is combined with the material properties corresponding to the visible pixels and substituted into the diffuse reflection model to calculate the indirect light diffuse reflection contribution value. Obtain the direct lighting result, and mix the direct lighting result with the indirect light diffuse reflection contribution value according to the scene brightness change setting mixing ratio to generate the final pixel lighting color.

[0012] The present invention also provides a real-time global illumination processing method system, comprising: The probe initialization module is used to deploy a network of light probes in a virtual scene, wherein each light probe generates a cube map centered on itself, and the cube map stores the initial emissivity information of the scene; The sampling sample generation module is used to emit a preset number of rays from each of the illumination probe positions based on the initial emissivity information, take the intersection of the rays with the object surface or the sky as sampling samples, and generate a sampling sample set, wherein each sampling sample records the corresponding emissivity value, position, normal and material properties. The sampling sample optimization module is used to optimize the sampling sample set, including merging spatially similar sampling samples and encoding the sampling sample data into a two-dimensional texture; The dynamic illumination update module is used to acquire current light source information and dynamically update the emissivity value of the sampled sample based on the current light source information. A spherical harmonic illumination coding module is used to integrate and encode the radiance value using a spherical harmonic function to generate an irradiance coefficient for the sampled sample set covered by each illumination probe. The real-time indirect lighting rendering module is used to interpolate the irradiance coefficient of the surrounding light probes based on the spatial position of the visible pixels on the surface of the 3D model during real-time rendering. It combines the material properties corresponding to the visible pixels, substitutes them into the diffuse reflection physical model to calculate the contribution of indirect light diffuse reflection, and superimposes the direct lighting results to obtain the final pixel lighting color.

[0013] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, characterized in that the processor executes the computer program to implement the steps of a real-time global illumination processing method.

[0014] The present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the steps of a real-time global illumination processing method.

[0015] The beneficial effects of this invention are as follows: This invention uses a technical solution that combines a light probe network with a cube map to sample a set of samples. This solution significantly improves processing efficiency while ensuring the accuracy of light calculation. It can reduce the amount of real-time calculation by using pre-calculated initial radiance information, and can respond to changes in the state of the light source and the object based on a dynamic update mechanism, effectively balancing the contradiction between accuracy and real-time performance.

[0016] Furthermore, by optimizing the sample set, invalid calculations are reduced, data access efficiency is improved, and resource waste is avoided. The frame update strategy combined with the priority mechanism ensures that the sampled samples in key areas are updated in a timely manner, thus solving the problem of delayed sample update.

[0017] Furthermore, the irradiance coefficient is generated by integral encoding of the radiance value using a multi-order spherical harmonic function, and the coefficient difference between adjacent illumination probes is constrained by spatial filtering, ensuring the spatial continuity of illumination and avoiding abrupt changes in illumination in the rendered image; the interpolation algorithm based on inverse distance squared weighting further improves the spatial smoothness of the irradiance coefficient and enhances visual coherence.

[0018] Furthermore, it dynamically adjusts the fusion ratio of direct and indirect light based on scene brightness, enabling lighting effects to transition naturally under different brightness environments. This enhances the realism and adaptability of global illumination, meeting the needs of games, virtual reality, and other fields for high-fidelity real-time rendering. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of a method flow according to an embodiment of this application.

[0020] Figure 2 This is a schematic diagram of the system structure according to an embodiment of this application.

[0021] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0022] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0023] like Figure 1 As shown, this application provides a real-time global illumination processing method, including: S1, Deploy a network of light probes in a virtual scene, wherein each light probe generates a cube map centered on itself, and the cube map stores the initial emissivity information of the scene; S2, based on the initial emissivity information (using the stable and unchanging illumination emissivity in the scene), a preset number of rays are emitted from each of the illumination probe positions, and the intersection of the rays with the object surface or the sky is used as a sampling sample, and a sampling sample set is generated, wherein each sampling sample records the corresponding emissivity value, position, normal and material properties. S3, optimize the sample set, including merging spatially similar sample samples and encoding the sample data into a two-dimensional texture; S4, acquire current light source information, and dynamically update the emissivity value of the sampled sample based on the current light source information; S5, for each of the sampling sample sets covered by the illumination probe, the radiance value is integrated and encoded using a spherical harmonic function to generate an irradiance coefficient; S6. During real-time rendering, based on the spatial position of the visible pixels on the surface of the 3D model, the irradiance coefficient of the surrounding light probes is interpolated. Combined with the material properties corresponding to the visible pixels, the indirect light diffuse reflection contribution is calculated by substituting into the diffuse reflection physical model. The final pixel lighting color is obtained by superimposing the direct lighting results.

[0024] As described in steps S1-S6 above, this invention deploys a lighting probe network in a virtual scene and generates a cube map storing initial radiance information. Based on this information, a sampling sample set is generated and optimized. The radiance values ​​of the sampling samples are dynamically updated in conjunction with the current light source information. Then, the irradiance coefficient of the lighting probe is generated through spherical harmonic function integral encoding. Finally, during real-time rendering, the irradiance coefficient is interpolated to calculate the indirect light contribution and superimposed with direct lighting, thereby achieving efficient processing of real-time global illumination in the virtual scene to meet the dual requirements of real-time performance and accuracy of global illumination in the virtual scene.

[0025] Global illumination involves the combined effects of direct and indirect light in a scene. Indirect light, formed by reflection or scattering from object surfaces, has a complex propagation path, making accurate and real-time calculation of global illumination in virtual scenes extremely challenging. Traditional real-time rendering methods struggle to balance accuracy and performance. For example, while ray tracing can accurately calculate global illumination, its computational load is enormous, making it difficult to meet the frame rate requirements of real-time rendering. Baking lightmaps, on the other hand, can pre-calculate lighting information but cannot handle dynamic changes in light sources or objects within the scene, lacking flexibility. This invention addresses these issues by proposing a solution combining lighting probes, sampling samples, and spherical harmonic function encoding techniques. Through a step-by-step processing flow, it aims to significantly improve the real-time performance of global illumination while maintaining a certain level of lighting calculation accuracy.

[0026] Specifically, step S1, "deploying a network of lighting probes in a virtual scene, where each lighting probe generates a cube map centered on itself, the cube map storing the initial emissivity information of the scene," is technically implemented by rationally deploying multiple lighting probes in the virtual scene according to the complexity and accuracy requirements of the scene. These lighting probes act as "observation points" in the scene. Each lighting probe emits rays in six directions (±X, ±Y, ±Z), collecting emissivity information in each direction and generating a cube map. The initial emissivity information stored in the cube map mainly comes from stable and unchanging lighting contributions in the scene, such as reflected light from static object surfaces and skylight. This information can be pre-calculated through offline rendering. For example, for object surface areas, the material albedo of the 3D model is sampled and the pre-calculated lighting map is used; for sky areas, the emissivity values ​​at different elevation angles are calculated using an atmospheric scattering model. The significance of this step in this invention is to provide basic data for subsequent lighting calculations. By distributing the lighting probes, the complex 3D scene is divided into multiple local regions, and the lighting information of each region is collected and characterized by the corresponding lighting probe, thereby reducing the complexity of global lighting calculations. For example, in an indoor scene containing multiple static objects, by placing lighting probes at different locations in the room, the cube map of each probe can store the initial emissivity reflected by the surfaces of the surrounding walls, furniture, etc., providing a starting point for subsequent calculations of the lighting in that area.

[0027] Step S2, "Based on the initial emissivity information (using the stable and unchanging illumination emissivity in the scene), emit a predetermined number of rays from each of the illumination probe positions. The intersections of these rays with the object surface or the sky are used as sampling samples, and a sampling sample set is generated. Each sampling sample records its corresponding emissivity value, position, normal, and material properties." The significance of this step in the invention is that, based on the initial emissivity information collected by the illumination probes, more detailed local illumination-related data in the scene can be obtained. The sampling samples are equivalent to "sampling points" in the scene, recording the illumination, geometry, and material information of specific locations, providing concrete calculation objects for subsequent dynamic updates of emissivity and calculation of irradiance coefficients. For example, if a ray emitted from an illumination probe intersects the surface of a red sofa, this intersection point, as a sampling sample, will record information such as the emissivity at that point, the position of the sofa surface, the normal direction, and the albedo of the red fabric. This information is crucial for accurately calculating the illumination changes at that point under dynamic light sources.

[0028] Step S3, "Optimizing the sample set, including merging spatially similar sampled samples and encoding the sampled sample data into a two-dimensional texture," is significant in reducing data volume and improving the efficiency of subsequent processing. Since the sampling process may generate a large number of redundant sampled samples with similar spatial locations and attributes, these samples increase the computational burden and offer limited improvement to the results. Merging redundant sampled samples simplifies the data. Encoding the sampled sample data into a two-dimensional texture leverages the GPU's efficient texture processing capabilities, accelerating subsequent radiometric updates and illumination calculations. For example, multiple sampled samples densely distributed on a plane, with minimal differences in location and attributes, can be merged into a few representative sampled samples after optimization, reducing data volume without significantly affecting the accuracy of illumination calculations.

[0029] Step S4, "Acquire current light source information and dynamically update the radiance value of the sampled sample based on the current light source information," is significant in this invention because it enables the radiance value of the sampled sample to reflect the dynamic changes of the light source in the scene in real time, thereby ensuring the timeliness of global illumination calculation. Since light sources in the scene may move, change intensity, or be on / off, these changes directly affect the illumination of object surfaces. By dynamically updating the radiance value of the sampled sample, subsequent irradiance coefficient calculations and real-time rendering can be based on the latest illumination state, thus presenting accurate dynamic lighting effects. For example, when a point light source in the scene is moved, the radiance value of the surrounding sampled samples will be recalculated to reflect the changes in light intensity and color caused by the change in the light source's position.

[0030] Step S5, "For each set of samples covered by the illumination probe, integrate and encode the radiance values ​​using a spherical harmonic function to generate irradiance coefficients," is significant in that it compresses and encodes the radiance information of the sampled samples for efficient use in subsequent real-time rendering. The spherical harmonic function can represent complex radiance distributions with a small number of coefficients. By integrating the radiance values ​​of the sampled samples, irradiance coefficients for the area covered by the illumination probe are obtained. These coefficients can approximately characterize the lighting environment of the area, providing crucial data for quickly calculating indirect light contributions during real-time rendering. For example, if a illumination probe covers an area with multiple sampled samples, after integration and encoding using a spherical harmonic function, a set of irradiance coefficients is obtained. This set of coefficients represents the overall lighting conditions of the area and can be directly used to calculate the indirect lighting on the surfaces of objects within that area during real-time rendering.

[0031] Step S6, "During real-time rendering, based on the spatial position of visible pixels on the surface of the 3D model, interpolate the irradiance coefficients of the surrounding neighboring light probes, combine the material properties corresponding to the visible pixels, substitute them into the diffuse reflection physical model to calculate the indirect light diffuse reflection contribution, and superimpose the direct lighting result to obtain the final pixel lighting color," signifies that this step applies the previously calculated irradiance coefficients to the actual rendering process, generating a realistic global illumination effect. By interpolating the irradiance coefficients of neighboring light probes, suitable lighting environment information for each visible pixel's position can be provided. The indirect light contribution is calculated by combining material properties and superimposed with direct lighting, ultimately obtaining a pixel color that balances both direct and indirect light, making the rendered virtual scene more realistic and believable. For example, when rendering a visible pixel on the surface of an object, by interpolating the irradiance coefficients of several light probes surrounding the pixel, combining the material albedo of the object's surface, the indirect light received by the pixel is calculated, and then the direct light illumination effect is superimposed to obtain the final color of the pixel, presenting rich lighting details.

[0032] Through the above steps, this invention can achieve efficient and accurate real-time global illumination processing in virtual scenes. It overcomes the shortcomings of traditional methods in terms of real-time performance and flexibility. Through the optimized design of each step, it ensures the accuracy and efficiency of illumination calculation, making the rendering effect of virtual scenes more realistic and better meeting the needs of games, virtual reality and other fields for real-time global illumination.

[0033] In one embodiment of the present invention, based on the emissivity information of the cube map, a predetermined number of rays are emitted from each of the illumination probe positions, and the intersections of the rays with the object surface or the sky are used as sampling samples to generate a sampling sample set. S21, based on uniformly distributed random numbers, emit rays from each of the illumination probes through a spherical uniform sampling function; S22, acquire 3D model data, and determine the position of the intersection point between the ray and the object surface or the sky based on the vertex positions, triangle patch indices, and collision box information in the 3D model data: If the intersection point corresponds to the surface of an object, the vertex normal vector of the triangle facet is used as the normal vector of the sampled sample by coordinate interpolation, and the albedo corresponding to the triangle facet is extracted from the three-dimensional model data as the material property of the sampled sample. If the intersection point corresponds to the sky, then the sky mask is used to mark the sampled data. S23, determine the face index and UV coordinates 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 use the result as the radiance value of the sampled sample; S24, collect all the sampling samples generated by the illumination probes to form a sampling sample set containing the location, normal, material properties and emissivity value of each sampling sample.

[0034] As described in steps S21-S24 above, this invention uses the initial emissivity information stored in the cube map generated by the illumination probe to obtain the intersection points with the object surface or the sky as sampling samples by emitting uniformly distributed rays from the illumination probe. The emissivity value, position, normal and material properties of the sampling samples are accurately recorded, and finally a complete sampling sample set is formed, providing high-quality basic data for subsequent dynamic updates of emissivity and calculation of irradiance coefficient.

[0035] Since the core of global illumination is the accurate calculation of direct and indirect light radiation received at each point in the scene, and emissivity, as a physical quantity describing the intensity and color of light in a certain direction, directly determines the accuracy of the lighting calculation due to its spatial distribution, cube maps, while capable of storing initial emissivity information around a light probe, provide a holistic representation of spatial directions and cannot accurately reflect the local radiation characteristics of different locations in the scene (such as different points on an object's surface or different areas of the sky). Therefore, it is necessary to transform the "macro" information of the cube map into "micro" point information through sampling samples. These sampling samples, acting as "observation points" at specific locations in the scene, record their position, normal (reflecting surface orientation), material properties (such as albedo, reflecting the surface's ability to reflect light), and emissivity values. Together, these constitute a complete feature describing the lighting environment of that point, solving the problem of insufficient representation of local details by cube maps and providing a precise calculation object for dynamically adjusting emissivity in conjunction with real-time light sources in subsequent steps.

[0036] Specifically: First, "based on uniformly distributed random numbers, rays from each illumination probe are emitted through a spherical uniform sampling function." This is achieved by using two uniformly distributed random numbers, u and v, within the range (0,1). An azimuth angle φ = 2πu and a polar angle θ = arccos(1-2v) are generated using a spherical coordinate transformation formula. These angles are then converted into three-dimensional ray direction vectors (x = sinθcosφ, y = sinθsinφ, z = cosθ), ensuring that the rays are uniformly distributed on a sphere centered on the illumination probe. This uniformity avoids bias in the sampling direction. For example, in a spherical space, a balanced number of rays can be obtained regardless of whether the direction is towards the object or towards the sky, ensuring that subsequent sampling samples cover all areas of the scene and providing comprehensive raw data for emissivity calculation.

[0037] 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.

[0038] 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.

[0039] 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.

[0040] Next, "based on the ray direction vector, the face index and UV coordinates of the cube map are determined. Bilinear interpolation is then performed on the initial radiance information of several pixels adjacent to this direction in the cube map, and the result is used as the radiance value of the sampled sample." Here, the face index is determined by comparing the absolute values ​​of the x, y, and z components of the ray direction vector. For example, if |x| is maximum and x is positive, it corresponds to the +X face of the cube map. The UV coordinates are obtained by normalizing the other two components of the direction vector; for example, the UV coordinates of the +X face are derived from the normalized values ​​of y / z. Bilinear interpolation performs a weighted calculation on the four (discrete) pixels surrounding the UV coordinates. The weight is determined by the distance between the UV coordinates and the pixel center; the closer the distance, the greater the weight. This method converts discrete pixel radiance into continuous ray direction radiance, avoiding radiance jumps caused by pixel boundaries. For example, if the ray direction points to a certain position on the +X plane, and its UV coordinates fall between two pixels, by interpolating the radiance of these two pixels and the other two adjacent pixels, a more accurate sample radiance value can be obtained, so that the initial radiance of the sample is seamlessly connected with the stored information of the cube map.

[0041] Finally, the step of "collecting all sampled samples generated by the illumination probes to form a sampled sample set containing the location, normal, material properties, and emissivity values ​​of each sample" integrates the scattered sampled samples into a structured data set. The location information is used to determine whether a sampled sample is within the coverage area of ​​the illumination probe, the normal and material properties are used for reflection calculations when dynamically updating the emissivity, and the emissivity value serves as an initial value for subsequent adjustments. The formation of the sampled sample set allows subsequent steps to be processed based on a complete and unified data structure. For example, when merging spatially close sampled samples, the location information in the sampled sample set needs to be called for distance calculations, ensuring the data consistency of the entire method flow.

[0042] Through the above steps, the accurate conversion from macroscopic emissivity information of cube maps to microscopic sampled samples is achieved. Its technical features directly improve the uniformity of sampling, the accuracy of sampled sample attributes, and the precision of emissivity values, laying a high-quality data foundation for subsequent real-time calculation of global illumination. It not only solves the bias and coarseness problems of traditional sampling methods, but also ensures that the sampled sample information can truly reflect the physical characteristics of the scene by combining 3D model data and interpolation algorithms.

[0043] In one embodiment of the present invention, the step of optimizing the sample set includes: S31, traverse all sampled samples and calculate the positional distance and normal vector dot product of any two sampled samples, and filter out redundant sampled sample pairs whose positional distance is less than a first threshold and whose normal vector dot product is greater than a second threshold; S32, discard redundant sample samples with reversed normal vectors and duplicate sample samples, and retain only representative sample samples; S33: The albedo RGB channel of the representative sample is mapped to the RGB channel of the two-dimensional texture; the x and y components of the normal vector are normalized and stored in the texture Alpha channel, and the sign bit of the z component of the normal vector is embedded in the least significant bit of the albedo R channel; the position information of the sample is mapped to the texture U and V coordinates through spherical coordinate transformation and normalized and compressed, and stored independently in the lower half of the texture. S34 stores the representative sample index as uint and two ushort codes, completing the merging process and two-dimensional textured storage.

[0044] As described in steps S31-S34 above, the present invention optimizes the generated sample set by merging spatially similar redundant sample samples and encoding the sample data into a two-dimensional texture, thereby reducing the amount of data and improving the efficiency of subsequent processing. At the same time, it ensures the integrity and efficient accessibility of the sample information, providing concise and structured data support for real-time global illumination calculation.

[0045] While the sample set contains rich local lighting information from the scene, redundant samples with similar spatial locations and properties (such as normals and materials) are inevitably generated during the generation process due to the density of ray sampling or the presence of many similar surfaces in the scene. These redundant samples not only consume additional storage resources but also increase unnecessary computation in subsequent steps such as emissivity updates and irradiance coefficient calculations, reducing overall processing efficiency. Furthermore, inconsistent or unsuitable data formats for the samples can also affect the processing speed of GPUs and other hardware. Therefore, it is necessary to optimize the processing to address sample redundancy and data format compatibility issues, improving the real-time performance of the entire method while ensuring that the accuracy of lighting calculations is not significantly affected.

[0046] Traditional methods directly retain all sampled data, even if two samples are almost spatially overlapping and have identical attributes, resulting in redundant storage and computation and wasted computing power. Furthermore, in terms of data storage, using unstructured formats such as arrays makes it difficult for GPUs to efficiently read data during parallel processing, impacting processing speed. This invention addresses these problems by setting a threshold to filter redundant sampled data and encoding the data into a two-dimensional texture. This approach reduces data volume while leveraging the texture processing advantages of GPUs, thus improving overall workflow efficiency.

[0047] Specifically: First, "traverse all sampled samples and calculate the dot product of the positional distance and normal vector of any two sampled samples, filtering out redundant sampled sample pairs where the positional distance is less than a first threshold and the dot product of the normal vector is greater than a second threshold." The positional distance is calculated using the Euclidean distance formula for two points in three-dimensional space; the dot product of the normal vector is a1·a2=|a1||a2|cosθ (θ is the angle between the two normal vectors). Since the normal vectors have been normalized, the dot product result is cosθ. The first threshold is set according to the scene's accuracy requirements; for example, in scenes with high accuracy requirements, it is set to 0.1 meters to ensure that sampled samples that are too close are considered redundant. The second threshold is set to 0.9 (corresponding to an angle of approximately 25 degrees) to ensure that only sampled samples with similar normal vector directions are considered redundant. Through this dual filtering, sampled sample pairs that are spatially close and have similar surface orientations can be accurately identified. For example, two closely adjacent sampled samples on a plane, with a small positional distance and almost identical normal vectors, will be filtered out as redundant sampled sample pairs.

[0048] Next, the process "discards redundant sample pairs with reversed normal vectors and duplicate samples, retaining only representative samples" means that the dot product of the normal vectors of two samples is less than 0 (angle greater than 90 degrees). Even if they are close in position, they may belong to opposite sides of an object (such as the two sides of a thin plate) and should not be merged. "Duplicate samples" refers to samples with identical positions and attributes; only one should be retained. The retained representative sample is usually the sample closer to the center of the region or with more typical attributes among the redundant sample pairs. For example, the sample in the center of multiple redundant samples can be selected as the representative sample. This maximizes the preservation of the region's illumination information while effectively reducing the number of samples. This step significantly reduces the amount of data in the sample set by removing redundancy. For example, 1000 samples may be filtered to retain 600, saving approximately 40% of computational power in subsequent calculations.

[0049] Then, the encoding process "maps the albedo RGB channels of representative samples to the RGB channels of the 2D texture; the x and y components of the normal vector are normalized and stored in the texture's Alpha channel, and the sign bit of the z component of the normal vector is embedded in the least significant bit of the albedo R channel; the position information of the sampled samples is mapped to the texture's U and V coordinates through spherical coordinate transformation and normalized and compressed, and stored independently in the lower half of the texture." This process fully utilizes the channel characteristics of the texture: the albedo RGB values ​​directly correspond to the texture's RGB channels without conversion; the x and y components of the normal vector... The original range of the components is [-1, 1]. After normalization to [0, 1], they can be stored in the Alpha channel (8-bit or 16-bit). The sign bit (0 or 1) of the z-component is embedded in the least significant bit of the albedo R channel (without affecting the visual effect of albedo). In this way, complete normal vector information is stored with fewer channels. After the position information is converted into spherical coordinates (radius, polar angle, azimuth angle), the polar angle and azimuth angle are normalized to [0, 1] as the U and V coordinates of the texture, and the radius is stored separately. In this way, the position information can be associated with the texture coordinates for easy and fast access. For example, for the normal vector (0.3, -0.4, 0.8), the x and y components are normalized and stored in the Alpha channel, and the z-component is positive, with its sign bit embedded in the least significant bit of the albedo R channel as 1.

[0050] Finally, "the representative sample indexes are stored as two ushort encodings using uint, completing the merging process and two-dimensional textured storage." This index encoding establishes the correspondence between the position of the sample in the texture and the original sample information. Each ushort can store an index value from 0 to 65535. Combining two ushorts into a uint can cover more sample samples, ensuring the uniqueness of the index. After encoding the sample data into a two-dimensional texture, the GPU can efficiently read the sample information using texture caching and parallel texture access mechanisms. For example, during radiometric updates, the GPU's multi-threaded processing can simultaneously access sample data at different locations in the texture, processing speed 2-3 times faster than accessing array format. Simultaneously, textured storage makes the data structure more compact, saving memory space. For example, information such as albedo, normal vectors, and positions, which originally required multiple arrays to store, can now be integrated into a single texture, facilitating management and transmission.

[0051] The above steps optimize and efficiently store the sample set, resulting in two key benefits: first, merging redundant samples reduces the data volume, lowering the computational burden of subsequent steps; second, encoding the sample data into two-dimensional textures fully leverages the GPU's hardware advantages, improving data access and processing efficiency. These optimizations enable real-time global illumination processing to meet higher frame rate requirements while maintaining accuracy, making it particularly suitable for demanding real-time scenarios such as games and virtual reality.

[0052] 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: 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. 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: ; 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).

[0053] 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: ; 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.

[0054] S44, for the object surface sampling sample, obtain the initial emissivity value of the sampling sample and the indirect emissivity value calculated from the previous frame. Extract the contribution value of the indirect emissivity value according to a preset ratio. Combine the initial emissivity value with the sum of the direct emissivity values ​​of the directional light source and the point light source. Determine the fusion weight based on the light source state, and calculate the final emissivity value of the object surface sampling sample using the weighted average formula: ; In the formula, This represents the final emissivity value of a sample taken from the surface of an object. This represents the fusion weights determined based on the light source state. This represents the initial emissivity value of a sampled object surface (from a cube map). This represents the indirect optical radiance value of the preceding frame. This represents the contribution of the indirect radiance value (0.2 is used as an example here; multiplying the indirect radiance value by 0.2 is used to avoid excessive energy accumulation). S45, for the sky sample, obtain the initial sky radiance value and the real-time calculated sky color value of the sample. Based on the dynamically changing fusion weights over time, the final radiance value of the sky sample is obtained by weighting the values, as shown in the formula: ; In the formula, This represents the final emissivity value of the sky sample. This represents the fusion weights that change dynamically over time. This represents the initial radiance value of the sky sample (from the cubemap). This represents the sky light color value calculated in real time.

[0055] As described in steps S41-S45 above, this invention obtains the current light source information, determines the update range of the sampling sample based on the light source type (directional light source or point light source), calculates the direct light contribution of different light sources to the sampling sample, and then combines the initial radiance of the sampling sample, the indirect light radiance of the previous frame, and other information to dynamically update the radiance value of the sampling sample through a weighted fusion mechanism. Furthermore, it adopts a frame-segmentation strategy to optimize the update process, so that the radiance of the sampling sample can reflect the changes in the light source in real time, providing accurate dynamic data support for the subsequent calculation of the irradiance coefficient.

[0056] Since emissivity is a key physical quantity describing the propagation of light in space, its value changes with the state of the light source (such as position, intensity, and type). Movement of the light source leads to changes in the direction and distance of illumination, intensity adjustments directly affect the energy output of the light, and different types of light sources (such as directional and point sources) have different illumination ranges and attenuation characteristics. Therefore, to achieve real-time global illumination, the emissivity values ​​of the sampled data must closely follow changes in the light source state; otherwise, the illumination effect calculated based on outdated emissivity will be out of sync with the actual scene. For example, when a point light source in the scene moves, the light intensity received by the surrounding sampled data will change. If the emissivity is not updated, the areas corresponding to these sampled data will exhibit incorrect brightness. This invention solves the problem of static emissivity failing to adapt to dynamic changes in the light source by using a dynamic update mechanism to ensure that the emissivity of the sampled data always matches the current light source state.

[0057] Specifically: First, "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 in the update range; for point light sources, determine the update range of the radius centered on the point light source location and based on its attenuation radius, and filter out sampled samples within this update range." The light source information here comes from the light source management module, which maintains the scene in real time. This module records the type identifier of each light source (e.g., directional light sources are marked as "DirLight," and point light sources as "PointLight"), three-dimensional spatial coordinates (the position coordinates of the point light source; the direction vector of the directional light source can be derived from its location), and attenuation parameters (the attenuation radius of the point light source, usually preset by the artist based on the light source's influence range, such as setting the attenuation radius of indoor lighting to 5 meters and outdoor searchlights to 20 meters). Because directional light sources have parallel light characteristics, their illumination range is theoretically not limited by distance. Therefore, all sampled samples are included in the update range (in practical applications, scene boundary clipping can be used to avoid invalid calculations for sampled samples outside the scene). The update range of point light sources is based on the attenuation radius. For example, when the attenuation radius is R, the update range radius is set to R. This is because the light intensity of a point light source decreases with the square of the distance. After exceeding the attenuation radius, the light intensity can be ignored. This method can significantly reduce the amount of computation.

[0058] Next, "for the sampled samples within the coverage area of ​​the directional light source, calculate the direct light contribution of the directional light source to that sampled sample," the formula of which is: .in Represents the albedo of the sampled sample within the coverage area of ​​the directional light source. It is derived from the material properties (extracted from the material file of the 3D model) and is used to describe the proportion of light reflected by the surface of the sampled sample. It is the product of the intensity and color of the directional light source, where the intensity is determined by the light source's "brightness" parameter, and the color is determined by the light source's "color temperature" or "RGB value" parameter. The two are multiplied together to obtain the light source's radiation intensity. It is the dot product of the sample normal and the light source direction vector, i.e., the cosine of the angle. Its physical meaning is the degree of coincidence between the surface orientation and the light source direction. The larger the dot product, the more directly the surface faces the light source and the more light it receives. The max function ensures that only the front side is illuminated (the dot product is 0 when it is less than 0 to avoid the back side being incorrectly illuminated). It is a shadow attenuation coefficient calculated by the Exponential Shadow Mapping (ESM) algorithm. This algorithm calculates the attenuation by comparing the depth of the sampled sample with the depth value of the light source's frustum depth buffer and using an exponential function. The value is between 0 and 1, where 1 indicates that the light source is fully illuminated and 0 indicates that the light source is fully in shadow. Compared with traditional shadow mapping, it can reduce shadow jaggedness.

[0059] Then, "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," the formula is as follows. This formula adds to the formula for directional light sources. The distance attenuation term (d is the straight-line distance from the sample to the point light source, calculated using the Euclidean distance formula between two points) is because the light intensity of the point light source follows the inverse square law, meaning the light intensity attenuates faster with increasing distance; the shadow coefficient... The percentage proximity filtering (PCF) algorithm is used to calculate the average shadow coverage as the attenuation coefficient by sampling multiple pixels around the corresponding position of the sample on the shadow map. Compared with ESM, it can generate softer shadows.

[0060] For object surface sampling samples, "the initial emissivity value of the sampling sample and the indirect emissivity value calculated from the previous frame are obtained. The contribution value of the indirect emissivity value is extracted according to a preset ratio. Combined with the initial emissivity value and the sum of the direct emissivity values ​​of the directional light source and the point light source, the fusion weight is determined according to the light source state, and the final emissivity value of the object surface sampling sample is obtained by weighted calculation." The formula is as follows: .in, It is the initial emissivity obtained from the cube map (from the pre-calculated results of static lighting in the scene); It is the indirect light radiance calculated by subsequent steps in the previous frame (stored in the historical data of the sampled samples). Multiplying it by a preset ratio of 0.2 is to avoid the indirect light energy accumulating too much in multiple frame iterations (indirect light is essentially multiple reflections of light, and excessive accumulation will lead to an overly bright scene). The blending weight is dynamically adjusted based on the light source's state—when the light source is stationary. Taking the smaller value results in a higher initial radiance and a higher proportion of historical indirect light, ensuring the stability of the radiance; when the light source moves... A larger value is chosen to allow the newly calculated direct and indirect light contributions to quickly become dominant, ensuring that the emissivity responds promptly to changes in the light source. For example, when the light source suddenly moves, =0.8, the final radiance of the sampled data is mainly determined by the new direct and indirect light, and can be updated within 1-2 frames, avoiding visual delay; while when the light source is stationary, =0.3, the emissivity changes gradually, reducing screen flicker.

[0061] For sky sampling samples, "the initial sky radiance value and the real-time calculated sky color value are obtained from the sampling sample, and the final radiance value of the sky sampling sample is obtained by weighting according to the fusion weight that changes dynamically over time," the formula is as follows. . The initial sky radiance obtained in the previous step (from pre-calculated skybox data); the initial sky radiance is the sky color calculated in real time by an atmospheric scattering model (such as the Henyey-Greenstein model), which calculates the sky color in different directions based on parameters such as solar altitude angle and atmospheric composition (e.g., orange-red near the sun at sunrise, and pale blue at high altitudes). It is a dynamically changing blending weight (range 0.1-0.5) that varies over time, and its value is determined by the rate of time passage, for example, in a fast-paced time lapse effect. Using 0.5 causes the sky light to change rapidly, while in normal time flow... Use 0.1 to ensure a smooth transition. For example, from daytime to dusk, the solar altitude angle decreases, and the calculation is performed in real time. It gradually changed from blue to orange-red. The radiance of the sky sample gradually increases over time, resulting in a smooth transition and a natural effect of sky light variation, avoiding abrupt color changes.

[0062] Through the above steps, dynamic updates of the sampled emissivity are achieved. The update range optimized according to the light source type reduces invalid calculations. The direct light formula designed based on physical laws ensures accuracy. Dynamic weight fusion balances response speed and stability. These technical features together ensure that the sampled emissivity data can always be provided in scenarios with dynamically changing light sources, laying a reliable foundation for subsequent global illumination calculations.

[0063] 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 further includes: S46 divides all sampled samples into multiple computationally balanced units based on the area covered by the lighting probe, according to the rendering frame rate. S47, assign update priorities in ascending order based on the spatial distance between the computing unit and the camera; S48, each frame selects the number of the computing units updated that are dynamically associated with the rendering frame rate, processes the emissivity value of the selected computing unit through parallel computing, and reuses the historical emissivity value data of the unselected computing unit. S49, when a change in the state of the light source is detected to exceed a preset value, the calculation units within the range of influence of the changed light source are immediately marked as high priority and forcibly included in the calculation queue in the next frame; S410, and based on the deviation between the computation time and the target frame time, dynamically adjusts the number of computation units updated in each frame through a negative feedback mechanism to achieve load balancing.

[0064] As described in steps S46-S410 above, the present invention divides the sampled samples into computational units based on the rendering frame rate, allocates update tasks according to priority, dynamically adjusts the number of updates per frame, and combines a forced update mechanism triggered by changes in light source state and a load balancing strategy to achieve efficient scheduling of the sampled sample radiance update process. While ensuring real-time performance, it ensures that the radiance data of key areas is updated in a timely manner, providing stable and timely input for subsequent illumination calculations.

[0065] Updating the radiometrics of sampled data requires computational resources, while real-time rendering scenes have strict frame rate requirements (e.g., 30FPS or 60FPS, corresponding to a maximum allowable frame time of approximately 33ms or 16ms). When the number of sampled data is large (e.g., tens of thousands or even hundreds of thousands), updating all sampled data every frame would far exceed the hardware's processing capabilities, leading to a sharp drop in frame rate or even stuttering. Conversely, if updates are not timely, especially when there is a lack of rapid response to changes in light sources, the lighting effects will lag behind the scene state, affecting realism. Therefore, a sophisticated task scheduling mechanism is needed to find a balance between computational resources and update requirements—controlling the computation time per frame to within limits while ensuring that critical sampled data (such as sampled data near the camera or within the range affected by changes in light sources) are updated first. This is one of the core challenges in achieving real-time global illumination.

[0066] Traditional methods struggle to maintain a stable frame rate when handling such computational scheduling, and important samples within the camera's field of view may experience queuing delays in updates. Furthermore, when the light source changes suddenly, the update of relevant samples cannot be triggered quickly, resulting in a disconnect between lighting effects and light source states. This invention addresses these issues by dynamically dividing computational units, prioritizing based on distance, adjusting the update quantity in relation to the frame rate, and implementing a forced update mechanism when the light source changes. This ensures both frame rate stability and improves the timeliness and relevance of updates.

[0067] Specifically: First, "based on the rendering frame rate, all sampled samples are divided into multiple computationally balanced units according to the coverage area of ​​the light probes." The rendering frame rate here refers to the target frame rate of the current scene (e.g., 60 FPS set by the user). The sampled samples are divided according to the coverage area of ​​the light probes because the coverage area of ​​each light probe is relatively independent (e.g., a spherical area centered on the light probe). Samples within the same area have strong correlation in update tasks, facilitating batch processing. Task balance means that the number of sampled samples in each computational unit is approximately equal (the difference does not exceed 10%). For example, if the total number of sampled samples is 10,000 and the target frame rate is 30 FPS, it may be divided into 4 units (approximately 2,500 sampled samples per unit), ensuring that the computation time of each unit is similar (e.g., approximately 5ms per unit), avoiding situations where a single unit exceeds the time limit due to too many sampled samples. This partitioning method breaks down the massive update task into manageable subtasks, laying the foundation for frame-by-frame processing. At the same time, by utilizing the spatial distribution characteristics of the illumination probes, the update calculations of samples within a unit can share some data (such as the influence parameters of the light source on the area), indirectly improving computational efficiency.

[0068] Next, "update priorities are assigned in ascending order based on 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 sampled samples within the unit) to the camera's position; the smaller the distance, the higher the priority. This is because the area corresponding to the sampled samples within the camera's field of view is the user's current visual focus, and the timeliness of its radiometric updates directly affects the visual experience; while areas far from the camera, even if updated later, are difficult for the user to perceive. For example, in a large indoor scene, when the camera is located in the living room, the computing units in and around the living room have the highest priority and will be updated first, while units in distant locations such as bedrooms and kitchens will be updated later. This strategy maximizes the improvement of visual effects with limited computing resources.

[0069] Then, "each frame selects the number of computational units to be updated dynamically related to the rendering frame rate, processes the radiance values ​​of the selected computational units through parallel computing, and reuses the historical radiance value data of the unselected computational units." The relationship between the number of computational units updated, 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 a full update is completed in 4 frames, ensuring that all units can be updated within a reasonable cycle. Parallel computing is implemented through the multi-threading of the GPU. Each thread processes the radiance update of one sample (such as the direct light contribution calculation and weighted fusion in weight 4). The parallel architecture of the GPU enables it to process hundreds of sample samples simultaneously, greatly reducing the update time of a single unit. Unselected units reuse the radiance value of the most recent frame. Although the data is not the latest, due to the short update cycle (such as 4 frames per cycle) and the priority mechanism that ensures that key areas are updated first, there is no obvious visual delay. For example, if a unit is not selected in the first frame, the emissivity value of the first frame is reused. When it is selected and updated in the second frame, there is only a one-frame interval, the emissivity changes little, and the transition of the image is natural.

[0070] When a change in light source status is detected exceeding a preset value, the computational units within the affected area of ​​the changed light source are immediately marked as high priority and forcibly included in the computation queue in the next frame. The preset values ​​for light source status changes include: light source on / off state switching (e.g., from off to on), intensity adjustment exceeding 15% (e.g., from 1.0 to 1.2), and position movement distance exceeding a preset step size (e.g., 0.5 meters). These thresholds are determined experimentally to avoid unnecessary forced updates triggered by minor changes while ensuring that significant changes are captured promptly. The affected area of ​​a changed light source is determined as follows: for directional light sources, the affected area is the computational units covered by its illumination direction; for point light sources, the affected area is the computational units within a radius of 1.5 times the attenuation radius centered on its position (slightly larger than the normal update range to ensure edge areas are also covered). Units marked as high priority will skip the normal queue and be forcibly updated in the next frame. For example, if a point light source suddenly moves 1 meter, the three computing units around it will be marked. In the next frame, regardless of whether it is their turn, they will be processed first. This ensures that the sampled samples in these units can quickly reflect the changes in emissivity after the light source moves, avoiding the disconnect where the light source has moved but the lighting effect has not changed.

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

[0072] Through the above steps, this invention constructs an adaptive computation scheduling mechanism. Its dynamic partitioning of computational units achieves balanced task allocation; distance-based priority sorting ensures timely updates of visually important regions; K-value adjustment related to frame rate balances update efficiency and real-time performance; a forced update mechanism for changes in light source ensures synchronization between lighting effects and scene states; and a negative feedback load balancing strategy enables the system to operate stably under various hardware and scene conditions. These technical features work together to ensure that the radiance updates of sampled data meet both the frame rate requirements of real-time rendering and accurately respond to scene changes, providing stable and timely foundational data for subsequent irradiance coefficient calculations and real-time rendering, directly improving the reliability and adaptability of real-time global illumination processing.

[0073] In one embodiment of the present invention, the step of generating an irradiance coefficient by integrating and encoding the radiance values ​​using a spherical harmonic function for the sampled sample set covered by each of the illumination probes includes: S51, based on the predetermined spatial coverage of the illumination probe, the sampling samples are filtered. When the number of covered sampling samples is insufficient, the sampling samples are supplemented from the adjacent illumination probes and distance-related weight attenuation is applied.

[0074] S52, for each illumination probe, the irradiance coefficient is calculated by spherical projection integral of the radiance values ​​of the sampled samples within its coverage area using a multi-order spherical harmonic function. The formula is as follows: ; In the formula, Indicates the first Rank Irradiance coefficient, This represents the irradiance conversion factor (which is the conversion factor of the spherical harmonic function from emissivity to irradiance). It represents the total solid angle of a sphere (in steradian degrees) and is used to normalize discretely sampled emissivity values ​​to the full spatial range. This represents the total number of samples involved in the calculation, i.e., the number of valid samples within the coverage area of ​​the illumination probe (including supplementary samples). Indicates the first The final emissivity value updated for each sampled data point. Indicates the first The spherical harmonic basis function value for each sampled direction is a mathematical function describing the weight of that direction in the spherical harmonic function. Indicates the first The polar angle of each sample relative to the illumination probe (the angle between the sample and the Z-axis of the spatial coordinate system where the illumination probe is located). Indicates the first The azimuth angle of each sample relative to the illumination probe (the rotation angle around the Z-axis of the spatial coordinate system where the illumination probe is located).

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

[0076] As described in steps S51-S53 above, this invention, for the sampling sample set covered by each illumination probe, filters and supplements the sampling samples and applies weights, and uses a multi-order spherical harmonic function to perform spherical projection integral calculation on the radiance value of the sampling samples to generate irradiance coefficients, which are then stored and optimized. This compresses the scattered radiance information of the sampling samples into a compact coefficient form, providing efficient and accurate illumination environment description data for the rapid calculation of indirect light contribution during real-time rendering.

[0077] Irradiance describes the total energy of incident light received at a point from all directions and is a core parameter for calculating indirect light reflection from an object's surface. The radiance of a single sample only reflects the light intensity in a specific direction, while a lighting probe needs to characterize the overall lighting environment within its coverage area—that is, the radiance distribution in all directions. Directly storing the radiance data of all samples would consume a large amount of memory and would be difficult to reuse quickly during real-time rendering. Spherical harmonic functions, as orthogonal basis functions on a sphere, can decompose complex radiance distributions into a small number of coefficients (i.e., irradiance coefficients), achieving efficient data compression and reconstruction. This is analogous to using Fourier series to decompose complex waveforms, where a small number of harmonic components can approximate the original signal. Therefore, using spherical harmonic functions to integrally encode the radiance of sampled data is a key method to balance accuracy and efficiency, solving the problem of efficient characterization of radiance distributions.

[0078] This invention addresses these issues specifically by filtering and supplementing sample data, employing multi-order spherical harmonic function integration, and optimizing spatial filtering. This approach ensures the accuracy of the irradiance coefficient while improving its usability in real-time rendering.

[0079] Specifically: First, "samples are selected based on the predetermined spatial coverage of the illumination probe. When the number of covered samples is insufficient, samples are supplemented from adjacent illumination probes with distance-related weight attenuation." The predetermined spatial coverage of the illumination probe is typically a sphere centered on its location (e.g., radius 3-5 meters, set according to scene accuracy requirements). When selecting samples, the distance between the sample location and the illumination probe is calculated, and samples with a distance less than this radius are retained. If the number of samples after selection is less than a preset threshold (e.g., 32), samples are selected from the coverage of the three nearest adjacent illumination probes to supplement them. These adjacent probes are obtained through pre-calculated spatial indexes (e.g., grid-based neighbor lookup). The weight of the supplemented samples decreases linearly with increasing distance from the current probe (e.g., weight is 1 when distance d=0, weight is 0 when d=2 meters), ensuring that the influence of the supplemented samples attenuates reasonably with distance and avoiding the introduction of illumination interference from irrelevant areas. For example, if there are only 20 sampled samples within the coverage area of ​​a certain illumination probe (below the threshold of 32), then 4 sampled samples are introduced from each of the 3 adjacent probes, and weighted by distances of 0.8, 0.5, and 0.3, which both supplements the number of sampled samples and ensures data relevance.

[0080] Next, "For each illumination probe, the irradiance coefficient is calculated by spherical projection integral of the radiance values ​​of the sampled samples within its coverage area using a multi-order spherical harmonic function, as shown in the formula..." The design of this formula is based on the integral properties of spherical harmonic functions: multi-order spherical harmonic functions are usually third-order (l=0,1,2), with a total of 9 basis functions (m from -l to l), which can capture changes in the direction of illumination more precisely than lower-order functions; It is the irradiance conversion factor (e.g.) =3.1415), ( =2.0943), ( =0.7853), used to convert the emissivity integral result into irradiance; is the total solid angle of the sphere, used to normalize the emissivity of discrete samples to the entire space; N is the total number of samples involved in the calculation (including supplementary samples, and the supplementary samples need to be multiplied by weights); It is the final emissivity value after the sample is updated; It is a spherical harmonic basis function, determined by the polar angle of the sampled sample relative to the illumination probe. (Angle with Z-axis) and azimuth angle The rotation angle around the Z-axis is determined, describing the weight of that direction in spherical harmonic space. The integration process involves summing the products of the radiance of all sampled samples and their corresponding basis function values, then multiplying by a normalization coefficient to obtain the irradiance coefficients for each order and index. For example, for basis functions with l=0 and m=0 (corresponding to omnidirectional illumination), the integration result reflects the average light intensity received in that region, while the coefficients with l=1 and m=0 reflect the illumination deviation along the Z-axis. These multi-order coefficients together constitute a complete description of the illumination environment.

[0081] Finally, "the irradiance coefficients are stored in a floating-point texture format according to a three-dimensional spatial distribution, and the difference threshold of the irradiance coefficients of adjacent lighting probes is constrained by spatial filtering." Three-dimensional spatial distribution storage refers to storing the irradiance coefficients of the lighting probes in voxels of a three-dimensional texture according to their X, Y, and Z coordinates in the scene. Each voxel contains 9 coefficients (corresponding to third-order spherical harmonic functions), using floating-point formats such as RGBAHalf to support high dynamic range (HDR) lighting. Spatial filtering is performed by weighted averaging of the coefficients of each lighting probe and its neighboring probes (e.g., 3x3x3 neighborhood filtering) to ensure that the difference in coefficients between adjacent probes does not exceed a preset threshold (e.g., 5%). For example, if a probe has a coefficient of 100 at l=0, the coefficients of adjacent probes should be within the range of 95-105 to avoid obvious lighting boundaries on the object surface due to abrupt changes in coefficients during rendering. This storage method allows the GPU to quickly obtain probe coefficients through texture sampling during real-time rendering, while spatial filtering ensures the spatial continuity of lighting, improving the visual consistency of the image.

[0082] Through the above steps, this invention achieves the transformation from discrete sample radiance to compact irradiance coefficients. Its sample supplementation mechanism ensures integration accuracy, multi-order spherical harmonic functions enhance the richness of the lighting description, and 3D texture storage and spatial filtering optimize coefficient access efficiency and spatial continuity. These technical features directly support efficient calculation of indirect light in the real-time rendering stage—during rendering, only a few irradiance coefficients need to be interpolated and reconstructed to quickly restore the lighting environment. Compared to directly using the original sample radiance, this significantly reduces computational and storage overhead. Simultaneously, filtering improves the smoothness of the lighting effect, serving as a crucial bridge connecting sample updates and real-time rendering.

[0083] In one embodiment of the present invention, during real-time rendering, the steps of interpolating the irradiance coefficients of the surrounding light probes based on the spatial position of the visible pixels on the surface of the 3D model, combining the material properties corresponding to the visible pixels, substituting them into the diffuse reflection physical model to calculate the indirect light diffuse reflection contribution, and then superimposing the direct lighting results to obtain the final pixel lighting color include: S61, select multiple illumination probes adjacent to the visible pixels on the surface of the three-dimensional model by spatial index retrieval.

[0084] 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: ; 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.

[0085] 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: ; 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. This represents the spherical harmonic basis function value corresponding to the surface normal of the visible pixel after interpolation, where is the normal vector of the pixel surface (this function represents the weight distribution of the normal direction in spherical harmonic space).

[0086] S64, obtain the direct lighting result, and mix the direct lighting result with the indirect light diffuse reflection contribution value according to the scene brightness change setting mixing ratio to generate the final pixel lighting color.

[0087] As described in steps S61-S64 above, in the real-time rendering process, the present invention retrieves the lighting probes around the visible pixels and interpolates their irradiance coefficients. Combined with the material properties corresponding to the pixels, the indirect light diffuse reflection contribution is calculated using the diffuse reflection physical model. Then, it is dynamically mixed with the direct lighting result according to the scene brightness to finally obtain a pixel lighting color that conforms to physical laws and is visually natural, thereby realizing the real-time presentation of global lighting effects in the virtual scene.

[0088] The color of visible pixels on an object's surface is ultimately the result of the combined effects of direct light (direct illumination from a light source) and indirect light (ambient reflected light). Direct light can be calculated through direct interaction between the light source and the pixel, while indirect light, due to its complex multipath reflections, is difficult to calculate accurately in real time. The irradiance coefficient, as a compressed representation of ambient lighting by the lighting probe, can provide ambient lighting information for any pixel's location through interpolation. Combined with the material's albedo (describing the surface's reflectivity), the contribution of indirect light can be calculated using a diffuse reflection model. Therefore, the core of weight 7 is to establish a mapping from the irradiance coefficient of the lighting probe to the final pixel color, solving the problem of real-time indirect light calculation. This ensures that the rendering result includes both the contrast of direct lighting and the smooth transition of ambient light, conforming to the human eye's perception of real-world lighting.

[0089] This invention addresses these issues by improving coefficient accuracy through inverse distance squared weighted interpolation, calculating indirect light using a physics-based diffuse reflection model, and combining scene brightness with dynamic mixed lighting results. It significantly enhances the realism of lighting effects while ensuring real-time performance.

[0090] Specifically: First, "multiple lighting probes near the visible pixels on the surface of the 3D model are selected using spatial indexing." Spatial indexing is a pre-built spatial distribution data structure of lighting probes (such as a mesh index or kd-tree), which can quickly locate the surrounding lighting probes based on the spatial coordinates of a visible pixel. The coordinates of the visible pixel come from the vertex shader output in the real-time rendering pipeline (the pixel position obtained after rasterization). During retrieval, the four closest lighting probes are typically selected (the number can be adjusted according to accuracy requirements), and the inclusion of invalid probes is limited by a maximum retrieval radius (e.g., 8 meters)—if there are only two probes within 8 meters of a 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, if a pixel is located in the center of a room, the spatial indexing can quickly find four lighting probes in the four corners of the room, and these probes accurately reflect the ambient lighting at the pixel's location.

[0091] Next, "within the limited maximum search radius, effective illumination probes are selected and coefficient interpolation is performed using the inverse distance squared weighted algorithm, where the weight calculation formula for each illumination probe is..." An effective illumination probe refers to a probe whose distance from a pixel is less than the maximum search radius. The irradiance coefficient is calculated using the Euclidean distance between the pixel coordinates and the light probe coordinates. The principle of inverse distance-squared weighting is that probes closer to a pixel have a greater impact on the pixel's illumination and therefore a higher weight. For example, if a pixel is 2 meters from the first probe and 4 meters from the second probe, the weight of the first probe is 1 / 2² = 0.25, the weight of the second probe is 1 / 4² = 0.0625, and the total weight is 0.3125. Therefore, the normalized weight of the first probe is 0.25 / 0.3125 = 0.8, and the weight of the second probe is 0.2. The interpolated irradiance coefficient is then calculated as: first probe coefficient × 0.8 + second probe coefficient × 0.2. This interpolation method ensures a smooth transition of illumination from one probe to another, avoiding abrupt changes in illumination at probe boundaries.

[0092] Then, "the interpolated irradiance coefficient, combined with the pixel material albedo, is substituted into the diffuse reflection model to calculate the indirect light diffuse reflection contribution value, the formula is..." This formula is based on Lambert's cosine law (ideal diffuse reflection model), where... It is the material albedo corresponding to the pixel (extracted from the material data of the 3D model). It is a normalization coefficient that ensures energy conservation; Represents the nine basis functions for a third-order spherical harmonic function ( =0 to 2, Summing from -l to l); It is the interpolated irradiance coefficient (from the calculation result of the previous step); It 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.

[0093] Finally, "obtain the direct lighting result, and mix the direct lighting result with the indirect light diffuse reflection contribution value according to the scene brightness change setting mixing ratio to generate the final pixel lighting color." The direct lighting result comes from the light source calculation in the real-time rendering pipeline (such as shadow mapping of directional light sources, attenuation calculation of point light sources, etc.), including the intensity and color of the direct illumination from the light source; the scene brightness is obtained by statistically analyzing the average brightness of all pixels in the current frame (such as using Mipmap downsampling for fast calculation). 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 nits), the proportion of direct light is high (such as 70%), and the proportion of indirect light is low (30%), highlighting the direct sunlight effect; when the scene brightness is low (such as indoor candlelight, average brightness < 200 nits), the proportion of indirect light increases (such as 60%), and the proportion of direct light decreases (40%), reflecting the soft lighting of ambient light; intermediate brightness transitions linearly. For example, if a pixel has a direct lighting result of 1.0 and an indirect lighting contribution of 0.5, and the scene brightness is 500 nits (in the middle range), then the mixing ratio is 55% direct light and 45% indirect light. 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 types of lighting, making the image appear natural in different brightness environments.

[0094] The above steps achieve a complete calculation process from the irradiance coefficient of the lighting probe to the final color of the pixel. Spatial indexing and inverse distance interpolation ensure the spatial continuity of lighting, while a physically based diffuse reflection model guarantees the accuracy of indirect lighting calculations. Dynamic blending ratios allow the lighting effects to adapt to different brightness levels. These technical features work together to enable real-time rendered virtual scenes to display both the clear outlines of direct light sources and the smooth transitions of environmental reflections. While ensuring controllable rendering time per frame, this significantly improves the realism of global illumination, directly meeting the real-time high-fidelity rendering needs of fields such as games and virtual reality.

[0095] like Figure 2 As shown, the present invention also provides a real-time global illumination processing method system, comprising: The probe initialization module is used to deploy a network of light probes in a virtual scene, wherein each light probe generates a cube map centered on itself, and the cube map stores the initial emissivity information of the scene; The sampling sample generation module is used to emit a preset number of rays from each of the illumination probe positions based on the initial emissivity information, take the intersection of the rays with the object surface or the sky as sampling samples, and generate a sampling sample set, wherein each sampling sample records the corresponding emissivity value, position, normal and material properties. The sampling sample optimization module is used to optimize the sampling sample set, including merging spatially similar sampling samples and encoding the sampling sample data into a two-dimensional texture; The dynamic illumination update module is used to acquire current light source information and dynamically update the emissivity value of the sampled sample based on the current light source information. A spherical harmonic illumination coding module is used to integrate and encode the radiance value using a spherical harmonic function to generate an irradiance coefficient for the sampled sample set covered by each illumination probe. The real-time indirect lighting rendering module is used to interpolate the irradiance coefficient of the surrounding light probes based on the spatial position of the visible pixels on the surface of the 3D model during real-time rendering. It combines the material properties corresponding to the visible pixels, substitutes them into the diffuse reflection physical model to calculate the contribution of indirect light diffuse reflection, and superimposes the direct lighting results to obtain the final pixel lighting color.

[0096] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, characterized in that the processor executes the computer program to implement the steps of a real-time global illumination processing method.

[0097] The present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the steps of a real-time global illumination processing method.

[0098] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.

[0099] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A real-time global illumination processing method, characterized in that, include: A network of light probes is deployed in a virtual scene, wherein each light probe generates a cube map centered on itself, and the cube map stores the initial emissivity information of the scene; Based on the initial emissivity information, a preset number of rays are emitted from each of the illumination probe positions. The intersections of the rays with the object surface or the sky are used as sampling samples, and a sampling sample set is generated. Each sampling sample records the corresponding emissivity value, position, normal, and material properties. The sample set is optimized by merging spatially similar sample samples and encoding the sample data into a two-dimensional texture. Obtain current light source information, and dynamically update the emissivity value of the sampled sample based on the current light source information; For each of the sampling sample sets covered by the illumination probe, the radiance value is integrated and encoded using a spherical harmonic function to generate an irradiance coefficient; During real-time rendering, based on the spatial position of visible pixels on the surface of the 3D model, the irradiance coefficient of the surrounding light probes is interpolated. Combined with the material properties corresponding to the visible pixels, the contribution of indirect light diffuse reflection is calculated by substituting into the diffuse reflection physical model. The final pixel lighting color is obtained by superimposing the direct lighting results.

2. The real-time global illumination processing method according to claim 1, characterized in that, Based on the emissivity information of the cube map, a predetermined number of rays are emitted from each of the illumination probe positions, and the intersections of the rays with the object surface or the sky are used as sampling samples to generate a sample set. Based on uniformly distributed random numbers, rays are emitted from each of the illumination probes using a spherical uniform sampling function; Acquire 3D model data, and determine the position of the intersection point between the ray and the object surface or sky based on the vertex positions, triangle patch indices, and collision box information in the 3D model data: If the intersection point corresponds to the surface of an object, the vertex normal vector of the triangle facet is used as the normal vector of the sampled sample by coordinate interpolation, and the albedo corresponding to the triangle facet is extracted from the three-dimensional model data as the material property of the sampled sample. If the intersection point corresponds to the sky, then the sky mask is used to mark the sampled data. The face index and UV coordinates of the cube map are determined based on the ray direction vector. Bilinear interpolation is performed on the initial radiance information of several pixels adjacent to the cube map in that direction, and the result is used as the radiance value of the sampled sample. Collect all the sampling samples generated by the illumination probes to form a sampling sample set containing the location, normal, material properties and emissivity value of each sampling sample.

3. The real-time global illumination processing method according to claim 1, characterized in that, The steps for optimizing the sample set include: Traverse all sampled samples and calculate the positional distance and normal vector dot product of any two sampled samples, and filter out redundant sampled sample pairs whose positional distance is less than a first threshold and whose normal vector dot product is greater than a second threshold; Discard redundant sample samples with reversed normal vectors and duplicate sample samples, and retain only representative sample samples; The albedo RGB channels of representative samples are mapped to the RGB channels of a 2D texture; the x and y components of the normal vector are normalized and stored in the texture Alpha channel, and the sign bit of the z component of the normal vector is embedded in the least significant bit of the albedo R channel; the position information of the sampled samples is mapped to the texture U and V coordinates through spherical coordinate transformation and normalized and compressed, and stored independently in the lower half of the texture. The representative sample index is stored as two ushort codes in uint, and the merging process and two-dimensional textured storage are completed.

4. The real-time global illumination processing method according to claim 1, characterized in that, The steps of acquiring current light source information and dynamically updating the emissivity value of the sampled sample based on the current light source information include: 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 in 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 this update range; 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; 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; For the object surface sampling sample, the initial emissivity value of the sampling sample and the indirect light emissivity value calculated from the previous frame are obtained. The contribution value of the indirect light emissivity value is extracted according to a preset ratio. Combined with the initial emissivity value and the sum of the direct light emissivity values ​​of the directional light source and the point light source, the fusion weight is determined according to the light source state, and the final emissivity value of the object surface sampling sample is obtained by weighted calculation. For the sky sample, the initial sky radiance value and the real-time calculated sky color value are obtained. The final radiance value of the sky sample is obtained by weighting the samples according to the fusion weight that changes dynamically over time.

5. The real-time global illumination processing method according to claim 4, characterized in that, The step of acquiring current light source information and dynamically updating the emissivity value of the sampled sample based on the current light source information further includes: Based on the rendering frame rate, all sampled samples are divided into multiple computationally balanced units according to the coverage area of ​​the lighting probe; The update priority is assigned in ascending order based on the spatial distance between the computing unit and the camera; Each frame selects the number of computational units updated that are dynamically associated with the rendering frame rate, processes the emissivity value of the selected computational units through parallel computation, and reuses the historical emissivity value data of the unselected computational units. When a change in the state of a light source is detected to exceed a preset value, the calculation units within the range of the changed light source are immediately marked as high priority and forcibly included in the calculation queue in the next frame. Meanwhile, based on the deviation between the computation time and the target frame time, the number of computation units updated in each frame is dynamically adjusted through a negative feedback mechanism to achieve load balancing.

6. The real-time global illumination processing method according to claim 1, characterized in that, The step of generating an irradiance coefficient by integrating and encoding the radiance values ​​using a spherical harmonic function for the sample set covered by each of the illumination probes includes: Samples are selected based on the predetermined spatial coverage of the illumination probes. When the number of covered samples is insufficient, samples are supplemented from adjacent illumination probes and distance-related weights are applied to attenuate the samples. For each illumination probe, the irradiance coefficient is calculated by spherical projection integral of the radiance values ​​of the sampled samples within its coverage area using a multi-order spherical harmonic function; The irradiance coefficients are stored in a floating-point texture format storage medium according to the three-dimensional spatial distribution, and the difference threshold of the irradiance coefficients of adjacent light probes is constrained by spatial filtering.

7. The real-time global illumination processing method according to claim 1, characterized in that, During real-time rendering, the steps for interpolating the irradiance coefficients of nearby light probes based on the spatial position of visible pixels on the 3D model surface, combining the material properties corresponding to the visible pixels, substituting them into the diffuse reflection physical model to calculate the indirect light diffuse reflection contribution, and then superimposing the direct lighting results to obtain the final pixel lighting color include: Multiple illumination probes adjacent to visible pixels on the surface of the 3D model are selected by spatial index retrieval; Within a limited maximum search radius, effective illumination probes are selected and coefficients are interpolated using an inverse distance squared weighted algorithm. The interpolated irradiance coefficient is combined with the material properties corresponding to the visible pixels and substituted into the diffuse reflection model to calculate the indirect light diffuse reflection contribution value. Obtain the direct lighting result, and mix the direct lighting result with the indirect light diffuse reflection contribution value according to the scene brightness change setting mixing ratio to generate the final pixel lighting color.

8. A real-time global illumination processing method system, used to implement the method according to any one of claims 1 to 7, characterized in that, include: The probe initialization module is used to deploy a network of light probes in a virtual scene, wherein each light probe generates a cube map centered on itself, and the cube map stores the initial emissivity information of the scene; The sampling sample generation module is used to emit a preset number of rays from each of the illumination probe positions based on the initial emissivity information, take the intersection of the rays with the object surface or the sky as sampling samples, and generate a sampling sample set, wherein each sampling sample records the corresponding emissivity value, position, normal and material properties. The sampling sample optimization module is used to optimize the sampling sample set, including merging spatially similar sampling samples and encoding the sampling sample data into a two-dimensional texture; The dynamic illumination update module is used to acquire current light source information and dynamically update the emissivity value of the sampled sample based on the current light source information. A spherical harmonic illumination coding module is used to integrate and encode the radiance value using a spherical harmonic function to generate an irradiance coefficient for the sampled sample set covered by each illumination probe. The real-time indirect lighting rendering module is used to interpolate the irradiance coefficient of the surrounding light probes based on the spatial position of the visible pixels on the surface of the 3D model during real-time rendering. It combines the material properties corresponding to the visible pixels, substitutes them into the diffuse reflection physical model to calculate the contribution of indirect light diffuse reflection, and superimposes the direct lighting results to obtain the final pixel lighting color.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for achieving global illumination of 3D game engine

    CN103995700A

  • 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

  • Data processing method and device and storage medium

    CN116310061A