Heterogeneous parallel hybrid ray tracing method

By dividing sequential and non-sequential ray tracing areas in the optical system, and utilizing heterogeneous parallel computing of CPU and GPU, the problem of large calculation amount and complexity of existing ray tracing methods is solved, and efficient and load-balanced ray tracing is achieved. trace.

CN118567863BActive Publication Date: 2024-10-29CHANGCHUN INST OF OPTICS FINE MECHANICS & PHYSICS CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411005347.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-10-29
Estimated Expiration
2044-07-25

AI Technical Summary

Technical Problem

Existing non-sequential ray tracing methods are computationally intensive and complex, making debugging and error troubleshooting difficult, and lack heterogeneous parallel acceleration and load balancing optimization under the CPU architecture.

Method used

A heterogeneous parallel hybrid ray tracing method is used to divide the surface of the optical system into sequential and non-sequential areas. The heterogeneous parallel computing of the CPU and GPU is used to dynamically adjust task allocation and reduce rays through bounding box collision testing and intersection calculations. Tracking time and complexity.

Benefits of technology

Significantly improves the performance and efficiency of ray tracing, reduces computing costs and time costs, and achieves load balancing and efficient ray tracing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567863B_ABST
    Figure CN118567863B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of ray tracing technology, and in particular, to a heterogeneous parallel hybrid ray tracing method. It includes: S1: defining at least one sequential ray tracing region in a non-sequential ray tracing region; S2: judging whether there is ray data to be intersected in the ray data queue of the non-sequential ray tracing region; S3: performing intersection calculation on the effective surface of the optical system in the non-sequential ray tracing region and the ray data to be intersected; S4: judging whether the intersecting surface obtained in step S3 belongs to the sequential ray tracing region; S5: completing ray tracing of the current sequential ray tracing region based on the ray data to be intersected input into the current sequential ray tracing region, and adding the ray data emitted from the current sequential ray tracing region to the ray data queue of the non-sequential ray tracing region, and executing step S2. The present invention can greatly improve the performance and efficiency of ray tracing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of ray tracing, and in particular relates to a heterogeneous parallel hybrid ray tracing method. Background Art

[0002] The ray tracing technology in optical simulation software covers knowledge from multiple disciplines, including optics, computer graphics, and numerical analysis. Ray tracing technology in simulation software is based on the physical properties of light and is used to simulate the propagation path of the intersecting light data in different media to calculate the interaction between the intersecting light data and the object. Early optical design and analysis relied on manual calculations and optical diagrams. With the development of computing technology, optical design has gradually been introduced into computer-aided design (CAD). Ray tracing has been widely used as a rendering technology in the 1980s. The ray tracing method proposed by Turner Whitted in 1980 made ray tracing an important method in computer graphics. Modern optical simulation software combines advanced computing methods and hardware acceleration technology to achieve high-precision and high-efficiency ray tracing. These software are widely used in optical design, lighting engineering, scientific research and other fields. The calculation methods of ray tracing in the current context are mainly Monte Carlo and energy spectroscopy, and the parallel processing capabilities of multi-core CPUs are used to accelerate the calculation of ray tracing. However, existing simulation software all use non-sequential ray tracing methods, which have the following disadvantages: non-sequential ray tracing needs to calculate all possible paths of each ray in the scene, including multiple reflection, refraction and scattering paths, which requires a large amount of calculation, and therefore has high requirements for computing resources and memory space; since the ray path is dynamic and non-deterministic, debugging and error troubleshooting are relatively complicated; non-sequential ray tracing needs to calculate all intersecting surfaces and intersections of each ray in the scene, and the computing time cost is high; the intersection calculation of non-sequential ray tracing does not have the advantage of scalable heterogeneous parallel acceleration under the CPU architecture, and cannot optimize the load balancing of heterogeneous parallelism. Summary of the invention

[0003] In view of this, the invention aims to provide a heterogeneous parallel hybrid ray tracing method to reduce the complexity and calculation time of non-sequential ray tracing of the same order of magnitude, greatly improve the performance and efficiency of ray tracing, and overcome the shortcomings of traditional ray tracing technology such as high calculation cost and high time cost. To achieve the above purpose, the technical solution created by the invention is implemented as follows:

