Real-time light shadow tracing rendering system for virtual reality environment

By using optical path density field data and inter-frame feature perception analysis, the sampling point set density is adaptively adjusted, solving the problems of uneven resource allocation and loss of rendering details in existing technologies, and achieving efficient rendering and stable lighting effects for complex occluded areas.

CN120707715BActive Publication Date: 2026-05-15南京宁笙科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
南京宁笙科技有限公司
Filing Date
2025-06-13
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing real-time rendering technologies suffer from uneven resource allocation when dealing with complex occlusion areas, leading to loss of rendering details and unstable shadow edge processing. Insufficient utilization of inter-frame features results in flickering and instability.

Method used

The optical path density field data is established by the light source accessibility pre-computation module. The normal gradient and brightness variance are extracted by the inter-frame feature perception analysis module to generate a set of pixel feature intensity values. The sampling point set density is adaptively adjusted to construct a non-uniform sampling point distribution. Based on the optical path density field data, the ray travel strategy is set to perform ray tracing and scattering accumulation.

Benefits of technology

It improves the recognition accuracy of complex occlusion structures, optimizes resource allocation, reduces resource waste, enhances the physical rationality of light scattering simulation and the matching degree of computational resource configuration, and realizes highly adaptable modeling of dynamic structures in light and shadow space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120707715B_ABST
    Figure CN120707715B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of real-time rendering, in particular to a real-time light and shadow tracking rendering system for virtual reality environment, the system comprising: a light source accessibility pre-computation module, based on the scene geometry and the light source position of the virtual reality environment, projecting a connecting line to the light source for each unit in the three-dimensional grid covering the volume medium, in the present application, by performing connecting line occlusion ratio judgment based on the scene geometry and the light source position, establishing light path density field data reflecting the spatial distribution of occlusion, constructing a density representation of light accessibility at the voxel level, enabling the subsequent light path advancement to have density perception ability, and enhancing the recognition accuracy of complex occlusion structure, extracting the normal gradient in G-Buffer and the brightness variance of the previous frame, fusing the inter-frame geometric boundary change and the brightness fluctuation behavior, constructing a set of pixel-level feature intensity values, and writing into a two-dimensional atlas, used to guide the subsequent sampling density regulation, realizing the local response of cross-frame dynamic information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of real-time rendering technology, and in particular to a real-time ray tracing rendering system for virtual reality environments. Background Technology

[0002] The field of real-time rendering technology focuses on generating and updating images or screens in a very short time to support the real-time response requirements of interactive graphics systems.

[0003] In existing technologies, image generation largely relies on uniform sampling in screen space and a fixed stepping strategy. This leads to uneven resource allocation or loss of rendering details when the sampling density is mismatched with scene complexity. Due to the lack of density prediction for lighting occlusion structures, current real-time rendering often struggles to adjust the speed of light path progression based on occlusion levels, resulting in frequent misjudgments in highly occluded areas and affecting shadow edge processing and transparent area representation. Inter-frame feature utilization is limited to pixel value differences, failing to integrate bidirectional cues of geometric and brightness changes, resulting in an overly coarse dynamic region update strategy that easily causes flickering and instability. Therefore, improvements are needed. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of existing technologies and propose a real-time ray tracing rendering system for virtual reality environments.

[0005] To achieve the above objectives, the present invention adopts the following technical solution: a real-time ray tracing rendering system for a virtual reality environment includes:

[0006] The light source accessibility pre-calculation module, based on the scene geometry and light source position of the virtual reality environment, projects a connection line to the light source for each cell in the three-dimensional mesh covering the volume medium, determines the length ratio of the connection line that is blocked, and establishes optical path density field data.

[0007] The inter-frame feature perception and analysis module extracts the normal gradient of the current frame G-Buffer and the brightness variance of the previous rendering 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.

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

[0009] The optical path-guided volumetric ray tracing module queries the position of each ray in the initial ray tracing set in the optical path density field data and obtains the density value. It sets a step length that is inversely proportional to the density value to obtain a single ray travel strategy. Based on the single ray travel strategy, it performs stepping and scattering accumulation along the ray path to generate a frame rendering pixel color matrix.

[0010] Preferably, the steps for acquiring the optical path density field data are as follows:

[0011] Based on the three-dimensional coordinate information of scene geometry and light source loaded in the virtual reality environment, each unit voxel in the three-dimensional voxel mesh is traversed one by one. For the center position of each voxel unit, a straight path to the light source is constructed. The path is evenly divided into several continuous sampling segments, and occlusion is determined for each segment. The physical length of all occlusion segments is counted and recorded to generate the occlusion segment length sequence of the voxel.

[0012] The density value is calculated based on the sequence of occlusion lengths for each voxel and the length of the complete ray path.

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

[0014] Preferably, the step of obtaining the set of pixel feature intensity values ​​is as follows:

[0015] Extract the normal vectors of all pixels in the G-Buffer of the current frame, and calculate the normal gradient intensity of each pixel with a 4-neighbor window. Then, call the brightness information of the previous rendered frame image, and calculate the variance of the brightness value with a 4-neighbor window at each pixel. Perform max-min normalization on the normal gradient intensity and brightness variance of all pixels respectively to generate the normalized normal gradient value and normalized brightness variance value of each pixel.

[0016] The feature intensity value of a pixel is calculated based on the normalized normal gradient value and the normalized brightness variance value of each pixel.

[0017] Based on the feature intensity value of each pixel, write it into a two-dimensional array with the same size as the current frame image according to its spatial location to generate a set of pixel feature intensity values.

[0018] Preferably, the step of obtaining the sampling injection guidance map is as follows:

[0019] Based on the set of pixel feature intensity values, all feature intensity values ​​are extracted pixel by pixel. 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, forming 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, the feature intensity values ​​of all pixels in the surrounding neighborhood are averaged to smooth and suppress local fluctuations in feature intensity values, 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, thus completing the establishment of the sampling injection guide map.

