Surface cache global illumination rendering method based on geometry-illumination feature perception
Through a multi-stage hierarchical clustering algorithm based on geometric-light feature perception, the cache distribution is dynamically regulated, which solves the problems of light leakage and rendering in the existing surface cache rendering methods, and achieves a more accurate global lighting rendering effect.
Patent Information
- Application Number
- CN202510608257.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-07-18
AI Technical Summary
The existing surface cache global lighting rendering method has problems such as light leakage and inaccurate rendering results in complex scenes, mainly due to the lack of light field perception capability of the cache distribution strategy and the reconstruction and blurring of areas with severe lighting changes.
Using a multi-stage hierarchical clustering algorithm based on geometric-light feature perception, we use the clustering lighting complexity and screen space lighting change rate of the scene surface, dynamically regulate the cache distribution, adaptively adjust the cache coverage range, and generate a new surface cache to improve rendering accuracy.
It effectively avoids light leakage, improves the accuracy of indirect lighting reconstruction and lighting adaptability in complex scenes, and achieves more accurate global lighting rendering results.
Smart Images

Figure CN120339490A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to rendering technology, and in particular to a surface cache global illumination rendering method and device based on geometry-illumination feature perception. Background Art
[0002] As a key technology in the field of computer graphics, real-time global illumination technology has important application value in game development, virtual reality, film and television special effects and other fields. The current mainstream real-time global illumination technology is mainly divided into the following categories:
[0003] (1) Pre-calculated radiation transfer scheme: compress scene light transfer data through basis functions such as spherical harmonics to achieve real-time rendering under dynamic environment lighting. Although this type of method can reduce runtime overhead, it has poor adaptability to dynamic changes in the scene, is difficult to handle complex material interactions, and suffers from severe loss of high-frequency lighting details.
[0004] (2) World space probe solution: Use uniformly distributed illumination probes to record scene radiation information and reconstruct indirect illumination through trilinear interpolation. A typical example is the DDGI algorithm, whose core defects are: the uniform distribution strategy of the probes leads to insufficient sampling of high-frequency illumination areas, which easily causes light leakage in geometric mutation areas; visibility judgment relies on the Chebyshev inequality approximation, which will result in incorrect occlusion judgment when the probe depth distribution does not meet the normal assumption;
[0005] (3) Voxelization: The scene lighting information is discretized through a 3D voxel grid, and the indirect lighting is calculated using cone tracing technology. This method has a contradiction between voxel resolution and memory usage, and is prone to light leakage in thin-walled structures and complex surface topology scenes.
[0006] (4) Screen space solution: Reconstruct scene geometry based on the depth buffer and perform indirect lighting calculations through ray stepping. Although this method can avoid the light leakage problem of the world space solution, it has the inherent defect of limited field of view, cannot handle the lighting interaction of objects outside the screen, and has poor timing stability, requiring complex noise reduction processing.
[0007] Surface caching technologies (such as GIBS) that have emerged in recent years attempt to combine the advantages of world space and screen space solutions to distribute lighting sampling points on the surface of objects. However, existing surface caching solutions still have two key defects: first, the cache distribution strategy only considers spatial proximity, which is prone to cache error mixing in complex surface topology areas, resulting in erroneous propagation of indirect lighting on geometrically discontinuous surfaces; second, the cache generation strategy lacks light field perception capabilities, and the uniform coverage radius setting is difficult to adapt to the frequency domain characteristics of the indirect light field. Reconstruction blur is prone to occur in areas with drastic lighting changes, while there is sampling redundancy in flat areas.
[0008] Specifically, in terms of the cache interpolation mechanism, the traditional method uses spatial proximity queries with a fixed radius. When multiple surfaces are spatially proximate but actually have an occlusion relationship, incorrect lighting interpolation will lead to light leakage. In terms of the cache generation strategy, existing methods mostly perform uniform sampling based on screen space coverage rate or depth information, failing to effectively perceive the local complexity of the indirect light field, resulting in the inability to preferentially allocate limited cache resources to high-frequency light field regions and inaccurate rendering results. Summary of the Invention
[0009] Aiming at the problems existing in the prior art, the purpose of the present invention is to provide a geometric-lighting feature-aware surface cache global illumination rendering method and device that can reduce light leakage and have more accurate rendering results.
[0010] To achieve the above invention purpose, the present invention provides the following technical solutions:
[0011] A geometric-lighting feature-aware surface cache global illumination rendering method includes the following steps:
[0012] S1. Preprocess the scene surface, and divide all patches in the scene surface in world space into several clusters;
[0013] S2. For the current frame to be rendered, according to the data stored in the surface cache updated in the previous frame, count all the surface caches belonging to each cluster; wherein, the surface cache stores the basic geometric data, irradiance, coverage radius, and the cluster to which it belongs corresponding to the shading point.
[0014] S3. For each cluster, calculate the lighting complexity of the cluster according to the irradiance stored in all the surface caches of the cluster, and generate the surface cache coverage radius of the cluster, and update it to each surface cache belonging to the cluster; wherein, the more dispersed the irradiance stored in all the surface caches in the cluster, the higher the lighting complexity of the cluster, and the smaller the surface cache coverage radius of the cluster.
[0015] S4. According to the hardware ray tracing technology, calculate the irradiance of each shading point corresponding to the surface cache, and update it to the corresponding surface cache.
[0016] S5. According to the lighting complexity of the cluster to which each pixel in the screen space belongs, calculate the adaptive generation probability of each pixel to generate a new surface cache; wherein, the higher the lighting complexity of the cluster, or the higher the lighting change rate of the pixel, the higher the adaptive generation probability.
[0017] S6. For each pixel in the screen space, calculate the contribution weight of each neighbor surface cache to each pixel based on the basic geometric data and the coverage radius, and accumulate the contribution weights to obtain the coverage rate of each pixel.
[0018] S7. Generate new surface caches at the pixels with the highest adaptive generation probability and at the pixels with the smallest coverage rate and less than a preset threshold.
[0019] S8. Weighted sum the contribution weights of each surface cache to each pixel and the irradiance of the corresponding surface cache to calculate the indirect illumination, calculate the direct illumination, combine the direct illumination and the indirect illumination with the Gbuffer data to generate the global illumination result of the current frame, and return to execute step S2 in the next frame.
[0020] Further, step S1 specifically includes:
[0021] S1.1. Obtain the patch data of the scene surface in world space.
[0022] S1.2. In a three-dimensional Cartesian coordinate system, perform coarse-grained clustering on all patches based on the length of the patch on the maximum axis of the Cartesian coordinate system; where the maximum axis of the Cartesian coordinate system is: the coordinate axis with the largest patch dispersion in the three-dimensional Cartesian coordinate system, and the length of the patch on the maximum axis of the Cartesian coordinate system is specifically: the difference between the maximum value and the minimum value of the value range of the patch on the maximum axis of the Cartesian coordinate system.
[0023] S1.3. Calculate the normal average vector of all vertices of each patch, and convert it to a three-dimensional spherical coordinate system. Perform fine-grained clustering on the coarse-grained clustering result based on the angle of the patch normal average vector on the maximum axis of the spherical coordinate system, and use the fine-grained clustering result as the final clustering result; where the maximum axis of the spherical coordinate system is: the coordinate axis with the largest normal average vector dispersion in the spherical Cartesian coordinate system.
[0024] S1.4. For each patch in each fine-grained cluster, traverse its adjacent patches. If an adjacent patch is not assigned to any cluster, assign it to the current cluster until each patch is assigned to a cluster to complete the clustering.
[0025] Further, step S1.2 includes:
[0026] S1.2.1. Form an initial cluster for all patches and put it into the queue to be processed.
[0027] S1.2.2. Extract a cluster from the queue to be processed, and determine whether the lengths of all patches in the current cluster on the maximum axis of the Cartesian coordinate system are all less than a preset space threshold.
[0028] If so, put the cluster into the coarse-grained cluster set.
[0029] Otherwise, sort all the patches in the current cluster in ascending order of the length of the patch on the maximum axis of the rectangular coordinate system, and take the midpoint as the splitting point to split into two new clusters, and add them to the queue to be processed;
[0030] S1.2.3. Loop and execute S1.2.2 until there are no clusters in the queue to be processed. Take the clusters in the coarse-grained cluster set at this time as the result of the coarse-grained clustering.
[0031] Furthermore, step S1.3 includes:
[0032] S1.3.1. Calculate the normal average vector of all vertices of each patch, and convert it to the three-dimensional spherical coordinate system. From the two coordinate axes of the polar angle θ and the azimuth angle φ, select the coordinate axis with the largest normal average vector dispersion as the maximum axis of the spherical coordinate system;
[0033] S1.3.2. Put all the clusters in the coarse-grained cluster set into the queue to be processed;
[0034] S1.3.3. Extract a cluster from the queue to be processed, and judge whether the angles of the normal average vectors of all the patches in the current cluster on the maximum axis of the spherical coordinate system are all less than the preset normal threshold;
[0035] If so, put the cluster into the fine-grained cluster set;
[0036] Otherwise, judge whether the maximum axis of the spherical coordinate system is the θ axis;
[0037] If so, sort all the patches in the current cluster in ascending order of the angle of the patch normal average vector on the θ axis, and take the midpoint as the splitting point to split into two new clusters, and add them to the queue to be processed;
[0038] Otherwise, sort all the patches in the current cluster in ascending order of the angle of the patch normal average vector on the φ axis, find the two angles with the largest angle difference on the φ axis among every two adjacent patches in the sorted set, take the median angle of these two angles and the median angle + π as the two demarcation points, split the current cluster into two new clusters, and add them to the queue to be processed;
[0039] S1.3.4. Loop and execute S1.3.3 until there are no clusters in the queue to be processed. Take the clusters in the fine-grained cluster set at this time as the result of the fine-grained clustering.
[0040] Furthermore, step S2 specifically includes the steps:
[0041] S2.1. According to the cluster to which it belongs stored in the surface cache, use the cluster cache counter count to perform an atomic accumulation operation on all the surface caches of each cluster in turn;
[0042] S2.2. Use the value of count before accumulation for each cluster as the storage offset value corresponding to the cluster;
[0043] S2.3. Write the cache ID of the corresponding surface cache into the corresponding storage space according to the storage offset value, so that all surface caches of the cluster can be located by reading the cache ID from the storage space during subsequent use.
[0044] Further, step S3 includes:
[0045] S3.1. Calculate the lighting complexity of each cluster according to the irradiance stored in all surface caches within each cluster:
[0046]
[0047] In the formula, V c represents the lighting complexity of a cluster, γ(N) represents the adjustment coefficient, N represents the number of surface caches participating in the calculation, E i is the irradiance stored in surface cache i in the cluster, is the average irradiance, dist() is the Euclidean distance, λ represents a preset constant, and T represents a threshold;
[0048] S3.2. Calculate the coverage radius of the surface caches belonging to the cluster according to the lighting complexity of each cluster according to the following formula:
[0049] R = clamp(R0(w max - αV c ), w min R0, w max R0)
[0050]
[0051] In the formula, R represents the coverage radius of the surface caches belonging to the cluster, clamp(R0(w max - αV c ), w min R0, w max R0) means restricting R0(w max - αV c ) within the range [w min R0, w max R0], α is the sensitivity factor of the cluster lighting complexity, R0 represents the reference radius, Distance represents the distance from the cache corresponding shading point to the camera, w min , w max represent the minimum and maximum radius ratios respectively, Area represents the screen space projection area, Fovy is the vertical field of view angle, and Width and Height are the screen space width and height;
[0052] S3.3. Store the surface cache coverage radius of each cluster into each surface cache belonging to that cluster.
[0053] Further, step S4 includes:
[0054] S4.1. Determine the number of rays allocated to the current frame for each surface cache according to the variance of the irradiance stored in each surface cache;
[0055] S4.2. Use the hardware ray tracing technology to accumulate the radiance of multiple bounces of each allocated ray, and store the ray direction information, probability density function information, and radiance of each ray together in the RayTraceResult buffer;
[0056] S4.3. For each surface cache, locate all the rays of the surface cache, and calculate the irradiance according to the information in the RayTraceResult buffer according to the following formula:
[0057]
[0058] where E i represents the irradiance of surface cache i, N i is the number of rays of surface cache i, L k,i is the radiance of ray k, d k,i is the direction of ray k, n i is the normal vector of surface cache i, and pdf i is the probability density function of ray k.
[0059] Further, step S5 includes:
[0060] S5.1. Calculate the light change rate of each pixel in screen space according to the irradiance stored in the surface cache according to the following formula:
[0061]
[0062] In the formula, D p represents the light change rate of pixel p, i, j are the surface cache indexes covering pixel p, E i , E j respectively represent the irradiance stored in the i-th and j-th surface caches, avg represents taking the average value, and max represents taking the maximum value;
[0063] S5.2. Calculate the adaptive generation probability of each pixel according to the light change rate of each pixel according to the following formula:
[0064] P p = p base ·(1 + β·V c ·S)
[0065] p base = V c · D p
[0066] In the formula, P p represents the adaptive generation probability of generating a new surface cache on pixel p, p base represents the base probability, V c represents the illumination complexity of the cluster to which the current pixel belongs, β represents the randomness fluctuation control constant, and S represents a random number between 0 and 1.
[0067] Furthermore, step S6 includes:
[0068] S6.1. For each pixel in screen space, based on the basic geometric data and the coverage radius, obtain the neighbor surface cache and calculate the contribution weight of each neighbor surface cache to each pixel:
[0069] w g = N s · N p
[0070]
[0071] w t = smoothstep(0, δ, f)
[0072] c p,i = w g · w d · w t
[0073] In the formula, N s is the world space normal of the shading point in the basic geometric data stored in the surface cache, N p is the normal of pixel p in screen space, d is the distance between the shading point and pixel p, R is the coverage radius of the surface cache, f is the number of frames the surface cache exists, δ is a preset constant, w g is the normal weight, w d is the distance weight, w t is the smooth transition weight, smoothstep(0, δ, f) represents making f take a smoothly transitioned value within the range [0, δ], and c p,i represents the contribution weight of surface cache i to pixel p;
[0074] S6.2. Accumulate the contribution weights to obtain the coverage rate of each pixel:
[0075]
[0076] In the formula, C pCoverage of pixel p is denoted as, and the number of neighbor surface caches is denoted as n.
[0077] Furthermore, after step S7, the following steps are also included:
[0078] Obtain the clustering adjacency relationship from the rendering pipeline; among them, the clustering adjacency relationship is calculated in step S1 and stored in the rendering pipeline;
[0079] Write the cluster ID to which the pixel point where the new surface cache is located belongs into the surface cache;
[0080] Sample pixel points within the coverage radius of the new surface cache, and query whether the clusters to which these pixel points belong are neighbors of the cluster to which the current new surface cache belongs according to the clustering adjacency relationship. If so, write the neighbor cluster ID into the surface cache as the cluster to which the current surface cache belongs.
[0081] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0082] 1. There is a light leakage phenomenon in the traditional grid-based surface cache method. The present invention proposes a clustering solution based on surface geometry. By adopting a multi-stage hierarchical clustering algorithm, a balance is achieved between computational efficiency and geometric accuracy, effectively avoiding the light leakage problem caused by incorrect mixing of surface caches and improving the accuracy of indirect illumination reconstruction.
[0083] 2. The present invention dynamically adjusts the cache distribution by quantifying the screen space light change rate and the light complexity of the clustering region. A radius adaptive mechanism based on the clustering light complexity is proposed to narrow the cache coverage range of high-complexity light field regions, achieve more accurate rendering results, and enhance the light adaptability in complex scenes. Description of the Drawings
[0084] Figure 1 is the implementation architecture diagram of the global illumination rendering method for surface cache based on geometric-light feature perception provided by the present invention;
[0085] Figure 2 is the result of hierarchical clustering of the present invention;
[0086] Figure 3 is the comparison result diagram of the indirect light rendering quality between the present invention and the GIBS scheme;
[0087] Figure 4 is the comparison result diagram of the global illumination rendering quality between the present invention and the GIBS scheme
[0088] Figure 5 is the result diagram of the visualization of the clustering light complexity of the present invention;
[0089] Figure 6It is a comparison graph of the influence of the clustering illumination complexity sensitivity factor of the present invention on the global illumination rendering result;
[0090] Figure 7 It is a comparison graph of the influence of the clustering illumination complexity sensitivity factor of the present invention on the pure indirect illumination rendering result. Specific embodiments
[0091] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention.
[0092] Embodiment 1
[0093] The embodiment of the present invention provides a surface cache global illumination rendering method based on geometric-illumination feature perception, as Figure 1 shown, including the following steps:
[0094] S1. Preprocess the scene surface and divide all patches of the scene surface in the world space into several clusters.
[0095] This step specifically includes:
[0096] S1.1. Obtain the patch data of the scene surface in the world space; wherein, this step is performed based on the scene surface that has been divided into several patches, so only the patch data needs to be obtained in this step;
[0097] S1.2. In the three-dimensional rectangular coordinate system, perform coarse-grained clustering on all patches based on the length of the patch on the maximum axis of the rectangular coordinate system; wherein, the maximum axis of the rectangular coordinate system is: the coordinate axis with the largest patch dispersion in the rectangular coordinate system (one of the x, y, and z axes), and the length of the patch on the maximum axis of the rectangular coordinate system is specifically: the difference between the maximum value and the minimum value of the value range of the patch on the maximum axis of the rectangular coordinate system;
[0098] S1.3. Calculate the normal average vector of all vertices of each patch, convert it to the three-dimensional spherical coordinate system, and perform fine-grained clustering on the coarse-grained clustering result based on the angle of the patch normal average vector on the maximum axis of the spherical coordinate system, and use the fine-grained clustering result as the final clustering result; wherein, the maximum axis of the spherical coordinate system is: the coordinate axis with the largest dispersion of the normal average vector in the spherical rectangular coordinate system;
[0099] S1.4. For each patch in each fine-grained cluster, traverse its adjacent patches. If the adjacent patch is not assigned to any cluster, it is assigned to the current cluster until each patch is assigned to a cluster (Cluster), and the clustering is completed, as Figure 2 shown.
[0100] Specifically, step S1.2 includes:
[0101] S1.2.1. Form an initial cluster from the set of all patches and place it in the queue to be processed.
[0102] S1.2.2. Extract a cluster from the queue to be processed and determine whether the lengths of all patches in the current cluster on the maximum axis of the rectangular coordinate system are all less than the preset space threshold.
[0103] If so, place this cluster in the set of coarse-grained clusters.
[0104] Otherwise, sort all the patches in the current cluster in ascending order according to the length of the patch on the maximum axis of the rectangular coordinate system, and take the midpoint as the splitting point to split into two new clusters, and add them to the queue to be processed.
[0105] S1.2.3. Loop through S1.2.2 until there are no clusters in the queue to be processed, and take the clusters in the set of coarse-grained clusters at this time as the result of the coarse-grained clustering.
[0106] Among them, step S1.3 includes:
[0107] S1.3.1. Calculate the normal average vector of all vertices of each patch and convert it to the three-dimensional spherical coordinate system (0 < φ < 2π, ) and select the coordinate axis with the largest normal average vector dispersion from the two coordinate axes of the polar angle θ and the azimuth angle φ as the maximum axis of the spherical coordinate system.
[0108] S1.3.2. Place all the clusters in the set of coarse-grained clusters into the queue to be processed.
[0109] S1.3.3. Extract a cluster from the queue to be processed and determine whether the angles of the normal average vectors of all patches in the current cluster on the maximum axis of the spherical coordinate system are all less than the preset normal threshold; the normal average vector is the average vector of the normals of all vertices of the patch.
[0110] If so, place this cluster in the set of fine-grained clusters.
[0111] Otherwise, determine whether the maximum axis of the spherical coordinate system is the θ axis.
[0112] If so, sort all the patches in the current cluster in ascending order according to the angle of the patch normal average vector on the θ axis, and take the midpoint as the splitting point to split into two new clusters, and add them to the queue to be processed.
[0113] Otherwise, sort all the patches in the current cluster in ascending order of the angle of the average vector of the patch normal on the φ axis. Then, find the two angles with the largest difference in the φ axis between every two adjacent patches in the sorted set. Take the median angle of these two angles and the median angle + π as the two demarcation points, split the current cluster into two new clusters, and add them to the queue to be processed.
[0114] S1.3.4. Loop through S1.3.3 until there are no clusters in the queue to be processed. Take the clusters in the fine-grained cluster set at this time as the result of the fine-grained clustering.
[0115] By subdividing the normal direction in the spherical coordinate system, the direction similarity of irradiance interpolation can be ensured, avoiding the lighting calculation error caused by excessive normal differences.
[0116] Among them, step S1.4 realizes the connectivity division, which can eliminate potential non-continuous surface interference. Specifically, use the breadth-first search or union-find algorithm to perform a connected subgraph division inside the formed clusters according to the patch adjacency relationship. The specific operation is to establish an adjacency list of patches in the cluster, initialize the label array and the cluster index. For each patch in the cluster, traverse its neighbor patches through the queue. If the neighbor patch is not marked, mark it as the current cluster and add it to the queue to continue traversing. Finally, assign a new cluster ID to each patch according to the division result to ensure that the patches in the same cluster are topologically connected and avoid light leakage problems caused by non-continuous surfaces.
[0117] In addition, due to the difference in cache coverage density and interpolation sample inconsistency in the cluster boundary region, obvious cluster boundary artifacts will be caused. In the present invention, the cluster adjacency relationship (two clusters sharing an edge are adjacent clusters) can also be pre-calculated in step S1. During runtime, the cluster adjacency relationship data is passed into the rendering pipeline for subsequent step S7.
[0118] Before step S2 and after step S1, there is also a step: generating screen space geometry data and writing the basic geometry data of each pixel into the Gbuffer, specifically including the world space position, normal, material ID, etc., as well as information such as the cluster ID, the ID of the physical object it belongs to, the ID of the patch it belongs to, and the centroid coordinates.
[0119] S2. For the current frame to be rendered, count all the surface caches belonging to each cluster according to the data stored in the updated surface cache of the previous frame.
[0120] Among them, the surface cache stores the basic geometry data (world space position, normal) of the corresponding shading point, irradiance (long-term and short-term mean, variance, etc. information), coverage radius, and the cluster it belongs to (cluster ID).
[0121] To collect the cache indices existing in the same cluster together for subsequent indexing and interpolation, the specific steps of step S2 are as follows:
[0122] S2.1. According to the data stored in the surface cache, use the cluster cache counter count to perform an atomic accumulation operation on all surface caches of each cluster in turn;
[0123] S2.2. Take the value of count before accumulation for each cluster as the storage offset value of the corresponding cluster; for example, before calculating the first cluster, count is 0, so the storage offset value of the first cluster is 0. If the first cluster has two surface caches, the value of count becomes 2 after accumulation. The value of count before accumulation for the second cluster is 2, that is, the storage offset value of the second cluster is 2; the same applies to other clusters. Subsequently, all surface caches belonging to this cluster can be located according to this storage offset value. Reset the cluster cache counter to prepare for subsequent cache filling counting.
[0124] S2.3. Each thread processes one surface cache, writes the cache ID of the corresponding surface cache into the corresponding storage space according to the storage offset value, and at the same time maintains the current write position through an atomic addition operation to ensure thread-safe data access and avoid competing writes. When used subsequently, all surface caches of this cluster can be located by reading the cache ID from the storage space.
[0125] S3. For each cluster, calculate the lighting complexity of the cluster according to the irradiance stored in all surface caches of the cluster, and generate the surface cache coverage radius of the cluster, and update it to each surface cache belonging to the cluster.
[0126] Among them, the more dispersed the irradiance values stored in all surface caches in the cluster are numerically, the higher the lighting complexity of the cluster is, and the smaller the surface cache coverage radius of the cluster is.
[0127] Specifically, this step includes:
[0128] S3.1. Calculate the lighting complexity of each cluster according to the irradiance stored in all surface caches within each cluster:
[0129]
[0130] In the formula, V c represents the lighting complexity of a cluster, γ(N) represents the adjustment coefficient, N represents the number of surface caches participating in the calculation, and E i is the irradiance stored in surface cache i in this cluster, Let \(I\) be the average irradiance, \(dist()\) be the Euclidean distance, \(\lambda\) represent a preset constant, and \(T\) represent the threshold; the partitioning method of clustering determines its internal geometric consistency. If the indirect light results of each cache vary greatly, there may be sudden changes in light and shadow within the cluster, and the lighting complexity is relatively high. In this step, since the surface caches involved in calculating the lighting complexity of the cluster are restricted, when there are many non-converged caches in the Cluster and few stable caches, the number of samples used to calculate the lighting complexity is too small, and the calculated lighting complexity may not reflect the true situation of the Cluster. Therefore, a regulation coefficient \(\gamma(N)\) is added to the lighting complexity. When the number \(N\) of caches participating in the calculation is less than the threshold \(T\), as \(N\) decreases, the lighting complexity will increase by a certain proportion to give a higher cache allocation priority to the Cluster. In addition, the surface caches participating in the calculation here are limited to those whose irradiance variance converges to a preset small range, because caches with large \(\gamma(N)\) variances do not converge to a relatively stable irradiance, and their irradiance values may be misleading due to noise and cannot be used as a true reflection of the internal lighting complexity of the cluster. Therefore, it will wait for the irradiance of the surface cache to converge before participating in the calculation of the lighting complexity of the cluster.
[0131] S3.2. According to the lighting complexity of each cluster, calculate the coverage radius of the surface cache belonging to the cluster according to the following formula:
[0132] R = clamp(R0(w max -αV c ),w min R0,w max R0)
[0133]
[0134] In the formula, \(R\) represents the coverage radius of the surface cache belonging to the cluster, and clamp(R0(w max -αV c ),w min R0,w max R0) means restricting \(R0(w max -αVc c ) within the range \([w min R0,w max R0]\). \(\alpha\) is the clustering lighting complexity sensitivity factor, \(R0\) represents the reference radius, Distance represents the distance from the cache corresponding shading point to the camera, \(w min \), \(w max represent the minimum and maximum radius ratios respectively, Area represents the screen space projection area, Fovy is the vertical field of view angle, and Width and Height are the screen space width and height;
[0135] S3.3. Store the coverage radius of the surface cache for each cluster into each surface cache belonging to that cluster.
[0136] In this step, an adaptive adjustment mechanism sensitive to lighting complexity is adopted for the cache coverage radius. Traditional surface cache methods usually use a fixed screen space projection size to determine the cache radius. This method does not take into account the differences in lighting complexity in different regions, which easily leads to insufficient reconstruction accuracy in areas with drastic lighting changes and waste of computing resources in areas with gentle lighting. The present invention dynamically adjusts the cache coverage range by monitoring the lighting complexity within the surface cluster. Specifically, when the lighting complexity within a certain cluster area is high, it means that the lighting changes in this area are relatively drastic. At this time, the cache coverage radius of this area will be dynamically shrunk and the cache density will be increased to better capture the details of lighting changes and improve the reconstruction accuracy. This adaptive adjustment mechanism enables the cache density to better match the change level of the local light field, while ensuring the visual continuity of the distant view area, providing a more accurate lighting reconstruction effect for the near-view detail area.
[0137] S4. Calculate the irradiance of the shading point corresponding to each surface cache according to the hardware ray tracing technology and update it to the corresponding surface cache.
[0138] Specifically, this step includes:
[0139] S4.1. Determine the number of rays allocated to each surface cache for the current frame according to the variance of the irradiance stored in each surface cache;
[0140] S4.2. Use the hardware ray tracing technology to determine the mapping relationship between threads and caches according to the pre-allocated number of rays. Starting from the shading point position in the surface cache, emit rays in a random direction along the hemisphere (or the ray-guided optimization direction). In the ClosestHit, probabilistically retain some rays for the next bounce according to the Russian roulette until the maximum depth is reached. When the ray terminates the bounce, use the surface cache system to calculate its final contribution after multiple bounces, and accumulate step by step to obtain the radiance result of this ray. Store the ray direction information, probability density function (PDF) information, and radiance of each ray together in the RayTraceResult buffer;
[0141] S4.3. For each surface cache, locate all the rays of the surface cache and calculate the irradiance according to the information in the RayTraceResult buffer according to the following formula:
[0142]
[0143] where E i represents the irradiance of surface cache i, Ni The number of rays for surface cache i, L k,i The radiance of ray k, d k,i The direction of ray k, n i The normal vector of surface cache i, pdf i The probability density function of ray k.
[0144] S5. Calculate the adaptive generation probability of each pixel to generate a new surface cache according to the lighting complexity of the cluster to which each pixel in the screen space belongs.
[0145] The cache generation strategy in this application establishes a dynamic allocation model based on the light field. By quantifying the lighting change rate of pixel points in the screen space and the lighting complexity of the surface clustering area, a probability-driven cache generation strategy is constructed. Among them, the higher the lighting complexity of the cluster or the higher the lighting change rate of the pixel, the higher the adaptive generation probability.
[0146] S5.1. First, calculate the lighting change rate of pixel points in the screen space to determine the lighting change situation at each position. Then, based on the lighting change rate in the screen space and the cluster lighting complexity, assign a probability of generating a cache to each pixel point. To avoid the limitation that the traditional greedy algorithm is prone to falling into local optimality, a controllable random perturbation factor is introduced in this process. This enables the system to not only give priority to the areas with the most obvious lighting changes when generating caches but also randomly explore other areas to a certain extent, thereby discovering potential lighting change areas. In this way, the caches can be more reasonably distributed in the scene, improving the adaptability to complex light fields. Among them, the lighting change rate of each pixel in the screen space is:
[0147]
[0148] In the formula, D p represents the lighting change rate of pixel p, i, j are the surface cache indices covering pixel p, E i , E j respectively represent the irradiance stored in the i-th and j-th surface caches. Among them, a surface cache covers multiple pixels within the coverage radius, and a pixel may also be covered by multiple surface caches. avg represents taking the average value, and max represents taking the maximum value;
[0149] S5.2. Then, according to the lighting change rate of each pixel, calculate the adaptive generation probability of each pixel according to the following formula:
[0150] P p = p base ·(1 + β·V c ·S)
[0151] p base = Vc ·D p
[0152] Wherein, P p represents the adaptive generation probability of generating a new surface cache on pixel p, p base represents the base probability, V c represents the lighting complexity of the cluster to which the current pixel belongs, β represents the randomness fluctuation control constant, and S represents a random number between 0 and 1. Since it is desired that the higher the lighting complexity of the cluster, the higher the probability of generating a new cache, and the higher the screen space lighting change rate, the higher the probability of generating a cache, the two are combined to obtain p base . However, if only p base is used to select only the largest result each time, the generation strategy will lose its probabilistic nature. Therefore, a random number S between 0 and 1 is introduced and combined with the lighting complexity of the cluster. The higher the lighting complexity, the more randomness is introduced. β is a constant for controlling the amplitude of randomness fluctuation, and thus the adaptive generation probability P of each pixel is obtained p .
[0153] S6. For each pixel in the screen space, based on the basic geometric data and the coverage radius, calculate the contribution weight of each neighbor surface cache to each pixel, and accumulate the contribution weights to obtain the coverage rate of each pixel.
[0154] This step specifically includes:
[0155] S6.1. For each pixel in the screen space, each thread processes one pixel. Based on the basic geometric data and the coverage radius, obtain the neighbor surface cache (specifically retrieve the nearby neighbor surface cache according to the cluster ID information), and calculate the contribution weight of each neighbor surface cache to each pixel:
[0156] w g = N s ·N p
[0157]
[0158] w t = smoothstep(0, δ, f)
[0159] c p,i = w g ·w d ·w t
[0160] Wherein, N s is the world space normal of the shading point in the basic geometric data stored in the surface cache, N pLet \(n_p\) be the normal of pixel \(p\) in screen space, \(d\) be the distance between the shading point and pixel \(p\), \(R\) be the coverage radius of the surface cache, \(f\) be the number of frames the surface cache exists, \(\delta\) be a preset constant, \(w_n\) g be the normal weight, \(w_d\) d be the distance weight, \(w_s\) t be the smooth transition weight, where \(smoothstep(0,\delta,f)\) represents a smoothly transitioned value of \(f\) within the range \([0,\delta]\), and \(w_s\) t is used to alleviate the noise problem caused by insufficient sampling in newly generated caches (\(f\) is small), and the smooth transition is achieved through the \(smoothstep\) function. \(c_i(p)\) p,i represents the contribution weight of surface cache \(i\) to pixel \(p\);
[0161] S6.2. Accumulate (integrate) the contribution weights to obtain the coverage rate of each pixel:
[0162]
[0163] In the formula, \(C_p\) p represents the coverage rate of pixel \(p\), and \(n\) represents the number of neighboring surface caches.
[0164] S7. Generate new surface caches at the pixels with the highest adaptive generation probability and at the pixels with the lowest coverage rate and less than the preset threshold.
[0165] In this step, after packing the coverage rate and the corresponding pixel coordinates into unsigned integers, perform an in-group atomic Min (InterlockedMin) operation. The adaptive generation probability is also packed into an unsigned integer together with the corresponding pixel coordinates. After all threads have finished execution, if the minimum coverage rate is less than the preset threshold, then extract the pixel coordinates, generate a new surface cache at that location, and obtain the clustering adjacency relationship from the rendering pipeline. Calculate the clustering ID information that the new surface cache will be filled with, including the belonging clustering ID and the neighbor clustering ID. Specifically, sample some samples within the radius range of the pixel coordinates and query whether their clustering IDs are neighbors of the current new surface cache clustering ID. If so, then assign the surface cache to the neighbor clustering at the same time, that is, fill the neighbor clustering ID into the surface cache as well. In this way, smooth transition of lighting in the boundary region is achieved. Similarly, generate a new surface cache at the pixel with the highest adaptive probability and calculate the clustering ID information that the new surface cache will be filled with according to the clustering adjacency relationship.
[0166] S8. Weightedly sum the contribution weights of each surface cache to each pixel and the irradiance of the corresponding surface cache to calculate the indirect illumination, and calculate the direct illumination. Combine the direct illumination and the indirect illumination with the Gbuffer data to generate the global illumination result of the current frame, and return to execute step S2 in the next frame.
[0167] Among them, the calculation of direct illumination is prior art and will not be elaborated here.
[0168] The following conducts simulation verification for the present invention.
[0169] The simulation experiment is carried out on a host equipped with a 12th Gen Intel i9-12900KF CPU, 32GB RAM, and an NVIDIA GeForce RTX 3080Ti graphics card.
[0170] Figure 2 Shows the result of hierarchical clustering of the Cornellbox patches of the present invention, where each different color represents a cluster.
[0171] Figure 3 In, due to the existence of thin walls, the GIBS scheme has light leakage to varying degrees on the left and right side walls, and the yellow cache in the upper compartment is wrongly contributed to the adjacent walls in the lower compartment, but the two are topologically separated from each other. Since the partition walls are thin, incorrect radiation propagation is likely to occur. However, in the method of the present invention, since the adjacency relationship between each Cluster is pre-calculated, the walls of the upper and lower compartments do not belong to the adjacency relationship, so there is no case of cache sharing, and the incorrect radiation propagation is correctly blocked.
[0172] Figure 4 Respectively show the results of GIBS, the scheme of the present invention, and path tracing. From the small figure on the right, obvious indirect illumination results reflected on the wall near the wall surface can be observed. The blue and red indirect lights are fused together in the GIBS scheme in the small figure, while they are retained to a large extent in the present scheme. The yellow indirect light in the small figure is contributed by the yellow sofa, and the green indirect light is contributed by the green plants. There is a relatively clear boundary between the two in the Reference, but they are integrated into one in the GIBS with a single radius size. However, due to the adaptive radius of the scheme of the present invention, such boundary details are better retained.
[0173] Figure 5 Shows the visualization of the clustering illumination complexity. The more obvious the red color, the greater the clustering illumination complexity at that place. By comparing with the Reference, it can be observed that the areas with obvious red color are concentrated in the areas where the indirect illumination changes significantly.
[0174] Figure 6 Shows the influence of the clustering illumination complexity sensitivity factor α on the result accuracy. As α increases, more indirect illumination details can be gradually observed on the wall.
[0175] Figure 7It shows the influence of different clustering illumination complexity sensitivity factors α on the results of pure indirect illumination. It can be observed that when α = 0, there is a certain degree of color bleeding artifact in the ground indirect light, and after being adjusted by the clustering illumination complexity sensitivity factor, the color bleeding is alleviated.
[0176] It should be understood that the above embodiments and the descriptions in the specification are only the principles, main features and advantages of the present invention. Without departing from the spirit and scope of the present invention, the present invention will have various changes and improvements, and these changes and improvements all fall within the protection scope of the present invention.
Claims
1. A method for global illumination rendering with surface caching based on geometric - illumination feature perception, characterized in that Including the following steps: S1. Preprocess the scene surface, and divide all patches on the scene surface in world space into several clusters; S2. For the current frame to be rendered, according to the data stored in the surface cache updated in the previous frame, count all surface caches belonging to each cluster; wherein, the surface cache stores the basic geometric data, irradiance, coverage radius and the cluster to which it belongs of the corresponding shading points; S3. For each cluster, calculate the lighting complexity of the cluster according to the irradiance stored in all surface caches of the cluster, and generate the surface cache coverage radius of the cluster, and update it to each surface cache belonging to the cluster; wherein, the more dispersed the irradiance values stored in all surface caches in the cluster are numerically, the higher the lighting complexity of the cluster is, and the smaller the surface cache coverage radius of the cluster is; S4. According to the hardware ray tracing technology, calculate the irradiance of the shading point corresponding to each surface cache, and update it to the corresponding surface cache; S5. Calculate the adaptive generation probability of generating a new surface cache for each pixel according to the lighting complexity of the cluster to which each pixel in screen space belongs; wherein, the higher the lighting complexity of the cluster is, or the higher the lighting change rate of the pixel is, the higher the adaptive generation probability is; S6. For each pixel in screen space, calculate the contribution weight of each neighbor surface cache to each pixel based on the basic geometric data and the coverage radius, and accumulate the contribution weights to obtain the coverage rate of each pixel; S7. Generate a new surface cache at the pixel with the highest adaptive generation probability, and at the pixel with the smallest coverage rate and less than the preset threshold; S8. Perform a weighted sum of the contribution weight of each surface cache to each pixel and the irradiance of the corresponding surface cache to calculate the indirect lighting, and calculate the direct lighting. Combine the direct lighting and the indirect lighting with the Gbuffer data to generate the global lighting result of the current frame, and return to execute step S2 in the next frame.
2. The method for surface caching global illumination rendering based on geometric-illumination feature perception according to claim 1, wherein Step S1 specifically includes: S1.
1. Obtain the patch data of the scene surface in world space; S1.
2. In a three-dimensional rectangular coordinate system, perform coarse-grained clustering on all patches based on the length of the patch on the maximum axis of the rectangular coordinate system; wherein, the maximum axis of the rectangular coordinate system is: the coordinate axis with the largest patch dispersion in the three-dimensional rectangular coordinate system, and the length of the patch on the maximum axis of the rectangular coordinate system is specifically: the difference between the maximum value and the minimum value of the value range of the patch on the maximum axis of the rectangular coordinate system; S1.
3. Calculate the normal average vector of all vertices of each patch, and convert it to a three-dimensional spherical coordinate system. Perform fine-grained clustering on the coarse-grained clustering result based on the angle of the patch normal average vector on the maximum axis of the spherical coordinate system, and use the fine-grained clustering result as the final clustering result; wherein, the maximum axis of the spherical coordinate system is: the coordinate axis with the largest dispersion of the normal average vector in the spherical rectangular coordinate system; S1.
4. For each patch in each fine-grained cluster, traverse its adjacent patches. If the adjacent patch is not assigned to any cluster, divide it into the current cluster until each patch is assigned to a cluster, and the clustering is completed.
3. The method for global illumination rendering with surface caching based on geometric-illumination feature perception according to claim 2, wherein Step S1.2 includes: S1.2.
1. Form an initial cluster from the set of all patches and put it into the queue to be processed. S1.2.
2. Extract a cluster from the queue to be processed, and determine whether the lengths of all patches in the current cluster on the maximum axis of the rectangular coordinate system are all less than the preset space threshold. If so, put the cluster into the coarse-grained cluster set. Otherwise, sort all the patches in the current cluster in ascending order according to the length of the patch on the maximum axis of the rectangular coordinate system, take the midpoint as the splitting point to split into two new clusters, and add them to the queue to be processed. S1.2.
3. Loop through S1.2.2 until there are no clusters in the queue to be processed, and take the clusters in the coarse-grained cluster set at this time as the result of the coarse-grained clustering.
4. The method for surface cache global illumination rendering based on geometric-light feature perception according to claim 2, wherein Step S1.3 includes: S1.3.
1. Calculate the normal average vector of all vertices of each patch, and convert it to the three-dimensional spherical coordinate system. From the two coordinate axes of the polar angle θ and the azimuth angle φ, select the coordinate axis with the largest dispersion of the normal average vector as the maximum axis of the spherical coordinate system. S1.3.
2. Put all the clusters in the coarse-grained cluster set into the queue to be processed. S1.3.
3. Extract a cluster from the queue to be processed, and determine whether the angles of the normal average vectors of all patches in the current cluster on the maximum axis of the spherical coordinate system are all less than the preset normal threshold. If so, put the cluster into the fine-grained cluster set. Otherwise, determine whether the maximum axis of the spherical coordinate system is the θ axis. If so, sort all the patches in the current cluster in ascending order according to the angle of the patch normal average vector on the θ axis, take the midpoint as the splitting point to split into two new clusters, and add them to the queue to be processed. Otherwise, sort all the patches in the current cluster in ascending order according to the angle of the patch normal average vector on the φ axis, find the two angles with the largest difference in the φ axis angle among every two adjacent patches in the sorted set, take the median angle of these two angles and the median angle + π as the two demarcation points, split the current cluster into two new clusters, and add them to the queue to be processed. S1.3.
4. Loop through S1.3.3 until there are no clusters in the queue to be processed, and take the clusters in the fine-grained cluster set at this time as the result of the fine-grained clustering.
5. The method for global illumination rendering of surface caching based on geometric-light feature perception according to claim 1, wherein Step S2 specifically includes the steps: S2.
1. According to the cluster to which it belongs stored in the surface cache, use the cluster cache counter count to perform an atomic accumulation operation on all the surface caches of each cluster in turn. S2.
2. Take the value of count before accumulation for each cluster as the storage offset value corresponding to the cluster. S2.
3. Write the cache ID of the corresponding surface cache into the corresponding storage space according to the storage offset value, so that all the surface caches of the cluster can be located by reading out the cache ID from the storage space during subsequent use.
6. The method for global illumination rendering with surface caching based on geometric-light feature perception according to claim 1, characterized in that Step S3 includes: S3.
1. Calculate the lighting complexity of each cluster according to the irradiance stored in all the surface caches within each cluster. wherein, V c represents the illumination complexity of a cluster, γ(N) represents the adjustment coefficient, N represents the number of surface caches participating in the calculation, and E i is the irradiance stored in the surface cache i in this cluster, is the average irradiance, dist() is the Euclidean distance, λ represents a preset constant, and T represents a threshold; S3.
2. Calculate the surface cache coverage radius of the cluster according to the lighting complexity of each cluster according to the following formula. R = clamp(R0(w max -αV c ), w min R0, w max R0) wherein, R represents the surface cache coverage radius of the clustering, clamp(R0(w max -αV c ), w min R0, w max R0) means restricting R0(w max -αV c ) within the range [w min R0, w max R0], ρ is the clustering illumination complexity sensitivity factor, R0 represents the reference radius, Distance represents the distance from the cached corresponding shaded point to the camera, w min and w max respectively represent the minimum and maximum radius ratios, Area represents the screen space projection area, Fovy is the vertical field of view angle, Width and Height are the screen space width and height; S3.
3. Store the surface cache coverage radius of each cluster into each surface cache belonging to the cluster.
7. The method for global illumination rendering of surface caching based on geometric-illumination feature perception according to claim 1, wherein Step S4 includes: S4.
1. Determine the number of rays allocated to each surface cache for the current frame based on the variance of the irradiance stored in each surface cache; S4.
2. Using hardware ray tracing technology, accumulate the radiance of multiple bounces of each allocated ray, and store the ray direction information, probability density function information, and radiance of each ray together in the RayTraceResult buffer; S4.
3. For each surface cache, locate all the rays of the surface cache, and calculate the irradiance according to the following formula based on the information in the RayTraceResult buffer: Among them, E i represents the irradiance of surface cache i, N i is the number of light rays of surface cache i, L k,i is the radiance of light ray k, d k,i is the direction of light ray k, n i is the normal vector of surface cache i, pdf i is the probability density function of light ray k.
8. The method for global illumination rendering of surface caching based on geometric-illumination feature perception according to claim 1, wherein Step S5 includes: S5.
1. Calculate the light change rate of each pixel in screen space according to the following formula based on the irradiance stored in the surface cache: where D p represents the illumination change rate of pixel p, i and j are the surface cache indices covering pixel p, and E i , E j respectively represent the irradiance stored in the i-th and j-th surface caches, avg represents taking the average value, and max represents taking the maximum value; S5.
2. Calculate the adaptive generation probability of each pixel according to the following formula based on the light change rate of each pixel: P p = p base ·(1 + β·V c ·S) p base = V c · D p Wherein, P p represents the adaptive generation probability of generating a new surface cache on pixel p, p base represents the base probability, V c represents the illumination complexity of the cluster to which the current pixel belongs, β represents the randomness fluctuation control constant, and S represents a random number between 0 and 1.
9. The method for global illumination rendering with surface caching based on geometric-illumination feature perception according to claim 1, wherein Step S6 includes: S6.
1. For each pixel in screen space, obtain the neighbor surface cache based on the basic geometric data and coverage radius, and calculate the contribution weight of each neighbor surface cache to each pixel: w g = N s ·N p w t = smoothstep(0, δ, f) c p,i = w g · w d · w t Where N s is the world space normal of the shading point in the basic geometric data stored in the surface cache, N p is the normal of the pixel p in screen space, d is the distance between the shading point and the pixel p, R is the coverage radius of the surface cache, f is the number of frames in which the surface cache exists, δ is a preset constant, w g is the normal weight, w d is the distance weight, w t is the smooth transition weight, smoothstep(0, δ, f) represents the value obtained by smoothly transitioning f within the range [0, δ], c p,i represents the contribution weight of the surface cache i to the pixel p; S6.
2. Accumulate the contribution weights to obtain the coverage rate of each pixel: where C p represents the coverage rate of pixel p, and n represents the number of neighbor surface caches.
10. The method for global illumination rendering with surface caching based on geometric-light feature perception according to claim 1, wherein After step S7 generates a new surface cache, it also includes: Obtain the clustering adjacency relationship from the rendering pipeline; wherein, the clustering adjacency relationship is calculated in step S1 and stored in the rendering pipeline; Write the cluster ID to which the pixel point where the new surface cache is located belongs into the surface cache; Sample pixel points within the coverage radius of the new surface cache, and query whether the clusters to which these pixel points belong are neighbors of the cluster to which the current new surface cache belongs according to the clustering adjacency relationship. If so, also write the neighbor cluster ID as the cluster to which the current surface cache belongs into the surface cache.