[0004] A heterogeneous parallel hybrid ray tracing method specifically comprises the following steps:

[0005] S1: Setting light source parameters so that the light source generates a batch of light data with starting points and directions, and adding all the light data to the light data queue of the non-sequential ray tracing area, defining at least one sequential ray tracing area in the non-sequential ray tracing area, and obtaining the surface data of the optical system of the non-sequential ray tracing area and the surface data of the optical system of the sequential ray tracing area;

[0006] S2: Determine whether there is any ray data to be intersected in the ray data queue of the non-sequential ray tracing area. If yes, execute step S3. Otherwise, terminate the mixed ray tracing.

[0007] S3: performing intersection calculation on the effective surface of the optical system in the non-sequential ray tracing area and the light data to be intersected, obtaining the intersecting surface and the normal, intersection point and surface optical properties corresponding to the intersecting surface, and calculating new light data to be intersected emitted from the intersecting surface;

[0008] S4: Determine whether the intersecting surface obtained in step S3 belongs to the sequential ray tracing area. If so, add the new ray data to be intersected to the ray data queue of the sequential ray tracing area and execute step S5. Otherwise, add the new ray data to be intersected to the ray data queue of the non-sequential ray tracing area and execute step S2.

[0009] S5: Based on the to-be-intersected light data input into the current sequence ray tracing area, intersection calculation and optical property calculation are performed on the next surface of the i-th surface of the optical system in the current sequence ray tracing area until the ray tracing of the current sequence ray tracing area is completed, and the light data emitted from the current sequence ray tracing area to the non-sequential ray tracing area is added to the light data queue of the non-sequential ray tracing area, and step S2 is executed.

[0010] Furthermore, step S3 specifically includes the following steps:

[0011] S31: performing a bounding box collision test on all surfaces of the optical system in the non-sequential ray tracing area, and estimating the surface intersecting with the light data to be intersected according to the bounding box collision test result, which is the valid surface of the optical system, and recording the ID number of the valid surface;

[0012] S32: Based on the ID numbers of all valid surfaces, perform intersection calculation on all valid surfaces and the light data to be intersected, and obtain the intersecting surfaces and the normals, intersection points and surface optical properties corresponding to the intersecting surfaces;

[0013] S33: Calculate new light data to be intersected emitted from the intersecting surface according to the intersecting surface and the normal direction, intersection point and surface optical properties corresponding to the intersecting surface.

[0014] Furthermore, step S5 specifically includes the following steps:

[0015] S51: Determine whether the next surface of the i-th surface in the current sequential ray tracing area is obtained, and use the next surface of the i-th surface as the intersection surface to be calculated. If so, execute step S52; otherwise, add the light data emitted from the current sequential ray tracing area to the non-sequential ray tracing area to the light data queue of the non-sequential ray tracing area, and execute step S2;

[0016] S52: performing a bounding box collision test on the intersecting surface to be calculated in the current sequential ray tracing area, estimating the light rays intersecting with the intersecting surface to be calculated according to the bounding box collision test result, which is the valid light ray data, recording the ID number of the valid light ray data, and adding the light rays that have not collided successfully to the light ray data queue of the non-sequential ray tracing area;

[0017] S53: Based on the ID numbers of all valid light data, perform intersection calculation on the current intersection surface to be calculated and all valid light data;

[0018] S54: Determine whether there is any light ray data to be intersected that intersects with the surface to be intersected. If so, calculate the optical properties of the light ray data to be intersected and the surface to be intersected, obtain the light ray data to be intersected emitted from the surface to be intersected, and re-execute step S51; otherwise, add the light ray data emitted from the current sequential ray tracing area to the light ray data queue of the non-sequential ray tracing area, and execute step S2.

[0019] Furthermore, in step S1, the surface data of the non-sequential ray tracing area and the surface data of the sequential ray tracing area both include surface number, surface index, surface face ID, surface analytical expression, surface Nurbs data, surface bounding box information and surface optical properties.

[0020] Further, in step S1, a batch of light data includes no less than two pieces of light data.

[0021] Furthermore, in step S3 and step S5, in the non-sequential ray tracing area and the sequential ray tracing area, a heterogeneous parallel acceleration method is used to perform intersection calculation:

[0022] Allocate storage space on the CPU and GPU sides according to the amount of light data to be intersected;

