Volume rendering method, device, equipment and storage medium based on spherical harmonics
Through the method based on spherical harmonics, the medium density information of volume rendering is pre-integrated and saved, which reduces the number of Ray Marching, solves the problem of high calculation cost of volume rendering, and achieves efficient rendering effects.
Patent Information
- Application Number
- CN202011217769.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-04
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-11-04
AI Technical Summary
The existing technology has high computational costs during volume rendering, mainly because each pixel requires multiple Ray Marching sampling noises and volumetric light and shadow calculations, resulting in high overhead.
Using a method based on spherical harmonics, pre-integration of the line of sight direction is performed by selecting a preset number of angle values to obtain the pre-integration result of the medium density and save it as a spherical harmonic function coefficient. When receiving any line of sight direction, read The corresponding coefficients are used to obtain volumetric light and shadow information for rendering, reducing the number of Ray Marching.
It reduces computational overhead, saves the number of Ray Marchings, improves rendering efficiency, and reduces storage costs while ensuring rendering accuracy.
Smart Images

Figure CN112489181B
Abstract
Description
Technical Field
[0001] The present application relates to the field of real-time rendering technology, and in particular to a volume rendering method, apparatus, device and storage medium based on spherical harmonics. Background Art
[0002] At present, in order to achieve volume rendering, the method usually adopted is to express volume information with volume slice information or point cloud, and to achieve volume rendering based on ray marching. For example, when simulating the shape of clouds, 3D noise is generally sampled to simulate the shape of clouds, thereby increasing the sense of hierarchy of clouds in the vertical direction. However, since each pixel needs to sample or generate noise through a very large number of ray marchings, as well as calculate the light and shadow of the volume, the cost is very high in terms of computational overhead.
[0003] Therefore, how to save computing costs during volume rendering has become an urgent problem to be solved by those skilled in the art. Summary of the invention
[0004] The embodiments of the present application provide a volume rendering method, apparatus, device and storage medium based on spherical harmonics to at least solve the problem of how to save computing costs in volume rendering in the related art.
[0005] In a first aspect, an embodiment of the present application provides a volume rendering method based on spherical harmonics, comprising: selecting a preset number of angle values, each of the angle values corresponding to a viewing direction; pre-integrating the medium density inside the object to be rendered in each viewing direction to obtain a medium density pre-integration result corresponding to each viewing direction; saving each viewing direction and the medium density pre-integration result corresponding to each viewing direction as spherical harmonic coefficients; when any viewing direction is received, reading the medium density pre-integration result corresponding to the viewing direction according to the saved spherical harmonic coefficients, and obtaining light and shadow information of the volume according to the medium density pre-integration result; and rendering according to the light and shadow information of the volume.
[0006] In some embodiments, selecting a preset number of angle values includes: selecting a preset number of angle values by Monte Carlo random selection.
[0007] In some of the embodiments, the pre-integration of the medium density inside the object to be rendered in each of the line of sight directions to obtain the medium density pre-integration result corresponding to each of the line of sight directions includes: performing light stepping in each of the line of sight directions, pre-integrating the medium density inside the object to be rendered, and gradually accumulating all of the medium densities from the line of sight entrance surface to the line of sight exit back surface to obtain the medium density pre-integration result corresponding to each of the line of sight directions.
[0008] In some embodiments, the pre-integration results of each of the line of sight directions and the medium density corresponding to each of the line of sight directions are saved as spherical harmonic function coefficients, including: saving each of the line of sight directions and the pre-integration results of the medium density corresponding to each of the line of sight directions as second-order spherical harmonic function coefficients.
[0009] In some embodiments, the pre-integration results of each of the viewing directions and the medium density corresponding to each of the viewing directions are saved as second-order spherical harmonic function coefficients, including: obtaining volumetric light and shadow information based on the medium density pre-integration results, and pre-baking the volumetric light and shadow information to the vertices of the model of the object to be rendered or storing it in a map.
[0010] In the second aspect, an embodiment of the present application provides a volume rendering device based on spherical harmonics, including a selection module, a pre-integration module, a saving module, a reading module and a rendering module, wherein the selection module is used to select a preset number of angle values, each of which corresponds to a line of sight direction; the pre-integration module is used to pre-integrate the medium density inside the object to be rendered in each line of sight direction, and obtain a medium density pre-integration result corresponding to each line of sight direction; the saving module is used to save each line of sight direction and the medium density pre-integration result corresponding to each line of sight direction as spherical harmonic coefficients; the reading module is used to read the medium density pre-integration result corresponding to any line of sight direction according to the saved spherical harmonic coefficients when receiving the line of sight, and obtain the light and shadow information of the volume according to the medium density pre-integration result; the rendering module is used to render according to the light and shadow information of the volume.
[0011] In some embodiments, selecting a preset number of angle values includes: selecting a preset number of angle values by Monte Carlo random selection.
[0012] In some of the embodiments, the pre-integration of the medium density inside the object to be rendered in each of the line of sight directions to obtain the medium density pre-integration result corresponding to each of the line of sight directions includes: performing light stepping in each of the line of sight directions, pre-integrating the medium density inside the object to be rendered, and gradually accumulating all of the medium densities from the line of sight entrance surface to the line of sight exit back surface to obtain the medium density pre-integration result corresponding to each of the line of sight directions.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a storage medium storing a computer program, wherein the computer program, when executed by the processor, implements a volume rendering method based on spherical harmonics as described in any one of the above items.
[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the volume rendering method based on spherical harmonics as described in any one of the above items is implemented.
[0015] According to the above content, the volume rendering method based on spherical harmonics in the embodiment of the present application includes: selecting a preset number of angle values, each angle value corresponds to a line of sight direction; pre-integrating the medium density inside the object to be rendered in each line of sight direction to obtain the medium density pre-integration result corresponding to each line of sight direction; saving each line of sight direction and the medium density pre-integration result corresponding to each line of sight direction as a spherical harmonic coefficient; when receiving any line of sight direction, reading the medium density pre-integration result corresponding to the line of sight direction according to the saved spherical harmonic coefficient, and obtaining the light and shadow information of the volume according to the medium density pre-integration result; rendering according to the light and shadow information of the volume. The embodiment of the present application constructs volume rendering results under different lines of sight based on the line of sight direction offset, and saves them through spherical harmonic coefficients, so as to facilitate the restoration of the medium density information in the received line of sight direction, save a large number of Ray Marching times, reduce the calculation overhead, and thus achieve the effect of saving calculation costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0017] Figure 1 It is a schematic diagram of the effect of volume cloud rendering based on Ray Marching according to the related art;
[0018] Figure 2 It is a schematic diagram of the effect of volume cloud rendering based on Ray Marching according to the related art;
[0019] Figure 3 It is a schematic diagram of expression at different observation angles according to an embodiment of the present application;
[0020] Figure 4 is a flow chart of a volume rendering method based on spherical harmonics according to an embodiment of the present application;
[0021] Figure 5 Schematic diagram of expression of several-order spherical harmonic functions according to an embodiment of the present application;
[0022] Figure 6 is a schematic diagram of the effect of volume rendering based on spherical harmonics according to an embodiment of the present application;
[0023] Figure 7 is a schematic diagram of the effect of volume rendering based on spherical harmonics according to an embodiment of the present application;
[0024] Figure 8 is a structural block diagram of a volume rendering device based on spherical harmonics according to an embodiment of the present application;
[0025] Fig. 9 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in 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.
[0027] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.
[0028] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0029] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0030] Figure 1 This is a schematic diagram of the effect of volumetric cloud rendering based on Ray Marching according to the relevant technology. Figure 2 This is a schematic diagram of the effect of volumetric cloud rendering based on Ray Marching according to related technologies. Please refer to Figure 1 and Figure 2As shown, when rendering a volume cloud based on Ray Marching, each pixel performs 32 Ray Marchings, but the actual frame rate is only 15fps. Since each advance of Ray Marching requires a sampling and calculation overhead, the denser the step size, the greater the overhead, so for the current hardware configuration, the calculation cost is very high. In addition, the related art uses volume slice information or point cloud to express volume information, and requires a large number of Ray Marchings to achieve volume rendering. Therefore, how to save the number of Ray Marchings is also a key problem to be solved by the technical solution of this application.
[0031] In the embodiment of the present application, a 3D model can be combined with a 3D volume texture to express the macroscopic shape of an object to be rendered and the internal medium density information, so as to better reconstruct the volume rendering, preferably, to construct the volume rendering results under different viewing angles. The medium distribution inside the object to be rendered can be uniform or non-uniform. If it is uniform, the object to be rendered is, for example, a material similar to glass or beeswax.
[0032] However, Figure 3 It is a schematic diagram of expression according to different observation angles of the embodiment of the present application, such as Figure 3 As shown, when an observer observes an object from different angles, the distribution of the medium density of the object seen may be non-uniform in the process of the eye's line of sight penetrating from the surface of the object to the other side of the object. Therefore, the distribution of medium density during volume rendering is related to the direction of the line of sight.
[0033] The embodiment of the present application analyzes and saves the medium distribution information inside the object to be rendered according to each different observation angle, i.e., the view direction bias. After obtaining the medium distribution information, it is convenient to evaluate the various interactions of light inside the medium, such as scattering, absorption, etc., so as to obtain the volumetric light and shadow information. It can be seen that the volumetric light and shadow information is not a fixed value, and then, volume rendering can be performed based on the light and shadow information.
[0034] Figure 4 is a flow chart of a volume rendering method based on spherical harmonics according to an embodiment of the present application, such as Figure 4 As shown, the following steps are included:
[0035] S100: Selecting a preset number of angle values, each angle value corresponding to a line of sight direction;
[0036] S200: Pre-integrating the medium density inside the object to be rendered in each sight line direction to obtain a medium density pre-integration result corresponding to each sight line direction;
[0037] S300: Pre-integration results of each line of sight direction and medium density corresponding to each line of sight direction are saved as spherical harmonic function coefficients;
[0038] S400: When any sight line direction is received, a medium density pre-integration result corresponding to the sight line direction is read according to the stored spherical harmonic function coefficients, and light and shadow information of the volume is obtained according to the medium density pre-integration result;
[0039] S500: Rendering is performed according to the light and shadow information of the volume.
[0040] According to the above content, the light and shadow information of the volume can be obtained according to the medium distribution information (ie, the medium density pre-integration result), so the following mainly describes in detail the calculation and storage of the medium density pre-integration result.
[0041] The embodiment of the present application uses spherical harmonics to save the medium distribution information under the current observation angle. Figure 5 is a schematic diagram of expressing several-order spherical harmonic functions according to an embodiment of the present application, such as Figure 5 As shown, P represents Legendre polynomials; the two parameters l and m classify these polynomials into several groups, l is the group number, and its value is an integer between [0, 6], and m is an integer between [0, 6]. The significance of spherical harmonics is that the amplitudes in different directions can be expressed by spherical harmonics factors (coefficients) of different orders. It is a derivation of the spherical coordinate system solution of the Laplace equation, and the values in different directions can be expressed by spherical coordinates. In the volume rendering of the embodiment of the present application, the diffuse illumination convolution of the environment is stored by spherical harmonic illumination.
[0042] As an example, Ray Marching is performed in the current viewing direction to pre-integrate the medium density inside the object to be rendered, and all medium densities from the viewing entrance surface to the viewing exit back surface are gradually accumulated to obtain the medium density pre-integration result in the current viewing direction.
[0043] Optionally, each time Ray Marching is performed, the current line of sight direction and its corresponding medium density pre-integration result are saved as the second-order spherical harmonic coefficients. Since the second-order spherical harmonic coefficients correspond to 4 factors (coefficients), after obtaining the volume light and shadow information according to the medium density pre-integration result, the volume light and shadow information can be well pre-baked to the vertices of the model of the object to be rendered, or stored in the texture. The volume light and shadow information also refers to the scene information, which includes the depth and direction of the scene. Since the 4 coefficients just correspond to a Float4 value, the GPU is calculated based on a four-dimensional vector as the basic unit, and the Float4 vector composed of 4 floating-point numbers is the most basic type built into the GPU, so whether it is stored in a texture or a vertex, it is very convenient to save the data. In addition, in actual development, the spherical harmonic coefficients need to be saved offline, so the spherical harmonic coefficients have different calculation processing methods when saving the spherical harmonic coefficients due to different orders of spherical harmonics. Theoretically, the higher the order of the spherical harmonic function, the more accurate the rendering result will be. However, the number of spherical harmonic function coefficients will also increase, which will increase both the storage cost and the calculation cost. Therefore, in order to ensure the accuracy of the rendering result while reducing the storage cost and the calculation cost, the second-order spherical harmonic function coefficients are used here for expression.
[0044] According to the above content, all (i.e., a preset number) of sight directions and the medium density pre-integration results in each sight direction are input into the second-order coefficients of the spherical harmonic function for storage. Optionally, by combining the Monte Carlo random sampling method with the noise sampling method, 1024 angle values are randomly selected in space, each angle value corresponds to a sight direction, and Ray Marching is performed in each sight direction, and these 1024 sight directions and corresponding sampling results (i.e., medium density) will be obtained. After pre-integration of the sampling results, they are saved as spherical harmonic function coefficients. Theoretically, at a 360° viewing angle, Ray Marching is required for each angle to sample medium density information, and these medium density information are saved in the spherical harmonic function coefficients. Although the smaller the sampling interval around the entire 360° space sphere, the better the effect, the overhead is very large based on the amount of calculation based on such uniform sampling distribution. Therefore, the above-mentioned preset number, i.e., 1024, can be a balanced value for balancing spherical harmonic function coefficients and rendering effects.
[0045] Based on the above content, when the sight direction is input (i.e., the hardware receives the sight direction), the medium density information (i.e., the medium density pre-integration result) in the currently received sight direction is restored according to the saved spherical harmonic function coefficients. Thus, the volume light and shadow information is obtained based on the restored medium density pre-integration result, and rendering is performed according to the volume light and shadow information.
[0046] Figure 6 is a schematic diagram of the effect of volume rendering based on spherical harmonics according to an embodiment of the present application, Figure 7 is a schematic diagram of the effect of volume rendering based on spherical harmonics according to an embodiment of the present application, such as Figure 6 and Figure 7 As shown, the volume rendering method based on spherical harmonics of the embodiment of the present application can be used in Unity3D, which can save a lot of Ray Marching overhead, and the additional overhead is only to save the vertex data of a part of the spherical harmonic coefficients, and it is static, and the calculation overhead of this part of the data is so small that it can be almost ignored. At the same time, for different viewing angles, the volume rendering information can be accurately restored by the spherical harmonic coefficients. Therefore, the volume rendering method of the embodiment of the present application can save computing costs while ensuring rendering accuracy.
[0047] The present application embodiment provides a volume rendering device based on spherical harmonics, Figure 8 is a structural block diagram of a volume rendering device based on spherical harmonics according to an embodiment of the present application, such as Figure 8 As shown, the device includes a selection module 1, a pre-integration module 2, a storage module 3, a reading module 4 and a rendering module 5, wherein the selection module 1 is used to select a preset number of angle values, each angle value corresponds to a line of sight direction; preferably, the preset number of angle values are randomly selected by Monte Carlo. The pre-integration module 2 is used to pre-integrate the medium density inside the object to be rendered in each line of sight direction, and obtain the medium density pre-integration result corresponding to each line of sight direction; preferably, light stepping is performed in each line of sight direction, the medium density inside the object to be rendered is pre-integrated, and all the medium densities from the line of sight entry surface to the back side of the exit are gradually accumulated to obtain the medium density pre-integration result corresponding to each line of sight direction. The storage module 3 is used to save each line of sight direction and the medium density pre-integration result corresponding to each line of sight direction as a spherical harmonic function coefficient. The reading module 4 is used to read the medium density pre-integration result corresponding to the line of sight direction according to the stored spherical harmonic function coefficient when receiving any line of sight direction, and obtain the volume light and shadow information according to the medium density pre-integration result. The rendering module 5 is used to render according to the volume light and shadow information.
[0048] The present application also provides an electronic device, Fig. 9 is a structural block diagram of an electronic device according to an embodiment of the present application, such as Fig. 9 As shown, the electronic device may include a processor 81 and a memory 82 storing computer program instructions.
[0049] Specifically, the processor 81 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0050] Among them, the memory 82 may include a large-capacity memory for data or instructions. By way of example and not limitation, the memory 82 may include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 82 may include a removable or non-removable (or fixed) medium. Where appropriate, the memory 82 may be inside or outside the data processing device. In a specific embodiment, the memory 82 is a non-volatile memory. In a specific embodiment, the memory 82 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable Programmable Read-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable Programmable Read-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0051] The memory 82 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 81 .
[0052] The processor 81 implements any one of the volume rendering methods based on spherical harmonics in the above embodiments by reading and executing computer program instructions stored in the memory 82 .
[0053] In some embodiments, the electronic device may further include a communication interface 83 and a bus 80. Fig. 9 As shown, the processor 81, the memory 82, and the communication interface 83 are connected via a bus 80 and communicate with each other.
[0054] The communication interface 83 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication interface 83 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.
[0055] The bus 80 includes hardware, software or both, and couples the components of the electronic device to each other. The bus 80 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 80 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 80 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0056] In addition, in combination with the volume rendering method based on spherical harmonics in the above embodiments, the present application embodiment can provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the volume rendering methods based on spherical harmonics in the above embodiments is implemented.
[0057] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A volume rendering method based on spherical harmonics, characterized in that: include: Selecting a preset number of angle values, each of which corresponds to a line of sight direction; Pre-integrating the medium density inside the object to be rendered in each of the sight lines to obtain a medium density pre-integration result corresponding to each of the sight lines; The pre-integration results of the respective sight lines and the medium density corresponding to the respective sight lines are saved as spherical harmonic function coefficients; When any of the sight lines is received, the medium density pre-integration result corresponding to the sight line direction is read according to the stored spherical harmonic function coefficients, and the light and shadow information of the volume is obtained according to the medium density pre-integration result; Rendering is performed according to the light and shadow information of the volume.
2. The volume rendering method based on spherical harmonics according to claim 1, characterized in that: The selected preset number of angle values includes: A preset number of angle values are randomly selected via Monte Carlo.
3. The volume rendering method based on spherical harmonics according to claim 1, characterized in that: The pre-integration of the medium density inside the object to be rendered in each of the sight lines to obtain the medium density pre-integration result corresponding to each of the sight lines includes: Light stepping is performed in each of the sight lines, the medium density inside the object to be rendered is pre-integrated, and all the medium densities from the sight entry surface to the sight exit back surface are gradually accumulated to obtain the medium density pre-integration result corresponding to each of the sight lines.
4. The volume rendering method based on spherical harmonics according to claim 1, characterized in that: The step of storing the pre-integration results of the respective sight lines and the medium density corresponding to the respective sight lines as spherical harmonic function coefficients includes: Each of the sight lines and the medium density pre-integration results corresponding to each of the sight lines are saved as second-order spherical harmonic function coefficients.
5. The volume rendering method based on spherical harmonics according to claim 4, characterized in that: The step of storing the pre-integration results of the respective sight lines and the medium density corresponding to the respective sight lines as second-order spherical harmonic function coefficients includes: Volumetric light and shadow information is obtained according to the medium density pre-integration result, and the volumetric light and shadow information is pre-baked onto the vertices of the model of the object to be rendered or stored into a map.
6. A volume rendering device based on spherical harmonics, characterized in that: include: A selection module, used for selecting a preset number of angle values, each of which corresponds to a line of sight direction; A pre-integration module, used for pre-integrating the medium density inside the object to be rendered in each of the sight lines, to obtain a medium density pre-integration result corresponding to each of the sight lines; A saving module, used for saving each of the sight lines and the medium density pre-integration results corresponding to each of the sight lines as spherical harmonic function coefficients; A reading module, configured to read the medium density pre-integration result corresponding to any of the line of sight directions according to the stored spherical harmonic function coefficients when receiving the line of sight directions, and obtain volumetric light and shadow information according to the medium density pre-integration result; The rendering module is used for rendering according to the light and shadow information of the volume.
7. The volume rendering device based on spherical harmonics according to claim 6, characterized in that: The selected preset number of angle values includes: A preset number of angle values are randomly selected via Monte Carlo.
8. The volume rendering device based on spherical harmonics according to claim 6, characterized in that: The pre-integration of the medium density inside the object to be rendered in each of the sight lines to obtain the medium density pre-integration result corresponding to each of the sight lines includes: Light stepping is performed in each of the sight lines, the medium density inside the object to be rendered is pre-integrated, and all the medium densities from the sight entry surface to the sight exit back surface are gradually accumulated to obtain the medium density pre-integration result corresponding to each of the sight lines.
9. An electronic device comprising a processor and a storage medium storing a computer program, characterized in that: When the computer program is executed by the processor, the volume rendering method based on spherical harmonics according to any one of claims 1 to 5 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the volume rendering method based on spherical harmonics according to any one of claims 1 to 5 is implemented.
