Real-time light and shadow tracking and rendering system for virtual reality environment

By optimizing the light path through light path density field data and inter-frame feature perception analysis, the problem of uneven resource allocation in existing real-time rendering technology is solved, and more accurate light and shadow tracking and stable rendering effects are achieved.

CN120707715AActive Publication Date: 2025-09-26南京宁笙科技有限公司

Patent Information

Application Number
CN202510787833.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-13
Publication Date
2025-09-26
Estimated Expiration
2045-06-13

AI Technical Summary

Technical Problem

Existing real-time rendering technology allocates resources unevenly when processing complex scenes, resulting in loss of rendering details and inaccurate shadow edge processing. The inter-frame feature update strategy is rough, which easily causes flickering and instability.

Method used

The light path density field data is established through the light source reachability pre-calculation module, and the pixel feature intensity value is extracted by combining the inter-frame feature perception analysis module. The adaptive sampling light generation module is used to adjust the sampling point set density, and the inverse step length is set in the light path guided volume ray tracing module to optimize the light path advancement.

Benefits of technology

It improves the recognition accuracy of complex occlusion structures, dynamically adjusts the sampling density, enhances the matching degree of resource allocation, improves the adaptability of dynamic structure modeling in light and shadow space, and reduces resource waste and visual defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120707715A_ABST
    Figure CN120707715A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of real-time rendering, in particular to a real-time light and shadow tracking and rendering system for a virtual reality environment, and the system comprises a light source reachability pre-calculation module which projects a connecting line to a light source to each unit in a three-dimensional grid covering a volume medium based on the scene geometry of the virtual reality environment and the position of the light source. According to the method, the connection line shielding proportion judgment is executed based on the scene geometry and the light source position, the optical path density field data reflecting shielding space distribution is established, and the density representation of illumination reachability is constructed on the voxel level, so that the subsequent light path propulsion has the density sensing capability, and the recognition precision of the complex shielding structure is enhanced. And extracting a normal gradient in the G-Buffer and a brightness variance of a previous frame, fusing an inter-frame geometric boundary change and a brightness fluctuation behavior, constructing a pixel-level feature intensity value set, and writing the pixel-level feature intensity value set into a two-dimensional map for guiding subsequent sampling density regulation and control and realizing local response of cross-frame dynamic information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of real-time rendering technology, and in particular to a real-time light and shadow tracing rendering system for a virtual reality environment. Background Art

[0002] The field of real-time rendering technology focuses on completing the generation and update of images or pictures in a very short time to support the interactive graphics system's demand for real-time response to pictures.

[0003] In existing technologies, image generation mostly relies on uniform sampling of screen space and a fixed step strategy, which leads to uneven resource allocation or loss of rendering details when the sampling density does not match the complexity of the scene. Due to the lack of density estimation of lighting occlusion structures, existing real-time rendering often finds it difficult to adjust the speed of light path advancement according to the occlusion level, resulting in frequent misjudgments in high-occlusion areas, affecting shadow edge processing and transparent area performance. The use of inter-frame features is limited to pixel value difference judgment, and fails to integrate the two-way change clues of geometry and brightness, resulting in a dynamic area update strategy that is too coarse and prone to flickering and instability. Therefore, improvement is needed. Summary of the Invention

[0004] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a real-time light and shadow tracing rendering system for a virtual reality environment.

[0005] To achieve the above objectives, the present invention adopts the following technical solution: A real-time light and shadow tracing rendering system for a virtual reality environment comprises:

[0006] The light source accessibility pre-calculation module, based on the scene geometry and light source position of the virtual reality environment, projects a line to the light source for each unit in the 3D grid covering the volume medium, determines the length ratio of the line that is blocked, and establishes the light path density field data;

[0007] The inter-frame feature perception analysis module extracts the normal gradient of the current frame G-Buffer and the brightness variance of the previous rendered frame to obtain a set of pixel feature intensity values. Based on the set of pixel feature intensity values, it writes them into a two-dimensional map to establish a sampling injection guidance map.

[0008] an adaptive sampling ray generation module that reads the pixel feature intensity value of each pixel in the sampling injection guidance map, adjusts the local point density of the basic sampling pattern according to the pixel feature intensity value to form a non-uniform sampling point distribution in screen space, and establishes an initial tracing ray set based on the non-uniform sampling point distribution in screen space;

[0009] The light path guided volumetric ray tracing module queries the position of each ray in the initial tracing ray set in the light path density field data and obtains the density value, sets a step length inversely proportional to the density value, and obtains a single ray marching strategy. Based on the single ray marching strategy, steps and scattering accumulation are performed along the ray path to generate a frame rendering pixel color matrix.

[0010] Preferably, the steps of acquiring the optical path density field data are:

[0011] Based on the 3D coordinate information of the scene geometry and light source loaded in the virtual reality environment, each voxel in the 3D voxel grid is traversed one by one. A straight line path to the light source is constructed for the center position of each voxel unit. The path is evenly divided into several continuous sampling segments. The occlusion judgment is performed on each spatial position. The physical length of all occlusion segments is counted and recorded to generate a voxel occlusion segment length sequence;

[0012] Calculate the density value based on the sequence of occlusion segment lengths and the complete ray path length for each voxel;

[0013] According to the density value of each voxel unit, the density value is written into the corresponding position in the three-dimensional voxel grid structure as an optical path shielding index to form optical path density field data.

[0014] Preferably, the step of obtaining the pixel feature intensity value set is:

[0015] Extract the normal vectors of all pixels in the G-Buffer of the current frame, and calculate the normal gradient strength of the pixel at each pixel position with a 4-neighborhood window, and call the brightness information of the previous rendered frame image, and calculate the variance of the brightness value at each pixel position with a 4-neighborhood window. Then perform maximum and minimum normalization processing on the normal gradient strength and brightness variance of all pixels respectively, and generate the normalized normal gradient value and normalized brightness variance value of each pixel;

[0016] Calculate the pixel's characteristic intensity value based on the normalized normal gradient value and normalized brightness variance value of each pixel;

[0017] According to the characteristic intensity value of each pixel, it is written into a two-dimensional array with the same size as the current frame image according to the spatial position to generate a set of pixel characteristic intensity values.

[0018] Preferably, the steps of obtaining the sampling injection guidance map are:

[0019] Based on the pixel feature intensity value set, all feature intensity values ​​are extracted pixel by pixel, and the feature intensity value of each pixel is mapped point by point to a corresponding position of a two-dimensional array having the same size as the current frame image according to the horizontal and vertical coordinates of the pixel in the current frame image, to form an initial two-dimensional mapping array;

[0020] Based on the initial two-dimensional mapping array, a predefined spatial neighborhood range is used, with each pixel position as the center, and the feature intensity values ​​of all pixels in the surrounding neighborhood are averaged to smooth and suppress local fluctuations of the feature intensity values, thereby forming a smoothed two-dimensional feature intensity matrix;

[0021] Based on the smoothed two-dimensional feature intensity matrix, the smoothed feature intensity values ​​of all pixels are sequentially written into the two-dimensional map corresponding to the pixel position to complete the establishment of the sampling injection guidance map.

[0022] Preferably, the steps of obtaining the non-uniform distribution of sampling points in screen space are:

[0023] Reading the pixel feature intensity value stored at each pixel position in the sampling injection guidance map, mapping the pixel feature intensity values ​​to the corresponding basic sampling pattern positions in the screen space one by one, and recording the pixel feature intensity value corresponding to each basic sampling pattern position to form an initial local intensity mapping set of the basic sampling pattern;