[0023] Acquire CPU resources and GPU resources at the same time. If both GPU resources and CPU resources are acquired at the same time, perform GPU and CPU parallel calculations. Otherwise, determine whether only CPU resources are acquired. If so, call the CPU parallel function to perform intersection calculations. Otherwise, terminate the intersection calculations.

[0024] Furthermore, the specific steps of GPU and CPU heterogeneous parallel computing are:

[0025] Different light data in the same batch of light data intersect with the surface of the non-sequential ray tracing area and the surface of the sequential ray tracing area respectively. The CPU loads the analytical information and Nurbs information of the surface of the optical system, and calls the CPU parallel function to perform intersection calculation; the GPU loads the Nurbs information of the surface of the optical system, and calls the GPU parallel function to perform intersection calculation; until the intersection calculation of all rays is completed.

[0026] Furthermore, in the heterogeneous parallel computing process of the GPU and the CPU, the GPU and the CPU allocate the computing amount of the Nurbs information according to their respective core numbers, storage space allocation results and computing capabilities, thereby completing the heterogeneous parallel computing of the GPU and the CPU.

[0027] Furthermore, the process of calling the CPU parallel function to perform intersection calculation is as follows: if the surface of the optical system has both analytical information and Nurbs information, the CPU parallel function is called to perform intersection calculation on the analytical information; if the surface of the optical system only has Nurbs information, the CPU parallel function is directly called to perform intersection calculation on the Nurbs information.

[0028] Compared with the prior art, the invention can achieve the following beneficial effects:

[0029] (1) The heterogeneous parallel hybrid ray tracing method created by the present invention divides the surface of the optical system into areas to which it belongs, loads and calls CPU+GPU resources based on information of different geometric representation forms of the surface of the optical system, and realizes heterogeneous parallel hybrid tracing of non-sequential and sequential ray tracing methods.

[0030] (2) The heterogeneous parallel hybrid ray tracing method created by the present invention defines part of the surface of the optical system in a sequential ray tracing region, and the light data to be intersected that is incident on the sequential ray tracing region is sequentially emitted from each surface of the optical system in the sequential ray tracing region. Therefore, it is only necessary to determine whether the light intersects with the next surface to calculate the next emitted light, thereby reducing the ray tracing time in the non-sequential ray tracing region. The heterogeneous parallel hybrid ray tracing method can make full use of different computing resources. By reasonably allocating tasks to different computing units (CPU and GPU), the overall performance of ray tracing is significantly improved; the heterogeneous parallel hybrid ray tracing method can dynamically adjust task allocation to ensure load balancing of each computing unit, thereby avoiding the situation where some units are overloaded while other units are idle; the GPU has a high-bandwidth video memory, which is suitable for processing large-scale data parallel computing, while the CPU's main memory can process large-scale global data and complex data structures; the heterogeneous parallel hybrid ray tracing method can reasonably allocate and manage data storage to improve memory access efficiency, reduce data transmission bottlenecks, and optimize memory bandwidth and storage space; the heterogeneous parallel hybrid ray tracing method has high adaptability and scalability, and can flexibly adjust the allocation of computing resources according to specific application requirements, making the method of expanding and upgrading the system simple and improving resource utilization; the heterogeneous parallel hybrid ray tracing method can provide strong support for achieving efficient and high-quality ray tracing, so that it can be applied in multiple fields. The present invention adopts a mode in which sequential surfaces and non-sequential surfaces are mixed to participate in ray tracing, which reduces the complexity and calculation time of non-sequential ray tracing of the same order of magnitude, greatly improves the performance and efficiency of ray tracing, and overcomes the shortcomings of high calculation cost and high time cost of traditional ray tracing technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The drawings constituting part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments and descriptions of the present invention are used to explain the present invention and do not constitute an improper limitation on the present invention. In the drawings:

[0032] Figure 1 A schematic diagram of a flow chart of a heterogeneous parallel hybrid ray tracing method according to an embodiment of the present invention;

[0033] Figure 2 A schematic diagram of a first structure for performing intersection calculation on the next surface of the i-th surface of the optical system in the current sequence ray tracing area according to an embodiment of the present invention;

