Ambient light reflection simulation method, device and storage medium based on physical principles
By pre-generating and processing 2D environment maps based on physical principles, the problem of cube maps' high memory usage and low rendering accuracy in Unity3D is solved, and more efficient ambient light reflection rendering is achieved.
Patent Information
- Application Number
- CN202011165334.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-27
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2040-10-27
AI Technical Summary
In Unity3D or real-time rendering technology, when using cubemap for ambient light reflection, it takes up a lot of memory and the texture sampling cache is lost, which affects rendering efficiency and accuracy.
A method based on physical principles is used to pre-generate a 2D environment map, which contains the material information of the rendered object, and is preprocessed and sampled according to the surface roughness. It replaces the Cubemap composed of six pictures, and improves rendering through Mipmaps and Monte Carlo distribution statistical algorithms. Efficiency and accuracy.
It reduces memory usage, reduces CPU computing costs, improves the rendering accuracy of ambient light reflection effects, saves storage costs, and reduces cache losses of texture sampling.
Smart Images

Figure CN112381915B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of real-time rendering technology, and in particular to a method, device and storage medium for simulating ambient light reflection based on physical principles. Background Art
[0002] At present, in Unity3D or in the field of real-time rendering technology, cubemaps are commonly used to achieve ambient light reflection, that is, image-based lighting (IBL), in which the image is the cubemap. However, cubemaps not only take up a lot of memory, but also have a lot of cache misses in texture sampling, which not only affects the efficiency of real-time rendering, but also reduces the accuracy of effect rendering. Summary of the invention
[0003] The embodiments of the present application provide a method, device and storage medium for simulating ambient light reflection based on physical principles, so as to at least solve the problems of high storage cost and low accuracy of rendering results when rendering ambient light reflection effects in related technologies.
[0004] In a first aspect, an embodiment of the present application provides a method for simulating ambient light reflection based on physical principles, including: pre-generating a 2D environment map through a rendering method based on physical principles, wherein the 2D environment map contains material information of a rendered object; pre-processing the 2D environment map according to the ambient light reflection information of the surface roughness of the rendered object to obtain a pre-processed 2D environment map; sampling the pre-processed 2D environment map, and expressing the ambient light reflection effect of the rendered object based on the sampled data.
[0005] In some of the embodiments, the pre-generating a 2D environment map by a rendering method based on physical principles includes: pre-generating a 2D environment map according to a global illumination algorithm in a PBR rendering method.
[0006] In some of the embodiments, the pre-generated 2D environment map according to the global illumination algorithm in the PBR rendering method includes: pre-generating the 2D environment map according to the global illumination algorithm in the PBR rendering method under the condition of pre-rendering with the scene of the current perspective, or under the condition of pre-rendering with an art-oriented style.
[0007] In some embodiments, the surface roughness of the rendered object in the 2D environment map is 0 by default, and the preprocessing of the 2D environment map according to the ambient light reflection information of the surface roughness of the rendered object to obtain the preprocessed 2D environment map includes: based on physical principles, setting the surface roughness range of the rendered object to 0 to 1, and saving the ambient light reflection information corresponding to different surface roughnesses through Mipmaps; and preprocessing the 2D environment map using the Mipmaps to obtain the preprocessed 2D environment map.
[0008] In some of the embodiments, the sampling of the preprocessed 2D environment map includes: sampling the preprocessed 2D environment map according to the line of sight direction and the normal direction of the rendered object, and sampling multi-level texture offset information of different levels for different surface roughness.
[0009] In some embodiments, the sampling of the preprocessed 2D environment map includes: performing offline sampling of the preprocessed 2D environment map based on a Monte Carlo distribution statistics algorithm.
[0010] In a second 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 the ambient light reflection simulation method based on physical principles as described in any one of the above items.
[0011] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for simulating ambient light reflection based on physical principles as described in any one of the above items is implemented.
[0012] According to the above content, the ambient light reflection simulation method based on physical principles of the embodiment of the present application includes: pre-generating a 2D environment map through a rendering method based on physical principles, the 2D environment map contains material information of the rendered object; pre-processing the 2D environment map according to the ambient light reflection information of the surface roughness of the rendered object to obtain a pre-processed 2D environment map; sampling the pre-processed 2D environment map, and expressing the ambient light reflection effect of the rendered object based on the sampled data. The embodiment of the present application can replace the Cubemap composed of six images in the prior art with an independent 2D map, which can reduce memory usage (i.e., save storage costs), while saving CPU computing costs and improving rendering efficiency. Moreover, it effectively solves the problem of low rendering accuracy due to more cache losses of map sampling, thereby improving the accuracy of rendering of ambient light reflection effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] 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:
[0014] Figure 1 is a flow chart of a method for simulating ambient light reflection based on physical principles according to an embodiment of the present application;
[0015] Figure 2 It is a 2D environment map of the rendered objects of different materials in the embodiment of the present application;
[0016] Figure 3 is a schematic diagram of different light reflection effects under different surface roughness of a rendered object in an embodiment of the present application;
[0017] Figure 4 is a schematic diagram of the ambient light reflection effect of a rendered object in an embodiment of the present application;
[0018] Figure 5 is a schematic diagram of the ambient light reflection effect of a rendered object in an embodiment of the present application;
[0019] Figure 6 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0020] 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.
[0021] 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.
[0022] 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.
[0023] 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.
[0024] In the process of real-time rendering of the game, it is necessary to simulate and restore the ambient lighting in a realistic way. For the ambient light reflected by the rendered object, IBL is used in related technologies and simulated based on images, such as through 3D Cubemaps. However, Cubemaps not only occupy more memory, but also cause more cache losses in texture sampling. Therefore, the ambient light reflection simulation method based on physical principles in the embodiment of the present application can replace the Cubemap composed of six images with an independent 2D image, so it saves 5 / 6 of the memory usage. At the same time, the embodiment of the present application adopts a physical fitting-based approach to deal with the situation of bidirectional distribution of reflected light in physical lighting.
[0025] Figure 1 is a flow chart of the ambient light reflection simulation method based on physical principles in an embodiment of the present application. Figure 1As shown, the following steps are included:
[0026] Step S100: pre-generate a 2D environment map by a rendering method based on physical principles, where the 2D environment map contains material information of the rendered object;
[0027] Step S200: preprocessing the 2D environment map according to the ambient light reflection information of the surface roughness of the rendered object to obtain a preprocessed 2D environment map;
[0028] Step S300: sampling the preprocessed 2D environment map, and expressing the ambient light reflection effect of the rendered object based on the sampled data.
[0029] Each step is described in detail below.
[0030] In some of the embodiments, step S100: pre-generate a 2D environment map through a rendering method based on physical principles, and the 2D environment map contains material information of the rendered object. For example, when rendering an object, a PBR (Physically-Based Rendering) rendering method based on physical principles is adopted. PBR is a shading method based on the material properties of the object surface, in which diffuse reflection and reflection involved are the two most basic manifestations of the effect of light on the surface of the object. When the light reaches the surface of the object, part of the light will bounce along the vertical normal of the surface in the opposite direction of the source light. The smoother the surface, the more it looks like a mirror reflection. This phenomenon is called surface highlight. However, not all light will be reflected. Some light will enter the interior of the illuminated object. Part of this light will be absorbed by the object and converted into heat energy, and the other part will be scattered inside the object, and finally leave the object and be captured by the human eye and the camera. This phenomenon is called "diffuse reflection" and "sub-surface scattering". In addition, the above phenomenon satisfies the law of energy conservation. Diffuse reflection and reflection are two independent parts. Part of the incident light is reflected on the surface of the object, and the part that is not reflected enters the surface of the object and is absorbed or scattered. Therefore, an important conclusion can be drawn: diffuse reflection light + reflected light = incident light, which is the energy conservation of light. This phenomenon is manifested in that under the same lighting conditions, the more intense the reflection, the weaker the diffuse reflection of the surface of the material. Figure 2 is a 2D environment map of the rendered objects of different materials in the embodiment of the present application, such as Figure 2 As shown, the surface diffuse reflection of rendered objects of different materials is different (manifested as different brightness and darkness in the figure).
[0031] According to the above content, when rendering the reflection of the ambient light GI (Global Illumination), the embodiment of the present application identifies the material of the rendered object through a pre-generated environment map, that is, the environment map contains the material information of the rendered object. Among them, the GI algorithm not only takes into account the lighting conditions directly from the light source (direct lighting), but also takes into account the subsequent situation when the light from the same light source hits the surface of the object in the scene and bounces back to other surfaces (indirect lighting). In the real world, light sources emit a large number of photons (Light photons). After the photons reach the surface of the object, they bounce (Bounce), change their own color according to the color surface of the rebound surface, and finally enter our eyes. The GI global illumination mode attempts to simulate this photon-bounce physical lighting process. This photon simulation process adds a sense of reality to the rendering, so that a more vivid and realistic picture can be obtained.
[0032] In some embodiments, the 2D environment map is pre-generated under the condition of pre-rendering with the scene of the current viewing angle, or under the condition of pre-rendering with the style of the art preference. In other words, the 2D environment map can be pre-rendered with the scene of the current viewing angle, or can be stylized by identifying the art preference.
[0033] Step S200: Preprocess the 2D environment map according to the ambient light reflection information of the surface roughness of the rendered object to obtain the preprocessed 2D environment map. This means that before using the above-mentioned pre-generated 2D environment map, the embodiment of the present application needs to preprocess the map. For example, it is assumed that the above-mentioned pre-generated 2D environment map is used to simulate the reflection situation when the surface roughness of the object is 0, but in fact the surface roughness of the object will have different values. Assuming that the surface roughness is standardized to the interval range of 0 to 1 in the embodiment of the present application, and the ambient light reflection information corresponding to different surface roughnesses is saved through Mipmaps, the 2D environment map is preprocessed using Mipmaps (i.e., the object is preprocessed based on physical principles) to obtain the preprocessed 2D environment map. Among them, the above-mentioned Mipmaps is a computer graphics image technology used to achieve a stereoscopic effect in a two-dimensional substitute for a three-dimensional image. Combining the Mipmaps technology with the material mapping technology of the embodiment of the present application can present a single material map in the form of multiple images with different resolutions according to the different distances from the viewer and represent the plane texture.
[0034] Step S300: Sampling the pre-processed 2D environment map, and expressing the ambient light reflection effect of the rendered object based on the sampled data. That is, during actual rendering sampling, the pre-processed 2D environment map can be sampled according to the view direction and the normal direction of the rendered object, and at the same time, for different surface roughnesses, different levels of multi-level texture offset (mipmap bias) information can be sampled, so that the ambient light reflection effect under different surface roughnesses can be expressed based on physical principles. Figure 3 is a schematic diagram of different light reflection effects under different surface roughness of the rendered object in the embodiment of the present application, such as Figure 3 As shown, the smoother the surface of the rendered object, the stronger the light reflection.
[0035] In some of the embodiments, in order to generate a physically correct surface roughness fit based on physical principles, the above-mentioned preprocessed 2D environment map can be sampled offline based on the Monte Carlo distribution statistics algorithm. The characteristic of the Monte Carlo distribution statistics algorithm is that an approximate result can be calculated on random sampling, and as the sampling increases, the probability that the result obtained is a correct result gradually increases. A more important point is that it is necessary to use importance sampling as a sampling strategy, so the embodiment of the present application selects a physically correct importance sampling strategy based on the physics of 2D images to perform Monte Carlo sampling, which is more physically correct than the known sampling based entirely on Gaussian blur or uniform distribution, and also has a better restoration of the bidirectional reflection distribution function BRDF (Bidirectional Reflectance Distribution Function), thereby improving the accuracy of ambient light reflection simulation (i.e., rendering effect).
[0036] Figure 4 is a schematic diagram of the ambient light reflection effect of a rendered object in an embodiment of the present application, Figure 5 is a schematic diagram of the ambient light reflection effect of a rendered object in an embodiment of the present application, such as Figure 4 and Figure 5 As shown, due to Figure 5 The surface ratio of the rendered object in Figure 4 The surface of the rendered object in is rougher, so Figure 5 The ambient reflection effect of the rendered object is compared to Figure 4 Darker. In addition, Figure 4 or Figure 5 The ambient light reflection effects of various parts of the rendered objects are also rendered very accurately.
[0037] The present application also provides an electronic device, Figure 6is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 6 As shown, the electronic device may include a processor 81 and a memory 82 storing computer program instructions.
[0038] 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.
[0039] 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.
[0040] 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 .
[0041] The processor 81 reads and executes the computer program instructions stored in the memory 82 to implement any one of the ambient light reflection simulation methods based on physical principles in the above embodiments.
[0042] In some embodiments, the electronic device may further include a communication interface 83 and a bus 80. Figure 6 As shown, the processor 81, the memory 82, and the communication interface 83 are connected via a bus 80 and communicate with each other.
[0043] 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 port 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.
[0044] 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.
[0045] In addition, in combination with the ambient light reflection simulation method based on physical principles 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 the processor, any one of the ambient light reflection simulation methods based on physical principles in the above embodiments is implemented.
[0046] 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 method for simulating ambient light reflection based on physical principles, characterized in that: include: Pre-generating a 2D environment map by a rendering method based on physical principles, wherein the 2D environment map contains material information of the rendered object; Preprocessing the 2D environment map according to the ambient light reflection information of the surface roughness of the rendered object, setting the surface roughness range of the rendered object to 0-1 based on physical principles, and saving the ambient light reflection information corresponding to different surface roughnesses through Mipmaps, wherein the surface roughness of the rendered object in the 2D environment map is 0 by default; Preprocessing the 2D environment map using the Mipmaps to obtain a preprocessed 2D environment map; The preprocessed 2D environment map is sampled, and based on the sampled data, the ambient light reflection effect of the rendered object is expressed.
2. The method for simulating ambient light reflection based on physical principles according to claim 1, characterized in that: The pre-generated 2D environment map by the rendering method based on physical principles includes: According to the global illumination algorithm in the PBR rendering method, a 2D environment map is pre-generated.
3. The method for simulating ambient light reflection based on physical principles according to claim 2, characterized in that: The pre-generated 2D environment map according to the global illumination algorithm in the PBR rendering method includes: Under the condition of pre-rendering with the scene of the current perspective, or under the condition of pre-rendering with an art-oriented style, a 2D environment map is pre-generated according to the global illumination algorithm in the PBR rendering method.
4. The method for simulating ambient light reflection based on physical principles according to claim 1, characterized in that: The sampling of the preprocessed 2D environment map comprises: The preprocessed 2D environment map is sampled according to the sight direction and the normal direction of the rendered object, and at the same time, multi-level texture offset information of different levels is sampled for different surface roughnesses.
5. The method for simulating ambient light reflection based on physical principles according to claim 1, characterized in that: The sampling of the preprocessed 2D environment map comprises: The pre-processed 2D environment map is sampled offline based on a Monte Carlo distribution statistics algorithm.
6. 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 method for simulating ambient light reflection based on physical principles according to any one of claims 1 to 5 is implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for simulating ambient light reflection based on physical principles according to any one of claims 1 to 5 is implemented.
