A real-time path guiding rendering method based on local visible light portal
By identifying and constructing local visible light ingress meshes, and combining weighted reservoir sampling and multi-importance sampling, the calculation of light paths is optimized, solving the problem of low rendering efficiency in complex scenes and achieving high-quality real-time rendering effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NORTHWEST UNIV
- Filing Date
- 2026-03-18
- Publication Date
- 2026-06-19
AI Technical Summary
Existing real-time rendering technologies are computationally inefficient when dealing with complex scenes. They are prone to noise, especially under strong light sources or specular reflection conditions, and it is difficult to quickly locate the area that contributes the most to the lighting, resulting in wasted resources and slow rendering.
By identifying the incident radiation brightness distribution at scene sampling points, a local visible light entrance is generated, and a visibility grid covering the entire scene is constructed. By combining weighted reservoir sampling and balanced heuristic multi-importance sampling, the ray path calculation is optimized.
It significantly improves the rendering quality and efficiency of complex scenes, reduces invalid sampling overhead, and suppresses bright noise, making it suitable for dynamic real-time rendering scenarios such as games and virtual reality.
Smart Images

Figure CN122244272A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information technology, and in particular to a real-time path-guided rendering method based on a local visible light inlet. Background Technology
[0002] In the field of computer graphics, real-time rendering technology is a crucial foundation for achieving high-quality visual effects, especially in scenarios such as interior design, architectural visualization, and product demonstrations, where there is an extremely high demand for realistic lighting effects and computational efficiency. This technology directly impacts user experience and the accuracy of design decisions, becoming a key driving force for the development of virtual reality and digital content creation.
[0003] However, existing methods often face significant limitations when dealing with complex scenes. Many techniques experience a sharp drop in computational efficiency under special lighting conditions such as strong light sources or specular reflections, resulting in noticeable noise in the image, especially in areas with uneven light distribution, which greatly diminishes the realism of the rendering. These problems are not simply due to insufficient computing resources, but rather to the unintelligent handling of light propagation paths, leading to a significant waste of computing resources on inefficient ray tracing.
[0004] A deeper technical challenge lies in accurately identifying and utilizing the areas in a scene that contribute the most to illumination—those high-energy luminous regions. In complex indoor and outdoor environments, light propagation is affected by various factors such as object occlusion and reflection angles. If it's impossible to quickly determine which light sources or reflection paths contribute the most to the final image, computational resources will be scattered, and the rendering process will become exceptionally slow. For example, in an exhibition hall scene, strong light sources may be partially blocked, and the light will create complex highlight effects after being reflected by mirrored objects. If the system cannot quickly lock onto these critical light paths, noticeable grainy noise will appear in the bright areas of the image, severely impacting visual quality.
[0005] Therefore, how to quickly locate the high-energy luminous regions that contribute the most to illumination in real-time rendering and optimize the calculation of light paths for these regions has become a key issue in improving the rendering quality and efficiency of complex scenes. Summary of the Invention
[0006] This invention provides a real-time path-guided rendering method based on a local visible light inlet, mainly comprising: S1. Identify the bright areas in the incident radiation brightness distribution of the scene sampling points, generate initial candidate light entrances, then merge similar candidate light entrances, remove duplicate light entrances, and obtain all light entrances in the scene. S2. Construct a world space local visible light entry grid covering the entire scene. Calculate the visibility of each grid cell and all light entry points using hardware-accelerated ray tracing. Store the corresponding number and index information of local visible light entry points in each grid cell to form a visibility grid. S3. At the start of each frame rendering, the average incident radiance of each light entrance in the forward and reverse directions is calculated through path tracing, and the sampling direction of each light entrance is determined based on the average incident radiance. S4. Perform path tracing and sampling fusion. The specific process is as follows: S4.1 Obtain the 3D coordinates of the current path vertex, query the visibility mesh based on the 3D coordinates, and obtain the set of local visible light entrances corresponding to the mesh cell to which the path vertex belongs; S4.2 If the set of local visible light entrances is not empty, calculate the weight of each light entrance based on the solid angle from each light entrance to the path vertex and the average incident radiance, and select the target light entrance from the set of local visible light entrances through weighted reservoir sampling. S4.3, According to the preset optical inlet sampling probability Perform optical inlet sampling according to BRDF sampling probability. Perform BRDF sampling and fuse the two sampling results through balanced heuristic multi-importance sampling; S4.4 If the local visible light inlet set is empty, directly perform BRDF sampling.
[0007] The above method, specifically step S1, includes the following steps: S1.1. Sample the scene to obtain multiple point samples. For each point sample, emit light rays from the point sample position to render a distance map and a radiance map. Among them, the distance map stores the nearest distance information, and the radiance map stores the angular distribution of the incident radiance under a constant environment map; Light rays are generated from the pixel center of the normally oriented semi-octahedral texture; S1.2 Set a high-brightness pixel threshold on the radiance map, identify the area with incident radiance greater than the threshold as the high-brightness area in the scene sampling point incident radiance distribution, and generate a corresponding mask. The high-brightness area contains the initial candidate light entrance, and the number of the high-brightness areas is multiple. S1.3 Calculate the ratio of the number of bright pixels in each bright region to the total number of pixels. When the ratio is lower than the preset ratio threshold, discard the bright region. S1.4 Perform morphological closing operation on the mask, detect the contour of each connected region, and fill the region with the index of each contour to obtain the index map; S1.5. Using the distance information in the distance map and the light direction defined by the semi-octahedral texture pixels, calculate the depth of the pixels, identify pixels with a depth greater than a preset depth threshold as edge pixels, and record the position of the edge pixels. S1.6 Perform a dilation operation on the index map to obtain the region index of the edge pixels; divide all points into multiple point clouds according to the region index; S1.7 Calculate the distance between adjacent point clouds, merge point clouds with a distance less than a preset distance threshold, and obtain the merged point cloud; S1.8. Clustering algorithm is used to cluster the point cloud, and clusters with fewer than a preset threshold number of points are removed. S1.9. Use a plane detection algorithm to detect the plane, remove outliers from the points in the plane, and project the remaining points onto the plane. S1.10 Find the rectangle with the smallest area for each projection area. This rectangle is the generated light entrance.
[0008] In the above method, the clustering algorithm described in step S1.9 is the density-based clustering algorithm DBSCAN.
[0009] In the above method, the plane detection algorithm in step S1.9 is the RANSAC algorithm.
[0010] In the above method, the visibility grid in step S2 is a two-level data structure. The bottom layer is a list of light entrances that stores information on all local visible light entrance vertices, and the top layer is a uniform grid that stores the number and index of local visible light entrances in each grid cell.
[0011] In the above method, the light inlet is a double-sided light inlet. The normal direction of the light inlet is defined as the positive direction. If the average incident radiation brightness in the positive direction is less than that in the negative direction, the light is guided from the positive direction to the negative direction; otherwise, the light is guided from the negative direction to the positive direction.
[0012] The method described above, specifically step S3, involves calculating the average incident radiance as follows: S3.1 At the centroid of each optical entrance rectangle, define the positive hemisphere direction with its normal vector, and generate multiple uniformly distributed sampling directions through a low-difference sequence; S3.2. For each sampling direction, emit light rays, trace the propagation path of the light rays in the scene, and determine the first intersection point; S3.3 At the first intersection point, the rendering equation is solved by recursively executing path tracing to obtain the outgoing radiance value along the sampling direction; if the ray does not hit any geometry, the value is assigned according to the ambient light. S3.4. Based on the sign of the dot product between the sampling direction and the light inlet normal vector, the outgoing radiance of all sampling directions is divided into forward datasets and reverse datasets. S3.5. Perform a weighted average of the radiance values in the forward and reverse datasets respectively to obtain the forward average incident radiance and the reverse average incident radiance of the optical entrance, which will be used for the adaptive flipping of the optical entrance normal in subsequent steps.
[0013] The weight calculation formula for the optical entrance in step S4.2 of the above method is as follows:
[0014] in, For light entrance Corresponding path vertex The weight, For light entrance At the apex solid angle at that location For light entrance The average incident radiance in both directions.
[0015] The above method, in step S4.2, involves sampling and filtering the target optical inlet using a weighted water storage tank. Then, the probability density function PDF of the optical inlet sampling is corrected using the following formula:
[0016] in, This is a PDF correction factor. This represents the sum of weights for the local visible light ingress set. For the target light entrance The weight, This is a parameter related to the number of sampling directions, and its value is consistent with the number of sampling directions at the centroid of the entrance.
[0017] The above method, specifically step S4.3, involves calculating the probability density function (PDF) for multiple importance sampling as follows: When sampling at the optical inlet:
[0018] BRDF sampling:
[0019] in, The coordinates of the path vertex. Sampling direction, The outgoing direction of the path vertex. The sampling probability of the optical inlet. This refers to the number of local visible light inlets. The final sampling probability density function, Let be the probability density function for sampling at the optical inlet. The probability density function for BRDF sampling.
[0020] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects: 1. This invention analyzes the incident radiation brightness distribution at scene sampling points and automatically generates light entrances using image processing and 3D back-projection technology. Compared to traditional manual placement methods, this method can accurately capture the features of geometric edges and high-energy radiation areas in the scene, automatically adapting to the geometric complexity and illumination distribution of different scenes, significantly improving the accuracy and scene universality of light entrance generation.
[0021] 2. This invention constructs a local visible light entry mesh based on a two-level data structure. The top-level uniform mesh stores only the index and quantity of light entry points, while the bottom-level mesh stores only geometric information, avoiding the huge memory consumption caused by constructing high-dimensional (5D) data structures in traditional path-guided methods. Visibility pre-computation is performed through hardware-accelerated ray tracing, which significantly reduces the occupation of video memory resources while ensuring query efficiency, providing a fundamental guarantee for real-time rendering.
[0022] 3. During path tracing, this invention limits the sampling range by querying local visible light inlet grids, avoiding invalid global searches. Combined with Weighted Reservoir Sampling (WRS) technology, it prioritizes high-contribution light inlets, achieving efficient sampling in complex visibility scenes (such as highly occluded indoor spaces), effectively reducing sampling variance, and maintaining high-quality rendering results even with low sample counts.
[0023] 4. This invention organically integrates light entry sampling and BRDF sampling by modifying the probability density function (PDF) and introducing multiple importance sampling (MIS) based on a balanced heuristic. This mechanism effectively guides the transmission path of indirect lighting through the light entry point and adapts to the reflection characteristics of different materials through BRDF sampling, ensuring the physical unbiasedness of the rendering results. While maintaining realism, it eliminates noise artifacts in complex lighting conditions that are present in traditional methods.
[0024] 5. This invention supports online visibility updates for dynamically changing scene geometry. When the scene changes, the visibility of mesh cells and light inlets is recalculated in real time through hardware-accelerated ray tracing, ensuring the timeliness and accuracy of visibility mesh data. This allows the rendering method to be stably applied to dynamic real-time rendering scenes, such as games, virtual reality, and architectural visualization.
[0025] 6. This invention significantly reduces invalid sampling overhead. In real-time rendering scenarios with a small number of strong light sources or mirror objects, it greatly suppresses bright noise, accelerates convergence, and improves image quality, providing efficient and high-quality lighting solutions for applications such as indoor commercial spaces, exhibition hall lighting, automotive material display, and architectural visualization. Attached Figure Description
[0026] Figure 1 This is a flowchart of a real-time path-guided rendering method based on a local visible light inlet according to the present invention; Figure 2 This is a case scenario provided in the embodiments of the present invention; Figure 3 For the purposes of this invention, Figure 2 Point cloud results after automatic light inlet generation; Figure 4 For the purposes of this invention, Figure 2 The optical inlet result after automatic optical inlet generation; Figure 5 This is a two-level data structure for the local visible light entry grid in this invention. The top level stores the number of local visible light entry points and their corresponding indices, while the bottom level stores the vertex coordinate information of the light entry points. Detailed Implementation
[0027] The technical solutions of the embodiments of the present invention will be clearly and thoroughly described below with reference to the accompanying drawings. The described embodiments are merely some embodiments of the present invention.
[0028] like Figure 1 This embodiment of a real-time path-guided rendering method based on a local visible light inlet may specifically include: This invention provides a real-time path-guided rendering method based on a local visible light inlet. Figure 1 This is a schematic diagram of the overall process of the real-time path-guided rendering method based on a local visible light inlet provided in an embodiment of the present invention. Figure 2 Examples provided in the embodiments of the present invention; such as Figure 1 As shown, the method includes the following main steps: Step S1: Identify the bright areas in the incident radiance distribution of the scene sampling points, generate initial candidate light entrances, merge similar candidate light entrances, remove duplicate light entrances, and obtain all light entrances in the scene.
[0029] Specifically, to quickly locate luminous regions that significantly contribute to the final image in a complex scene, it is necessary to filter out the truly strong incident radiation from a large number of sampling points. Sampling points in a scene can be understood as representative locations used to evaluate illumination; these locations are typically distributed on the main geometric surfaces of the scene, such as walls, floors, tabletops, and furniture surfaces. In one implementation, a sufficient number of sampling points are first selected from the scene; these sampling points can be obtained through uniform sampling, importance sampling, or pre-baked grid points.
[0030] Step S1.1: Sample the scene to obtain multiple point samples. For each point sample, emit rays from the point sample position to render a distance map and a radiance map. The distance map stores the nearest distance information, and the radiance map stores the angular distribution of the incident radiance brightness under a constant environment map. Rays are generated from the pixel center of the normal-oriented semi-octahedral map.
[0031] In practical processing, a local hemispherical view centered on each sampling point is constructed. Semi-octahedral mapping is a common method for mapping hemispherical directions to 2D textures. Its advantages include relatively uniform coverage of all outgoing directions and good boundary continuity. For each sampling point, a large number of rays are emitted from the hemisphere along the normal direction, with each ray corresponding to a pixel center in the semi-octahedral map. Using hardware ray tracing or pre-computation, the distance between each ray and the scene at its first intersection is recorded, forming a distance map. Simultaneously, assuming the entire environment is surrounded by a constant-brightness environment map, the incident radiance carried back by each ray is recorded, forming a radiosity map. The value of each pixel in the distance map represents the geometric distance from the sampling point along that direction to the nearest occluder, while the radiosity map reflects the distribution of ambient light intensity that might be received if that direction were completely unobstructed.
[0032] Step S1.2: Set a high-brightness pixel threshold on the radiometry map, identify areas with incident radiance greater than the threshold as high-brightness areas in the scene sampling point incident radiance distribution, and generate a corresponding mask. The high-brightness area contains the initial candidate light entrance, and the number of high-brightness areas is multiple.
[0033] A radiosity map essentially records the intensity of radiation energy that a sampling point may receive from various directions. Highlighted areas correspond to directions with particularly strong incident radiation, usually indicating the presence of a strong light source or a highly reflective surface in that direction. By setting a brightness threshold, such as multiplying the median brightness of all pixels in the radiosity map by an empirical magnification factor, or by directly using a fixed threshold, pixels exceeding the threshold are marked as 1, and the rest as 0, thus obtaining a binary mask. The proportion of pixels with a value of 1 in the mask is then counted relative to the total number of pixels in the entire semi-octahedral texture. This proportion should be between 0.1% and 5%. If the proportion is less than 0.1%, it is considered noise or a lack of light entry; if the proportion is greater than 5%, it may mean that the sampling point is too close to the light entry point, preventing a complete view, and these are all discarded.
[0034] Step S1.3: Calculate the ratio of the number of bright pixels in each bright region to the total number of pixels. When the ratio is lower than the preset ratio threshold, discard the bright region.
[0035] S1.4 Perform morphological closing operation on the mask, detect the contour of each connected region, and fill the region with the index of each contour to obtain the index map; Due to noise inherent in ray tracing and the complexity of scene geometry, the highlighted regions segmented from the radiosity map may contain small holes or fine breaks. Morphological closing operations, involving dilation followed by erosion, effectively fill these holes and connect adjacent fragmented highlighted regions, resulting in more complete and regular connected regions. Subsequently, connected component analysis is performed on the mask after the closing operation, assigning a unique index value to each independent connected region and filling this index value back into the corresponding pixel position, forming an index map. Regions with the same value in the index map represent the same potential cluster of high-energy incident directions.
[0036] S1.5. Using the distance information in the distance map and the light direction defined by the semi-octahedral texture pixels, calculate the depth of the pixels, identify pixels with a depth greater than a preset depth threshold as edge pixels, and record the position of the edge pixels. S1.6 Perform a dilation operation on the index map to obtain the region index of the edge pixels; divide all points into multiple point clouds according to the region index.
[0037] Although the index map marks highlighted areas, these areas are only two-dimensional projections. To obtain the true three-dimensional light entry point location, the two-dimensional highlighted areas need to be back-projected back into three-dimensional space using the distance map. For each edge pixel in the index map, the corresponding three-dimensional direction vector of the pixel is reconstructed according to the mapping rules of the semi-octahedral texture. Then, combined with the nearest intersection distance along that direction recorded in the distance map, the actual three-dimensional position of the edge pixel in world space can be calculated. Grouping these edge positions according to their respective region indices forms a preliminary point cloud set, with each point cloud roughly corresponding to a potential light entry plane region.
[0038] Step S1.7: Calculate the distance between adjacent point clouds, merge point clouds with a distance less than a preset distance threshold, and obtain the merged point cloud.
[0039] During the analysis of multiple sampling points across the entire scene, the same physical light entrance (such as a luminous window, a highly reflective mirror, or the luminous surface of a powerful light fixture) may be repeatedly detected by multiple neighboring sampling points, forming multiple point clouds with similar locations and orientations. To avoid subsequent redundant calculations, these point clouds need to be merged based on similarity. The merging criteria mainly include several geometric measures such as the distance between the center positions of the point clouds, the average normal angle of the point clouds, and the degree of overlap of the bounding boxes of the point clouds. When two point clouds meet preset distance thresholds, normal angle thresholds, and overlap ratio thresholds, they are considered to describe the same light entrance, and the points of one point cloud are merged into the other point cloud, or the center is recalculated after taking the union of the two.
[0040] Figure 3 For the purposes of this invention, Figure 2 Point cloud results after automatic light inlet generation; S1.8. Clustering algorithm is used to cluster the point cloud, and clusters with fewer than a preset threshold number of points are removed. S1.9. Use a plane detection algorithm to detect the plane, remove outliers from the points in the plane, and project the remaining points onto the plane. S1.10 Find the rectangle with the smallest area for each projection area. This rectangle is the generated light entrance.
[0041] Figure 4 For the purposes of this invention, Figure 2 The optical inlet result after automatic optical inlet generation; After multi-point merging, the point cloud of each candidate optical inlet may still contain noisy points or points belonging to different coplanar regions. To further refine the data, density-based spatial clustering is first performed on each point cloud to remove isolated points or small clusters with low density, retaining only the main cluster containing the most points. Then, assuming this main cluster is roughly located on a plane, a random sampling consensus method is used to repeatedly and randomly select three non-collinear points to fit the plane, counting the number of interior points, and selecting the plane with the most interior points as the best-fit plane. The distances from all points to this plane are compared with a small threshold, outliers are removed, and the remaining points are orthogonally projected onto this plane. Finally, in the projected two-dimensional point set, the bounding rectangle with the smallest area that contains all projected points is calculated. This rectangle serves as the finally identified optical inlet, and its four vertex coordinates, normal vector, and center position can be directly obtained.
[0042] Through the complete process of step S1 described above, the locally highlighted areas in the scene that significantly contribute to illumination are effectively identified and abstracted into a finite number of rectangular light entrances. These light entrances are far fewer in number than all the luminous triangles in the scene, yet they capture the vast majority of important direct lighting and specular reflection paths, providing crucial prior information for subsequent real-time path guidance.
[0043] Step S2: Construct a world space local visible light entry grid covering the entire scene. Calculate the visibility of each grid cell and all light entry points using hardware-accelerated ray tracing. Store the corresponding number and index information of local visible light entry points in each grid cell to form a visibility grid.
[0044] If a ray of light is emitted from a certain observation point in the scene and successfully reaches a certain light entrance without obstruction, then that light entrance is the local visible light entrance of that observation point. Each observation point may have multiple local visible light entrances.
[0045] After obtaining all light entrances, it is necessary to quickly answer the question of which light entrances are visible from any scene location. If each path ray is tested for visibility from the current vertex to each light entrance one by one, the computational cost will increase linearly with the number of light entrances, making it difficult to meet real-time requirements in complex scenes. Therefore, a spatial acceleration structure is introduced to pre-compute visibility.
[0046] Specifically, the entire scene bounding box is uniformly divided into a 3D mesh, such as a uniform voxel mesh of 64×64×64 or 128×128×128, which is called the visibility mesh. The choice of mesh resolution needs to be balanced between memory usage and accuracy, and usually the side length of a single mesh cell is close to 1 / 20 to 1 / 50 of the average object size in the scene.
[0047] In step S2, the underlying data structure is a list of light inlets, which stores the geometric information of all light inlets sequentially, including the coordinates of the four vertices of the rectangle, the center coordinates, the normal vector, and the area. The top layer is a uniform grid, and each grid cell stores two pieces of information: the count of locally visible light inlets, and the starting position and length of a contiguous array pointing to the corresponding inlet index in the light inlet list. Through this two-level structure, any grid cell can record its locally visible subset of light inlets with extremely low memory overhead.
[0048] To fill the visibility mesh, for the center point of each mesh cell (or multiple randomly sampled representative points), test rays are emitted towards the center or four vertices of all light entrances in the scene. Hardware ray tracing is used to quickly determine if occlusion exists. If there is at least one unobstructed path from the representative point of the mesh cell to the four vertices of the light entrance rectangle, or if the line connecting to the center of the light entrance is unobstructed and has a sufficiently large solid angle, then the mesh cell is considered to be able to see the light entrance, and its index is added to the local visible light entrance list of that mesh cell.
[0049] Figure 5 This is a two-level data structure for the local visible light entry grid in this invention. The top level stores the number of local visible light entry points and their corresponding indices, while the bottom level stores the vertex coordinate information of the light entry points.
[0050] In one possible implementation, to further reduce false positives, a multi-point visibility test can be performed on each light inlet. For example, 10×10×10 representative points can be uniformly sampled on the light inlet rectangle, and the light is considered visible only when a certain proportion of the grid cells to these representative points are unobstructed. This conservative strategy can effectively filter out cases where the light only brushes past the edge or is partially obstructed by small occluders, improving the reliability of subsequent importance sampling.
[0051] After pre-calculation, the visibility mesh provides a fast query interface for each voxel location in the scene: given any 3D coordinates, a single 3D index calculation is sufficient to obtain a list of all locally visible light entry points at that location. This list is typically much smaller than the total number of global light entry points, especially in indoor scenes with significant occlusion, where a single mesh cell often contains only 3 to 15 locally visible light entry points, greatly reducing the candidate set size for each path ray during the sampling phase.
[0052] Step S3: At the start of each frame rendering, the average incident irradiance of each light entrance in the forward and reverse directions is calculated by path tracing, and the sampling direction of the light entrance is determined based on the average incident irradiance.
[0053] Because the light source itself may be a translucent glass window, a high-gloss metallic surface, a mirror-reflective surface, or a self-emissive panel, the radiant energy received on its two sides often differs significantly. For example, a glass pane facing a window indoors receives strong sunlight and skylight on its front side (outdoor orientation) during the day, while on its back side (indoor orientation) it mainly receives diffuse indoor light, with the brightness difference between the two sides reaching tens or even hundreds of times. If sampling is always performed from a fixed side, it will inevitably lead to a large number of invalid paths or a severe underestimation of energy.
[0054] Therefore, a lightweight update of the radiative characteristics of each optical inlet is required at the beginning of each frame. The method for calculating the average incident radiance in step S3 is as follows: S3.1 At the centroid of each optical entrance rectangle, define the positive hemisphere direction with its normal vector, and generate multiple uniformly distributed sampling directions through a low-difference sequence; S3.2. For each sampling direction, emit light rays, trace the propagation path of the light rays in the scene, and determine the first intersection point; S3.3 At the first intersection point, the rendering equation is solved by recursively executing path tracing to obtain the outgoing radiance value along the sampling direction; if the ray does not hit any geometry, the value is assigned according to the ambient lighting. S3.4. Based on the sign of the dot product between the sampling direction and the light inlet normal vector, the outgoing radiance of all sampling directions is divided into forward datasets and reverse datasets. S3.5. Perform a weighted average of the radiance values in the forward and reverse datasets to obtain the forward average incident radiance and the reverse average incident radiance of the optical inlet, which will be used for the adaptive flipping of the optical inlet normal in subsequent steps.
[0055] In one embodiment, to reduce computational overhead per frame, a time reuse strategy can be employed: the average incident radiance calculated in both directions from the previous frame is fused with the newly sampled result of the current frame using an exponential moving average, and the fusion coefficient is adaptively adjusted according to the dynamic range of the scene. When the light source moves quickly or the camera moves rapidly in the scene, the fusion coefficient is biased towards the current frame; when the scene is relatively static, more historical information is retained, thereby reducing noise while maintaining response speed.
[0056] Step S4: Perform path tracing and sampling fusion, which consists of the following sub-steps.
[0057] S4.1 Obtain the 3D coordinates of the current path vertex, query the visibility grid based on the 3D coordinates, and obtain the set of local visible light entrances corresponding to the grid cell to which the path vertex belongs.
[0058] In each iteration of path tracing, when a ray collides with scene geometry to form a new path vertex, the world space 3D coordinates of that vertex are first read. These coordinates are then mapped to a pre-built visibility mesh index, specifically by linearly mapping each component of the coordinates and rounding them to obtain the corresponding voxel mesh index. The number of local visible light entrances stored in that voxel cell and the corresponding starting offset of the index array are then queried. Subsequently, the light entrance objects pointed to by these indices are read sequentially from the global light entrance list, thereby obtaining the set of local visible light entrances that the current path vertex can directly see.
[0059] It's important to note that because the visibility mesh is uniformly divided, all surface points within the same voxel theoretically share approximately the same visibility information. In an indoor office setting, such as a conference room with floor-to-ceiling windows, when a path vertex is located in the center of the conference table, its corresponding mesh cell can typically observe all or most of the window area. However, when it's located near a filing cabinet in a corner, it might only see part of the window edge or be completely obscured by a pillar. This spatial locality means that the size of the resulting set of local visible light entrances is usually kept relatively small, typically between 2 and 12, thus providing an efficient candidate set for subsequent weighted selection.
[0060] Step S4.2: If the local visible light entrance set is not empty, calculate the weight of each light entrance based on the solid angle from each light entrance to the path vertex and the average incident irradiance, and select the target light entrance from the local visible light entrance set through weighted reservoir sampling.
[0061] When there is at least one local visible light entrance at a path vertex, the most valuable entrance needs to be selected as the primary guiding target for this sampling. The weight calculation considers two factors: first, the geometric factor, namely the solid angle that the light entrance opens relative to the path vertex. The larger the solid angle, the higher the proportion of the field of view occupied by the entrance in the current vertex view, and the more worthy it is of priority sampling; second, the radiation factor, namely the bidirectional average incident radiance estimated by the entrance in the current frame. The higher the radiance, the stronger the energy being transmitted by the entrance.
[0062] Specifically, for each optical entrance in the set, the average distance from the four vertices of its rectangle to the path vertex is first calculated. Then, the solid angle is approximately estimated based on the entrance area and this average distance. Next, the solid angle value is multiplied by the mean bidirectional average incident radiance of that entrance to obtain the overall weight. The weights of all optical entrances are summed to form a normalized distribution.
[0063] Subsequently, a weighted reservoir sampling algorithm is used to extract a target light entrance from this distribution. The advantage of weighted reservoir sampling is that the selection can be completed by traversing the candidate set only once, and the selection probability is strictly proportional to the weight, thus ensuring that entrances with high energy and large viewing angle are selected first. In actual rendering of a living room with multiple downlights and floor-to-ceiling windows, when the path vertex is near the sofa, the weight calculation usually gives the floor-to-ceiling windows a much higher weight than the downlights, because the solid angle of the floor-to-ceiling windows and the transmitted outdoor sky light energy are much greater than those of a single downlight.
[0064] In one possible implementation, to further stabilize the sampling results, a small amount of random perturbation can be introduced into the weights, or a smooth transition can be achieved by combining the entry point selected in the previous path, so as to avoid screen flickering caused by drastic changes in the sampling target between consecutive frames.
[0065] The formula for calculating the weight of the optical entrance in step S4.2 is as follows:
[0066] in, For light entrance Corresponding path vertex The weight, For light entrance At the apex solid angle at that location For light entrance The mean of the two-way average incident radiance.
[0067] The weighted reservoir sampling in step S4.2 filters out the target light inlet. Then, the probability density function PDF of the optical inlet sampling is corrected using the following formula:
[0068] in, This is a PDF correction factor. This represents the sum of weights for the local visible light ingress set. For the target light entrance The weight, This is a parameter related to the number of sampling directions, and its value is consistent with the number of sampling directions at the centroid of the entrance.
[0069] Step S4.3: According to the preset optical inlet sampling probability Perform optical inlet sampling according to BRDF sampling probability. Perform BRDF sampling and fuse the two sampling results through balanced heuristic multi-importance sampling.
[0070] After selecting the target local visible light entry point, the first step is to perform light entry point sampling. This involves randomly sampling a target point from the current path vertex into the selected light entry point rectangle as the direction of the next ray. The sampling method can be either uniform sampling of the rectangle area or importance sampling based on the projected area observed from the vertex to reduce invalid edge sampling. After obtaining the sampling direction, the probability density function value corresponding to that direction is calculated. This value is mainly determined by the area and distance of the light entry point, as well as the sampling strategy.
[0071] Simultaneously, an independent sampling based on the material's BRDF is performed. Based on the material properties at the path vertices, such as diffuse, specular, refractive, or anisotropic specular highlights, an outgoing direction conforming to the BRDF distribution is generated, and the corresponding BRDF probability density function value is calculated.
[0072] Subsequently, the directional contributions obtained from optical inlet sampling and BRDF sampling are fused using a balanced heuristic multiple importance sampling method. Specifically, the weighted probability of optical inlet sampling is used as the numerator, divided by the total weighted probability of all sampling strategies in the denominator; this denominator is the sum of the numerator and the weighted probability of BRDF sampling. This method can simultaneously utilize optical inlet priors to reduce variance while retaining the adaptability of BRDF sampling to complex materials, thus significantly reducing noise in high-gloss material regions such as mirrors, glass, and metals.
[0073] For example, when rendering a scene of a sports car parked in a showroom, when the path vertex is located in the highlight area of the car's hood, the light entry sampling tends to connect directly to the track lights on the ceiling, while BRDF sampling may generate a path biased towards the direction of specular reflection. The fusion of the two can capture the direct reflection of strong light while preserving the color of the car paint and the micro-surface details.
[0074] The probability density function (PDF) for multiple importance sampling described in step S4.3 is calculated as follows: When sampling at the optical inlet:
[0075] BRDF sampling:
[0076] in, The coordinates of the path vertex. Sampling direction, The outgoing direction of the path vertex. The sampling probability of the optical inlet. This refers to the number of local visible light inlets. The final sampling probability density function, Let be the probability density function for sampling at the optical inlet. Probability density function for BRDF sampling
[0077] Step S4.4: If the local visible light inlet set is empty, directly perform BRDF sampling.
[0078] When the set of local visible light entrances obtained from the path vertex query is empty, it means that the current position is completely occluded and no pre-identified high-energy entrance areas can be directly seen. In this case, to ensure the continuity and integrity of the path, it immediately reverts to the traditional BRDF-based sampling strategy, generating the direction of the next ray according to the material's emission distribution. This fallback mechanism ensures that even in completely enclosed corners, inside cabinets, or areas surrounded by heavy occlusions, the renderer can still continue to generate valid paths, avoiding premature path termination or noticeable black spots.
[0079] In practical applications, this empty set situation often occurs deep in secondary diffuse surfaces or in areas severely obscured by multiple layers of furniture. In this case, although BRDF sampling converges slowly, due to the unbiasedness of path tracing itself, it can still eventually approximate the correct solution through a sufficient number of paths.
[0080] Based on the complete process of path tracing and sampling fusion described above, each path can intelligently select whether to prioritize connecting to the high-energy light entrance based on the local visibility of the current position during each ejection. When there are multiple candidates, the optimal selection is made by weighting. At the same time, the contributions of the two sampling strategies are effectively balanced through multiple importance sampling, thereby significantly improving the convergence speed and quality of the image in areas with strong light sources, specular reflection, and high dynamic range while maintaining real-time performance.
[0081] In one implementation, to further adapt to different scene complexities, the size threshold of the visible light inlet set can be dynamically adjusted. For example, in open outdoor building scenes, each grid cell is allowed to retain more visible inlets to capture contributions from distant sky and sun; while in highly shaded underground parking lot scenes, each grid cell is strictly limited to retaining a maximum of 5 inlets to ensure that the sampling overhead of each path is controllable.
[0082] Furthermore, before the weighted reservoir sampling in step S4.2, the weights can be adjusted by depth attenuation based on the remaining depth of the path. When the path has bounced multiple times and approached the maximum depth, the weight of the distant optical inlet is appropriately reduced, and the inlet with a larger solid angle and closer distance is prioritized, thereby reducing the contribution of invalid long paths and improving energy utilization efficiency.
[0083] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.
Claims
1. A real-time path-guided rendering method based on a local visible light inlet, characterized in that, The method includes the following steps: S1. Identify the bright areas in the incident radiation brightness distribution of the scene sampling points, generate initial candidate light entrances, then merge similar candidate light entrances, remove duplicate light entrances, and obtain all light entrances in the scene. S2. Construct a world space local visible light entry grid covering the entire scene. Calculate the visibility of each grid cell and all light entry points using hardware-accelerated ray tracing. Store the corresponding number and index information of local visible light entry points in each grid cell to form a visibility grid. S3. At the start of each frame rendering, the average incident radiance of each light entrance in the forward and reverse directions is calculated through path tracing, and the sampling direction of each light entrance is determined based on the average incident radiance. S4. Perform path tracing and sampling fusion. The specific process is as follows: S4.1 Obtain the 3D coordinates of the current path vertex, query the visibility mesh based on the 3D coordinates, and obtain the set of local visible light entrances corresponding to the mesh cell to which the path vertex belongs; S4.2 If the set of local visible light entrances is not empty, calculate the weight of each light entrance based on the solid angle from each light entrance to the path vertex and the average incident radiance, and select the target light entrance from the set of local visible light entrances through weighted reservoir sampling. S4.3, According to the preset optical inlet sampling probability Perform optical inlet sampling according to BRDF sampling probability. Perform BRDF sampling and fuse the two sampling results through balanced heuristic multi-importance sampling; S4.4 If the local visible light inlet set is empty, directly perform BRDF sampling.
2. The method according to claim 1, characterized in that, S1 specifically includes the following steps: S1.
1. Sample the scene to obtain multiple point samples. For each point sample, emit light rays from the point sample position to render a distance map and a radiance map. Among them, the distance map stores the nearest distance information, and the radiance map stores the angular distribution of the incident radiance under a constant environment map; Light rays are generated from the pixel center of the normally oriented semi-octahedral texture; S1.2 Set a high-brightness pixel threshold on the radiance map, identify the area with incident radiance greater than the threshold as the high-brightness area in the scene sampling point incident radiance distribution, and generate a corresponding mask. The high-brightness area contains the initial candidate light entrance, and the number of the high-brightness areas is multiple. S1.3 Calculate the ratio of the number of bright pixels in each bright region to the total number of pixels. When the ratio is lower than the preset ratio threshold, discard the bright region. S1.4 Perform morphological closing operation on the mask, detect the contour of each connected region, and fill the region with the index of each contour to obtain the index map; S1.
5. Using the distance information in the distance map and the light direction defined by the semi-octahedral texture pixels, calculate the depth of the pixels, identify pixels with a depth greater than a preset depth threshold as edge pixels, and record the position of the edge pixels. S1.6 Perform a dilation operation on the index map to obtain the region index of the edge pixels; divide all points into multiple point clouds according to the region index; S1.7 Calculate the distance between adjacent point clouds, merge point clouds with a distance less than a preset distance threshold, and obtain the merged point cloud; S1.
8. Clustering algorithm is used to cluster the point cloud, and clusters with fewer than a preset threshold number of points are removed. S1.
9. Use a plane detection algorithm to detect the plane, remove outliers from the points in the plane, and project the remaining points onto the plane. S1.10 Find the rectangle with the smallest area for each projection area. This rectangle is the generated light entrance.
3. The method according to claim 1, characterized in that, The clustering algorithm described in step S1.9 is the density-based clustering algorithm DBSCAN.
4. The method according to claim 1, characterized in that, The plane detection algorithm described in step S1.9 is the RANSAC algorithm.
5. The method according to claim 1, characterized in that, The visibility grid described in step S2 is a two-level data structure. The bottom layer is a list of light entrances that stores information on all local visible light entrance vertices, and the top layer is a uniform grid that stores the number and index of local visible light entrances in each grid cell.
6. The method according to claim 1, characterized in that, The light inlet is a double-sided light inlet. The normal direction of the light inlet is defined as the positive direction. If the average incident radiation brightness in the positive direction is less than that in the reverse direction, the light is guided from the positive direction to the reverse direction. Conversely, it guides the light from the opposite direction to the positive direction.
7. The method according to claim 1, characterized in that, The method for calculating the average incident radiance in step S3 is as follows: S3.1 At the centroid of each optical entrance rectangle, define the positive hemisphere direction with its normal vector, and generate multiple uniformly distributed sampling directions through a low-difference sequence; S3.
2. For each sampling direction, emit light rays, trace the propagation path of the light rays in the scene, and determine the first intersection point; S3.3 At the first intersection point, the rendering equation is solved by recursively executing path tracing to obtain the outgoing radiance value along the sampling direction; if the ray does not hit any geometry, the value is assigned according to the ambient light. S3.
4. Based on the sign of the dot product between the sampling direction and the light inlet normal vector, the outgoing radiance of all sampling directions is divided into forward datasets and reverse datasets. S3.
5. Perform a weighted average of the radiance values in the forward and reverse datasets respectively to obtain the forward average incident radiance and the reverse average incident radiance of the optical entrance, which will be used for the adaptive flipping of the optical entrance normal in subsequent steps.
8. The method according to claim 1, characterized in that, The formula for calculating the weight of the optical entrance in step S4.2 is as follows: in, For light entrance Corresponding path vertex The weight, For light entrance At the apex solid angle at that location For light entrance The average incident radiance in both directions.
9. The method according to claim 1, characterized in that, The target optical inlet is selected by sampling and filtering in the weighted water storage tank as described in step S4.
2. Then, the probability density function PDF of the optical inlet sampling is corrected using the following formula: in, This is a PDF correction factor. This represents the sum of weights for the local visible light ingress set. For the target light entrance The weight, This is a parameter related to the number of sampling directions, and its value is consistent with the number of sampling directions at the centroid of the entrance.
10. The method according to claim 1, characterized in that, The probability density function (PDF) for multiple importance sampling described in step S4.3 is calculated as follows: When sampling at the optical inlet: BRDF sampling: in, The coordinates of the path vertex. Sampling direction, The outgoing direction of the path vertex. The sampling probability of the optical inlet. This refers to the number of local visible light inlets. The final sampling probability density function, Let be the probability density function for sampling at the optical inlet. The probability density function for BRDF sampling.