[0034] Figure 3 A schematic diagram of a second structure for performing intersection calculation on the next surface of the i-th surface of the optical system in the current sequence ray tracing area according to an embodiment of the present invention;

[0035] Figure 4 A third structural schematic diagram of performing intersection calculation on the next surface of the i-th surface of the optical system in the current sequence ray tracing area according to an embodiment of the present invention;

[0036] Figure 5 A schematic diagram of a structure of defining at least two sequential ray tracing areas in a non-sequential ray tracing area according to an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solution and advantages of the invention more clear, the invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described here are only used to explain the invention and do not constitute a limitation of the invention.

[0038] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.

[0039] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.

[0040] In the description of the invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the invention can be understood according to specific circumstances.

[0041] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments.

[0042] Heterogeneous parallelism utilizes the respective advantages of different types of hardware (such as CPU, GPU, etc.) to optimize the distribution of computing tasks, improve overall computing performance, and dynamically allocate computing tasks according to the load and performance of each hardware unit to ensure load balancing and improve resource utilization.

[0043] like Figure 1 As shown, the present invention provides a heterogeneous parallel hybrid ray tracing method, which specifically includes the following steps:

[0044] S1: Setting light source parameters so that the light source generates a batch of light data with starting points and directions, and adding all the light data to the light data queue of the non-sequential ray tracing area, defining at least one sequential ray tracing area in the non-sequential ray tracing area, and obtaining the surface data of the optical system of the non-sequential ray tracing area and the surface data of the optical system of the sequential ray tracing area;

[0045] In step S1, a batch of light data includes no less than two pieces of light data.

[0046] Light source parameters include the light source position, as well as the energy, wavelength, and direction of the light emitted by the light source.

[0047] S2: Determine whether there is any ray data to be intersected in the ray data queue of the non-sequential ray tracing area. If yes, execute step S3. Otherwise, terminate the mixed ray tracing.

[0048] S3: performing intersection calculation on the effective surface of the optical system in the non-sequential ray tracing area and the light data to be intersected, obtaining the intersecting surface and the normal, intersection point and surface optical properties corresponding to the intersecting surface, and calculating new light data to be intersected emitted from the intersecting surface;

[0049] Step S3 specifically includes the following steps:

[0050] S31: performing a bounding box collision test on all surfaces of the optical system in the non-sequential ray tracing area, and estimating the surface intersecting with the light data to be intersected according to the bounding box collision test result, which is the valid surface of the optical system, and recording the ID number of the valid surface;

[0051] S32: Based on the ID numbers of all valid surfaces, perform intersection calculation on all valid surfaces and the light data to be intersected, and obtain the intersecting surfaces and the normals, intersection points and surface optical properties corresponding to the intersecting surfaces;

[0052] The valid surface that intersects with the ray data to be intersected is taken as the intersection surface.

[0053] S33: Calculate new light data to be intersected emitted from the intersecting surface according to the intersecting surface and the normal direction, intersection point and surface optical properties corresponding to the intersecting surface.

[0054] S4: Determine whether the intersecting surface obtained in step S3 belongs to the sequential ray tracing area. If so, add the new ray data to be intersected to the ray data queue of the sequential ray tracing area and execute step S5. Otherwise, add the new ray data to be intersected to the ray data queue of the non-sequential ray tracing area and execute step S2.

[0055] S5: Based on the to-be-intersected light data input into the current sequence ray tracing area, intersection calculation and optical property calculation are performed on the next surface of the i-th surface of the optical system in the current sequence ray tracing area until the ray tracing of the current sequence ray tracing area is completed, and the light data emitted from the current sequence ray tracing area to the non-sequential ray tracing area is added to the light data queue of the non-sequential ray tracing area, and step S2 is executed.

[0056] Step S5 specifically includes the following steps:

[0057] S51: Determine whether the next surface of the i-th surface in the current sequential ray tracing area is obtained, and use the next surface of the i-th surface as the intersection surface to be calculated. If so, execute step S52; otherwise, add the light data emitted from the current sequential ray tracing area to the non-sequential ray tracing area to the light data queue of the non-sequential ray tracing area, and execute step S2;

