An improved method of photon mapping
By optimizing the storage and computation of photon maps using BVH trees and KD trees in the photon mapping algorithm, the problems of high memory requirements and image noise in the photon mapping algorithm are solved, and efficient lighting rendering effect is achieved.
Patent Information
- Application Number
- CN202211307676.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-25
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2042-10-25
AI Technical Summary
Existing photon mapping algorithms require a large amount of memory during rendering and have uneven photon distribution, resulting in image noise and high memory requirements.
BVH trees are used for preprocessing to store photon maps on each object. KD trees and KNN nearest neighbor estimation are used for radiance estimation to optimize the organization and storage of photon maps. The SAH strategy is combined to improve the speed of finding intersections between rays or photons and objects.
It reduces memory requirements, decreases image noise, and improves rendering quality and speed, especially in large-scene rendering where it effectively manages memory and computing resources.
Smart Images

Figure CN115512032B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of realistic rendering in computer graphics, and specifically to an improved photon mapping algorithm. Background Technology
[0002] Photon mapping is a global illumination algorithm used to achieve realistic rendering effects. Realistic rendering technology is an important research area in computer graphics, and global illumination is a crucial means of obtaining realistic graphics effects. Its main purpose is to simulate the interaction between light and objects in the real world as closely as possible, taking into account various lighting effects to make the scene look more in line with human perception.
[0003] The photon mapping algorithm is a two-stage global illumination algorithm:
[0004] The first stage is the photon tracing stage. Photons are emitted from the light source into the scene, and then these photons are tracked in the scene space. If a photon intersects with the surface of a diffuse object, it is stored in the photon map, containing data including photon energy, position, and incident direction. Otherwise, the photon's direction is first changed based on the object's surface properties, and then the photon is recursively tracked. During photon tracing, when a photon collides with an object surface, it may be reflected, refracted, scattered, and absorbed, but the photon does not split; only its energy is reduced due to absorption by the colliding object. After all photon tracing is complete, all the stored photons are organized into a KD tree for radiance estimation in the second channel.
[0005] The second stage is the ray tracing stage. First, rays are emitted from the viewpoint through screen pixels into the scene, and these rays are traced in scene space. If a ray intersects a diffuse object, the radiance is estimated based on finding K (K>=1) photons near the intersection point, and the color value of the intersection point is calculated. Otherwise, the ray's outgoing direction is calculated based on the object's surface properties, and the ray is traced until it reaches the diffuse object's surface, the light source, or the maximum tracing depth. Compared to other global illumination methods, photon mapping not only achieves global illumination effects but also effectively handles caustics and glow effects, and its performance is highly efficient. However, it requires additional memory space to store the photon map. Summary of the Invention
[0006] The original photon mapping algorithm stores all photons in a large photon map. However, to ensure the final rendering quality, a large number of photons need to be emitted, resulting in a large memory requirement for the photon map, while computer memory is limited. Furthermore, due to the randomness of the photon emission function, the photon distribution in the photon map is uneven, leading to noise in the final rendered image. To address these problems, this invention provides an improved photon mapping method.
[0007] An improved method for photon mapping includes the following steps:
[0008] Step 1: Preprocess the scene and organize the BVH tree;
[0009] Step 2, calculate photon tracing: randomly emit photons from the light source into the scene and trace these photons in the scene space;
[0010] Step 3: Determine whether the photon intersects with a certain BVH node. If they do not intersect, discard the photon; otherwise, calculate the intersection result between the photon and the object within the BVH node.
[0011] Step 4: Determine if the intersection point is a point on the diffuse reflection surface. If not, recursively trace the photon based on the information from the object's surface and return to Step 3.
[0012] Step 5: Detect whether the photon is a caustic photon. If it is, save the photon in the caustic photon map of the intersecting object; otherwise, save it in the global photon map of the intersecting object.
[0013] Step 6, calculate ray tracing: emit rays from the viewpoint into the scene and perform photon tracing;
[0014] Step 7: Determine whether the ray intersects with a BVH node. If they do not intersect, return the background color. Otherwise, calculate the intersection result of the ray with the object in the BVH node and calculate the direct lighting.
[0015] Step 8: Determine if the intersection point is a point on the diffuse reflection surface. If not, recursively trace the light rays based on the information of the object's surface and return to step 7.
[0016] Step 9: Check whether the two photon maps of the object have been organized using a KD tree. If not, organize the photon maps using a KD tree first, and then use the K-nearest neighbor method to estimate the radiance of the collision point based on the photon maps organized using the KD tree, and calculate the indirect diffuse reflection illumination and indirect caustic illumination.
[0017] Step 10: Calculate the global illumination at the collision point.
[0018] As a preferred approach, photon maps are stored on each object individually, rather than as a whole. For global illumination rendering of large scenes, objects and photon maps that are not within the field of view can also be placed in external storage, and only objects and photon maps within the field of view are loaded, thus reducing the memory limitation on the algorithm.
[0019] If the photon graphs of intersecting objects are not organized using KD trees, then KD trees are used to organize the photon graphs first, and then KNN nearest neighbor estimation is used to estimate the radiance. The photon graphs of each object are only organized using KD trees when needed and for the first time.
[0020] As a preferred approach, a BVH tree based on the SAH strategy is used to preprocess objects in the scene.
[0021] As a preferred option, the global illumination calculation formula is as follows: Global Illumination = Direct Illumination + Indirect Diffuse Illumination + Indirect Caustic Illumination + Gloss / Specular Illumination;
[0022] The rendering equation for lighting is as follows:
[0023]
[0024] Where: p represents the incident point, L o (p,w o ) represents starting from point p on the surface of the object, along w o Outgoing radiance in the direction; L e (p,w o () represents the intrinsic radiance of an object; this value is only valid for self-luminous objects; L i (p,w i () is the incident direction w i The intensity of the incident light hitting point p; f r (p,w i ,w o () is the incident direction w i Illuminate point p, then along w o The BRDF value reflected in the direction; n is the normal vector of point p on the object surface, L r (p,w o () represents the incident radiance in all directions on a hemisphere;
[0025] The above rendering equation shows that the outgoing radiance of an object's surface in the scene is equal to the sum of its own radiance and the incident radiance in all directions on the hemisphere.
[0026] The second part of the rendering equation, L r (p,w o )include:
[0027] First, the BRDF reflection function can be divided into two parts based on roughness: gloss / specular reflectance: f r,s and diffuse reflectance: f r,d :
[0028] f r (p,w i ,w o )=f r,s (p,w i ,w o )+f r,d (p,w i ,w o )
[0029] Secondly, in photon mapping, the source of illumination (i.e., the incident radiance) can be divided into three parts:
[0030] L i,l (p,w o Direct lighting, that is, receiving light directly from a real light source;
[0031] L i,c (p,w o Caustic lighting refers to indirect lighting that originates from the light source and reaches the diffuse surface after at least one specular / glossy reflection / refraction.
[0032] L i,d (p,w o Other indirect lighting refers to indirect lighting that originates from the light source, undergoes at least one diffuse reflection, and falls onto the diffuse surface.
[0033] Therefore, the second part L of the rendering equation r (p,w o The calculation is as follows:
[0034]
[0035] In the above formula, the first part represents direct illumination, which is calculated using the Blinn-Phong model;
[0036] The second part represents gloss / specular reflection, using the illumination / specular reflection coefficient f. r,s ;
[0037] The third part represents caustic illumination, which occurs only on diffuse surfaces, so the reflectance coefficient used is f. r,d It will extract photons from the caustic photon map to estimate radiance;
[0038] Part four represents multiple diffuse reflections, using a reflection coefficient of f. r,dIt indicates that the incident light has undergone at least one diffuse reflection after leaving the source, and then reflected again from the current diffuse surface. It will obtain photons from the global photon map to estimate the radiance.
[0039] The essential features of this invention are as follows:
[0040] (1) By storing the photon map on each object, when estimating the radiance of the collision point, it is not necessary to traverse the entire scene's photon map. This can filter out most photons that do not affect the collision point, thus improving the calculation speed of radiance estimation.
[0041] (2) A BVH tree based on the SAH strategy is used to preprocess objects in the scene. This is done to improve the speed of intersection between light or photon and scene objects.
[0042] (3) The lighting calculation at the shading point is split, which can greatly improve the final rendering quality. Attached Figure Description
[0043] Figure 1 This is a schematic diagram of photon mapping.
[0044] Figure 2 Here is a flowchart of the photon mapping process;
[0045] Figure 3 This is a flowchart illustrating the improved photon mapping method implemented in this invention. Detailed Implementation
[0046] The technical solution of the present invention will be further described in detail below through specific embodiments and in conjunction with the accompanying drawings.
[0047] like Figure 1 , Figure 2 and Figure 3 As shown, the present invention divides the implementation process of global illumination into the following three stages:
[0048] (1) Preprocessing stage: The objects in the scene are organized using a BVH tree based on the SAH strategy, which is used to accelerate the intersection of light or photon with scene objects.
[0049] (2) Photon tracing stage:
[0050] 1. Randomly emit photons from the light source into the scene and track these photons in the scene space.
[0051] 2. Determine whether a photon intersects with a certain BVH node.
[0052] 3. If the photon does not intersect, discard it; otherwise, calculate the intersection result between the photon and the object within the BVH node.
[0053] 4. Determine if the intersection point is a point on the diffuse reflection surface.
[0054] 5. If the photon is not recursively tracked based on information from the object's surface, proceed to step 2.
[0055] 6. Otherwise, check whether the photon is a caustic photon.
[0056] 7. If yes, store the photon in the caustic photon map of the intersecting objects; otherwise, store it in the global photon map of the intersecting objects.
[0057] 8. Note: Only photons that have bounced once or multiple times are saved here; direct photons are not saved. (3) Ray tracing stage:
[0058] 1. Emit rays from the viewpoint into the scene and perform photon tracing.
[0059] 2. Determine whether the ray intersects with a certain BVH node.
[0060] 3. If the light does not intersect, return the background color; otherwise, calculate the intersection of the light with the object within the BVH node and calculate the direct lighting (Note: If the light intersects with the light source, directly return the light source color, and the following steps are unnecessary).
[0061] 4. Determine if the intersection point is a point on the diffuse reflection surface.
[0062] 5. If not, recursively trace the light rays based on the information from the object's surface, and proceed to step 2.
[0063] 6. Otherwise, check whether the two photon maps of the object have been organized using a KD tree.
[0064] 7. If not, first use a KD-tree to organize the photon map, and then use the K-nearest neighbor method to estimate the radiance of the collision points based on the KD-tree-organized photon map, calculating the indirect diffuse illumination and indirect caustic illumination.
[0065] 8. Calculate the global illumination at the collision point (Global Illumination = Direct Illumination + Indirect Diffuse Illumination + Indirect Caustic Illumination + Gloss / Specular Illumination)
[0066] The improvements of this invention are as follows:
[0067] (1) A new method for storing photon maps
[0068] Instead of storing the photon map as a whole, it is stored separately for each object. This eliminates the need to traverse the entire scene's photon map when estimating radiance at collision points, filtering out most photons that do not affect the collision points and improving the computation speed of radiance estimation. Furthermore, for global illumination rendering of large scenes, objects and photon maps outside the viewport can be stored in external storage, loading only those within the viewport, reducing memory constraints on the algorithm. Additionally, if the photon maps of intersecting objects are not organized using a KD-tree, they are first organized using a KD-tree, followed by KNN nearest neighbor estimation for radiance estimation. Each object's photon map is only organized using a KD-tree when needed and for the first time, avoiding many unnecessary calculations.
[0069] (2) Use BVH trees based on SAH strategy to preprocess objects in the scene.
[0070] This is done to improve the speed of finding intersections between rays or photons and scene objects. The intersection result between the ray or photon and the child nodes (or objects) within a node is only calculated when the ray or photon intersects with a certain BVH node. This allows for the rapid identification of objects that intersect with the ray or photon.
[0071] (3) Split the lighting calculation at the shading point.
[0072] The rendering equation is as follows:
[0073]
[0074] Where: p represents the incident point, L o (p,w o ) represents starting from point p on the surface of the object, along w o Outgoing radiance in the direction; L e (p,w o () represents the intrinsic radiance of an object; note that this value is only valid for self-illuminating objects; L i (p,w i () is the incident direction w i The intensity of the incident light hitting point p; f r (p,w i ,w o () is the incident direction w i Illuminate point p, then along w o The BRDF value reflected in the direction; n is the normal vector of point p on the object surface, L r (p,w o () represents the incident radiance in all directions on the hemisphere.
[0075] The above rendering equation shows that the outgoing radiance of an object's surface in the scene is equal to the sum of its own radiance and the incident radiance in all directions on the hemisphere.
[0076] For the second part L of the rendering equation r (p,w o It can be further divided.
[0077] First, the BRDF reflection function can be divided into two parts based on roughness: gloss / specular reflectance: f r,s and diffuse reflectance: f r,d :
[0078] f r (p,w i ,w o )=f r,s (p,w i ,w o )+f r,d (p,w i ,w o )
[0079] Secondly, in photon mapping, the source of illumination (i.e., the incident radiance) can be divided into three parts:
[0080] ·L i,l (p,w o Direct lighting, that is, receiving light directly from a real light source.
[0081] ·L i,c (p,w o Caustic lighting refers to indirect lighting that originates from a light source and is reflected or refracted at least once by a specular / glossy surface before reaching a diffuse surface.
[0082] ·L i,d (p,w o Other indirect lighting refers to indirect lighting that originates from the light source, undergoes at least one diffuse reflection, and falls onto the diffuse surface.
[0083] Therefore, the second part L of the rendering equation r (p,w o The calculation is as follows:
[0084]
[0085] In the above formula, the first part represents direct illumination, which can be calculated directly using the Blinn-Phong model.
[0086] The second part represents gloss / specular reflection, using the illumination / specular reflection coefficient f. r,sIt will be calculated using traditional ray tracing methods, without involving any photon estimation.
[0087] The third part represents caustic illumination, which occurs only on diffuse surfaces, so the reflectance coefficient used is f. r,d It will extract photons from the caustic photon map to estimate radiance.
[0088] The fourth part represents multiple diffuse reflection, using a reflection coefficient of f. r,d It indicates that the incident light has undergone at least one diffuse reflection after leaving the source, and then reflected again from the current diffuse surface. It will obtain photons from the global photon map to estimate the radiance.
[0089] Ignoring self-emission, the global illumination of a shading point equals direct lighting + indirect diffuse lighting + indirect caustic lighting + glossy / specular lighting. This significantly improves the final rendering quality.
Claims
1. An improved method for photon mapping, characterized in that, Includes the following steps: Step 1: Preprocess the scene and organize the BVH tree; Step 2, calculate photon tracing: randomly emit photons from the light source into the scene and trace these photons in the scene space; Step 3: Determine whether the photon intersects with a certain BVH node. If they do not intersect, discard the photon; otherwise, calculate the intersection result between the photon and the object within the BVH node. Step 4: Determine if the intersection point is a point on the diffuse reflection surface. If not, recursively trace the photon based on the information from the object's surface and return to Step 3. Step 5: Detect whether the photon is a caustic photon. If it is, save the photon in the caustic photon map of the intersecting object; otherwise, save it in the global photon map of the intersecting object. Step 6, calculate ray tracing: emit rays from the viewpoint into the scene and perform photon tracing; Step 7: Determine whether the ray intersects with a BVH node. If they do not intersect, return the background color. Otherwise, calculate the intersection result of the ray with the object in the BVH node and calculate the direct lighting. Step 8: Determine if the intersection point is a point on the diffuse reflection surface. If not, recursively trace the light rays based on the information of the object's surface and return to step 7. Step 9: Check whether the two photon maps of the object have been organized using a KD tree. If not, organize the photon maps using a KD tree first, and then use the K-nearest neighbor method to estimate the radiance of the collision point based on the photon maps organized using the KD tree, and calculate the indirect diffuse reflection illumination and indirect caustic illumination. Photon maps are stored on each object individually, rather than as a whole. For global illumination rendering of large scenes, objects and photon maps that are not within the field of view can be placed in external storage, and only objects and photon maps within the field of view are loaded, reducing the memory limitation on the algorithm. If the photon graphs of intersecting objects are not organized using KD trees, then KD trees are used to organize the photon graphs first, and then KNN nearest neighbor estimation is used to estimate the radiance. The photon graphs of each object are only organized using KD trees when needed and for the first time. Step 10: Calculate the global illumination at the collision point.
2. The improved method for photon mapping according to claim 1, characterized in that, A BVH tree based on the SAH strategy is used to preprocess objects in the scene.
3. The improved method for photon mapping according to claim 1, characterized in that, The formula for calculating global illumination is as follows: Global Illumination = Direct Illumination + Indirect Diffuse Illumination + Indirect Caustic Illumination + Gloss / Specular Illumination; The rendering equation for lighting is as follows: Where: p represents the incident point, L o (p,w o ) represents starting from point p on the surface of the object, along w o Outgoing radiance in the direction; L e (p,w o () represents the intrinsic radiance of an object; this value is only valid for self-luminous objects; L i (p,w i () is the incident direction w i The intensity of the incident light illuminating point p; f r (p,w i ,w o () is the incident direction w i Illuminate point p, then along w o The BRDF value reflected in the direction; n is the normal vector of point p on the object surface, L r (p,w o () represents the incident radiance in all directions on a hemisphere; The above rendering equation shows that the outgoing radiance of an object's surface in the scene is equal to the sum of its own radiance and the incident radiance in all directions on the hemisphere. The second part of the rendering equation, L r (p,w o )include: First, the BRDF reflection function can be divided into two parts based on roughness: gloss / specular reflectance: f r,s and diffuse reflectance: f r,d : f r (p,w i ,w o )=f r,s (p,w i ,w o )+f r,d (p,w i ,w o ) Secondly, in photon mapping, the source of illumination (i.e., the incident radiance) can be divided into three parts: L i,l (p,w o Direct lighting, that is, receiving light directly from a real light source; ·L i,c (p,w o Caustic lighting refers to indirect lighting that originates from the light source and reaches the diffuse surface after at least one specular / glossy reflection / refraction. L i,d (p,w o Other indirect lighting refers to indirect lighting that originates from the light source, undergoes at least one diffuse reflection, and falls onto the diffuse surface. Therefore, the second part L of the rendering equation r (p,w o The calculation is as follows: In the above formula, the first part represents direct illumination, which is calculated using the Blinn-Phong model; The second part represents gloss / specular reflection, using the illumination / specular reflection coefficient f. r,s ; The third part represents caustic illumination, which occurs only on diffuse surfaces, so the reflectance coefficient used is f. r,d It will extract photons from the caustic photon map to estimate radiance; Part four represents multiple diffuse reflections, using a reflection coefficient of f. r,d It indicates that the incident light has undergone at least one diffuse reflection after leaving the source, and then reflected again from the current diffuse surface. It will obtain photons from the global photon map to estimate the radiance.