[0024] Based on the initial local intensity mapping set of the basic sampling pattern, the point set density of each basic sampling pattern position is adjusted one by one according to the pixel feature intensity value. Specifically, based on the predetermined density, if the pixel feature intensity value exceeds a set threshold, the number of sampling points at that position is increased, otherwise the number of sampling points is reduced, thereby forming a sampling point set with adaptive local density adjustment;

[0025] Based on the sampling point set after the local density adaptive adjustment, all the adjusted sampling point sets are distributed according to the coordinate positions of the screen space and written one by one into the corresponding two-dimensional coordinates in the screen space to form a non-uniform sampling point distribution in the screen space.

[0026] Preferably, the steps of obtaining the initial tracing ray set are:

[0027] Based on the non-uniform distribution of sampling points in the screen space, position coordinate data of each sampling point in the two-dimensional coordinate system of the screen is read one by one, and the three-dimensional coordinate position of the camera origin in the world coordinate system of the current rendering scene is determined to form a set of coordinate pairs corresponding to the camera origin and the sampling point position;

[0028] Based on the set of coordinate pairs corresponding to the camera origin and the sampling point positions, the spatial direction vector of each light ray is calculated and constructed point by point, specifically the difference between the coordinates of each sampling point position and the coordinates of the camera origin, and the difference vector is normalized to obtain a unit direction vector to form a set of light ray direction vectors;

[0029] Based on the light direction vector set, with the camera origin coordinates as the common starting point of all light rays, each unit direction vector is combined with the camera origin one by one to form a starting point and direction combination of each light ray, thereby generating an initial tracing light ray set.

[0030] Preferably, the steps of obtaining the single ray marching strategy are:

[0031] Based on the initial tracing ray set, sequentially extracting the spatial starting point position coordinates and direction vectors of each initial tracing ray in the set, calculating and determining the corresponding grid unit position of the initial position of each ray in the three-dimensional grid of the optical path density field data, and generating a density field unit position index of the initial tracing ray;

[0032] Based on the density field unit position index of the initial tracing ray, query the density value recorded at the corresponding unit position in the corresponding optical path density field data for each initial tracing ray one by one, record the density value as the current density data of each ray, and generate a density value set of the initial tracing ray;

[0033] Based on the density value set of the initial tracing rays, and based on the density value of each initial tracing ray obtained, according to the inverse relationship between the step length and the density value, the next travel distance of each ray is determined one by one, and the step length of each ray is recorded in turn to form a single ray travel strategy.

[0034] Preferably, the step of obtaining the frame rendering pixel color matrix is:

[0035] Based on the single ray marching strategy, the initial position and predetermined step length of each ray in the strategy are read one by one, the spatial position is advanced by a fixed distance along the ray direction vector, and the new spatial position after each advancement is gradually calculated to form a single ray position step sequence;

[0036] According to the single ray position stepping sequence, each time the ray advances to a new spatial position, the optical path density field data is called at the current position, the density value of the voxel unit corresponding to the current position is extracted, the scattering contribution value of the current stepping position is determined based on the density value, and all the scattering contribution values ​​on the advancement path of each ray are accumulated in sequence to form a cumulative scattering contribution value corresponding to each ray;

[0037] Based on the cumulative scattering contribution value corresponding to each light ray, each ray is mapped one by one to the screen space sampling point coordinate position corresponding to the initial position of each light ray, pixel color data matching the current rendering frame resolution is generated, and the color data is written one by one into a two-dimensional array to form a frame rendering pixel color matrix.

[0038] Compared with the prior art, the advantages and positive effects of the present invention are:

[0039] In the present invention, by performing line occlusion ratio judgment based on scene geometry and light source position, optical path density field data reflecting the spatial distribution of occlusion is established, and a density representation of illumination accessibility is constructed at the voxel level, so that subsequent light path advancement has density perception ability, and the recognition accuracy of complex occlusion structures is enhanced. The normal gradient and the brightness variance of the previous frame in the G-Buffer are extracted, and the geometric boundary changes and brightness fluctuation behaviors between frames are integrated to construct a pixel-level feature intensity value set, and write it into a two-dimensional map to guide subsequent sampling density regulation and achieve local response of cross-frame dynamic information. The local point set density in the basic sampling pattern is dynamically adjusted according to the pixel feature intensity value, and a non-uniform sampling point distribution is constructed, so that sparse sampling areas avoid resource waste, and high-feature areas obtain fine-grained tracking coverage, thereby enhancing spatial allocation efficiency. Combined with the non-uniform sampling results, a ray tracing path is established, the density information of each step in the optical path density field is queried in real time, and the inverse step length is set. The light automatically slows down in high-density areas and quickly passes through low-density areas, effectively improving the physical rationality of light scattering simulation and the matching degree of computing resource allocation. Achieve highly adaptive modeling of the dynamic structure of light and shadow space under a limited time budget. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a system flow chart of the present invention. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0042] See also Figure 1 The present invention provides a technical solution: a real-time light and shadow tracing rendering system for a virtual reality environment, comprising:

[0043] The light source accessibility pre-calculation module, based on the scene geometry and light source position of the virtual reality environment, projects a line to the light source for each unit in the 3D grid covering the volume medium, determines the length ratio of the line that is blocked, and establishes the light path density field data;

[0044] The inter-frame feature perception analysis module extracts the normal gradient of the current frame G-Buffer and the brightness variance of the previous rendered frame to obtain a set of pixel feature intensity values. Based on the set of pixel feature intensity values, it writes them into a two-dimensional map and establishes a sampling injection guidance map.

[0045] The adaptive sampling ray generation module reads the pixel feature intensity value of each pixel in the sampling injection guidance map, adjusts the local point density of the basic sampling pattern based on the pixel feature intensity value, forms a non-uniform sampling point distribution in screen space, and establishes the initial tracking ray set based on the non-uniform sampling point distribution in screen space;

[0046] The light path guided volumetric ray tracing module queries the position of each ray in the initial tracing ray set in the light path density field data and obtains the density value, sets the step length inversely proportional to the density value, and obtains a single ray marching strategy. Based on the single ray marching strategy, steps and scattering are accumulated along the ray path to generate a frame rendering pixel color matrix.

[0047] The steps for obtaining optical path density field data are as follows:

[0048] Based on the 3D coordinate information of the scene geometry and light source loaded in the virtual reality environment, each voxel in the 3D voxel grid is traversed one by one. A straight line path to the light source is constructed for the center position of each voxel unit. The path is evenly divided into several continuous sampling segments. The occlusion judgment is performed on each spatial position. The physical length of all occlusion segments is counted and recorded to generate a voxel occlusion segment length sequence;

[0049] The density value is calculated based on the occlusion segment length sequence of each voxel and the complete light path length. The calculation formula is:

[0050]

[0051] Among them, Q m Indicates the density value of the mth voxel unit, l k Indicates the length of the kth occlusion segment, L m represents the total length of the straight path from the center point of the mth voxel to the light source, represents the average length of all occlusion segments of the voxel, K is the number of occlusion segments of the voxel, α is the occlusion distribution adjustment coefficient, ∈ is a very small constant to prevent the denominator from being zero, and β is an exponential control factor that enhances the influence of occlusion distribution;

[0052] According to the density value of each voxel unit, the density value is written into the corresponding position in the three-dimensional voxel grid structure as an optical path shielding index to form optical path density field data.