[0058] S52: performing a bounding box collision test on the intersecting surface to be calculated in the current sequential ray tracing area, estimating the light rays intersecting with the intersecting surface to be calculated according to the bounding box collision test result, which is the valid light ray data, recording the ID number of the valid light ray data, and adding the light rays that have not collided successfully to the light ray data queue of the non-sequential ray tracing area;

[0059] This step reduces the number of rays required for intersection calculations in the sequential ray-traced region.

[0060] S53: Based on the ID numbers of all valid light data, perform intersection calculation on the current intersection surface to be calculated and all valid light data;

[0061] S54: Determine whether there is any light ray data to be intersected that intersects with the surface to be intersected. If so, calculate the optical properties of the light ray data to be intersected and the surface to be intersected, obtain the light ray data to be intersected emitted from the surface to be intersected, re-execute step S51, determine whether the next surface of the surface to be intersected in the current sequence ray tracing area is obtained, otherwise, add the light ray data emitted from the current sequence ray tracing area to the light ray data queue of the non-sequential ray tracing area, and execute step S2.

[0062] Assume that the optical system contains three surfaces, and the surface ID numbers are S0, S1 and S2 respectively. Figure 2 As shown, if the light data R1 is incident on the surface S0 from the current direction, the next surface of the surface S0 is S1, that is, the surface S1 is the intersection surface to be calculated, the light data R2 is the light data to be intersected, and the light data R3 emitted from the current sequential ray tracing area to the non-sequential ray tracing area is added to the light data queue of the non-sequential ray tracing area.

[0063] like Figure 3 As shown, if the light data R1 is incident on the surface S2 from the current direction, the next surface of the surface S2 is S1, that is, the surface S1 is the intersection surface to be calculated, the light data R2 is the light data to be intersected, and the light data R3 emitted from the current sequential ray tracing area to the non-sequential ray tracing area is added to the light data queue of the non-sequential ray tracing area.

[0064] like Figure 4 As shown, if the light data R1 is incident on the surface S1 from the current direction, the next surface of the surface S1 is S2, that is, the surface S2 is the intersection surface to be calculated, the light data R2 is the light data to be intersected, and the light data R3 emitted from the current sequential ray tracing area to the non-sequential ray tracing area is added to the light data queue of the non-sequential ray tracing area.

[0065] like Figure 5 As shown, at least one sequential ray tracing region is defined in the non-sequential ray tracing region, and each surface data of the optical system is divided into the surface data of the optical system in the non-sequential ray tracing region and the surface data of the optical system in the sequential ray tracing region. There is no intersection calculation order for the surfaces of the optical system in the non-sequential ray tracing region, that is, when performing intersection calculation in the non-sequential ray tracing region, it is necessary to traverse all surfaces of the optical system in the non-sequential ray tracing region until a surface intersecting with the light data to be intersected is found. The surfaces of the optical system in the sequential ray tracing region are intersected in the order set by the user.

[0066] The surface data of the optical system in the non-sequential ray tracing area and the surface data of the optical system in the sequential ray tracing area both include surface number, surface index, surface face ID, surface analytical expression, surface Nurbs data, surface bounding box information and surface optical properties.

[0067] (1) The surface number is unique, that is, the surface number can be used to find a unique surface in the surface list (short for the list of surface data). (2) The surface index is the order of arrangement in the list of surface data. The smaller the index, the higher the position of the surface in the surface list. In the sequential ray tracing area, the surface index is used to find the next surface to be calculated in the surface list. In the non-sequential ray tracing area, the surface index is used to traverse the surfaces in the surface list of all non-sequential ray tracing areas. (3) The surface face ID, surface analytical expression, and surface Nurbs data together complete the characterization of a surface geometric data level. The face type includes regular face type and free face type. The surface of a regular face type can be represented by an analytical expression or by Nurbs data. Regular surface types include plane, sphere, aspheric surface, quadratic surface, Zernike polynomial, stripe Zernike polynomial, XY polynomial, extended stripe Zernike polynomial, Qcon aspheric surface, Qbfs aspheric surface, X toroidal surface, Y toroidal surface, thermal value refractive index gradient, spline, deformed aspheric surface, super quadratic surface, odd-order polynomial, cylinder, extended spline, Fresnel parallel light shear, Fresnel non-parallel light shear, Fresnel plane base, segmented quadratic surface, thin Fresnel, Q2D free non-surface, a total of 25 regular surface types. There is no corresponding expression for free surface type, which can only be represented by Nurbs data. (4) Surface bounding box information is a simple regular geometric body information that completely contains the surface. Before calculating the intersection of the ray and the surface, the bounding box collision test of the ray is performed using the bounding box information of the surface. If the ray and the bounding box have no intersection, it is considered that the ray and the surface in the bounding box have no intersection either; if the ray and the bounding box have an intersection, it is considered that the ray and the surface in the bounding box may intersect, and then the intersection calculation between the ray and the surface is performed. (5) The optical properties of the surface are used when generating ray data by ray tracing.