[0022] Preferably, the step of obtaining the non-uniform sampling point distribution in the screen space is as follows:

[0023] Read the pixel feature intensity value stored at each pixel position in the sampling injection guide 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.

[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, with a predetermined density as a reference, 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 after local density adaptive adjustment.

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

[0026] Preferably, the step of obtaining the initial set of tracking rays is as follows:

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

[0028] Based on the set of coordinate pairs corresponding to the camera origin and sampling point positions, the spatial direction vector of each ray is calculated and constructed point by point. Specifically, it is the difference between the coordinates of each sampling point position and the coordinates of the camera origin. The difference vector is then standardized to obtain the unit direction vector, forming a set of ray direction vectors.

[0029] Based on the set of light direction vectors, 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 the starting point and direction combination of each light ray, generating the initial set of tracking light rays.

[0030] Preferably, the step of obtaining the single-ray travel strategy is as follows:

[0031] Based on the initial tracking ray set, the spatial starting point coordinates and direction vector of each initial tracking ray in the set are extracted sequentially. The initial position of each ray is calculated and determined in the corresponding grid cell position in the three-dimensional grid of the optical path density field data, and the density field cell position index of the initial tracking ray is generated.

[0032] Based on the density field cell position index of the initial tracking ray, query the density value recorded at the corresponding cell position in the corresponding optical path density field data for each initial tracking ray, record the density value as the current density data of each ray, and generate a set of density values ​​of the initial tracking ray.

[0033] Based on the initial set of tracking ray density values, and taking the density value of each initial tracking ray as a basis, the next travel distance of each ray is determined according to the inverse relationship between step length and density value. The step length of each ray is recorded in sequence to form a single-ray travel strategy.

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

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

[0036] According to the single-ray position stepping sequence, each time a new spatial position is advanced, 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 stepping position is determined based on the density value. All scattering contribution values ​​on each ray advancement path are accumulated in turn to form the cumulative scattering contribution value corresponding to each ray.

[0037] Based on the cumulative scattering contribution value corresponding to each ray, the coordinates of the screen space sampling point corresponding to the initial position of each ray are mapped one by one to generate pixel color data that matches the resolution of the current rendering frame. The color data is then written 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 as follows:

[0039] In this invention, by determining the occlusion ratio based on scene geometry and light source positions, an optical path density field reflecting the spatial distribution of occlusion is established. A density representation of illumination accessibility is constructed at the voxel level, enabling subsequent ray path advancement to have density perception capabilities and enhancing the recognition accuracy of complex occlusion structures. The normal gradient and the previous frame's brightness variance are extracted from the G-Buffer, and inter-frame geometric boundary changes and brightness fluctuations are fused to construct a set of pixel-level feature intensity values, which are then written into a two-dimensional map to guide subsequent sampling density adjustment, achieving local response to cross-frame dynamic information. Based on the pixel feature intensity values, the density of local point sets in the basic sampling pattern is dynamically adjusted to construct a non-uniform sampling point distribution. This avoids resource waste in sparse sampling areas and provides fine-grained tracking coverage in high-feature areas, enhancing spatial allocation efficiency. Combining 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 an inverse step length is set. Rays automatically decelerate in high-density areas and quickly traverse low-density areas, effectively improving the physical rationality of ray scattering simulation and the matching degree of computational resource allocation. Achieve highly adaptive modeling of dynamic structures in light and shadow space under a limited time budget. Attached Figure Description

[0040] Figure 1 This is a system flowchart of the present invention. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of this invention clearer, the 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 merely illustrative and not intended to limit the invention.

[0042] Please see Figure 1 This invention provides a technical solution: a real-time ray 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 connection line to the light source for each cell in the three-dimensional mesh covering the volume medium, determines the length ratio of the connection line that is blocked, and establishes optical path density field data.

[0044] The inter-frame feature perception and analysis module extracts the normal gradient of the current frame's 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 guide map, adjusts the local point set density of the basic sampling pattern according to the pixel feature intensity value, forms a non-uniform sampling point distribution in the screen space, and establishes an initial tracking ray set based on the non-uniform sampling point distribution in the screen space.

[0046] The optical path-guided volumetric ray tracing module queries the position of each ray in the initial ray set in the optical path density field data and obtains the density value. It sets a step length that is inversely proportional to the density value to obtain a single ray travel strategy. Based on the single ray travel strategy, it performs stepping and scattering accumulation along the ray path to generate the frame rendering pixel color matrix.

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

[0048] Based on the three-dimensional coordinate information of scene geometry and light source loaded in the virtual reality environment, each unit voxel in the three-dimensional voxel mesh is traversed one by one. For the center position of each voxel unit, a straight path to the light source is constructed. The path is evenly divided into several continuous sampling segments, and occlusion is determined for each segment. The physical length of all occlusion segments is counted and recorded to generate the occlusion segment length sequence of the voxel.

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

[0050]

[0051] Among them, Q m Let l represent the density value of the m-th voxel unit. k L represents the length of the k-th occlusion segment. m Let represent the total length of the straight-line path from the center point of the m-th voxel to the light source. denoted as the average length of all occluded segments of the voxel, K is the number of occluded segments of the voxel, α is the occlusion distribution adjustment coefficient, ∈ is a minimal constant to prevent the denominator from being zero, and β is an exponential control factor to enhance the influence of the occlusion distribution.

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

[0053] Specifically, based on the 3D 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 3D voxel mesh. For example, it sets the mesh structure to 128x128x128 according to the bounding box size of the scene. Then, the system starts a three-level nested loop, traversing all voxels in the mesh one by one. The loop variable is the voxel's index (i, j, k) in the 3D mesh. In each loop, the world coordinates of the voxel's center point are calculated based on the index (i, j, k) and the mesh resolution, and the 3D coordinates of a known single static light source are obtained. Then, a straight ray path from the voxel's center to the light source is constructed using these two 3D coordinate points, and its total length is calculated. Subsequently, the path is extended at a fixed step size, for example, 0.05 units. The system discretizes the path to obtain a series of continuous sampling points. For each sampling point on the path, the system performs occlusion determination. Specifically, a detection ray is emitted from the sampling point to the light source position and intersects with the triangular faces of all geometric objects in the scene. If the ray intersects with any triangular face before reaching the light source, the sampling point is determined to be occluded. The system continuously records the number of consecutively occluded sampling points. When an unoccluded sampling point is encountered, the previously accumulated number of consecutively occluded points is multiplied by a step size of 0.05 to obtain the physical length of an occlusion segment, which is stored in a dynamic array. This process continues along the complete ray path until the end of the path. Finally, all the occlusion segment length values ​​recorded in the dynamic array are integrated to generate an occlusion segment length sequence specific to the voxel.

[0054] formula: The advantage of this formula lies in the fact that it not only measures light attenuation by the ratio of total occlusion length to path length, but also introduces a standard deviation term for the occlusion segment length, controlled by an adjustment coefficient α and an exponential control factor β. This design can distinguish between two physical scenarios that produce drastically different visual effects (such as hard shadow edges and soft penumbra areas) – “a large continuous occlusion” and “multiple small discrete occlusions”. By quantifying the discreteness of the occlusion distribution, the calculated density value can more accurately reflect the scattering and attenuation characteristics of light as it passes through the medium, thus providing a richer and more realistic physical basis for subsequent volumetric ray tracing rendering, ultimately generating soft shadows and volumetric lighting effects with smooth transitions and realism.

[0055] l kThe length of the k-th occlusion segment is represented by the actual physical length of the continuously occluded segment obtained by stepping and sampling the path from the voxel center to the light source in the previous steps. The unit is meters. This data comes directly from the physical occlusion analysis of the scene geometry and reflects the specific size of the obstacles on the light path. For example, when analyzing the m-th voxel, if its occlusion segment length sequence is {0.8, 0.2}, then l1 = 0.8 meters and l2 = 0.2 meters.

[0056] L m This represents the total length of the straight-line path from the center of the m-th voxel to the light source. This parameter is calculated directly by querying and obtaining the 3D world coordinates of the m-th voxel's center and the light source, and then applying the Euclidean distance formula in 3D space. The unit is meters. It represents the total distance traveled by light without any deflection and is the benchmark for calculating the total occlusion ratio. For example, if the voxel's 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 as follows:

[0057] This represents the average length of all occlusion segments of the voxel. This parameter is a statistic calculated based on the "occlusion segment length sequence of the voxel" obtained in the preceding steps. Specifically, the calculation method involves taking the length values ​​l of all occlusion segments in the sequence. k Add them together and then divide by the total number of occlusion segments K, in meters. This reflects the average size of obstacles on the optical path and serves as a central moment reference for calculating the dispersion of the occlusion distribution. For example, if the occlusion segment length sequence of a voxel is {0.8, 0.2}, then its average value...

[0058]

[0059] K represents the number of occlusion segments of the voxel. This parameter is determined directly by counting the number of elements in the "voxel occlusion segment length sequence" generated in the previous steps. It is a dimensionless integer that represents the number of times an independent occlusion region is encountered on the optical path. The larger the value, the more scattered the occlusions are usually. For example, if the occlusion segment length sequence of a voxel is {0.8, 0.2}, then the number of 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 (e.g., a forest with many leaves, an interior with windows, a city with large buildings), a benchmark "golden" image is generated using high-precision rendering methods such as path tracing. 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. Finally, the Multi-Scale Structural Similarity Index (MS-SSIM) is used to calculate the similarity score between the rendered result 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. Finally, the α value that obtains the highest average MS-SSIM score in all test scenarios is selected as the global default configuration. For example, after testing, when α = 1.8, the rendered volumetric penumbra effect is closest to the reference image and the average MS-SSIM score is the highest. Therefore, α = 1.8 is set.

[0061] ∈ is a minimal constant to prevent the denominator from being zero. This is a numerically stable term used to avoid the average shading length when calculating the ratio of the standard deviation to the mean. An error occurs when the value is zero (i.e., there are no obstructions on the path), so 1×10 is selected. -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 brackets, non-linearly enhancing or weakening the contribution of occlusion dispersion to the final density. When β > 1, it amplifies the density difference between high dispersion (soft edges) and low dispersion (hard edges), and vice versa. The setting process is as follows: a real-time adjustment slider is provided to the technical artist, with a range of [0.5, 3.0]. In a test scene containing various representative occlusions (such as pillars, grids, and leaves), the technical artist observes the changes in volumetric lighting effects in real time by dragging the slider. When the softness of the penumbra and the clarity of the volumetric light outline meet the requirements of the project's artistic style, the β value is fixed. For example, in order to make the projection of small objects such as leaves appear softer while maintaining the hard outline of solid occlusions, the technical artist finally determined the value to be β = 1.2.

[0063] Calculation process:

[0064] Taking a voxel of the mth rank as an example, we substitute the example values ​​obtained in the previous parameter acquisition steps into the calculation.

[0065] The known parameters are as follows:

[0066] The sequence of voxel occlusion lengths is {0.8, 0.2}, therefore l1 = 0.8, l2 = 0.2.

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

[0068] The number of occluded segments is K = 2.

[0069] average length of the obstructed segment

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

[0071] To prevent the smallest constant ∈ = 0.000001 with a denominator of zero.

[0072] The exponential control factor β = 1.2 enhances the influence of shading distribution.

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

[0074]

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

[0076]

[0077] This result indicates that the density value Q of the m-th voxel unit... m The calculated value is 0.1738. This value is the optical path occlusion index of this voxel. It combines the total occlusion ratio and the dispersion of the occlusion distribution. The value itself (0.1738) represents a medium to low level of occlusion density. In the subsequent optical path-guided volumetric ray tracing module, when a ray travels to this voxel, the system will look up this density value and determine the behavior of the ray within the voxel based on this value. Specifically, a higher density value means stronger light absorption and scattering, which will result in a richer volumetric lighting effect and a shorter ray tracing step length. Conversely, a lower density value corresponds to a thinner medium.

[0078] Based on the density value of each voxel unit, the system performs a traversal operation, storing all previously calculated voxel density values ​​Q. mThe data is precisely filled into a 3D voxel mesh data structure, which is represented in memory as a 3D floating-point array. Its dimensions are exactly the same as the resolution of the voxel mesh divided in the scene, for example, 128x128x128. For each voxel whose density value is calculated in the second step, the system first obtains its 3D index (i, j, k) in the mesh, and then directly assigns the calculated floating-point density value, such as 0.1738, to the element at position [i][j][k] of the 3D array. This process continues until the density values ​​of all voxels in the mesh are successfully filled. Finally, a complete, static numerical field representing the light accessibility distribution of the entire scene space is constructed in memory, forming the optical path density field data.

[0079] The steps for obtaining the set of pixel feature intensity values ​​are as follows:

[0080] Extract the normal vectors of all pixels in the G-Buffer of the current frame, and calculate the normal gradient intensity of each pixel with a 4-neighbor window. Then, call the brightness information of the previous rendered frame image, and calculate the variance of the brightness value with a 4-neighbor window at each pixel. Perform max-min normalization on the normal gradient intensity and brightness variance of all pixels respectively to generate the normalized normal gradient value and normalized brightness variance value of each pixel.

[0081] The feature intensity value of each pixel is calculated based on its normalized normal gradient value and normalized luminance variance value. The calculation formula is as follows:

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

[0083] Among them, R i G′ represents the feature intensity value of the i-th pixel. i σ′ represents the normalized normal gradient intensity value of the i-th pixel. i w represents the normalized luminance variance of the i-th pixel. g w σ w gs These are the weighting coefficients for the normal gradient term, the brightness variance term, and the interaction term between the two, respectively.

[0084] Based on the feature intensity value of each pixel, write it into a two-dimensional array with the same size as the current frame image according to its spatial location to generate a set of pixel feature intensity values.

[0085] Specifically, the normal vectors of all pixels in the current frame's G-Buffer are extracted. For each pixel on the screen, the following calculations are performed in parallel: First, for the center pixel with coordinates (x, y), its 3D normal vector N(x, y) stored in the G-Buffer is accessed, and the normal vectors of its four adjacent pixels (upper, lower, left, and right) are also obtained. Then, the gradient is approximated by calculating the difference between the dot product of the center pixel's normal and the normals of its horizontal and vertical neighbors. Specifically, the horizontal gradient component is equal to 1 minus the dot product of the center normal and the normal of its right neighbor, and the vertical gradient component is equal to 1 minus the dot product of the center normal and the normal of its upper neighbor. The final normal gradient intensity of this pixel is the square root of the sum of the squares of these two components. At the same time, the system retrieves the brightness of the previously rendered frame. The system calculates the average brightness value of five pixels within a 4-neighborhood window centered at (x, y) (including the center pixel, totaling 5 points). It then calculates the average of the sum of squares of the differences between each pixel's brightness value and this average value to obtain the brightness variance at that pixel location. After calculating the normal gradient intensity and brightness variance for all pixels, the system iterates through all normal gradient intensity values ​​in the entire frame to determine the global maximum and minimum values. The same operation is performed on all brightness variance values. Finally, the system applies the max-min normalization formula, i.e., (current value - global minimum) / (global maximum - global minimum), to map the normal gradient intensity and brightness variance of each pixel to the interval between 0 and 1, generating the normalized normal gradient value and normalized brightness variance value for each pixel.

[0086] Formula: R i =ln(1+w g g′ i +w σ σ′ i +w gs (g′ i ·σ′ i The advantage of this formula is that it creates a unified pixel-level feature intensity index, identifying screen areas with high rendering resource requirements, by combining the normal gradient g′ representing geometric details. i And the luminance variance σ′ representing the temporal and spatial lighting complexity i And introduce an interactive item (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 defects (such as flickering and jagged edges). By using the logarithmic function ln(1+x) to process the weighted sum, the dynamic range of the output value is effectively compressed, preventing extreme feature values ​​from having an excessive impact on the overall sampling distribution, thus resulting in a smoother distribution.

[0087] g′ i This represents the normalized normal gradient strength value of the i-th pixel. This parameter is calculated in 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's neighborhood. High values ​​indicate object edges, sharp corners, or uneven surfaces, while low values ​​correspond to smooth curved or flat surfaces. This value is obtained directly from the preceding processing flow and does not require additional calculation. For example, for a pixel on the screen located at a sharp edge, its normalized normal gradient strength value is 0.92.

[0088] σ′ i This represents the normalized luminance variance value of the i-th pixel. This parameter is also calculated in the previous step and is a dimensionless floating-point number between 0 and 1. It quantifies the degree of drastic change in luminance within the pixel's neighborhood and compared to the previous frame. High values ​​indicate high-frequency textures, flickering highlights, or dynamically changing shadow areas, while low values ​​correspond to areas with uniform color and luminance. This value is obtained directly from the preceding processing flow. For example, for a pixel located at the edge of a dynamic flame effect, its normalized luminance variance value might be 0.85.

[0089] w g w σ w gs These are the weighted coefficients for the normal gradient term, the brightness variance term, and the interaction term, respectively. These dimensionless coefficients are used to adjust the contribution of the three feature components to the final feature intensity value. Their setting is based on minimizing rendering artifacts and optimizing performance. The specific setting process is as follows: First, select a set of representative VR scenes (including static detailed models, dynamic characters, complex lighting, etc.) and generate high-precision offline rendering results for these scenes as the "gold standard." Then, establish a performance evaluation function P = λ1·(1-SSIM) + λ2·T flicker Where SSIM is the structural similarity index between the current frame and the gold standard frame, and T flicker λ1 is the average pixel brightness difference between two consecutive frames, used to measure the degree of flicker. λ2 are meta-weights, for example, set to 0.6 and 0.4 respectively. A systematic search (such as Bayesian optimization) is performed within a preset weight range (for example, all coefficients are within [0, 10]) to find the value that minimizes the performance evaluation function P. g ,w σ ,w gs After optimization testing in 10 typical scenarios, it was found that when w g =3.5, w σ =5.0, w gs When the value is 2.0, it can achieve the lowest average P value while maintaining a high frame rate, so this set of weights is adopted.

[0090] Calculation process:

[0091] The feature intensity value R of each pixel is calculated based on the normalized normal gradient value and the normalized luminance variance value. i Here, we take a specific i-th pixel as an example and substitute the example value obtained in the previous parameter acquisition step for calculation.

[0092] The known parameters are as follows:

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

[0094] The normalized luminance variance value σ′ of the i-th pixel i =0.85.

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

[0096] Weighting coefficient w for the luminance variance term σ =5.0.

[0097] The weighting 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 results show that the feature 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 geometric and lighting changes in the region, and the more likely it is to produce rendering defects. Therefore, more computing resources (i.e., more sampled rays) are needed to ensure rendering quality. A value close to 0 (ln(1)) means that the pixel is in a very flat and stable region, while 2.306 indicates that this is a fairly complex region that needs to be focused on.

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

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

[0107] Based on the set of pixel feature intensity values, all feature intensity values ​​are extracted pixel by pixel. 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, forming an initial two-dimensional mapping array.

[0108] Based on the initial two-dimensional mapping array, a predefined spatial neighborhood range is used. The feature intensity values ​​of all pixels in the surrounding neighborhood are averaged with each pixel position as the center to smooth out and suppress local fluctuations in 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, thus completing the establishment of the sampling injection guide map.

[0110] Specifically, based on the set of pixel feature intensity values, a parallel data reorganization operation is initiated. This operation is implemented by scheduling a computation shader, assigning a processing thread to each feature intensity value in the set. Each thread 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 at 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 (e.g., a 1920x1080 floating-point texture) with the exact same size as the current frame image. The target position for writing is the (x, y) coordinates just calculated. This process does not involve any numerical calculations or transformations; it simply rearranges the disordered or one-dimensionally stored feature intensity values ​​into a two-dimensional data container with the same topology as the screen space, based on the spatial position of the pixels. All threads execute this mapping in parallel until all values ​​in the set of pixel feature intensity values ​​are copied to their corresponding positions in the new array, forming the initial two-dimensional mapping array.

[0111] Based on the initial two-dimensional mapping array, the system uses a predefined spatial neighborhood to smooth the data in the array. This spatial neighborhood is set as a 5x5 square kernel. The kernel size was determined based on offline tests conducted in multiple typical virtual reality scenarios. The tests compared the flicker suppression and detail preservation of the sampled injection guide maps processed with 3x3, 5x5, and 7x7 kernel sizes in the final rendered image. The temporal consistency index and structural similarity index (SSIM) were used for quantitative evaluation. Ultimately, it was found that the 5x5 kernel achieved a good balance between effectively smoothing high-frequency noise and preserving necessary geometric edge features. To achieve the optimal balance, during execution, the system starts a calculation thread for each pixel position in the initial two-dimensional mapping array. The thread reads the feature intensity values ​​of a total of 25 pixels in its 5x5 neighborhood, centered on its own pixel coordinates. For pixels at the image edge, the sampling points outside its neighborhood range are obtained by using the edge pixel repetition (Clamp-to-Edge) method. Then, the thread calculates the average of these 25 feature intensity values ​​and uses this average as the new value for this center pixel position, writing 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 2D feature intensity matrix, the system performs the final write and assignment operation, formally establishing the matrix as the sampling injection guide map for this frame. This process essentially involves referencing and binding the data memory region of the smoothed 2D feature intensity matrix generated in the previous stage within the rendering pipeline's state machine. This sets it as a read-only input texture resource for the subsequent adaptive sampling ray generation module. The system does not make any further modifications or moves to the values ​​in the matrix. Instead, it directly submits the complete data block containing all smoothed feature intensity values ​​of all pixels as a whole to the GPU via instructions from the graphics API. The GPU confirms the completion of the data write operation and marks it as the "sampling injection guide map." Subsequently, this map will remain unchanged in the remaining rendering process of the current frame, providing a stable and smoothed spatial distribution map that reflects the screen space rendering complexity for subsequent ray generation, thus completing the establishment of the sampling injection guide map.

[0113] The steps for obtaining the non-uniform sampling point distribution in screen space are as follows:

[0114] Read the pixel feature intensity value stored at each pixel position in the sampling injection guide 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 the 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, with a predetermined density as a reference, 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 after local density adaptive adjustment.

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

[0117] Specifically, the system reads the pixel feature intensity value stored at each pixel position in the sampling injection guide map. First, the screen space is divided into a non-overlapping 4x4 pixel basic sampling pattern grid. Then, for each basic sampling pattern, the system reads the corresponding pixel feature intensity values ​​of the 16 pixels it covers in the sampling injection guide map in parallel. These 16 floating-point values ​​are added together and divided by 16 to calculate the average feature intensity within the basic sampling pattern area. This average value will be used as a single intensity index representing the entire 4x4 area. Next, 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, generating a corresponding average feature intensity value for each pattern. Finally, all these data pairs are summarized to form the initial local intensity mapping set of the basic sampling patterns.

[0118] Based on the initial local intensity mapping set of the base 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 base sampling pattern. This value was determined during the development phase through performance analysis of the target VR hardware (90Hz refresh rate) 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 as follows: iterate through all the average feature intensity values ​​in the initial local intensity mapping set of the base sampling pattern, calculate the global mean and standard deviation of these values, and then set the threshold to "the global mean plus 0". The threshold of "0.5 times the standard deviation" will adaptively change with the overall complexity of each frame. Next, the system processes each basic sampling pattern one by one, and compares the average feature intensity value recorded with the calculated dynamic threshold. If the average feature intensity value is greater than the threshold, it is determined to be a high-complexity region, 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 region, and the number of sampling points is reduced to 2. After determining the number of sampling points, the system extracts the required number of two-dimensional coordinate points in sequence from a preset 16-point low-difference sequence (such as the Halton sequence) covering a 4x4 area, forming a sampling point set with local density adaptive adjustment.

[0119] Based on the locally density-adapted sampling point set, the system executes a final coordinate generation and aggregation process. First, it calculates the total number of sampling points required after adjusting all basic sampling patterns and allocates a sufficiently large single contiguous buffer 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 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 local coordinate... The system calculates the global floating-point coordinates (u, v) in screen space as follows: global X coordinate = bx * 4 + u + random number, global Y coordinate = by * 4 + v + random number, where the random number is between -0.5 and 0.5 and is used to add dithering 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 this buffer in parallel until all sampling points are written, forming a non-uniform sampling point distribution in screen space.

[0120] The steps for obtaining the initial set of tracing rays are as follows:

[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 coordinates of the screen are read one by one, and the three-dimensional coordinate position of the camera origin in the world coordinate system in the current rendering scene is determined, forming a set of coordinate pairs corresponding to the camera origin and the sampling point positions.

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

[0123] Based on the set of ray direction vectors, with the camera origin coordinates as the common starting point of 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, generating the initial set of tracking rays.

[0124] Specifically, based on the non-uniform sampling point distribution in screen space, the system initiates a parallel processing task for data pairing. First, it directly reads and locks the camera's 3D world coordinates for the current frame from the current rendering state. These coordinates are loaded into the GPU's constant buffer as a common reference point for all subsequent calculations. Then, the system schedules a computation shader with the same number of execution threads as the total number of sampling points in the non-uniform sampling point distribution in screen space. Each thread is assigned a unique index and reads a 2D screen coordinate (X, Y) from the buffer storing the non-uniform sampling point distribution based on this index. Next, the thread packages the read 2D screen coordinate (X, Y) with the 3D camera origin coordinates obtained from the constant buffer into a structure and writes this structure to the corresponding index position in a new output buffer. This process is executed in parallel for all sampling points without any coordinate transformation or complex calculations. 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 positions.

[0125] Based on the set of coordinate pairs corresponding to the camera origin and the sampling point positions, the system executes a process of constructing ray direction vectors from 2D screen space to 3D world space. This process is carried out in parallel by a computation shader processing each pair of data in the coordinate pair set. For each coordinate pair, the shader thread first reads the 2D screen coordinates (X, Y) of the sampling point and uses the inverse matrix of the current camera's projection matrix and view matrix to back-project and transform this 2D screen coordinates into a 3D point in world space. This 3D point is located on the camera's near clipping plane and corresponds precisely to the sampling point on the screen. Then, the thread reads the 3D world coordinates of the camera origin recorded in the coordinate pair and calculates the vector pointing from the camera origin to the newly transformed 3D point in world space. That is, the coordinates of the point on the near clipping plane are subtracted from the coordinates of the camera origin to obtain an initial direction vector. Finally, a normalization operation is performed on this difference vector, that is, each component is divided by the magnitude of the vector to obtain a unit direction vector of length 1. This unit vector will be written into a new output buffer to form a set of ray direction vectors.

[0126] Based on the ray direction vector set, the system performs the final ray data structure assembly operation. This process is completed in parallel by a computation 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 camera's 3D world coordinates for the current frame from the constant buffer as the common starting point for all rays. Then, 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. Then, the thread combines these two 3D vectors (starting point coordinates and direction vector) into a structure that defines the ray's geometric properties. This 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, this complete ray structure is written to the corresponding index position in a new, final output buffer. After all threads have completed their execution, the output buffer contains the complete definition of all rays to be tracked in the scene, generating the initial set of tracked rays.

[0127] The steps to obtain the single-ray travel strategy are as follows:

[0128] Based on the initial set of tracking rays, the spatial starting point coordinates and direction vector of each initial tracking ray in the set are extracted sequentially. The position of the initial position of each ray in the three-dimensional grid of the optical path density field data is calculated and determined, and the density field cell position index of the initial tracking ray is generated.

[0129] Based on the density field cell position index of the initial tracking ray, the density value recorded at the corresponding cell position in the corresponding optical path density field data for each initial tracking ray is queried one by one, and the density value is recorded as the current density data of each ray, generating a set of density values ​​of the initial tracking ray.

[0130] Based on the initial set of tracking ray density values, and taking the density value of each initial tracking ray as a basis, the next travel distance of each ray is determined according to the inverse relationship between step length and density value. 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 tracing rays, the system initiates a parallel computing task, assigning a processing thread to each initial tracing ray in the set. Each thread first reads the corresponding ray structure from the initial tracing ray set and extracts the spatial starting point coordinates of the ray. These coordinates 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 mesh (e.g., 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 mesh unit into which the starting point of the ray falls can be calculated. This calculation does not involve complex algorithms, but only basic vector and scalar operations. Finally, the thread writes the calculated three-dimensional integer index into a new output buffer, corresponding one-to-one with the index of the original ray in the set, generating the density field unit position index of the initial tracing ray.

[0132] Based on the density field unit position index of the initial tracing ray, the system initiates a parallel task of data query and recording. A processing thread is assigned 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 an address to directly access the three-dimensional texture or three-dimensional array storing the optical 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 ray. This 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 have completed parallel execution, the buffer completely contains the initial 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 density values ​​for the tracking rays, the system executes a parallel task to calculate 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 travel distance of the ray based on a preset inverse relationship between the step length and the density value. This relationship is expressed by the formula... Let S be the step size, D be the density value found, C be a basic step size constant, and ∈ be a minimal constant to prevent division by zero (implemented as, for example, 1 × 10⁻⁶). -6The base step size constant C is set based on the average scale of the scene and performance requirements. The setting process is as follows: During the development phase, a standard test scene is selected, and the C value is adjusted (for example, from 0.01 to 1.0) and the rendering time and final image quality are measured (compared with high-precision offline rendering results). A performance-quality curve is plotted, and the C value located at the "inflection point" of the curve is selected. This point provides the optimal performance while ensuring that the rendering quality does not have obvious visual defects (such as striped tortuosity). For example, after testing, C = 0.25 is determined to be the best value. After calculating the step size, the thread writes the floating-point value to a new output buffer. This buffer is specifically used to store the travel strategy of each ray, forming a single-ray travel strategy.

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

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

[0136] Based on the single-ray position stepping sequence, each time a new spatial position is advanced, 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 stepping position is determined based on the density value. All scattering contribution values ​​on each ray advancement path are accumulated in turn to form the cumulative scattering contribution value corresponding to each ray.

[0137] Based on the cumulative scattering contribution value corresponding to each ray, the coordinates of the screen space sampling point corresponding to the initial position of each ray are mapped one by one to generate pixel color data that matches the resolution of the current rendering frame. The color data is then written into a two-dimensional array to form a frame rendering pixel color matrix.

[0138] Specifically, based on the single-ray movement strategy, the system launches a parallel ray stepping calculation shader, assigning a processing thread to each ray. Each thread first reads the corresponding ray data from the initial ray tracing set, obtaining its 3D spatial starting position coordinates and unit direction vector. Simultaneously, it reads the pre-determined fixed step length for that ray from the single-ray movement strategy. Within the thread, a current position variable is initialized as the ray's starting position, and a loop is started. The number of times this loop executes is limited by a preset maximum step size, for example, 128 steps. This upper limit is set as a trade-off between performance and rendering distance. As a result, designed to ensure that light rays do not travel indefinitely in the scene while covering most of the visible volumetric lighting effects, in each iteration of the loop, the system calculates the new spatial position of the light ray 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 then appended to a dynamic array dedicated to that light ray. The loop continues until the maximum number of steps of 128 is reached, or the current position of the light ray exceeds the three-dimensional boundary of the optical path density field data. After the loop ends, the dynamic array constitutes the complete travel path of the light ray, forming a single-ray position step sequence.

[0139] Based on the single-ray position step sequence, the system executes a parallel scattering accumulation shader, assigning a processing thread to each ray. Within each thread, a four-component floating-point vector (RGBA) is initialized as the accumulated scattering contribution value, with an initial value of (0, 0, 0, 0), and a floating-point number is initialized as the ray transmittance, with an initial value of 1.0. Next, the thread iterates through each 3D spatial position point in the single-ray position step sequence corresponding to that ray. At each point, the system first converts the world coordinates of that point into a 3D mesh index in the optical path density field data, and uses this index to retrieve the density value at the current position from the density field. Then, based on this... The density value is used to calculate the scattering contribution at the current step position. The calculation method is to multiply the density value, the current step length, a global illumination color vector determined by the color of the scene's main light source, and a preset scattering coefficient (e.g., 0.15, which 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. This final result is added to the cumulative scattering contribution value. After that, the system updates the light transmittance by multiplying 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 have been traversed, forming the cumulative scattering contribution value for each ray.

[0140] Based on the cumulative scattering contribution value corresponding to each ray, the system executes a two-stage color analysis 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 rendering frame and an integer sample count buffer of the same size (initialized to all zero). Then, a computation shader is started, and a processing thread is assigned to each ray. This thread reads its corresponding cumulative scattering contribution value and obtains the screen space sampling point coordinates corresponding to the ray at the time of initial generation. By rounding these coordinates, the pixel position (px, py) to which it belongs is determined. Then, the thread uses atomic addition operations to calculate the cumulative scattering contribution value. The numerical value (a color vector) is safely added to the pixel at position (px, py) in the color accumulation buffer, and the count value at position (px, py) is incremented by one using an atomic increment operation. In the second stage, after the contributions of all rays have been accumulated, the system starts a second computation shader. This shader allocates a thread for each pixel on the screen. The thread reads the values ​​of the color accumulation buffer and the sample 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, this averaged color data is written one by one into a two-dimensional array to form the frame rendering pixel color matrix.

Claims

1. A real-time ray tracing rendering system for a virtual reality environment, characterized in that, The system includes: The light source accessibility pre-calculation module, based on the scene geometry and light source position of the virtual reality environment, projects a connection line to the light source for each cell in the three-dimensional mesh covering the volume medium, determines the length ratio of the connection line that is blocked, and establishes optical path density field data. The inter-frame feature perception and analysis module extracts the normal gradient of the current frame G-Buffer and the brightness variance of the previous rendering 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. The adaptive sampling ray generation module reads the pixel feature intensity value of each pixel in the sampling injection guide map, adjusts the local point set density of the basic sampling pattern according to the pixel feature intensity value, forms a non-uniform sampling point distribution in the screen space, and establishes an initial tracking ray set based on the non-uniform sampling point distribution in the screen space. The optical path-guided volumetric ray tracing module queries the position of each ray in the initial ray tracing set in the optical path density field data and obtains the density value. It sets a step length that is inversely proportional to the density value to obtain a single ray travel strategy. Based on the single ray travel strategy, it performs stepping and scattering accumulation along the ray path to generate a frame rendering pixel color matrix.

2. The real-time ray tracing 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 three-dimensional coordinate information of scene geometry and light source loaded in the virtual reality environment, each unit voxel in the three-dimensional voxel mesh is traversed one by one. For the center position of each voxel unit, a straight path to the light source is constructed. The path is evenly divided into several continuous sampling segments, and occlusion is determined for each segment. The physical length of all occlusion segments is counted and recorded to generate the occlusion segment length sequence of the voxel. The density value is calculated based on the sequence of occlusion lengths for each voxel and the length of the complete ray path. Based on the density value of each voxel unit, the density value is written as an optical path occlusion index into the corresponding position in the three-dimensional voxel mesh structure to form optical path density field data.

3. The real-time ray tracing rendering system for a virtual reality environment according to claim 1, characterized in that, The steps for obtaining the set of pixel feature intensity values ​​are as follows: Extract the normal vectors of all pixels in the G-Buffer of the current frame, and calculate the normal gradient intensity of each pixel with a 4-neighbor window. Then, call the brightness information of the previous rendered frame image, and calculate the variance of the brightness value with a 4-neighbor window at each pixel. Perform max-min normalization on the normal gradient intensity and brightness variance of all pixels respectively to generate the normalized normal gradient value and normalized brightness variance value of each pixel. The feature intensity value of a pixel is calculated based on the normalized normal gradient value and the normalized brightness variance value of each pixel. Based on the feature intensity value of each pixel, write it into a two-dimensional array with the same size as the current frame image according to its spatial location to generate a set of pixel feature intensity values.

4. The real-time ray tracing rendering system for a virtual reality environment according to claim 1, characterized in that, The steps for obtaining the sampling injection guidance map are as follows: Based on the set of pixel feature intensity values, all feature intensity values ​​are extracted pixel by pixel. 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, forming 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, the feature intensity values ​​of all pixels in the surrounding neighborhood are averaged to smooth and suppress local fluctuations in feature intensity values, 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, thus completing the establishment of the sampling injection guide map.

5. The real-time ray tracing rendering system for a virtual reality environment according to claim 1, characterized in that, The steps for obtaining the non-uniform sampling point distribution in the screen space are as follows: Read the pixel feature intensity value stored at each pixel position in the sampling injection guide 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. 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, with a predetermined density as a reference, 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 after local density adaptive adjustment. Based on the locally density adaptively adjusted sampling point set, all the adjusted sampling point sets are distributed according to the coordinate positions in the screen space and written into the corresponding two-dimensional coordinates in the screen space one by one, forming a non-uniform sampling point distribution in the screen space.

6. The real-time ray tracing rendering system for a virtual reality environment according to claim 1, characterized in that, The steps for obtaining the initial set of tracking rays are as follows: Based on the non-uniform distribution of sampling points in the screen space, the position coordinate data of each sampling point in the two-dimensional coordinates of the screen are read one by one, and the three-dimensional coordinate position of the camera origin in the world coordinate system in the current rendering scene is determined, forming a set of coordinate pairs corresponding to the camera origin and the sampling point positions. Based on the set of coordinate pairs corresponding to the camera origin and sampling point positions, the spatial direction vector of each ray is calculated and constructed point by point. Specifically, it is the difference between the coordinates of each sampling point position and the coordinates of the camera origin. The difference vector is then standardized to obtain the unit direction vector, forming a set of ray direction vectors. Based on the set of light direction vectors, 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 the starting point and direction combination of each light ray, generating the initial set of tracking light rays.

7. The real-time ray tracing rendering system for a virtual reality environment according to claim 1, characterized in that, The steps for obtaining the single-ray travel strategy are as follows: Based on the initial tracking ray set, the spatial starting point coordinates and direction vector of each initial tracking ray in the set are extracted sequentially. The initial position of each ray is calculated and determined in the corresponding grid cell position in the three-dimensional grid of the optical path density field data, and the density field cell position index of the initial tracking ray is generated. Based on the density field cell position index of the initial tracking ray, query the density value recorded at the corresponding cell position in the corresponding optical path density field data for each initial tracking ray, record the density value as the current density data of each ray, and generate a set of density values ​​of the initial tracking ray. Based on the initial set of tracking ray density values, and taking the density value of each initial tracking ray as a basis, the next travel distance of each ray is determined according to the inverse relationship between step length and density value. The step length of each ray is recorded in sequence to form a single-ray travel strategy.

8. The real-time ray tracing rendering system for a virtual reality environment according to claim 1, characterized in that, The steps for obtaining the frame rendering pixel color matrix are as follows: Based on the single-ray travel strategy, the initial position and predetermined step length of each ray in the strategy are read one by one, and the spatial position is advanced by a fixed distance along the ray direction vector. The new spatial position after each advancement is calculated step by step to form a single-ray position step sequence. According to the single-ray position stepping sequence, each time a new spatial position is advanced, 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 stepping position is determined based on the density value. All scattering contribution values ​​on each ray advancement path are accumulated in turn to form the cumulative scattering contribution value corresponding to each ray. Based on the cumulative scattering contribution value corresponding to each ray, the coordinates of the screen space sampling point corresponding to the initial position of each ray are mapped one by one to generate pixel color data that matches the resolution of the current rendering frame. The color data is then written into a two-dimensional array to form a frame rendering pixel color matrix.