[0053] Specifically, based on the three-dimensional coordinate information of the scene geometry and light source loaded in the virtual reality environment, the system first determines the boundary and resolution of the three-dimensional voxel grid. For example, the bounding box size of the scene is set to a 128x128x128 grid structure. Then, the system starts a three-layer nested loop to traverse all unit voxels in the grid one by one. The loop variable is the index (i, j, k) of the voxel in the three-dimensional grid. In each loop, the world coordinates of the center point of the voxel are calculated according to the index (i, j, k) and the grid resolution, and the three-dimensional coordinates of a known single static light source are obtained. Then, these two three-dimensional coordinate points are used to construct a straight line light path from the voxel center to the light source, and its total length is calculated. Subsequently, the path is lengthened with a fixed step size, for example, 0.05 units. The system discretizes the degree of occlusion to obtain a series of continuous sampling points. For each sampling point on the path, the system performs occlusion judgment by emitting a detection ray from the sampling point to the light source position and performing an intersection test with the triangles of all geometric bodies in the scene. If the ray intersects with any triangle before reaching the light source, the sampling point is determined to be occluded. The system continuously records the number of consecutive occluded sampling points. When an unoccluded sampling point is encountered, the previously accumulated number of consecutive occlusion points is multiplied by a step size of 0.05 to obtain the physical length of an occlusion segment and store it in a dynamic array. This process continues along the complete light path until the end of the path. Finally, all occlusion segment length values ​​recorded in the dynamic array are integrated to generate an occlusion segment length sequence exclusive to the voxel.

[0054] formula: The benefit of the formula is that it not only measures light attenuation by the ratio of the total occlusion length to the path length, but also introduces the standard deviation term of the occlusion segment length, which is controlled by the adjustment coefficient α and the exponential control factor β. This design can distinguish between "a large continuous occlusion" and "multiple small discrete occlusions", two physical scenarios that will produce completely different visual effects (such as hard shadow edges and soft penumbra areas). By quantifying the discrete degree of the distribution of the occluders, the calculated density value can more accurately reflect the scattering and attenuation characteristics of light when passing through the medium, thereby providing a richer and more realistic physical basis for subsequent volumetric ray tracing rendering, and ultimately generating soft shadows and volumetric light effects with smooth transitions and realism.

[0055] l kRepresents the length of the k-th occlusion segment. This parameter is the actual physical length of the continuous occluded segment calculated in the previous steps after step sampling and occlusion judgment on the path from the voxel center to the light source. Its unit is meter. This data is directly derived from the physical occlusion analysis of the scene geometry and reflects the specific size of the obstacle on the light path. For example, when analyzing the m-th voxel, the occlusion segment length sequence is {0.8, 0.2}, then l1 = 0.8 meters, l2 = 0.2 meters.

[0056] L m Represents the total length of the straight path from the center point of the mth voxel to the light source. This parameter is directly calculated by querying and obtaining the 3D world coordinates of the center point of the mth voxel and the 3D world coordinates of the light source, and then applying the Euclidean distance formula in 3D space. The unit is meter. It represents the total distance traveled by the light without any deflection and is the basis for calculating the total occlusion ratio. For example, if the voxel center coordinates are (10.0, 5.0, 8.0) and the light source coordinates are (2.0, 5.0, 20.0), then the total path length L is m The calculation method is:

[0057] Represents the average length of all occlusion segments of the voxel. This parameter is a statistic calculated based on the "voxel occlusion segment length sequence" obtained in the previous step. The specific calculation method is to calculate the length value l of all occlusion segments in the sequence k Add them together and divide them by the total number of occlusion segments K, in meters. It reflects the size of the average obstacle on the light path and is the central moment reference for calculating the discrete degree of occlusion distribution. For example, if the occlusion segment length sequence of a voxel is {0.8, 0.2}, then its average value is

[0058]

[0059] K is the number of occlusion segments of the voxel. This parameter is directly determined by counting the number of elements contained in the "voxel occlusion segment length sequence" generated in the previous step. It is a dimensionless integer representing the number of independent occlusion areas encountered on the light path. The larger the value, the more scattered the occlusion distribution is. For example, if the occlusion segment length sequence of a voxel is {0.8, 0.2}, then the number of its occlusion segments K = 2.

[0060] α is the occlusion distribution adjustment coefficient, which is used to adjust the weight of the influence of the standard deviation of the occlusion length distribution on the final density value. Its setting depends on the scene content and the desired artistic effect. The specific setting process is as follows: First, for a series of representative virtual scenes (for example, a forest with a lot of leaves, an interior with windows, and a city with large buildings), a high-precision rendering method such as path tracing is used to generate a benchmark "golden" image. Then, a set of candidate α values ​​is set, for example, {0.5, 1.0, 1.5, 2.0}, and these scenes are rendered using this system respectively. Then, the multi-scale structural similarity index (MS-SSIM) is used to calculate the similarity score between the rendering results of this system and the benchmark image. The formula is: Where X is the image rendered by this system, and Y is the reference image. The α value that achieves the highest average MS-SSIM score across all test scenes is ultimately selected as the global default configuration. For example, after testing, when α = 1.8, the rendered volumetric light penumbra effect is closest to the reference image and has the highest average MS-SSIM score, so α is set to 1.8.

[0061] ∈ is a very small constant to prevent the denominator from being zero. This is a numerical stability term used to avoid the problem of the average occlusion length when calculating the ratio of the standard deviation to the mean. When the value is zero (i.e., there is no occlusion on the path), a division by zero error occurs, and 1×10 -6 Its value is ∈=0.000001.

[0062] β is an exponential control factor that enhances the influence of occlusion distribution. This factor exponentially scales the occlusion distribution term within the entire bracket, and is used to nonlinearly enhance or weaken the contribution of occlusion discreteness to the final density. When β>1, the density difference between high discreteness (soft edge) and low discreteness (hard edge) will be magnified, and vice versa. The setting process is: provide a real-time adjustment slider to the technical artist, with a range of [0.5, 3.0]. In a test scene containing a variety of representative occluders (such as pillars, grilles, and leaves), the technical artist observes the changes in the volumetric lighting effect in real time by dragging the slider. When the softness of the penumbra area and the clarity of the volumetric light contours reach the requirements that best meet the project's artistic style, the β value is fixed. For example, in order to maintain the hard outline of the solid occluder while making the projection of small objects such as leaves appear softer, the technical artist finally determined the value to be β=1.2.

[0063] Calculation process:

[0064] Taking an m-th voxel as an example, the example values ​​obtained in the above parameter acquisition steps are substituted for calculation.

[0065] The known parameters are as follows:

[0066] The occlusion segment length sequence of the voxel is {0.8, 0.2}, so l1 = 0.8, l2 = 0.2.

[0067] Total path length L m =14.42 meters.

[0068] The number of occlusion segments K=2.

[0069] The average length of the occlusion segment

[0070] The occlusion distribution adjustment coefficient α=1.8.

[0071] A very small constant ∈=0.000001 that prevents the denominator from being zero.

[0072] The exponential control factor for enhancing the occlusion distribution effect is β=1.2.

[0073] First, calculate the standard deviation of the occlusion segment length

[0074]

[0075] Next, substitute all the values ​​into the complete formula to calculate the density value Q m :

[0076]

[0077] The result shows that the density value Q of the m-th voxel unit m It is calculated as 0.1738, which is the light path occlusion index of the voxel. It combines the total occlusion ratio and the discreteness of the occluder distribution. The value itself (0.1738) represents a medium to low occlusion density. In the subsequent light path guided volumetric ray tracing module, when a ray travels to the voxel, the system will query this density value and determine the behavior of the ray in the voxel based on this value. Specifically, a higher density value means stronger light absorption and scattering, which will result in a thicker rendered volumetric light effect and a correspondingly shorter step length for ray tracing. Conversely, a lower density value corresponds to a thinner medium.