[0068] In step S3 and step S5, in the non-sequential ray tracing area and the sequential ray tracing area, the heterogeneous parallel acceleration method is used to perform intersection calculation:

[0069] Allocate storage space on the CPU and GPU sides according to the amount of light data to be intersected;

[0070] Acquire CPU resources and GPU resources at the same time. If both GPU resources and CPU resources are acquired at the same time, perform GPU and CPU parallel calculations. Otherwise, determine whether only CPU resources are acquired. If so, call the CPU parallel function to perform intersection calculations. Otherwise, terminate the intersection calculations.

[0071] The specific steps of GPU and CPU heterogeneous parallel computing are:

[0072] Different rays in the same batch of rays intersect with the surface of the non-sequential ray tracing area and the surface of the sequential ray tracing area respectively. The CPU loads the analytical information and Nurbs information of the surface of the optical system, and calls the CPU parallel function to perform intersection calculations; the GPU loads the Nurbs information of the surface of the optical system, and calls the GPU parallel function to perform intersection calculations; until the intersection calculations of all rays are completed.

[0073] In the heterogeneous parallel computing process of GPU and CPU, GPU and CPU allocate the computing amount of Nurbs information according to their respective core numbers, storage space allocation results and computing capabilities to complete the heterogeneous parallel computing of GPU and CPU.

[0074] The running speeds of different configuration models when running the same software are different. Compared with models with strong computing power, models with weak computing power take longer to run the same software.

[0075] The process of calling the CPU parallel function to perform intersection calculation is as follows: if the surface of the optical system has both analytical information and Nurbs information, the CPU parallel function is called to perform intersection calculation on the analytical information; if the surface of the optical system only has Nurbs information, the CPU parallel function is directly called to perform intersection calculation on the Nurbs information.

[0076] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the disclosure of the present invention can be performed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in the present invention can be achieved, and this document does not limit this.

[0077] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A heterogeneous parallel hybrid ray tracing method, characterized by: The specific steps include: S1: Setting light source parameters so that the light source generates a batch of light data with starting points and directions, and adding all the light data to the light data queue of the non-sequential ray tracing area, defining at least one sequential ray tracing area in the non-sequential ray tracing area, and obtaining the surface data of the optical system of the non-sequential ray tracing area and the surface data of the optical system of the sequential ray tracing area; S2: Determine whether there is any ray data to be intersected in the ray data queue of the non-sequential ray tracing area. If yes, execute step S3. Otherwise, terminate the mixed ray tracing. S3: performing intersection calculation on the effective surface of the optical system in the non-sequential ray tracing area and the light data to be intersected, obtaining the intersecting surface and the normal, intersection point and surface optical properties corresponding to the intersecting surface, and calculating new light data to be intersected emitted from the intersecting surface; S4: Determine whether the intersecting surface obtained in step S3 belongs to the sequential ray tracing area. If so, add the new ray data to be intersected to the ray data queue of the sequential ray tracing area and execute step S5. Otherwise, add the new ray data to be intersected to the ray data queue of the non-sequential ray tracing area and execute step S2. S5: Based on the to-be-intersected light data input into the current sequence ray tracing region, perform intersection calculation and optical property calculation on the next surface of the i-th surface of the optical system in the current sequence ray tracing region until the ray tracing of the current sequence ray tracing region is completed, and add the light data emitted from the current sequence ray tracing region to the non-sequential ray tracing region to the light data queue of the non-sequential ray tracing region, and execute step S2; In step S3 and step S5, in the non-sequential ray tracing area and the sequential ray tracing area, the heterogeneous parallel acceleration method is used to perform intersection calculation: Allocate storage space on the CPU and GPU sides according to the amount of light data to be intersected; Acquire CPU resources and GPU resources at the same time. If both GPU resources and CPU resources are acquired at the same time, GPU and CPU parallel calculations are performed. Otherwise, determine whether only CPU resources are acquired. If so, call the CPU parallel function to perform intersection calculations. Otherwise, terminate the intersection calculations. In the heterogeneous parallel computing process of GPU and CPU, GPU and CPU allocate the computing amount of Nurbs information according to their respective core numbers, storage space allocation results and computing capabilities to complete the heterogeneous parallel computing of GPU and CPU.

