Method, device, equipment and storage medium for calculating global illumination
By establishing an additional sample pool in the world space and calculating global illumination based on ray tracing, the shortcomings of global illumination calculation in the existing technology are solved, and efficient and realistic rendering effects are achieved.
Patent Information
- Application Number
- CN202311865295.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2043-12-29
AI Technical Summary
The existing global lighting calculation methods have problems such as missing indirect light reflections outside screen space, violation of spatial adjacent similarity principle, resulting in lighting errors, and the rendering speed of neural network-based methods is slow and prone to errors.
Create multiple additional sample pools in world space, remap samples in the historical sample pools to these additional sample pools, calculate total radiation, including direct light and indirect light, based on multiple reflection ray tracing, and update the additional sample pools .
By making full use of historical data, the amount of calculation required to generate new data is reduced, processor performance is saved, rendering efficiency is improved, more realistic imaging effects are obtained, and problems such as light leakage are improved.
Smart Images

Figure CN117830501B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to, but is not limited to, the field of graphics processing technology, and in particular to a method, device, equipment and storage medium for calculating global illumination. Background Art
[0002] Global Illumination (GI) refers to a rendering technique that takes into account both the direct light from the light source in the scene and the indirect light reflected by other objects in the scene.
[0003] In the related technology, there are many problems with global illumination. For example, the calculation method based on screen space (Screnn Space) lacks the multiple reflected indirect light outside the screen space, which will cause the overall illumination and the corners of the scene to not receive enough illumination, thus causing the rendering effect to be dark. For another example, the calculation method based on probes is based on the principle of spatial proximity and similarity. Therefore, violations of the principle of spatial proximity and similarity will lead to illumination errors, thus causing problems such as light leakage. For another example, the calculation method based on neural networks involves training the network and fitting the radiation field, so additional training and computing resources are required, resulting in too slow rendering speed and prone to rendering errors. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a method, apparatus, device and storage medium for calculating global illumination, which can save processor performance and improve imaging effects.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] An embodiment of the present application provides a method for calculating global illumination, which includes: establishing multiple additional sample pools in world space; remapping samples in multiple historical sample pools to at least part of the additional sample pools; calculating total radiation in the world space based on ray tracing of multiple reflections; the total radiation includes direct light and indirect light; and updating the additional sample pool based on the total radiation.
[0007] In some embodiments, establishing multiple additional sample pools in the world space includes: dividing the world space into multiple voxels according to a hierarchical mapping structure; wherein the total number of voxels is equal to the product of the three-dimensional buffer resolution and the number of three-dimensional buffers; and establishing one additional sample pool in each voxel.
[0008] In some embodiments, the world space is divided into multiple voxels according to a hierarchical mapping structure, including: dividing the world space into multiple levels of spatial regions with the camera as the center; wherein the higher the level of each level of the spatial region is, the closer it is to the camera and the larger the radius of the region is; and each level of the spatial region is divided into multiple voxels.
[0009] In some embodiments, the higher the level of each level of the spatial region is, the more voxels are divided into at each level of the spatial region, and the smaller the volume of each voxel is.
[0010] In some embodiments, the total radiation is calculated in the world space based on ray tracing of multiple reflections, including: performing ray tracing of a single reflection to obtain multiple hit points; each hit point is the intersection of a beam of light emitted by a light source and the surface of a reflector; sampling samples in a neighboring sample pool with each hit point as the center; the distance between the center point of the voxel corresponding to the neighboring sample pool and the hit point is less than or equal to a first threshold; determining whether the samples in the neighboring sample pool are valid samples; if the samples in the neighboring sample pool are valid samples, performing weighted summation on the valid samples to obtain indirect light for each hit point.
[0011] In some embodiments, the total radiation is calculated in the world space based on ray tracing of multiple reflections, and also includes: calculating the direct light for each of the hit points; the direct light is the light directly received by each of the hit points; and combining the direct light and the indirect light of each of the hit points to obtain the total radiation of each of the hit points.
[0012] In some embodiments, determining whether the samples in the neighboring sample pool are valid samples includes: if the distance between any of the hit points and the camera is less than or equal to a second threshold, determining the corresponding unobstructed samples in the neighboring sample pool as the valid samples.
[0013] In some embodiments, the determining whether the samples in the neighboring sample pool are valid samples further includes: if the distance between any of the hit points and the camera is greater than a second threshold, all the corresponding samples in the neighboring sample pool are determined to be the valid samples.
[0014] In some embodiments, updating the additional sample pool based on the total radiation includes: calculating the coordinates of the additional sample pool corresponding to the total radiation; randomly sampling the total radiation; and updating the results of the random sampling to the additional sample pool corresponding to the sample pool coordinates.
[0015] In some embodiments, the random sampling of the total radiation includes: dividing the total radiation corresponding to the same additional sample pool into multiple sample columns; randomly selecting one of the sample columns, and updating the samples in the sample column to the corresponding additional sample pool.
[0016] In some embodiments, after updating the additional sample pool, the method for calculating global illumination further includes: updating a sample pool in screen space based on the additional sample pool; and rendering based on the updated sample pool in screen space.
[0017] An embodiment of the present application also provides a device for calculating global illumination, which includes: a sample pool establishment module, configured to establish multiple additional sample pools in the world space; a remapping module, configured to remap samples in multiple historical sample pools to at least part of the additional sample pools; a ray tracing module, configured to calculate total radiation in the world space based on ray tracing of multiple reflections; the total radiation includes direct light and indirect light; and a sample pool update module, configured to update the additional sample pool based on the total radiation.
[0018] An embodiment of the present application also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in an electronic device, a processor in the electronic device executes the steps in the above method.
[0019] An embodiment of the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the steps in the above method when executing the program.
[0020] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method are implemented.
[0021] It can be seen that, on the one hand, in the embodiment of the present application, samples in multiple historical sample pools are remapped to at least part of the additional sample pools, so that historical data can be fully utilized in global illumination, and the amount of calculation required to generate new data can be reduced, thereby saving processor performance and improving calculation efficiency. On the other hand, in the embodiment of the present application, based on ray tracing of multiple reflections, the total radiation including direct light and indirect light is calculated, so that the imaging effect is closer to the real living environment, that is, a more realistic imaging effect can be obtained, and problems such as light leakage can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1A schematic diagram of the implementation process of a method for calculating global illumination provided in an embodiment of the present application Figure 1 ;
[0023] Figure 2 A schematic diagram of voxels in world space in a method for calculating global illumination provided in an embodiment of the present application;
[0024] Figure 3 A schematic diagram of the implementation process of a method for calculating global illumination provided in an embodiment of the present application Figure 2 ;
[0025] Figure 4 A schematic diagram of the implementation process of a method for calculating global illumination provided in an embodiment of the present application Figure 3 ;
[0026] Figure 5 A schematic diagram of a spatial region in a method for calculating global illumination provided in an embodiment of the present application;
[0027] Figure 6 A schematic diagram of the implementation process of a method for calculating global illumination provided in an embodiment of the present application Figure 4 ;
[0028] Figure 7 A schematic diagram of an occlusion relationship in a method for calculating global illumination provided in an embodiment of the present application;
[0029] Figure 8 A schematic diagram of the implementation process of a method for calculating global illumination provided in an embodiment of the present application Figure 5 ;
[0030] Fig. 9 A schematic diagram of the implementation process of a method for calculating global illumination provided in an embodiment of the present application Figure 6 ;
[0031] Fig.10 A schematic diagram of the implementation process of a method for calculating global illumination provided in an embodiment of the present application Figure 7 ;
[0032] Fig.11 A schematic diagram of the implementation process of a method for calculating global illumination provided in an embodiment of the present application Figure 8 ;
[0033] Fig.12 It is a schematic diagram of rendering effect of related technology;
[0034] Fig.13 A schematic diagram of the rendering effect of a method for calculating global illumination provided in an embodiment of the present application;
[0035] Fig.14A schematic diagram of the structure of a device for calculating global illumination provided in an embodiment of the present application;
[0036] Fig.15 A hardware entity diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0038] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. The terms "first / second / third" involved are merely used to distinguish similar objects and do not represent a specific order for the objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0039] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing this application and are not intended to limit this application.
[0040] The present application embodiment provides a method for calculating global illumination, which can be executed by a processor of a computer device. The computer device may refer to a server, a laptop, a tablet computer, a desktop computer, a smart TV, a set-top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable gaming device), or other device with data processing capabilities.
[0041] Figure 1 A schematic diagram of the implementation flow of a method for calculating global illumination provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes steps S101 to S104.
[0042] S101. Establish multiple additional sample pools in world space.
[0043] It should be noted that the world space refers to the three-dimensional space of the constructed virtual world, and the screen space refers to the two-dimensional space of the display screen. A camera can be set in the world space. The camera can shoot the scene in the world space and present the shooting results in the screen space. The camera can adjust the shooting angle, so that the content of the screen space will change accordingly.
[0044] In the embodiment of the present application, the world space can be divided into a plurality of voxels, and then an additional sample pool is established in each voxel, so that a plurality of additional sample pools are established in the world space. Voxel is the abbreviation of volume pixel, which is the smallest unit of digital data in the three-dimensional space (i.e., world space). The three-dimensional containing voxels can be expressed by three-dimensional rendering or extracting polygonal isosurfaces with given threshold contours.
[0045] Figure 2 This shows some voxels in world space, see Figure 2 , the world space includes three dimensions: u, v, and s, in which 8 voxels are divided. Each voxel covers a certain spatial range. An additional sample pool can be established in each voxel to represent the texture data of the spatial range it covers.
[0046] In the embodiments of the present application, the additional sample pools need to be maintained and updated. The memory space required for each additional sample pool depends on the number of samples that each additional sample pool needs to store and the memory size required for each sample. In some embodiments of the present application, one sample is cached in each additional sample pool, and multiple 2D (two-dimensional) textures are used as cache media, wherein 2D textures are an organized physical memory provided by a GPU (graphics processing unit).
[0047] S102: Remap samples in a plurality of historical sample pools to at least part of the additional sample pools.
[0048] In the embodiment of the present application, due to the change of time, the change of the camera position or the change of the camera shooting angle, it is necessary to update the additional sample pool established in the world space. The samples in multiple historical sample pools can be remapped to at least part of the additional sample pool, so as to complete at least part of the update of the additional sample pool. For example, due to the change of the position of the camera, the distance between some historical sample pools and the camera becomes farther, that is, some texture data is changed from the near view to the distant view; then, the samples in the historical sample pool originally located in the near view can be remapped to the additional sample pool currently located in the distant view, that is, the texture data of the current distant view is updated using the texture data originally located in the near view.
[0049] In an embodiment of the present application, samples in multiple historical sample pools can be retained, and the coordinates of the corresponding additional sample pools can be determined based on the coordinates of the historical sample pools, and then the samples in the historical sample pools can be remapped to the corresponding additional sample pools. Among them, the coordinates of the historical sample pools can be world space coordinates or screen space coordinates; the coordinates of the additional sample pools are world space coordinates. Since screen space coordinates are two-dimensional coordinates, and world space coordinates are three-dimensional coordinates; therefore, determining the world space coordinates of the corresponding additional sample pool based on the screen space coordinates of the historical sample pool is actually the inverse process of transforming the three-dimensional coordinates (world space coordinates) to the corresponding two-dimensional coordinates (screen space coordinates).
[0050] In the embodiment of the present application, samples in multiple historical sample pools may be remapped to the same additional sample pool. For example, if a voxel has a large coverage area, multiple historical sample pools correspond to the additional sample pool of the voxel. In this case, a weighted average method can be used to determine the samples in the additional sample pool, that is, the corresponding samples in the additional sample pool are determined according to the weights of the samples in the multiple historical sample pools.
[0051] It can be understood that by remapping samples in multiple historical sample pools to at least part of the additional sample pools, historical data can be fully utilized in global illumination and the amount of calculation required to generate new data can be reduced, thereby saving processor performance and improving computing efficiency.
[0052] S103. In world space, calculate total radiation based on ray tracing of multiple reflections; the total radiation includes direct light and indirect light.
[0053] In an embodiment of the present application, ray tracing with multiple reflections can be performed in world space. Ray tracing is a rendering algorithm that simulates light emitted by a light source and tracks physical phenomena such as reflection, refraction, and absorption of light in world space; wherein the light source can be located at the position of a camera in world space, or at other positions in world space (for example, a simulated sun). Furthermore, ray tracing with multiple reflections refers to simulating both the path of light emitted directly by the light source and the path of light after reflection and refraction, that is, it can simulate the complete path of light after it is emitted by the light source.
[0054] In the embodiment of the present application, the ray tracing of multiple reflections can obtain the total radiation including direct light and indirect light. Specifically, in the real life environment, the light can come directly from the light source, or it can be obtained by reflection or refraction from other objects. Correspondingly, in the virtual world space, direct light and indirect light can also be simulated, wherein the direct light comes directly from the light source, and the indirect light is obtained by reflection or refraction from other objects.
[0055] It can be understood that by calculating the total radiation including direct light and indirect light based on ray tracing with multiple reflections, global illumination can be achieved and the imaging effect is closer to the real life environment. That is, a more realistic imaging effect can be obtained and problems such as light leakage can be improved.
[0056] S104. Update the additional sample pool based on the total radiation.
[0057] It should be noted that the total radiation contains a large number of samples, among which a large number of samples (e.g., hundreds of samples) may correspond to an additional sample pool. At the same time, the update of the additional sample pool needs to be an atomic operation, where an atomic operation refers to an operation that will not be interrupted by the thread scheduling mechanism. In this way, the processor performance pressure is relatively large, which may result in relatively large performance consumption.
[0058] In the disclosed embodiment, the total radiation may be randomly sampled first, a portion of samples may be sampled, and then the sampled portion of samples (i.e., the result of random sampling) may be updated to the corresponding additional sample pool. In this way, the number of samples that need to be updated in an additional sample pool may be reduced, thereby saving processor performance consumption and improving efficiency.
[0059] In some embodiments of the present application, Figure 3 S201 to S202 shown are implemented Figure 1 S101 shown will be described in conjunction with each step.
[0060] S201. Divide the world space into a plurality of voxels according to a hierarchical mapping structure; wherein the total number of voxels is equal to the product of the resolution of the three-dimensional buffer and the number of the three-dimensional buffer.
[0061] In the disclosed embodiment, the layered mapping structure (Clipmap) is a plurality of three-dimensional buffer areas of different sizes but the same voxels.
[0062] Furthermore, the total number of voxels is equal to the product of the 3D buffer resolution and the number of 3D buffers, as shown in the following formula (1):
[0063] Volumes = X * Y * Z * Num (1);
[0064] In the above formula (1), Volumes represents the number of voxels, X, Y, and Z represent the resolution values of the three-dimensional buffer in three dimensions, and Num represents the number of the three-dimensional buffer.
[0065] In the disclosed embodiment, the number of three-dimensional buffer areas can be determined according to demand, and thus the number of voxels can be determined according to demand.
[0066] S202: In each voxel, establish an additional sample pool.
[0067] In the disclosed embodiment, after the world space is divided into a plurality of voxels, an additional sample pool may be established in each voxel to represent texture data of the spatial range covered by each voxel.
[0068] In some embodiments of the present disclosure, Figure 4 S203-S204 shown are implemented Figure 3 S201 shown will be explained in combination with each step.
[0069] S203, taking the camera as the center, dividing the world space into multiple levels of spatial regions; wherein, the higher the level of each spatial region is, the closer it is to the camera and the larger the region radius is.
[0070] In the embodiments of the present disclosure, reference Figure 5 , with the camera as the center, the world space is divided into multiple levels of space regions. Each level of space region can correspond to a three-dimensional buffer area, thus realizing a hierarchical mapping structure.
[0071] It should be noted that Figure 5 The highest level area and the second highest level area are illustrated as examples, and other spatial areas can be understood by referring to the highest level area and the second highest level area.
[0072] In the embodiment of the present disclosure, the higher the level of each spatial region, the closer it is to the camera and the larger its radius; that is, as the level of the spatial region decreases, the farther the spatial region is from the camera, and the radius of the spatial region will also decrease multiples. Figure 5 The highest level area is closest to the camera, and the area radius d1 of the highest level area is the largest. Compared with the highest level area, the second highest level area is farther from the camera, and the area radius d2 of the second highest level area is smaller than the area radius d1 of the highest level area.
[0073] In the disclosed embodiment, the area radius of each level of spatial area can be determined according to demand, that is, the size covered by each level of spatial area can be determined according to demand.
[0074] S204, dividing each level of spatial region into a plurality of voxels.
[0075] In the embodiment of the present disclosure, after the world space is divided into multiple levels of spatial regions, each level of spatial region can be divided into multiple voxels. Figure 5 , the highest level region is divided into a plurality of voxels (the dividing lines are indicated by dotted lines); correspondingly, other spatial regions can also be divided into a plurality of voxels.
[0076] It can be understood that the world space is divided into multiple voxels according to the hierarchical mapping structure. In this way, on the one hand, the sample pool coordinates can be established, that is, each voxel can be located according to the level of the spatial region; for example, for any voxel, it is possible to first determine which level of spatial region the voxel belongs to, and then determine the position of the voxel in the spatial region of that level; thereby, the position of the voxel can be determined more quickly, reducing the amount of calculation in the process of determining the position of the voxel. On the other hand, the voxels can be set according to the level of the spatial region; for example, the voxels can be set according to the near view or the far view (i.e., the distance from the camera) to enhance the imaging effect.
[0077] In some embodiments of the present application, the number of voxels into which each spatial region is divided and the volume of each voxel may be determined according to the level of each spatial region.
[0078] For example, the higher the level of each spatial region, the more voxels are divided into each spatial region, and the smaller the volume of each voxel is. In other words, the highest level region can be divided into the most voxels, and the volume of each voxel is the smallest, that is, the voxels in the highest level region are arranged most densely; correspondingly, as the level of the spatial region decreases, the volume of the voxels in the spatial region increases step by step, and the compactness of the voxel arrangement in the spatial region also decreases step by step.
[0079] It can be understood that since the higher the level of the spatial area, the closer it is to the camera, therefore, dividing the voxels into smaller volumes in the higher-level spatial area is conducive to setting more texture data in the area closer to the camera, that is, being able to show the close view more clearly, which is conducive to a more realistic imaging effect.
[0080] In some embodiments of the present disclosure, Figure 6 S301 to S304 shown are implemented Figure 1 S103 shown will be described in conjunction with each step.
[0081] S301, performing ray tracing of a single reflection to obtain multiple hit points; each hit point is an intersection point between a beam of light emitted by a light source and a surface of a reflector.
[0082] In the embodiment of the present disclosure, when using the ray tracing method to generate samples, a single reflection ray tracing can be performed first to obtain multiple hit points. Figure 7 The projected light is a beam of light emitted by the light source, and a hit point is generated after the projected light hits the reflector. Correspondingly, multiple light rays emitted by the light source can obtain multiple hit points.
[0083] S302 , taking each hit point as the center, sampling samples in the adjacent sample pool; the distance between the center point of the voxel corresponding to the adjacent sample pool and the hit point is less than or equal to a first threshold.
[0084] In the disclosed embodiment, after obtaining multiple hit points, the samples in the adjacent sample pool can be sampled with the world space coordinates of each hit point of a single reflection as the center. Here, the adjacent sample pool is a sample pool in some voxels that are close to the hit point, and the judgment can be made by calculating the distance between the center point of the voxel and the hit point, wherein the distance can be calculated by the world space coordinates of the two; specifically, the distance between the world space coordinates of the center point of the voxel and the world space coordinates of the hit point can be calculated, and if the distance is less than or equal to the first threshold, the sample pool in the voxel can be determined to be a neighboring sample pool.
[0085] S303: Determine whether the samples in the adjacent sample pool are valid samples.
[0086] In the disclosed embodiment, after completing the sampling of the adjacent sample pool, it is necessary to determine whether the sample obtained by sampling is a valid sample.
[0087] In some embodiments of the present disclosure, if the distance between any hit point and the camera is less than or equal to the second threshold, the unobstructed samples in the corresponding adjacent sample pool can be determined as valid samples. For hit points that are closer to the camera, the occlusion relationship can be determined. Figure 7 ,Due to the existence of adjacent occlusion, only the unoccluded samples in the sample pool can be judged as valid samples, that is, some samples without adjacent occlusion between the hit point can be judged as valid samples.
[0088] In some embodiments of the present disclosure, if the distance between any hit point and the camera is greater than the second threshold, all samples in the corresponding adjacent sample pool are determined to be valid samples. That is, for hit points that are far away from the camera, the occlusion relationship determination may not be performed, and all samples are determined to be valid samples.
[0089] It can be understood that, on the one hand, for the hit points that are closer to the camera, valid samples are determined based on the occlusion relationship, which can make the close view more realistic and avoid light leakage problems. On the other hand, for the hit points that are farther away from the camera, the occlusion relationship is not determined, that is, no overly detailed calculation is performed for the distant view, which can save the amount of calculation, save the performance of the processor, and improve the calculation efficiency.
[0090] S304: If the samples in the adjacent sample pool are valid samples, weighted sum is performed on the valid samples to obtain the indirect light of each hit point.
[0091] In the disclosed embodiment, after valid samples are determined, weighted summation can be performed on valid samples corresponding to each hit point, and the result of the weighted summation can be used as the indirect light of the hit point. For each voxel, the weight of the valid sample can be determined according to the distance between the valid sample and the center point of the voxel. Specifically, the smaller the distance, the greater the weight.
[0092] In the disclosed embodiment, the obtained indirect light is used to simulate the light reflected or refracted by other objects, so that the effect of light after multiple reflections can be simulated, that is, the ray tracing of multiple reflections is realized.
[0093] In some embodiments of the present disclosure, it is also possible to Figure 8 S305 to S306 are shown to achieve Figure 1 S103 shown will be described in conjunction with each step.
[0094] S305, calculating the direct light of each hit point; the direct light is the light directly received by each hit point.
[0095] In the disclosed embodiment, after performing single-reflection ray tracing and obtaining multiple hit points, the direct light of each hit point can also be calculated, where the direct light is the light directly received by each hit point, that is, the light emitted by the light source in the single-reflection ray tracing.
[0096] S306. Combine the direct light and indirect light of each hit point to obtain the total radiation of each hit point.
[0097] In the disclosed embodiment, after obtaining the direct light and indirect light of each hit point, the direct light and the indirect light can be combined to obtain the total radiation of each hit point. The direct light is the light directly received by the hit point from the light source; the indirect light comes from the sample pool adjacent to the hit point, simulating the light reflected or refracted by other objects.
[0098] It can be understood that by combining direct light and indirect light to obtain the total radiation of light, multiple reflection ray tracing is achieved, global illumination is achieved, and the imaging effect is closer to the real life environment, that is, a more realistic imaging effect can be obtained, and problems such as light leakage can be improved.
[0099] In some embodiments of the present disclosure, Fig. 9 S401 to S403 shown are implemented Figure 1 S104 shown will be described in conjunction with each step.
[0100] S401. Calculate the coordinates of the additional sample pool corresponding to the total radiation.
[0101] In the disclosed embodiment, the coordinates of the corresponding additional sample pool can be calculated according to the world space coordinates of the total radiation. In the hierarchical mapping structure, the level of the spatial region where the additional sample pool is located can be determined first, and then the coordinates of the additional sample pool (i.e., the coordinates of the voxels corresponding to the additional sample pool) can be determined. In this way, the coordinates of the additional sample pool can be determined more quickly, reducing the amount of calculation.
[0102] S402. Randomly sample the total radiation.
[0103] S403: Update the random sampling results to the corresponding additional sample pool.
[0104] In the disclosed embodiment, the total radiation may be randomly sampled first, a portion of samples may be sampled, and then the sampled portion of samples (i.e., the result of random sampling) may be updated to the corresponding additional sample pool. In this way, the number of samples that need to be updated in an additional sample pool may be reduced, thereby saving processor performance consumption and improving efficiency.
[0105] In some embodiments of the present disclosure, Fig.10 S404 to S405 shown are implemented Fig. 9 S402 shown will be described in conjunction with each step.
[0106] S404: Divide the total radiation corresponding to the same additional sample pool into multiple sample columns.
[0107] S405: Randomly select a sample column, and update the samples in the sample column to the corresponding additional sample pool.
[0108] In the embodiment of the present disclosure, S404 to S405 may be implemented by the following pseudo code:
[0109] Uint2 RemappedId=uint2(SampleId%SELECT_NUM,SampleId / SELECT_NUM);
[0110] Uint SamplesColNum=ceil(SampleCount / SELECT_NUM);
[0111] Uint RandId=SamplesColNum*Rand(ReservoerCoord);
[0112] If RandId == RemappedId[1]
[0113] UpdateReservoir(SampleData)
[0114] Referring to the above pseudocode, SELECT_NUM is the number of samples required in any additional sample pool. SampleCount is the number of samples to be selected, that is, the number of samples in the total radiation corresponding to the additional sample pool. SampleId is a random ID corresponding to each sample, such as 0 to 9. RemappedId is a mapping ID, which represents the index value of the sample and contains two numbers (i.e. Uint2); specifically, RemappedId contains the result of SampleId modulo SELECT_NUM (i.e. SampleId%SELECT_NUM), and the result of SampleId divided by SELECT_NUM (i.e. SampleId / SELECT_NUM).
[0115] Furthermore, SamplesColNum represents the number of samples in each sample column. SamplesColNum can be obtained by dividing SampleCount by SELECT_NUM and rounding up (i.e., ceil). In this way, the total radiation corresponding to the same additional sample pool is divided into multiple sample columns.
[0116] Furthermore, RandId represents the random value of each column. RandId can be obtained by multiplying SamplesColNum by Rand(ReservoerCoord); where Rand(ReservoerCoord) represents a numerical value randomly generated by a computer, and its value range is between 0 and 1.
[0117] Furthermore, if RandId is equal to RemappedId[1], the candidate sample (i.e., SampleData) of the corresponding column is updated (i.e., UpdateReservoir) to the additional sample pool. RemappedId[1] is SampleId / SELECT_NUM. In this way, a sample column is randomly selected and the sample update is completed.
[0118] In some embodiments of the present disclosure, the method for calculating global illumination further includes: Fig.11 S105 to S106 shown will be described in conjunction with each step.
[0119] S105 . Update the sample pool in the screen space based on the additional sample pool.
[0120] In the disclosed embodiment, after the additional sample pool is updated, the sample pool in the screen space can be updated based on the updated additional sample pool. It is necessary to determine the corresponding screen space coordinates (i.e., the coordinates of the sample pool in the screen space) according to the world space coordinates of each additional sample pool. Since the screen space coordinates are two-dimensional coordinates, and the world space coordinates are three-dimensional coordinates; therefore, according to the world space coordinates of each additional sample pool, the corresponding screen space coordinates are determined, which is actually a process of transforming the three-dimensional coordinates (world space coordinates) into the corresponding two-dimensional coordinates (screen space coordinates).
[0121] S106: Rendering is performed based on the updated sample pool in the screen space.
[0122] In the embodiment of the present disclosure, after the sample pool in the screen space is updated, rendering may be performed based on the updated sample pool in the screen space.
[0123] Fig.12 This is a rendering effect without using the global illumination solution provided by this application. Fig.13 This is a rendering effect diagram using the method for calculating global illumination provided by this application. Fig.12 and Fig.13 , using the method for calculating global illumination provided in this application for rendering can greatly improve the overall brightness and provide more accurate illumination for backlit corners, thereby achieving a better rendering effect.
[0124] It is understandable that the method for calculating global illumination provided by the present application can improve the rendering effect, and at the same time, does not significantly increase the performance load of the processor. Compared with the global illumination calculation method based on screen space and probes, the method for calculating global illumination provided by the present application is based on the sample pool resampling method, which provides multiple reflections of indirect light by reusing samples to establish a spatial cache, thereby obtaining more accurate indirect light and improving the rendering effect. Compared with the global illumination calculation method based on neural networks, the method for calculating global illumination provided by the present application does not require repeated projection of light to generate illumination samples, and there is no additional training and fitting error risk cost, thereby saving the performance overhead of the processor.
[0125] Fig.14 A schematic diagram of the structure of a device for calculating global illumination provided in an embodiment of the present application is shown in FIG. Fig.14As shown, the device 800 for calculating global illumination includes: a sample pool establishment module 810, a remapping module 820, a ray tracing module 830 and a sample pool update module 840. The sample pool establishment module 810 is configured to establish multiple additional sample pools in the world space; the remapping module 820 is configured to remap samples in multiple historical sample pools to at least part of the additional sample pools; the ray tracing module 830 is configured to calculate the total radiation based on the ray tracing of multiple reflections in the world space; the total radiation includes direct light and indirect light; the sample pool update module 840 is configured to update the additional sample pool based on the total radiation.
[0126] In some embodiments of the present disclosure, the sample pool establishment module 810 is further configured to divide the world space into a plurality of voxels according to the hierarchical mapping structure, and to establish an additional sample pool in each voxel, wherein the total number of voxels is equal to the product of the 3D buffer resolution and the number of 3D buffers.
[0127] In some embodiments of the present disclosure, the sample pool establishment module 810 is further configured to divide the world space into multiple levels of spatial regions with the camera as the center; and divide each level of spatial region into multiple voxels. The higher the level of each level of spatial region, the closer it is to the camera and the larger the region radius; the higher the level of each level of spatial region, the more voxels each level of spatial region is divided into, and the smaller the volume of each voxel.
[0128] In some embodiments of the present disclosure, the ray tracing module 830 is also configured to perform ray tracing of a single reflection to obtain multiple hit points; wherein each hit point is the intersection of a beam of light emitted by a light source and the surface of a reflector; and, with each hit point as the center, samples in a neighboring sample pool are sampled; the distance between the center point of the voxel corresponding to the neighboring sample pool and the hit point is less than or equal to a first threshold; and, determine whether the samples in the neighboring sample pool are valid samples; and, if the samples in the neighboring sample pool are valid samples, perform weighted summation on the valid samples to obtain indirect light for each hit point.
[0129] In some embodiments of the present disclosure, the ray tracing module 830 is further configured to calculate the direct light for each hit point; the direct light is the light directly received by each hit point; and the direct light and indirect light of each hit point are combined to obtain the total radiation of each hit point.
[0130] In some embodiments of the present disclosure, the ray tracing module 830 is further configured to determine the unobstructed samples in the corresponding neighboring sample pool as valid samples if the distance between any hit point and the camera is less than or equal to a second threshold; or, if the distance between any hit point and the camera is greater than the second threshold, all samples in the corresponding neighboring sample pool are determined to be valid samples.
[0131] In some embodiments of the present disclosure, the sample pool update module 840 is further configured to calculate the coordinates of the additional sample pool corresponding to the total radiation; and to perform random sampling on the total radiation; and to update the results of the random sampling to the additional sample pool corresponding to the sample pool coordinates.
[0132] In some embodiments of the present disclosure, the sample pool update module 840 is further configured to divide the total radiation corresponding to the same additional sample pool into multiple sample columns; and randomly select a sample column and update the samples in the sample column to the corresponding additional sample pool.
[0133] In some embodiments of the present disclosure, the device 800 for calculating global illumination further includes: a rendering module 850. The sample pool updating module 840 is further configured to update the sample pool in the screen space based on the additional sample pool. The rendering module 850 is further configured to perform rendering based on the updated sample pool in the screen space.
[0134] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiment of the present application can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0135] It should be noted that in the embodiment of the present application, if the above-mentioned method for calculating global illumination is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.
[0136] An embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.
[0137] The embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.
[0138] An embodiment of the present application provides a computer program, including a computer-readable code. When the computer-readable code is run in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.
[0139] The embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.
[0140] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product of this application, please refer to the description of the method embodiment of this application for understanding.
[0141] Fig.15 A hardware entity diagram of a computer device provided in an embodiment of the present application is shown in FIG. Fig.15 As shown, the hardware entity of the computer device 1100 includes: a processor 1101 and a memory 1102, wherein the memory 1102 stores a computer program that can be run on the processor 1101, and the processor 1101 implements the steps in the method of any of the above embodiments when executing the program.
[0142] The memory 1102 stores computer programs that can be run on the processor. The memory 1102 is configured to store instructions and applications executable by the processor 1101. It can also cache data to be processed or processed by the processor 1101 and various modules in the computer device 1100 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0143] When the processor 1101 executes the program, the steps of any of the above methods for calculating global illumination are implemented. The processor 1101 generally controls the overall operation of the computer device 1100 .
[0144] An embodiment of the present application provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the method for calculating global illumination in any of the above embodiments.
[0145] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0146] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, and the embodiments of the present application are not specifically limited.
[0147] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.
[0148] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the serial number of each step / process mentioned above does not mean the order of execution, and the execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The serial numbers of the embodiments of the present application mentioned above are for description only and do not represent the advantages and disadvantages of the embodiments.
[0149] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0150] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0151] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0152] In addition, all functional units in the embodiments of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above method embodiments are executed; and the above storage medium includes: mobile storage devices, read-only memory (ROM), disks or optical disks, etc. Various media that can store program codes.
[0153] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0154] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. A method for calculating global illumination, characterized in that: The method for calculating global illumination comprises: Establish multiple additional sample pools in world space; Remapping samples in a plurality of historical sample pools to at least part of the additional sample pools; In the world space, total radiation is calculated based on ray tracing of multiple reflections; the total radiation includes direct light and indirect light; the direct light is the light directly received by the hit point of a single reflection; the indirect light is obtained by weighted summation of valid samples in a sample pool adjacent to the hit point; Random sampling is performed based on the total radiation to update the additional sample pool.
2. The method for calculating global illumination according to claim 1, characterized in that: The aforementioned establishment of multiple additional sample pools in the world space includes: According to the hierarchical mapping structure, the world space is divided into a plurality of voxels; wherein the total number of the voxels is equal to the product of the resolution of the three-dimensional buffer and the number of the three-dimensional buffer; In each of the voxels, an additional sample pool is established.
3. The method for calculating global illumination according to claim 2, characterized in that: The world space is divided into a plurality of voxels according to the hierarchical mapping structure, including: Taking the camera as the center, the world space is divided into multiple levels of spatial regions; wherein the higher the level of each spatial region is, the closer it is to the camera and the larger the region radius is; The spatial region at each level is divided into a plurality of voxels.
4. The method for calculating global illumination according to claim 3, characterized in that: The higher the level of each level of the spatial region is, the more voxels are divided into each level of the spatial region, and the smaller the volume of each voxel is.
5. The method for calculating global illumination according to claim 2, characterized in that: The total radiation is calculated in the world space based on ray tracing of multiple reflections, including: Performing ray tracing of a single reflection to obtain a plurality of hit points; each hit point is an intersection point between a beam of light emitted by a light source and a surface of a reflector; Taking each of the hit points as the center, sampling samples in the adjacent sample pool; the distance between the center point of the voxel corresponding to the adjacent sample pool and the hit point is less than or equal to a first threshold; Determining whether the sample in the adjacent sample pool is the valid sample; If the samples in the adjacent sample pool are the valid samples, weighted sum is performed on the valid samples to obtain the indirect light of each hit point.
6. The method for calculating global illumination according to claim 5, characterized in that: The calculating of total radiation based on ray tracing of multiple reflections in the world space also includes: Calculating the direct light for each of the hit points; The direct light and the indirect light of each hit point are combined to obtain the total radiation of each hit point.
7. The method for calculating global illumination according to claim 5, characterized in that: The determining whether the sample in the adjacent sample pool is the valid sample includes: If the distance between any of the hit points and the camera is less than or equal to the second threshold, the corresponding unobstructed sample in the adjacent sample pool is determined as the valid sample.
8. The method for calculating global illumination according to claim 5, characterized in that: The determining whether the sample in the adjacent sample pool is the valid sample further includes: If the distance between any of the hit points and the camera is greater than a second threshold, all samples in the corresponding adjacent sample pool are determined to be valid samples.
9. The method for calculating global illumination according to claim 2, characterized in that: The performing random sampling based on the total radiation and updating the additional sample pool comprises: Calculating the coordinates of the additional sample pool corresponding to the total radiation; performing a random sampling of the total radiation; The random sampling result is updated to the additional sample pool corresponding to the sample pool coordinate.
10. The method for calculating global illumination according to claim 9, characterized in that: The randomly sampling the total radiation comprises: dividing the total radiation corresponding to the same additional sample pool into a plurality of sample columns; A sample column is randomly selected, and samples in the sample column are updated into the corresponding additional sample pool.
11. The method for calculating global illumination according to claim 1, characterized in that: After updating the additional sample pool, the method for calculating global illumination further includes: Based on the additional sample pool, updating the sample pool in the screen space; Rendering is performed based on the updated sample pool in the screen space.
12. A device for calculating global illumination, characterized in that: The device for calculating global illumination comprises: A sample pool establishment module, configured to establish a plurality of additional sample pools in the world space; A remapping module, configured to remap samples in a plurality of historical sample pools to at least part of the additional sample pool; A ray tracing module is configured to calculate total radiation in the world space based on ray tracing of multiple reflections; the total radiation includes direct light and indirect light; the direct light is the light directly received by the hit point of a single reflection; the indirect light is obtained by weighted summation of valid samples in a sample pool adjacent to the hit point; The sample pool updating module is configured to update the additional sample pool by performing random sampling based on the total radiation.
13. A computer program product, characterized in that The invention comprises a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code is executed in an electronic device, a processor in the electronic device executes the steps in the method according to any one of claims 1 to 11.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the program, the steps in the method according to any one of claims 1 to 11 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Cone tracing dynamic global illumination method based on cascaded texture
CN108537869A