[0078] According to the density value of each voxel unit, the system performs a traversal operation to convert all previously calculated voxel density values ​​Q mAccurately fill it into the three-dimensional voxel grid data structure, which is represented in memory as a three-dimensional floating-point array with dimensions exactly the same as the voxel grid resolution of the scene division, for example 128x128x128. For each voxel whose density value is calculated in the second step, the system first obtains its three-dimensional index (i, j, k) in the grid, and then directly assigns the calculated floating-point density value, such as 0.1738, to the element at the [i][j][k] position of the three-dimensional array until the density values ​​of all voxels in the grid are successfully filled. Finally, a complete, static numerical field representing the light accessibility distribution of the entire scene space is constructed in the memory to form the light path density field data.

[0079] The steps for obtaining the pixel feature intensity value set are:

[0080] Extract the normal vectors of all pixels in the G-Buffer of the current frame, and calculate the normal gradient strength of the pixel at each pixel position with a 4-neighborhood window, and call the brightness information of the previous rendered frame image, and calculate the variance of the brightness value at each pixel position with a 4-neighborhood window. Then perform maximum and minimum normalization processing on the normal gradient strength and brightness variance of all pixels respectively, and generate the normalized normal gradient value and normalized brightness variance value of each pixel;

[0081] According to the normalized normal gradient value and normalized brightness variance value of each pixel, the characteristic intensity value of the pixel is calculated. The calculation formula is:

[0082] R i =ln(1+w g g′ i +w σ σ′ i +w gs (g′ i ·σ′ i ));

[0083] Among them, R i Represents the characteristic intensity value of the i-th pixel, g′ i Represents the normalized normal gradient intensity value of the i-th pixel, σ′ i represents the normalized brightness variance of the i-th pixel, w g 、w σ 、w gs are the weighted coefficients of the normal gradient term, the brightness variance term, and the interaction term between the two;

[0084] According to the characteristic intensity value of each pixel, it is written into a two-dimensional array with the same size as the current frame image according to the spatial position to generate a set of pixel characteristic intensity values.

[0085] Specifically, the normal vectors of all pixels in the G-Buffer of the current frame are extracted, and for each pixel on the screen, the following calculations are performed in parallel: First, for the center pixel with coordinates (x, y), its three-dimensional normal vector N(x, y) stored in the G-Buffer is accessed, and the normal vectors of its four adjacent pixels above, below, left, and right are obtained at the same time. Then, the gradient is approximated by calculating the dot product difference between the normal of the center pixel and the normals of the horizontally adjacent pixels, as well as the normals of the vertically adjacent pixels. Specifically, the horizontal gradient component is equal to 1 minus the dot product of the center normal and the right neighbor normal, and the vertical gradient component is equal to 1 minus the dot product of the center normal and the upper neighbor normal. The final normal gradient intensity of the pixel is the square root of the sum of the squares of these two components. At the same time, the system calls the stored brightness of the previous rendered frame Degree information graph, also in the 4-neighborhood window centered on (x, y) (including 5 points in total with the center pixel), calculate the average brightness value of these five pixels, and further calculate the average of the sum of the squares of the difference between the brightness value of each pixel and the average value to obtain the brightness variance of the pixel position. After completing the calculation of the normal gradient intensity and brightness variance of all pixels, the system traverses all normal gradient intensity values ​​of the entire frame to determine the global maximum and minimum values, and performs the same operation on all brightness variance values. Finally, the maximum and minimum normalization formula is applied, that is, (current value - global minimum value) / (global maximum value - global minimum value), and the normal gradient intensity and brightness variance of each pixel are mapped to the range of 0 to 1 respectively, generating the normalized normal gradient value and normalized brightness variance value of each pixel.