2. The heterogeneous parallel hybrid ray tracing method according to claim 1, characterized in that: Step S3 specifically includes the following steps: S31: performing a bounding box collision test on all surfaces of the optical system in the non-sequential ray tracing area, and estimating the surface intersecting with the light data to be intersected according to the bounding box collision test result, which is the valid surface of the optical system, and recording the ID number of the valid surface; S32: Based on the ID numbers of all valid surfaces, perform intersection calculation on all valid surfaces and the light data to be intersected, and obtain the intersecting surfaces and the normals, intersection points and surface optical properties corresponding to the intersecting surfaces; S33: Calculate new light data to be intersected emitted from the intersecting surface according to the intersecting surface and the normal direction, intersection point and surface optical properties corresponding to the intersecting surface.

3. The heterogeneous parallel hybrid ray tracing method according to claim 1, characterized in that: Step S5 specifically includes the following steps: S51: Determine whether the next surface of the i-th surface in the current sequential ray tracing area is obtained, and use the next surface of the i-th surface as the intersection surface to be calculated. If so, execute step S52; otherwise, add the light data emitted from the current sequential ray tracing area to the non-sequential ray tracing area to the light data queue of the non-sequential ray tracing area, and execute step S2; S52: performing a bounding box collision test on the intersecting surface to be calculated in the current sequential ray tracing area, estimating the light rays intersecting with the intersecting surface to be calculated according to the bounding box collision test result, which is the valid light ray data, recording the ID number of the valid light ray data, and adding the light rays that have not collided successfully to the light ray data queue of the non-sequential ray tracing area; S53: Based on the ID numbers of all valid light data, perform intersection calculation on the current intersection surface to be calculated and all valid light data; S54: Determine whether there is any light ray data to be intersected that intersects with the surface to be intersected. If so, calculate the optical properties of the light ray data to be intersected and the surface to be intersected, obtain the light ray data to be intersected emitted from the surface to be intersected, and re-execute step S51; otherwise, add the light ray data emitted from the current sequential ray tracing area to the light ray data queue of the non-sequential ray tracing area, and execute step S2.

4. The heterogeneous parallel hybrid ray tracing method according to claim 1, characterized in that: In step S1, the surface data of the non-sequential ray tracing area and the surface data of the sequential ray tracing area both include surface number, surface index, surface face ID, surface analytical expression, surface Nurbs data, surface bounding box information and surface optical properties.

5. The heterogeneous parallel hybrid ray tracing method according to claim 1, characterized in that: In step S1, a batch of light data includes no less than two pieces of light data.

6. The heterogeneous parallel hybrid ray tracing method according to claim 1, characterized in that: The specific steps of GPU and CPU heterogeneous parallel computing are: Different light data in the same batch of light data intersect with the surface of the non-sequential ray tracing area and the surface of the sequential ray tracing area respectively. The CPU loads the analytical information and Nurbs information of the surface of the optical system, and calls the CPU parallel function to perform intersection calculation; the GPU loads the Nurbs information of the surface of the optical system, and calls the GPU parallel function to perform intersection calculation; until the intersection calculation of all rays is completed.

7. The heterogeneous parallel hybrid ray tracing method according to claim 1, characterized in that: The process of calling the CPU parallel function to perform intersection calculation is as follows: if the surface of the optical system has both analytical information and Nurbs information, the CPU parallel function is called to perform intersection calculation on the analytical information; if the surface of the optical system only has Nurbs information, the CPU parallel function is directly called to perform intersection calculation on the Nurbs information.

Citation Information

Patent Citations

  • Light tracking acceleration method

    CN112712581A

  • Optical system stray light gradient simulation method and simulation system

    CN115546382A