[0086] Formula: R i =ln(1+w g g′ i +w σ σ′ i +w gs (g′ i ·σ′ i The benefit of the formula is that it creates a unified pixel-level feature strength metric that identifies screen areas with high rendering resource requirements by combining the normal gradient g′ representing geometric details. i and the brightness variance σ′ representing the temporal and spatial complexity of illumination i , and introduce an interaction term (g′ i ·σ′ i ), this formula can locate areas with both complex geometric structures and dynamic light and shadow changes (such as the changing shadows cast by moving objects on uneven surfaces). These areas are prone to visual artifacts (such as flickering and aliasing). The weighted sum is processed using the logarithmic function ln(1+x), which effectively compresses the dynamic range of the output value and prevents extreme eigenvalues ​​from excessively affecting the overall sampling distribution, making it smoother.

[0087] g′ i Represents the normalized normal gradient strength value of the i-th pixel. This parameter is calculated by the previous step and is a dimensionless floating-point number between 0 and 1. It quantifies the degree of drastic change in the surface geometry within the pixel neighborhood. High values ​​represent object edges, sharp corners, or uneven surface details, while low values ​​correspond to smooth curved surfaces or planes. This value is obtained directly from the previous processing flow without additional calculation. For example, for a pixel on a sharp edge on the screen, its normalized normal gradient strength value is 0.92.

[0088] σ′ i Represents the normalized brightness variance value of the i-th pixel. This parameter is also calculated by the previous step. It is a dimensionless floating-point number between 0 and 1. It quantifies the intensity of brightness changes within the pixel neighborhood and compared with the previous frame. High values ​​represent high-frequency textures, flickering highlights, or dynamically changing shadow areas, while low values ​​correspond to areas with uniform color and brightness. This value is obtained directly from the previous processing flow. For example, for a pixel at the edge of a dynamic flame effect, its normalized brightness variance value may be 0.85.

[0089] w g 、w σ 、w gs are the weighted coefficients of the normal gradient term, the brightness variance term, and the interaction term between the two. These dimensionless coefficients are used to adjust the contribution of the three feature components to the final feature intensity value. The setting basis is to minimize rendering defects and optimize performance. The specific setting process is as follows: First, a set of representative VR scenes (including static fine models, dynamic characters, complex lighting, etc.) are selected, and high-precision offline rendering results are generated for these scenes as the "gold standard". Then, a performance evaluation function P = λ1·(1-SSIM)+λ2·T is established. flicker , where SSIM is the structural similarity index between the current frame and the gold standard frame, T flicker is the average pixel brightness difference between two consecutive frames, which is used to measure the degree of flicker. λ1 and λ2 are meta-weights, which are set to 0.6 and 0.4 respectively in the implementation example. By performing a systematic search (such as Bayesian optimization) within a preset weight range (for example, each coefficient is within [0, 10]), we find the value (w g ,w σ ,w gs ) combination, after optimization tests on 10 typical scenarios, it was found that when w g =3.5, w σ =5.0, w gs = 2.0, the lowest average P value can be obtained while maintaining a high frame rate, so this set of weights is used.

[0090] Calculation process:

[0091] According to the normalized normal gradient value and normalized brightness variance value of each pixel, the characteristic intensity value R of the pixel is calculated i , here we take a specific i-th pixel as an example and substitute the example value obtained in the above parameter acquisition step for calculation.

[0092] The known parameters are as follows:

[0093] Normalized normal gradient intensity value g′ of the i-th pixel i =0.92.

[0094] Normalized brightness variance value σ′ of the i-th pixel i =0.85.

[0095] The weighted coefficient w of the normal gradient term g =3.5.

[0096] The weighted coefficient w of the brightness variance term σ =5.0.

[0097] The weighted coefficient w of the interaction term between the two gs =2.0.

[0098] Substitute all values ​​into the formula to calculate the characteristic intensity value R i :

[0099] R i =ln(1+3.5·0.92+5.0·0.85+2.0·(0.92·0.85));

[0100] =ln(1+3.22+4.25+2.0·0.782);

[0101] =ln(1+3.22+4.25+1.564);

[0102] =ln(10.034);

[0103] ≈2.306;

[0104] The result shows that the characteristic intensity value of the i-th pixel is 2.306. This value is a comprehensive indicator that quantifies the "rendering complexity" or "visual importance" of the pixel position. The higher the value, the more complex the geometry and lighting changes in the area, and the more likely it is to produce rendering defects. Therefore, more computing resources (that is, more sampling rays) are required to ensure rendering quality. A value close to 0 (ln(1)) means that the pixel is in a very flat and stable area, while 2.306 means that this is a very complex area that requires special attention.

[0105] Based on the characteristic intensity value of each pixel, the system starts a data writing process. First, a new two-dimensional memory area is allocated in the video memory of the graphics processing unit (GPU). Its size, for example, is 1920x1080 pixels, which is exactly the same as the image resolution of the current rendering frame. The data format is 32-bit single-precision floating point. Subsequently, a compute shader program is scheduled for execution. The program starts an execution thread for each pixel on the screen. Each thread is responsible for processing one pixel. Specifically, for a pixel with coordinates (x, y), its corresponding thread reads the characteristic intensity value R of the pixel calculated in the previous step. i , the implementation example is 2.306, then, the thread writes this floating-point value directly to the newly allocated two-dimensional memory area at the position with the same coordinates (x, y). Due to the parallel computing architecture of the GPU, this writing process is completed simultaneously for all pixels, thereby efficiently integrating all independent pixel feature intensity values ​​into a single, structured data set, and finally forming a pixel feature intensity value set.

[0106] The steps for obtaining the sampling injection guidance map are:

[0107] Based on the pixel feature intensity value set, all feature intensity values ​​are extracted pixel by pixel, and the feature intensity value of each pixel is mapped point by point to the corresponding position of a two-dimensional array with the same size as the current frame image according to the horizontal and vertical coordinates of the pixel in the current frame image to form an initial two-dimensional mapping array;

[0108] Based on the initial two-dimensional mapping array, a predefined spatial neighborhood range is used. With each pixel position as the center, the feature intensity values ​​of all pixels in the surrounding neighborhood are averaged to smooth and suppress local fluctuations of the feature intensity values, forming a smoothed two-dimensional feature intensity matrix.

[0109] Based on the smoothed two-dimensional feature intensity matrix, the smoothed feature intensity values ​​of all pixels are sequentially written into the two-dimensional map corresponding to the pixel position to complete the establishment of the sampling injection guidance map.

[0110] Specifically, based on the pixel feature intensity value set, a parallel data reorganization operation is started. The operation is implemented by scheduling a compute shader, and a processing thread is assigned to each feature intensity value in the pixel feature intensity value set. Each thread inversely calculates the corresponding two-dimensional pixel coordinates (x, y) based on its one-dimensional index in the set. For example, for a 1920x1080 image, the pixel coordinates of index i are (i / 1920, i / 1920). Subsequently, the thread reads the feature intensity value at index i and writes it directly into a newly created two-dimensional array with the same size as the current frame image (for example, a 1920x1080 floating-point texture). The target location of the write is exactly the (x, y) coordinate just calculated. This process does not involve any numerical calculation or transformation. It simply rearranges the unordered or one-dimensionally stored feature intensity values ​​into a two-dimensional data container with the same topological structure as the screen space according to the spatial position of the pixels. All threads execute this mapping in parallel until all values ​​in the pixel feature intensity value set are copied to the corresponding positions of the new array to form an initial two-dimensional mapping array.

[0111] Based on the initial two-dimensional mapping array, the system uses a predefined spatial neighborhood range to smooth the data in the array. The spatial neighborhood range is set to a 5x5 square kernel. The kernel size is determined based on offline tests in multiple typical virtual reality scenes. The test compares the flicker suppression effect and detail retention of the sample injection guidance map after processing with three kernel sizes of 3x3, 5x5, and 7x7 on the final rendered image. The temporal consistency index and structural similarity index (SSIM) are used for quantitative evaluation. It is finally found that the 5x5 kernel achieves the best balance between effectively smoothing high-frequency noise and retaining necessary geometric edge features. To achieve the best balance, during the specific execution, the system starts a calculation thread for each pixel position in the initial two-dimensional mapping array. The thread takes its own pixel coordinates as the center and reads the feature intensity values ​​of a total of 25 pixels in the 5x5 neighborhood around it. For pixels at the edge of the image, the sampling points outside the neighborhood will use the edge pixel repetition (Clamp-to-Edge) method to obtain the value. Then, the thread calculates the average of these 25 feature intensity values ​​and uses the average as the new value of this center pixel position and writes it into a new output two-dimensional array. After this process traverses all pixels, a smoothed two-dimensional feature intensity matrix is ​​formed.

[0112] Based on the smoothed two-dimensional feature intensity matrix, the system performs the final write and assignment operations, formally establishing the matrix as the sampling injection guidance map for this frame. This process essentially references and binds the data memory area of ​​the smoothed two-dimensional feature intensity matrix calculated and generated in the previous stage in the state machine of the rendering pipeline, that is, setting it as the read-only input texture resource of the subsequent adaptive sampling ray generation module. The system does not make any further modifications or moves to the values ​​in the matrix, but directly submits the complete data block containing the smoothed feature intensity values ​​of all pixels as a whole to the GPU through the instructions of the graphics API. The GPU confirms that the data write operation is completed and marks it as a "sampling injection guidance map". After that, the map will remain unchanged in the remaining rendering process of the current frame, providing a stable and smoothed spatial distribution map reflecting the complexity of screen space rendering for subsequent ray generation, completing the establishment of the sampling injection guidance map.

[0113] The steps to obtain the non-uniform distribution of sampling points in screen space are:

[0114] Read the pixel feature intensity value stored at each pixel position in the sampling injection guidance map, map the pixel feature intensity value to the corresponding basic sampling pattern position in the screen space one by one, and record the pixel feature intensity value corresponding to each basic sampling pattern position to form an initial local intensity mapping set of the basic sampling pattern;

[0115] Based on the initial local intensity mapping set of the basic sampling pattern, the point set density of each basic sampling pattern position is adjusted one by one according to the pixel feature intensity value. Specifically, based on the predetermined density, if the pixel feature intensity value exceeds the set threshold, the number of sampling points at that position is increased, otherwise the number of sampling points is reduced, forming a sampling point set with local density adaptive adjustment;

[0116] Based on the sampling point set adaptively adjusted based on the local density, all the adjusted sampling point sets are distributed according to the coordinate position of the screen space, and are written one by one into the corresponding two-dimensional coordinates in the screen space, forming a non-uniform sampling point distribution in the screen space.

[0117] Specifically, the pixel feature intensity value stored at each pixel position in the sampling injection guidance map is read. The system first divides the screen space into non-overlapping basic sampling pattern grids of size 4x4 pixels. Then, for each basic sampling pattern, the system reads the corresponding pixel feature intensity values ​​of the 16 pixels covered by it in the sampling injection guidance map in parallel, adds these 16 floating-point values ​​and divides them by 16, and calculates the average feature intensity within the basic sampling pattern area. This average value will serve as a single intensity indicator representing the entire 4x4 area. Then, the system records the calculated average feature intensity value and the two-dimensional index of the basic sampling pattern in the screen grid (for example, for the first 4x4 area in the upper left corner of the screen, its index is (0, 0)) as a data pair. This process traverses all 4x4 basic sampling patterns on the screen and generates a corresponding average feature intensity value for each pattern. Finally, all these data pairs are aggregated to form an initial local intensity map set for the basic sampling pattern.

[0118] Based on the initial local intensity map set of the basic sampling pattern, the system first determines a predetermined density as a benchmark. This benchmark is set to generate 4 sampling points for each 4x4 pixel basic sampling pattern. This value is determined by performance analysis of the target VR hardware (refresh rate 90Hz) during the development phase. It aims to ensure that the total number of rays can maintain a stable high frame rate in average complexity scenes. Subsequently, the system calculates a dynamic threshold for decision-making. The specific process is: traverse all the average feature intensity values ​​in the initial local intensity map set of the basic sampling pattern, calculate the global mean and standard deviation of these values, and then set the threshold to "global mean plus 0". 0.5 times the standard deviation", this threshold will change adaptively with the overall complexity of each frame. Next, the system processes each basic sampling pattern one by one, and compares its recorded average feature intensity value with the calculated dynamic threshold. If the average feature intensity value is greater than the threshold, it is determined to be a high-complexity area, and the number of sampling points is increased to 8. If it is less than or equal to the threshold, it is determined to be a low-complexity area, and the number of sampling points is reduced to 2. After determining the number of sampling points, the system sequentially extracts the required number of two-dimensional coordinate points from a preset 16-point low-discrepancy sequence (such as the Halton sequence) covering a 4x4 area, forming a sampling point set after local density adaptive adjustment.

[0119] Based on the sampling point set after local density adaptive adjustment, the system performs a final coordinate generation and aggregation process. First, the total number of sampling points required to be generated after all basic sampling patterns are adjusted is calculated, and a single continuous buffer large enough is allocated on the GPU to store the final two-dimensional coordinates. Then, the system processes each basic sampling pattern in parallel. For a basic sampling pattern located at the grid index (bx, by), the system obtains the sampling point set generated in the previous stage, which contains 2, 4 or 8 local coordinates (ranging from 0 to 4). For each of the local Coordinates (u, v), the system calculates its global floating-point coordinates in screen space, the calculation method is: global X coordinate = bx*4+u+random number, global Y coordinate = by*4+v+random number, where the random number range is between -0.5 and 0.5, which is used to add jitter within the pixel. Then, the system writes the calculated global coordinate pair (global X, global Y) into a pre-allocated single continuous buffer. All basic sampling patterns append their generated global coordinate points to the buffer in parallel until all sampling points are written, forming a non-uniform sampling point distribution in screen space.

[0120] The steps to obtain the initial set of traced rays are:

[0121] Based on the non-uniform distribution of sampling points in screen space, the position coordinate data of each sampling point in the two-dimensional coordinate system of the screen is read one by one, and the three-dimensional coordinate position of the camera origin in the world coordinate system of the current rendering scene is determined to form a set of coordinate pairs corresponding to the camera origin and the sampling point position;

[0122] Based on the coordinate pair set corresponding to the camera origin and the sampling point position, the spatial direction vector of each light ray is calculated and constructed point by point. Specifically, the difference between the position coordinates of each sampling point and the coordinates of the camera origin is normalized to obtain the unit direction vector, forming a set of light direction vectors.

[0123] Based on the light direction vector set, with the camera origin coordinates as the common starting point for all rays, each unit direction vector is combined with the camera origin one by one to form the starting point and direction combination of each ray, and generate the initial tracing ray set.

[0124] Specifically, based on the non-uniform distribution of sampling points in screen space, the system initiates a data pairing parallel processing task. First, it directly reads and locks the camera's 3D world coordinates for this frame from the current rendering state. This coordinate is loaded into the GPU's constant buffer as a common reference point for all subsequent calculations. Subsequently, the system schedules a compute shader whose execution thread number is exactly the same as the total number of sampling points in the non-uniform distribution of sampling points in screen space. Each thread is assigned a unique index and, based on this index, reads a 2D screen coordinate (X, Y) from the buffer storing the non-uniform distribution of sampling points. Next, the thread packages the read 2D screen coordinate (X, Y) with the 3D camera origin coordinate obtained from the constant buffer into a structure and writes this structure to the corresponding index in a new output buffer. This process is executed in parallel for all sampling points and does not involve any coordinate transformation or complex calculation. It simply associates and aggregates the position data of each sampling point with its corresponding, unique camera origin position to form a set of coordinate pairs corresponding to the camera origin and the sampling point position.

[0125] Based on the coordinate pair set corresponding to the camera origin and the sampling point position, the system performs a process of constructing a light direction vector from the two-dimensional screen space to the three-dimensional world space. This process processes each pair of data in the coordinate pair set in parallel through a compute shader. For each coordinate pair, the shader thread first reads the two-dimensional screen coordinates (X, Y) of the sampling point and uses the inverse matrix of the current camera's projection matrix and view matrix to reversely project this two-dimensional screen coordinate into a three-dimensional point in the world space. This three-dimensional point is located on the camera's near clipping plane and corresponds exactly to the sampling point on the screen. Then, the thread reads the three-dimensional world coordinates of the camera origin recorded in the coordinate pair and calculates the vector from the camera origin to the three-dimensional point in the world space just transformed. That is, the coordinates of the camera origin are subtracted from the coordinates of the point on the near clipping plane to obtain an initial direction vector. Finally, the difference vector is normalized, that is, each component is divided by the vector's modulus to obtain a unit direction vector with a length of 1. This unit vector will be written to a new output buffer to form a set of light direction vectors.

[0126] Based on the set of ray direction vectors, the system performs the final assembly of the ray data structure. This process is performed in parallel by a compute shader with the same number of threads as the total number of vectors in the ray direction vector set. First, the system reads and locks the 3D world coordinates of the camera for the current frame from the constant buffer again, which serves as the common starting point for all rays. Next, each shader thread reads a unit direction vector from the buffer of the ray direction vector set according to its unique index. At the same time, the thread also obtains the camera origin coordinates from the constant buffer. The thread then combines these two 3D vectors (origin coordinates and direction vector) into a structure that defines the geometric properties of the ray. The structure contains a field named origin and a field named direction. The thread assigns the camera origin coordinates to the origin field and the read unit direction vector to the direction field. Finally, the complete ray structure is written to the corresponding index in a new, final output buffer. After all threads have completed execution, the output buffer contains the complete definition of all rays to be traced in the scene, generating the initial set of traced rays.

[0127] The steps to obtain a single ray marching strategy are:

[0128] Based on the initial tracing ray set, the spatial starting point position coordinates and direction vectors of each initial tracing ray in the set are extracted in sequence, and the corresponding grid unit position of the initial position of the ray in the three-dimensional grid of the optical path density field data is calculated and determined one by one, and the density field unit position index of the initial tracing ray is generated;

[0129] Based on the density field unit position index of the initial tracing ray, query the density value recorded at the corresponding unit position in the corresponding optical path density field data for each initial tracing ray one by one, record the density value as the current density data of each ray, and generate the density value set of the initial tracing ray;

[0130] Based on the density value set of the initial tracing rays, and taking the density value of each initial tracing ray as the basis, according to the inverse relationship between the step length and the density value, the next travel distance of each ray is determined one by one, and the step length of each ray is recorded in sequence to form a single ray travel strategy.

[0131] Specifically, based on the initial set of traced rays, the system initiates a parallel computing task, assigning a processing thread to each initial traced ray in the set. Each thread first reads its corresponding ray structure from the initial traced ray set and extracts the spatial starting point position coordinates of the ray, which are three-dimensional floating-point vectors in the world coordinate system. Then, the system obtains the metadata of the optical path density field data, including its starting point coordinates in the world coordinate system, the total size of the grid (for example, 128x128x128), and the physical side length of each unit voxel. By subtracting the starting point coordinates of the density field from the starting point coordinates of the ray, dividing each component of the result by the side length of the unit voxel, and rounding down, the integer index (ix, iy, iz) of the three-dimensional grid cell where the ray starting point falls can be calculated. This calculation does not involve complex algorithms, only basic vector and scalar operations. Finally, the thread writes the calculated three-dimensional integer index to a new output buffer, which corresponds one-to-one with the index of the original ray in the set, generating the density field cell position index of the initial traced ray.

[0132] Based on the density field unit position index of the initial tracing ray, the system starts a parallel task of data query and recording, assigning a processing thread to each index in the set. Each thread first reads a three-dimensional integer index (ix, iy, iz) from the density field unit position index buffer of the initial tracing ray according to its own unique ID. Then, the thread uses this three-dimensional index as the address to directly access the three-dimensional texture or three-dimensional array storing the light path density field data, and retrieves the floating-point density value stored at the corresponding position. This query process is hardware-accelerated and extremely fast. After obtaining the density value, the thread records this density value as a new data item in a buffer specifically used to store the current state of the light. The buffer reserves storage space for each ray, and the recorded position is consistent with the original order of the ray in the initial tracing ray set. After all threads are executed in parallel, the buffer completely contains the starting density information of each initial tracing ray, generating a set of density values ​​for the initial tracing ray.

[0133] Based on the initial set of traced ray density values, the system performs a parallel task of calculating the ray step length. A processing thread is assigned to each density value in the set. Each thread first reads its corresponding initial density value and then determines the next distance traveled by the ray based on a preset inverse relationship between the step length and the density value. This relationship is expressed by the formula To define, where S is the step length, D is the density value queried, C is a basic step constant, ∈ is a very small constant to prevent division by zero (for example, 1×10 -6), the basic step constant C is set based on the average scale and performance requirements of the scene. The setting process is as follows: in the development stage, a standard test scene is selected, and the performance-quality curve is drawn by adjusting the C value (for example, from 0.01 to 1.0) and measuring the rendering time and final image quality (compared with the high-precision offline rendering results). The C value at the "inflection point" of the curve is selected, which provides the best performance while ensuring that the rendering quality does not have obvious visual defects (such as striped faults). For example, after testing, it is determined that C = 0.25 is the best value. After calculating the step length, the thread writes the floating-point value to a new output buffer, which is specifically used to store the marching strategy of each ray to form a single ray marching strategy.

[0134] The steps to obtain the frame rendering pixel color matrix are:

[0135] Based on the single ray marching strategy, the initial position and predetermined step length of each ray in the strategy are read one by one, the spatial position is advanced by a fixed distance along the ray direction vector, and the new spatial position after each advancement is gradually calculated to form a single ray position step sequence;

[0136] According to the single ray position step sequence, each time it advances to a new spatial position, the optical path density field data is called at the current position, the density value of the voxel unit corresponding to the current position is extracted, and the scattering contribution value of the current step position is determined based on the density value. All scattering contribution values ​​on each ray advancement path are accumulated in sequence to form the cumulative scattering contribution value corresponding to each ray;

[0137] Based on the cumulative scattering contribution value corresponding to each light ray, it is mapped one by one to the screen space sampling point coordinate position corresponding to the initial position of each light ray, and pixel color data matching the current rendering frame resolution is generated. The color data is written one by one into the two-dimensional array to form a frame rendering pixel color matrix.

[0138] Specifically, based on the single ray marching strategy, the system starts a parallel ray stepping compute shader and assigns a processing thread to each ray. Each thread first reads its corresponding ray data from the initial tracing ray set, obtains its three-dimensional space starting position coordinates and unit direction vector, and at the same time, reads the fixed step length predetermined for the ray from the single ray marching strategy, initializes a current position variable in the thread as the starting position of the ray, and starts a loop. The number of executions of the loop is limited by a preset maximum number of steps, for example 128 steps. The setting of the upper limit value is a trade-off between performance and rendering distance. The result is designed to ensure that the light does not travel infinitely in the scene while covering most of the visible volumetric light effects. In each iteration of the loop, the system calculates the new spatial position of the light after it is advanced by multiplying the unit direction vector by the step length and adding the result to the current position. This new three-dimensional coordinate point is appended to a dynamic array dedicated to the light. The loop will continue until the maximum number of steps of 128 is reached, or the current position of the light exceeds the three-dimensional boundary of the light path density field data. After the loop ends, the dynamic array constitutes the complete travel path of this light, forming a single light position step sequence.

[0139] According to the single-ray position step sequence, the system executes a parallel scattering accumulation calculation shader, assigns a processing thread to each ray, initializes a four-component floating-point vector (RGBA) in each thread as the cumulative scattering contribution value, and initializes a floating-point number as the light transmittance, and its initial value is 1.0. Then, the thread traverses each three-dimensional space position point in the single-ray position step sequence corresponding to the ray. At each point, the system first converts the world coordinates of the point into a three-dimensional grid index in the light path density field data, and uses the index to query the density value of the current position from the density field. Then, according to the The density value calculates the scattering contribution value of the current step position. The calculation method is to multiply the density value, the length of the current step, a global illumination color vector determined by the color of the scene's main light source, and a preset scattering coefficient (for example, 0.15, this coefficient is set by the artist to adjust the overall brightness of the volumetric light). The resulting color value is then multiplied by the current light transmittance, and this final result is added to the cumulative scattering contribution value. After that, the system will update the light transmittance and multiply it by an attenuation factor calculated based on the current density and step length. This process is repeated along the entire path until all step points are traversed, forming a cumulative scattering contribution value corresponding to each light.

[0140] Based on the cumulative scattering contribution value corresponding to each light, the system performs a two-stage color parsing process to generate the final image. In the first stage, the system clears a floating-point color accumulation buffer (initialized to all black) with the same resolution as the rendered frame and an integer sample count buffer of the same size (initialized to all zero). Then, a compute shader is started to assign a processing thread to each light. The thread reads the corresponding cumulative scattering contribution value and obtains the screen space sampling point coordinates corresponding to the light when it was initially generated. By rounding the coordinates, the pixel position (px, py) to which it belongs is determined. Then, the thread uses an atomic addition operation to add the cumulative scattering contribution The value (a color vector) is safely added to the pixel at the (px, py) position in the color accumulation buffer, and the count value of the sampling count buffer at the (px, py) position is increased by one using an atomic increment operation. In the second stage, when the contributions of all rays are accumulated, the system starts the second compute shader, which assigns a thread to each pixel on the screen. The thread reads the values ​​of the color accumulation buffer and the sampling count buffer at the corresponding pixel position. If the count value is greater than zero, the accumulated color value is divided by the count value to obtain the average color of the pixel. Finally, the averaged color data is written one by one into a two-dimensional array to form a frame rendering pixel color matrix.

Claims

1. A real-time light and shadow tracing rendering system for a virtual reality environment, characterized in that: The system comprises: The light source accessibility pre-calculation module, based on the scene geometry and light source position of the virtual reality environment, projects a line to the light source for each unit in the 3D grid covering the volume medium, determines the length ratio of the line that is blocked, and establishes the light path density field data; The inter-frame feature perception analysis module extracts the normal gradient of the current frame G-Buffer and the brightness variance of the previous rendered frame to obtain a set of pixel feature intensity values. Based on the set of pixel feature intensity values, it writes them into a two-dimensional map to establish a sampling injection guidance map. an adaptive sampling ray generation module that reads the pixel feature intensity value of each pixel in the sampling injection guidance map, adjusts the local point density of the basic sampling pattern according to the pixel feature intensity value to form a non-uniform sampling point distribution in screen space, and establishes an initial tracing ray set based on the non-uniform sampling point distribution in screen space; The light path guided volumetric ray tracing module queries the position of each ray in the initial tracing ray set in the light path density field data and obtains the density value, sets a step length inversely proportional to the density value, and obtains a single ray marching strategy. Based on the single ray marching strategy, steps and scattering accumulation are performed along the ray path to generate a frame rendering pixel color matrix.

2. The real-time light tracing and rendering system for a virtual reality environment according to claim 1, characterized in that: The steps for obtaining the optical path density field data are as follows: Based on the 3D coordinate information of the scene geometry and light source loaded in the virtual reality environment, each voxel in the 3D voxel grid is traversed one by one. A straight line path to the light source is constructed for the center position of each voxel unit. The path is evenly divided into several continuous sampling segments. The occlusion judgment is performed on each spatial position. The physical length of all occlusion segments is counted and recorded to generate a voxel occlusion segment length sequence; Calculate the density value based on the sequence of occlusion segment lengths and the complete ray path length for each voxel; According to the density value of each voxel unit, the density value is written into the corresponding position in the three-dimensional voxel grid structure as an optical path shielding index to form optical path density field data.

3. The real-time light tracing and rendering system for a virtual reality environment according to claim 1, wherein: The steps of obtaining the pixel feature intensity value set are: Extract the normal vectors of all pixels in the G-Buffer of the current frame, and calculate the normal gradient strength of the pixel at each pixel position with a 4-neighborhood window, and call the brightness information of the previous rendered frame image, and calculate the variance of the brightness value at each pixel position with a 4-neighborhood window. Then perform maximum and minimum normalization processing on the normal gradient strength and brightness variance of all pixels respectively, and generate the normalized normal gradient value and normalized brightness variance value of each pixel; Calculate the pixel's characteristic intensity value based on the normalized normal gradient value and normalized brightness variance value of each pixel; According to the characteristic intensity value of each pixel, it is written into a two-dimensional array with the same size as the current frame image according to the spatial position to generate a set of pixel characteristic intensity values.

4. The real-time light tracing and rendering system for a virtual reality environment according to claim 1, wherein: The steps for obtaining the sampling injection guidance map are: Based on the pixel feature intensity value set, all feature intensity values ​​are extracted pixel by pixel, and the feature intensity value of each pixel is mapped point by point to a corresponding position of a two-dimensional array having the same size as the current frame image according to the horizontal and vertical coordinates of the pixel in the current frame image, to form an initial two-dimensional mapping array; Based on the initial two-dimensional mapping array, a predefined spatial neighborhood range is used, with each pixel position as the center, and the feature intensity values ​​of all pixels in the surrounding neighborhood are averaged to smooth and suppress local fluctuations of the feature intensity values, thereby forming a smoothed two-dimensional feature intensity matrix; Based on the smoothed two-dimensional feature intensity matrix, the smoothed feature intensity values ​​of all pixels are sequentially written into the two-dimensional map corresponding to the pixel position to complete the establishment of the sampling injection guidance map.

5. The real-time light tracing and rendering system for a virtual reality environment according to claim 1, characterized in that: The steps for obtaining the non-uniform distribution of sampling points in screen space are as follows: Reading the pixel feature intensity value stored at each pixel position in the sampling injection guidance map, mapping the pixel feature intensity values ​​to the corresponding basic sampling pattern positions in the screen space one by one, and recording the pixel feature intensity value corresponding to each basic sampling pattern position to form an initial local intensity mapping set of the basic sampling pattern; Based on the initial local intensity mapping set of the basic sampling pattern, the point set density of each basic sampling pattern position is adjusted one by one according to the pixel feature intensity value. Specifically, based on the predetermined density, if the pixel feature intensity value exceeds a set threshold, the number of sampling points at that position is increased, otherwise the number of sampling points is reduced, thereby forming a sampling point set with adaptive local density adjustment; Based on the sampling point set after the local density adaptive adjustment, all the adjusted sampling point sets are distributed according to the coordinate positions of the screen space and written one by one into the corresponding two-dimensional coordinates in the screen space to form a non-uniform sampling point distribution in the screen space.

6. The real-time light tracing and rendering system for a virtual reality environment according to claim 1, characterized in that: The steps for obtaining the initial set of traced rays are: Based on the non-uniform distribution of sampling points in the screen space, position coordinate data of each sampling point in the two-dimensional coordinate system of the screen is read one by one, and the three-dimensional coordinate position of the camera origin in the world coordinate system of the current rendering scene is determined to form a set of coordinate pairs corresponding to the camera origin and the sampling point position; Based on the set of coordinate pairs corresponding to the camera origin and the sampling point positions, the spatial direction vector of each light ray is calculated and constructed point by point, specifically the difference between the coordinates of each sampling point position and the coordinates of the camera origin, and the difference vector is normalized to obtain a unit direction vector to form a set of light ray direction vectors; Based on the light direction vector set, with the camera origin coordinates as the common starting point of all light rays, each unit direction vector is combined with the camera origin one by one to form a starting point and direction combination of each light ray, thereby generating an initial tracing light ray set.

7. The real-time light tracing and rendering system for a virtual reality environment according to claim 1, wherein: The steps for obtaining the single ray marching strategy are: Based on the initial tracing ray set, sequentially extracting the spatial starting point position coordinates and direction vectors of each initial tracing ray in the set, calculating and determining the corresponding grid unit position of the initial position of each ray in the three-dimensional grid of the optical path density field data, and generating a density field unit position index of the initial tracing ray; Based on the density field unit position index of the initial tracing ray, query the density value recorded at the corresponding unit position in the corresponding optical path density field data for each initial tracing ray one by one, record the density value as the current density data of each ray, and generate a density value set of the initial tracing ray; Based on the density value set of the initial tracing rays, and based on the density value of each initial tracing ray obtained, according to the inverse relationship between the step length and the density value, the next travel distance of each ray is determined one by one, and the step length of each ray is recorded in turn to form a single ray travel strategy.

8. The real-time light tracing and rendering system for a virtual reality environment according to claim 1, wherein: The steps for obtaining the frame rendering pixel color matrix are: Based on the single ray marching strategy, the initial position and predetermined step length of each ray in the strategy are read one by one, the spatial position is advanced by a fixed distance along the ray direction vector, and the new spatial position after each advancement is gradually calculated to form a single ray position step sequence; According to the single ray position stepping sequence, each time the ray advances to a new spatial position, the optical path density field data is called at the current position, the density value of the voxel unit corresponding to the current position is extracted, the scattering contribution value of the current stepping position is determined based on the density value, and all the scattering contribution values ​​on the advancement path of each ray are accumulated in sequence to form a cumulative scattering contribution value corresponding to each ray; Based on the cumulative scattering contribution value corresponding to each light ray, each ray is mapped one by one to the screen space sampling point coordinate position corresponding to the initial position of each light ray, pixel color data matching the current rendering frame resolution is generated, and the color data is written one by one into a two-dimensional array to form a frame rendering pixel color matrix.

Citation Information

Patent Citations

  • Scene rendering method and device, computer readable storage medium and computer equipment

    CN111105491A

  • Rendering method of real-time optical smoke screen based on physical process

    CN112347708A

  • Image rendering method and device, electronic equipment and storage medium

    CN113888392A

  • Virtual scene construction method based on point cloud data, medium and equipment

    CN119251430A

  • Stable ray tracing

    US20180096516A1

Cited By

  • Animation scene light and shadow dynamic rendering method and system

    CN121259162A

  • Method and system for rendering light and shadow dynamics of animation scene

    CN121259162B

  • Virtual reality-based power transmission dense channel visual management and control system

    CN122199835A