Image rendering method and electronic device
By obtaining light source and object information, calculating photon maps and shadow maps, and combining with PBD models, the problem of inaccurate light transmission and reflection simulation in the existing technology is solved, and higher image authenticity and accuracy are achieved, improving user experience .
Patent Information
- Application Number
- PCT/CN2023/139302
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-23
- Filing Date
- 2023-12-15
- Publication Date
- 2025-01-02
AI Technical Summary
Existing image drawing methods cannot truly simulate the transmission and reflection of light in translucent materials, resulting in the image being not realistic enough, with poor accuracy, and the user's immersion and experience quality are also reduced accordingly.
An image drawing method is adopted to calculate photon maps and shadow maps by obtaining light source information and object information in the world space. Combined with the PBD model, considering the refractive direction of light on the surface of the object, calculate the subsurface scattering results, and use the screen space algorithm. Improve rendering efficiency and accuracy.
It significantly improves the authenticity and accuracy of the image, improves the user's immersion and experience quality, and can render translucent materials more realistically.
Smart Images

Figure CN2023139302_02012025_PF_FP_ABST
Abstract
Description
Image drawing method and electronic device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on May 23, 2023, with application number 202310595935.8 and application name “Image Drawing Method and Electronic Device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of the present application relate to the technical field of electronic devices, and in particular to an image drawing method and an electronic device. Background Art
[0003] Electronic devices require image rendering to display user interfaces. This is particularly true for scenarios requiring real-time image rendering, such as gaming, simulation, and virtual reality interactions. These scenarios often involve objects made of translucent materials or scattering media, such as milk, jade, marble, and skin. These objects may involve both internal light transmission and external reflection. Current image rendering methods are unable to realistically simulate light transmission. Consequently, images rendered using these methods lack realism and accuracy, resulting in poor user immersion and experience quality.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide an image rendering method and electronic device that can improve the authenticity and accuracy of images.
[0006] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions.
[0007] In a first aspect, the present application provides an image rendering method. The execution subject of the method can be an electronic device or a component located in the electronic device (e.g., a chip, a chip system, or a processor). The following description uses the execution subject being an electronic device as an example. The method may include: the electronic device obtains light source information and information about a first object in world space. The information about the first object includes material properties, including translucent materials and materials with scattering functions. The information about the first object also includes position information of each point on the surface of the first object. Based on the light source information and the information about the first object, the electronic device obtains diffuse reflection results, highlight results, and a photon map of the first object. The photon map includes position information, intensity information, and direction information of light after refraction on the surface of the first object at each point on the surface of the first object. The electronic device obtains normals and position information of each shading point on the first object in screen space. Based on the normals and position information of each shading point and the photon map, the electronic device determines the color value of each shading point to obtain a subsurface scattering result of the first object. The electronic device draws an image of the first object based on the subsurface scattering results, diffuse reflection results, and highlight results.
[0008] Thus, in the present application, the electronic device obtains the light source information and the information of the first object in the world space. The electronic device obtains the photon map based on the light source information and the object information. The photon map includes the position information of each point on the surface of the object, the intensity information and the direction information of the light after refraction on the surface of the object. The electronic device obtains the normal and position information of each shading point of the object in the screen space. Based on the normal and position information of each shading point and the photon map, the electronic device obtains the position information, direction and light intensity of each photon beam of each shading point. The electronic device determines the subsurface scattering result of the object based on the position information, direction and light intensity of each photon beam to draw an image of the object. The electronic device obtains the photon map and uses the direction information of the light after refraction on the surface of the object in the photon map to obtain the color value of each shading point of the object with high accuracy, so that the drawn image has a high sense of immersion and experience quality.
[0009] In one design solution, the electronic device determines a color value for each shading point based on the normal and position information of each shading point and the photon map to obtain a subsurface scattering result of the first object. Specifically, the electronic device may obtain the position information, direction, and light intensity of each photon beam corresponding to each shading point based on the normal and position information of each shading point and the photon map. The electronic device determines a color value for each shading point based on the position information, direction, and light intensity of each photon beam to obtain a subsurface scattering result of the first object.
[0010] In one design solution, the electronic device determines the color value of each shading point based on the position information, direction, and light intensity of each photon beam to obtain a subsurface scattering result of the first object. Specifically, the electronic device calculates the first color value of the first shading point for the first photon beam in screen space based on a photon beam PBD model. The electronic device determines the parameters of the PBD model based on the position information, direction, light intensity, and first color value of the first photon beam. After determining the parameters of the PBD model, the electronic device obtains the color value of each shading point for each photon beam in screen space based on the PBD model. The electronic device obtains the subsurface scattering result of the first object based on the color values of the multiple shading points of the first object.
[0011] In this application, by adopting the PBD model, the directional information of light after refraction on the surface of the object is taken into account in the photon map, that is, the refraction direction of light at the surface point of the object is taken into account, which significantly improves the accuracy of the results and makes more accurate rendering of backlight transmission and front scattering.
[0012] In one design, the parameters of the PBD model may include: the distance from the real source to the first shading point, the distance from the virtual source to the first shading point, the depth of the real source, and the depth of the virtual source. The real source is each photon in the first photon beam. The distance from the real source to the first shading point is the distance between each photon in the first photon beam and the first shading point. The depth of the real source is obtained based on the distance from the real source to the first shading point. The virtual source is each photon in a theoretical photon beam. The distance from the virtual source to the first shading point is determined based on the depth of the real source. The depth of the virtual source is determined based on the depth of the real source.
[0013] In one design solution, the electronic device obtains color values for each shading point of a first object in screen space for each photon beam based on a PBD model. Specifically, the electronic device may obtain a second color value and its weight for a second shading point in screen space for a second photon beam based on the PBD model. The electronic device obtains a third color value and its weight for a third shading point in screen space for a third photon beam based on the PBD model. The electronic device determines a final color value of the first shading point based on the first color value, the second color value and its weight, and the third color value and its weight.
[0014] In this application, the final color value of the first shading point is obtained by considering the influence of other photon beams on the color value of the first shading point and calculating the weight of the color value of the first shading point and the color value of the corresponding shading point, so that the final color value is more accurate and the resulting image is more realistic.
[0015] In some designs, the method may further include: the electronic device adjusting parameters of the PBD model based on the subsurface scattering result of the first object and a near-surface correction factor, wherein the near-surface correction factor is used to correct for overestimation of near-surface photons. In this way, the electronic device can eliminate model errors caused by photon position based on the first color value and the near-surface correction factor.
[0016] In some design solutions, the method may further include: the electronic device adjusting parameters of the PBD model based on the subsurface scattering result of the first object and an extinction coefficient correction factor; the extinction coefficient correction factor is used to correct errors caused by changes in the extinction coefficient. In this way, the electronic device can eliminate model errors caused by changes in the extinction coefficient based on the first color value and the extinction coefficient correction factor.
[0017] In some designs, the method may further include: the electronic device adjusting parameters of the PBD model based on the subsurface scattering result of the first object and a single scattering rate correction factor; the single scattering rate correction factor is used to correct errors caused by changes in the single scattering rate. In this way, the electronic device can correct the model based on the first color value and the single scattering rate, eliminating model errors caused by changes in the single scattering rate.
[0018] In a second aspect, the present application provides an electronic device that may include: an acquisition module, a determination module, and a drawing module; wherein,
[0019] The acquisition module is used to obtain light source information and information about the first object in world space; the information about the first object includes material properties, which include translucent materials and materials with scattering functions; the information about the first object also includes position information of each point on the surface of the first object. The acquisition module is used to obtain the diffuse reflection result, highlight result and photon map of the first object based on the light source information and the information of the first object. The photon map includes the position information, intensity information and direction information of light after refraction on the surface of the first object at each point on the surface of the first object. The acquisition module is used to obtain the normal and position information of each shading point on the first object in screen space. The determination module is used to determine the color value of each shading point based on the normal and position information of each shading point and the photon map to obtain the subsurface scattering result of the first object. The drawing module is used to draw an image of the first object based on the subsurface scattering result, diffuse reflection result and highlight result.
[0020] Thus, in the present application, the electronic device obtains the light source information and the information of the first object in the world space. The electronic device obtains the photon map based on the light source information and the object information. The photon map includes the position information of each point on the surface of the object, the intensity information and the direction information of the light after refraction on the surface of the object. The electronic device obtains the normal and position information of each shading point of the object in the screen space. Based on the normal and position information of each shading point and the photon map, the electronic device obtains the position information, direction and light intensity of each photon beam of each shading point. The electronic device determines the subsurface scattering result of the object based on the position information, direction and light intensity of each photon beam to draw an image of the object. The electronic device obtains the photon map and uses the direction information of the light after refraction on the surface of the object in the photon map to obtain the color value of each shading point of the object with high accuracy, so that the drawn image has a high sense of immersion and experience quality.
[0021] In one design scheme, the determination module is used to: obtain the position information, direction, and light intensity of each photon beam corresponding to each shading point based on the normal and position information of each shading point and the photon map; determine the color value of each shading point based on the position information, direction, and light intensity of each photon beam to obtain the subsurface scattering result of the first object.
[0022] In one design, a determination module is configured to: calculate a first color value for a first shading point in screen space for a first photon beam based on a photon beam PBD model; determine the parameters of the PBD model based on the position information, direction, light intensity, and first color value of the first photon beam; after determining the parameters of the PBD model, obtain the color values for each shading point of a first object in screen space for each photon beam based on the PBD model; and obtain the subsurface scattering results of the first object based on the color values of the multiple shading points of the first object. In this application, by adopting the PBD model, the directional information of light after refraction on the object surface is taken into account in the photon map, that is, the refraction direction of light at the object surface point is taken into account, significantly improving the accuracy of the results and providing more accurate rendering of both backlight transmission and frontal scattering.
[0023] In one design, the parameters of the PBD model include: the distance from the real source to the first shading point, the distance from the virtual source to the first shading point, the depth of the real source, and the depth of the virtual source. The real source is each photon in the first photon beam. The distance from the real source to the first shading point is the distance between each photon in the first photon beam and the first shading point. The depth of the real source is determined based on the distance from the real source to the first shading point. The virtual source is each photon in the theoretical photon beam; the distance from the virtual source to the first shading point is determined based on the depth of the real source. The depth of the virtual source is determined based on the depth of the real source.
[0024] In one design scheme, the acquisition module is used to: obtain the second color value and its weight of the second shading point of the second photon beam in the screen space according to the PBD model; obtain the third color value and its weight of the third shading point of the third photon beam in the screen space according to the PBD model; determine the final color value of the first shading point based on the first color value, the second color value and its weight, and the third color value and its weight.
[0025] In this application, the final color value of the first shading point is obtained by considering the influence of other photon beams on the color value of the first shading point and calculating the weight of the color value of the first shading point and the color value of the corresponding shading point, so that the final color value is more accurate and the resulting image is more realistic.
[0026] In one design, the electronic device may further include an adjustment module configured to adjust parameters of the PBD model based on the subsurface scattering result of the first object and a near-surface correction factor, wherein the near-surface correction factor is configured to correct for overestimation of near-surface photons. In this manner, the electronic device can eliminate model errors caused by photon position based on the first color value and the near-surface correction factor.
[0027] In one design, the adjustment module is further configured to adjust parameters of the PBD model based on the subsurface scattering result of the first object and an extinction coefficient correction factor. The extinction coefficient correction factor is used to correct errors caused by changes in the extinction coefficient. In this way, the electronic device can eliminate model errors caused by changes in the extinction coefficient based on the first color value and the extinction coefficient correction factor.
[0028] In one design, the adjustment module is further configured to adjust parameters of the PBD model based on the subsurface scattering result of the first object and a single scattering rate correction factor. The single scattering rate correction factor is used to correct errors caused by variations in the single scattering rate. In this way, the electronic device can eliminate model errors caused by variations in the single scattering rate based on the first color value and the single scattering rate correction.
[0029] In a third aspect, the present application provides an electronic device, comprising: one or more processors; and a memory, wherein the memory stores code; when the code is executed by the processor, the electronic device executes the method described in the first aspect.
[0030] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect.
[0031] In a fifth aspect, the present application provides a chip system comprising one or more processors. When the one or more processors execute instructions, the one or more processors execute the method as described in the first aspect.
[0032] Among them, the specific implementation methods and corresponding technical effects of each of the above-mentioned second to fifth aspects can refer to the specific implementation methods and technical effects of the above-mentioned first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] FIG1 is a schematic flow chart of an image drawing method;
[0034] FIG2 is a schematic flow chart of another image rendering method;
[0035] FIG3 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0036] FIG4 is a schematic diagram of a flow chart of an image drawing method provided in an embodiment of the present application;
[0037] FIG5-1 is a flow chart of an image drawing method provided in an embodiment of the present application;
[0038] FIG5-2 is a flow chart of an image drawing method provided in an embodiment of the present application;
[0039] FIG5-3 is a flow chart of an image drawing method provided in an embodiment of the present application;
[0040] FIG6 is a schematic diagram of a flow chart of an image drawing method provided in an embodiment of the present application;
[0041] FIG7 is a flow chart of an image drawing method provided by an embodiment of the present application in an application scenario;
[0042] FIG8 is a schematic diagram of a rendering effect of an image drawing method provided in an embodiment of the present application;
[0043] FIG9 is a schematic structural diagram of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] Electronic devices need to display user interfaces after rendering images. This is particularly true in scenarios requiring real-time image rendering, such as gaming, simulation, and virtual reality interactions. These scenarios often involve objects with translucent materials or scattering media, such as milk, jade, marble, and skin. These objects may involve both internal light transmission and external light reflection.
[0045] In one scenario, electronic devices can simulate the transmission of light on an object based on the bidirectional reflectance distribution function (BRDF) (or BRDF model). Since the BRDF model simulates the external appearance of an object based on the reflection and refraction of light, it can be seen that the BRDF model cannot well describe the transmission and reflection of light. Therefore, the image rendering method in this scenario renders images less realistic and less accurate, resulting in poor user immersion and experience quality.
[0046] To improve rendering accuracy, more complex subsurface scattering models, such as the bidirectional scattering surface reflectance distribution function (BSSRDF) model, need to be considered. The BSSRDF model can more realistically simulate the transmission of light within the material, and therefore can better render the effect of translucent materials. This model needs to take into account the absorption, scattering, and reflection properties of the material, and uses a series of mathematical formulas to describe these properties. The implementation of the BSSRDF model requires a high degree of computing resources and algorithm optimization, but once implemented, it can greatly improve the realism and accuracy of rendering, thereby enhancing the user's immersion and quality of experience.
[0047] To render translucent materials at real-time speeds, many mainstream rendering engines, such as Unity and UE4, currently employ screen-space subsurface scattering algorithms to improve rendering efficiency and speed. Screen space can be understood as the two-dimensional space on a computer screen. Screen-space algorithms filter the screen rendering results in a post-processing manner to simulate the detail reduction and diffused lighting effects of translucent materials. These algorithms typically employ a distance-dependent BSSRDF model, with the most representative works being the separable subsurface scattering (SSSS) model by Jimenez et al. and the normalized profile model by Christensen et al. The main advantage of screen-space subsurface scattering algorithms is their high speed, as they reduce computational overhead in non-critical areas of the scene and leverage the parallel computing capabilities of GPUs to accelerate the computational process. This makes screen-space algorithms widely used in real-time applications, for example, enabling realistic rendering of translucent materials such as human skin, blood, and candles in games.
[0048] Alternatively, electronic devices can utilize the screen-space translucency algorithm primarily used in Unity and UE4. This technique performs all light transport calculations normally in screen space, employing the normalized profile model of Christensen et al., and then applies a post-processing filter to the entire screen space to simulate subsurface scattering. For long-distance scattering and backlighting calculations, this technique uses the real-time realistic skin translucency algorithm proposed by Jimenez et al. to add the missing transmittance effect.
[0049] FIG1 is a flow chart of an image rendering method. As shown in FIG1 , an electronic device obtains interface information of an application, which may include light source information and object information in world space. The world space can be understood as a three-dimensional space used to represent the three-dimensional spatial coordinates of an object. Based on the light source information and the object information, the electronic device obtains a shadow map, a transmission result, a highlight result, and a reflected light result. Afterwards, the electronic device can obtain the position of the light source in the screen space and the subsurface scattering result of the light source on the object's shading point through the BSSRDF model. The electronic device draws an image of the object based on the subsurface scattering result, the transmission result, the highlight result, and the reflected light result. In this way, this method can effectively realize the real-time rendering function of translucent materials and solve the high time-consuming problem of subsurface scattering. However, there is still the problem of insufficient accuracy of the subsurface scattering calculation results.
[0050] In another scenario, compared to the above scenario, the difference is that, as shown in FIG2 , the electronic device obtains a shadow map in the world space. The electronic device stores the position, normal, and intensity information of the object surface in the world space. The electronic device constructs a splats map based on the position, normal, and intensity information of the object surface. Based on the splats map and the BSSRDF model, the electronic device obtains the subsurface scattering results of the light source on the object's shading point. The electronic device draws an image of the object based on the subsurface scattering results, highlight results, and reflected light results. In this way, this method has a higher accuracy in subsurface scattering calculation, but there is still a problem of insufficient accuracy of the subsurface scattering calculation results. Moreover, the electronic device uses the splats map to connect the light source space with the shading points in the screen space, and the construction of the splats causes excessive rendering rate loss.
[0051] To address the above technical issues, the present application provides an image rendering method, comprising: an electronic device obtaining light source information and information about a first object in world space. The first object information includes material properties, which may include translucent materials and materials with scattering capabilities. The first object information may also include position information for each point on the first object's surface. Based on the light source information and the first object information, the electronic device obtains a photon map and a shadow map. The photon map includes position information, intensity information, and direction information of light after refraction on the object's surface for each point on the object's surface. The shadow map is used to represent the shadow information of the first object. The electronic device obtains normals and position information for each shading point on the first object in screen space. Based on the normals and position information for each shading point and the photon map, the electronic device obtains position information, direction, and intensity of each photon beam corresponding to each shading point. Based on the position information, direction, and intensity of each photon beam, the electronic device determines a color value for each shading point to obtain a subsurface scattering result of the first object. The electronic device obtains diffuse reflection and highlight results of the first object. Based on the subsurface scattering, diffuse reflection, and highlight results, the electronic device renders an image of the first object. In this way, electronic devices obtain photon maps and use the directional information of light after refraction on the surface of the object in the photon map to obtain the color value of each shading point of the object with high accuracy, so that the drawn image has a higher sense of immersion and experience quality.
[0052] FIG3 is a structural block diagram of the electronic device.
[0053] As shown in Figure 3, the above-mentioned electronic device 100 may include a processor 110, a memory 120, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, a wireless communication module 160, a sensor module 150, and a display screen 170, etc.
[0054] It is understood that the structures illustrated in the embodiments of the present application do not constitute specific limitations on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0055] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0056] In some examples, the GPU is used to efficiently draw three-dimensional model data onto the desktop through a rendering pipeline.
[0057] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0058] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0059] In some examples, the processor 110 performs rendering process construction and data processing. Exemplarily, the processor 110 can adopt the Kirin 9000 processor.
[0060] In some examples, the present application provides a program code for an image drawing method that can be stored in the runtime engine, memory management, and rendering pipeline process of the platform software. As shown in Figure 4, at runtime, the program code of the present application runs in the host memory and GPU memory of the electronic device. Figure 4 shows the implementation form of the present application in the computer and platform software, where the part shown in the dotted box is the module that the present application changes on the existing GPU rendering architecture. Inside the geometry stage module 4011, the present application makes changes to the vertex shader 4012 module to process the additional vertex information of translucent objects; in the rasterization stage 4017 module, the present application makes modifications to the geometry shader module to allow calculation of various translucent material rendering operations including photon map construction, PBD model evaluation, texture filtering, etc.
[0061] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the electronic device's wireless charging coil. While charging the battery 142, the charging management module 140 can also power the electronic device through the power management module 141.
[0062] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 and provides power to the processor 110, the memory 120, the display 170, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0063] The wireless communication function of the electronic device can be implemented through the antenna 1, the wireless communication module 160, the modem processor and the baseband processor.
[0064] Antenna 1 is used to transmit and receive electromagnetic wave signals. Each antenna in an electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antenna can be used in conjunction with a tuning switch.
[0065] The wireless communication module 160 can provide wireless communication solutions for electronic devices, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 1, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 1.
[0066] The electronic device implements display functionality through a GPU, display screen 170, and an application processor. A GPU is a microprocessor for image processing that connects display screen 170 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0067] Display screen 170 is used to display images, videos, and the like. Display screen 170 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, the electronic device can include one or N display screens 170, where N is a positive integer greater than one.
[0068] The electronic device can implement a shooting function through an ISP, a video codec, a GPU, a display screen 170 , and an application processor.
[0069] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when an electronic device selects a frequency, the DSP performs a Fourier transform on the frequency energy.
[0070] Video codecs are used to compress or decompress digital video. Electronic devices may support one or more video codecs. This allows them to play or record videos in a variety of encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.
[0071] The memory 120 can be used to store computer-executable program code, which includes instructions. The internal memory 120 can include a program storage area and a data storage area. The program storage area can store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.). The data storage area can store data created during the use of the electronic device (such as audio data, a phone book, etc.).
[0072] Of course, the electronic device may also include other functional units, which is not limited in the embodiments of the present application.
[0073] The following describes the image drawing method provided by the embodiment of the present application, taking the architecture shown in Figure 3 as an example. Each unit in the following embodiment may have the components shown in Figure 3, which will not be described in detail. It should be noted that the message name or parameter name in the message exchanged between the various devices in the embodiment of the present application is only an example, and other names can also be used in the specific implementation. In addition, the actions, terms, etc. involved in the various embodiments of the present application can refer to each other without limitation.
[0074] The following is a detailed introduction to an image drawing method provided in an embodiment of the present application.
[0075] Figures 5-1 to 5-3 are flowcharts of an image drawing method provided in an embodiment of the present application. Combined with Figures 5-1 and 5-3, the method may include:
[0076] S500: The electronic device receives a user operation on a first application.
[0077] The first application may be any type of application, in particular a game application, a simulation application, a virtual reality interactive application, etc. The user interface of the first application is a scene interface in a world space.
[0078] The world space can be understood as a three-dimensional space used to represent the three-dimensional spatial coordinates of an object.
[0079] In one example, a user's operation on the first application can be understood as an operation on the icon of the first application, or as an operation on the user interface of the first application. The specific implementation needs to be determined based on the specific application scenario. The operation can be understood as a click operation, a press operation, a slide operation, etc. This application does not impose specific limitations on the embodiments, and during implementation, it can be selected based on the specific scenario.
[0080] For example, when a user clicks on the icon of a first application, the electronic device starts the first application. The process from the first application starting to the first application's user interface display is the process of the electronic device drawing the user interface, which is as follows:
[0081] S501. In response to the operation, the electronic device obtains interface information of the first application, where the interface information may include light source information and information of the first object in the world space.
[0082] The first object can be understood as a pre-set object model, which is used to represent a specified type of object. For example, the specified type of object can be milk, jade, marble, or skin, etc.
[0083] The first object information may include material properties, which may include translucent materials and materials with scattering capabilities. That is, the first object may be made of a translucent material. Alternatively, the first object may be an object with an internal structure that refracts light. The first object information may also include position information of various points on the surface of the first object, which may be understood as position information in world space.
[0084] The light source can be understood as a luminous light source in the scene. The information of the light source (referred to as light source information) may include light intensity, direction of photon beams, number of photon beams, and the like.
[0085] Of course, the electronic device obtaining the interface information of the first application in S501 is not limited to the triggering of S500. The electronic device may also obtain the interface information of the first application at a preset time interval. Of course, the electronic device may also be triggered by at least two methods, such as user operation and preset time interval, which is not specifically limited in the embodiments of the present application.
[0086] S502: The electronic device obtains a photon map and a shadow map based on the light source information and the information of the first object. The photon map includes position information, intensity information, and direction information of light after refraction on the surface of the object at each point on the surface of the object.
[0087] The photon map is used to represent a texture map for storing the starting position, direction and intensity of a photon beam. The starting position of a photon beam may refer to the position of an initial photon (or initial point or starting point) in the photon beam.
[0088] The shadow map is used to represent shadow information of the first object.
[0089] In one specific implementation, the electronic device stores the position information, intensity information, and direction information of light after refraction on the surface of each point on the first object in a two-dimensional texture based on light source information in world space, thereby generating a photon map and a shadow map. The intensity information can be determined based on information such as the world space position of the surface point, the single scattering rate, the radiance of the incident light, the incident direction, the normal, the Fresnel transmission term, and the refractive index.
[0090] In another specific implementation, the electronic device stores position information, intensity information, and direction information of light refraction on the surface of each point on the first object in a two-dimensional texture based on light source information in world space to generate a photon map. The electronic device then obtains a shadow map based on the light source information in world space to calculate shadow effects in world space and performs rendering calculations for the first object in screen space.
[0091] In a specific implementation, since a photon beam in world space is usually composed of 3-5 photon samples on the photon beam. Each sample point has its corresponding position and intensity. Storing all photons requires a large amount of memory space. According to the law that the photons on a photon beam are all located on the same ray and the photon intensity decays exponentially. Therefore, in the embodiment of the present application, only the position information and direction information of the initial point of each photon beam are stored, and the positions of other photons in the photon beam except the initial point can be dynamically set by offsetting t i To perform calculations, the expression can be:
[0092] Among them, P b is the world space position of the stored object surface point, that is, the initial point of the photon beam b. b is the direction of the stored photon beam b. The offset t i The decision is made by exponential sampling. i is a random number between (0,1), σ t is the extinction coefficient.
[0093] Similarly, since the photon intensity on the same photon beam decreases proportionally in the direction of the photon beam, it is only necessary to store the initial intensity information of the object surface (the initial intensity information can be understood as the intensity information of the object surface when the photon intensity in the photon beam is the strongest). Combined with the light source function in the photon beam diffusion (PBD) model, the expression of the intensity information stored in the photon map in the embodiment of the present application can be: I(P b ,ω)=α(P b )L(P b ,ω i )(n·ω)F t (ω,η)
[0094] Among them, P b is the world space position of the stored object surface point, α is the single scattering rate of the surface point of the first object, L is the radiance of the incident light, ω is the incident direction of the photon beam irradiating the object surface point, n is the normal of the object surface point, F t is the Fresnel transmission term, η is the refractive index of the surface of the first object. The incident direction can refer to the direction of the incident light at a point on the surface of the object, and the direction of the photon beam is the direction of the light.
[0095] Therefore, based on the information stored in the photon map, the position information and intensity information of all photons in the photon beam can be reconstructed in sequence according to the above formula. It can be seen that the use of photon maps in the embodiments of the present application significantly reduces the storage space required for photon beam information. The photon map is two-dimensional texture information, and the information format stored on the GPU is a texture format. In this way, the adaptability and computability of the photon map on the GPU side are greatly enhanced, effectively improving resource utilization and real-time rendering speed.
[0096] S503: The electronic device obtains normal and position information of each shading point on the first object in the screen space.
[0097] The screen space can be understood as the two-dimensional space of a computer screen.
[0098] The shading point can be understood as the point on the surface of the first object where the color value of the point needs to be calculated after the photon beam irradiates the point. That is, during the calculation process, the point is the shading point.
[0099] S504. The electronic device obtains the position information, direction, and light intensity of each photon beam corresponding to each shading point based on the normal and position information of each shading point and the photon map.
[0100] The shading points on the surface of the first object may include a first shading point and a second shading point. In a specific implementation method, the electronic device can project the first shading point of the position and normal to the photon map based on the normal and position information of the first shading point, and obtain the position information, direction and light intensity of the first photon beam corresponding to the first shading point. Similarly, the electronic device can obtain the position information, direction and light intensity of the second photon beam corresponding to the second shading point based on the normal and position information of the second shading point and the photon map. By analogy, the electronic device projects each shading point into the photon map, and can obtain the position information (such as starting point information), direction and intensity information of the photon beam corresponding to each shading point.
[0101] The first photon beam corresponding to the first colored point can be understood as the photon beam irradiating the first colored point.
[0102] S505: The electronic device determines the color value of each shading point according to the position information, direction, and light intensity of each photon beam to obtain a subsurface scattering result of the first object.
[0103] In a specific implementation, as shown in FIG5-2 , S505 may be implemented as follows:
[0104] S5051. The electronic device calculates a first color value of a first shading point of the first object by the photon beam in screen space based on the PBD model. The color value can be understood as an RGB value, where R represents Red, G represents Green, and B represents Blue.
[0105] The PBD model is a physically derived BSSRDF model whose parameters depend on both the scattering distance and the incident direction, offering better accuracy than the SSSS model and the canonical profile model. It evaluates subsurface scattering by distributing a beam of light within an object, where a number of photons are distributed across the beam. The SSSS model is a BSSRDF model derived through fitting, with parameters dependent only on the scattering distance, offering better accuracy. The canonical profile model is a BSSRDF model derived through fitting, with parameters dependent only on the scattering distance, offering better accuracy.
[0106] In one specific implementation, the electronic device may project the first shading point, corresponding to the position and normal of the first shading point, onto a photon map based on the normal and position information of the first shading point, thereby obtaining the position information, direction, and light intensity of the first photon beam corresponding to the first shading point. The electronic device then calculates a first color value for the first shading point of the first object in screen space for the first photon beam based on a PBD model.
[0107] S5052. The electronic device determines parameters of a PBD model according to the position information, direction, light intensity, and first color value of the first photon beam.
[0108] Since the PBD model requires many parameters, the electronic device can reversely deduce the parameters of the PBD model based on the first photon beam to obtain the following parameters: the distance d from the real light source (referred to as the real source) to the shading point r , the distance d from the virtual light source (referred to as virtual source) to the shading point v , the depth z of the true source r , the depth z of the virtual source v The real light source can be understood as the photons in the first photon beam. The virtual light source can be understood as the photons in the first photon beam offset, that is, the photons in the theoretical first photon beam.
[0109] Specifically, the electronic device determines the first color value of the first shading point based on the position information, direction, and light intensity of the first photon beam. The electronic device determines the parameters of the PBD model based on the position information, direction, light intensity, and first color value of the first photon beam. Exemplarily, as shown in FIG6 , the electronic device regards each photon on the first photon beam as a real source and the tangent plane of the first shading point on the surface of the first object as a ground reference, and the distance between the position of each photon in the first photon beam and the position of the first shading point can be regarded as d r , and this distance d r Decompose along the normal direction and the direction of the tangent plane at the first shading point, then d r The decomposition in the normal direction can be used as z r The depth z of the virtual source v Available through z r It can be deduced that z v =z r +2AD. A and D are normalization factors, and AD represents the multiplication of A and D. The electronic device shifts the position of each photon in the first photon beam by z along the normal direction of the color point. r +4AD, the position of the virtual source can be obtained, and the distance d from the virtual source to the shading point can be calculated based on the position of the virtual source v In this way, the electronic device can determine the parameters of the PBD model.
[0110] S5053: After the electronic device determines the parameters of the PBD model, the electronic device obtains, according to the PBD model, a second color value of a second shading point irradiated by a second photon beam other than the first photon beam. For example, the expression may be:
[0111] Among them, I(P b ,ω) represents the intensity information of the second shading point on the surface of the object.b is the world space position of the second shading point on the object surface. ω is the incident direction of the photon beam on the second shading point on the object surface. r(d ri ,d vi ,z ri ,z vi ) is the model calculation formula in the PBD model, which is used to calculate the P of a photon on the second photon beam. i The color value of the corresponding second shading point. ri Indicates the distance from the real source to the second shading point. vi Indicates the distance from the virtual source to the second shading point. ri Indicates the depth of the true source. z vi Represents the depth of the virtual source. N represents the number of photons in the second photon beam. The color value of the second shading point by the photon can be understood as the color value of the second shading point under the illumination of the photon.
[0112] Similarly, the electronic device obtains the third color value of the third shading point under the illumination of the third photon beam in addition to the first photon beam according to the PBD model. The specific calculation adopts the expression B above, which will not be repeated in this embodiment of the application.
[0113] In an embodiment of the present application, by adopting the PBD model, the directional information of light after refraction on the surface of the object is taken into account in the photon map, that is, the refraction direction of light at the surface point of the object is taken into account, which significantly improves the accuracy of the results and makes more accurate rendering of backlight transmission and front scattering.
[0114] Due to the impact of transitioning from world space to screen space, that is, from three-dimensional space to two-dimensional space, directly using the PBD model for calculations can result in significant errors. This error is caused by various factors, including the position of the photon, the extinction coefficient, and the single scattering rate. To eliminate or reduce this impact, in some embodiments, the electronic device employs at least one of three correction factors to eliminate the impact. Specifically, these three correction factors may include: a near-surface correction factor, an extinction coefficient correction factor, and a single scattering rate correction factor.
[0115] For example, the near-surface correction factor is used to correct for an overestimation of near-surface photons. This overestimation of near-surface photons can be understood as an overestimation of the value calculated by the PBD model. In other words, after correction by the near-surface correction factor, the value calculated by the PBD model is no longer overestimating. The expression of the near-surface correction factor is as follows:
[0116] Among them, σ t is the extinction coefficient of the semi-transparent material of the first object. r Indicates the distance from the real source to the shading point.
[0117] In this way, the electronic device can eliminate the model error caused by the photon position based on the above B and near-surface correction factor.
[0118] For example, the extinction coefficient correction factor is used to correct the error caused by the change of the extinction coefficient. The expression of the extinction coefficient correction factor is as follows: κ e =2.2pow(σ t ,-1.3)+0.02
[0119] Among them, σ t is the extinction coefficient of the semi-transparent material of the first object. Pow() represents the power function.
[0120] In this way, the electronic device can eliminate the model error caused by the change of the extinction coefficient based on the above B and the extinction coefficient correction factor.
[0121] For example, the single scattering rate correction factor is used to correct the error caused by the change of the single scattering rate. The single scattering rate correction factor is expressed as follows: κ α =0.34pow(α,20)+0.64
[0122] Wherein, α is the single scattering rate of the shading point on the surface of the first object.
[0123] In this way, the electronic device can be corrected based on the above B and the single scattering rate, eliminating the model error caused by the change of the single scattering rate.
[0124] In a specific implementation, the above B is multiplied by a near-surface correction factor, an extinction coefficient correction factor, and a single scattering rate correction factor to eliminate the influence.
[0125] The above method first calculates the first color value of the first shading point through the PBD model. Then, based on the position information, direction, light intensity, and first color value of the first photon beam, the parameters of the PBD model are inferred. After obtaining the parameters, the final color value of the first shading point is accurately calculated. Similarly, the final color value of each shading point is obtained.
[0126] S5054: The electronic device obtains a subsurface scattering result of the first object according to the color values of the multiple shading points of the first object.
[0127] In one specific implementation, the electronic device can obtain the first coordinates corresponding to the first shading point on the photon map by projecting the first shading point onto the photon map. The electronic device then obtains a preset area centered on the first coordinates. The preset area can be an area of any shape, such as a square area. The electronic device obtains the color values of all photon beams within the preset area for the first shading point. The electronic device can obtain the weight of each photon beam for the color value of the first shading point based on the distance between the surface point of the first object corresponding to each photon beam and the first shading point, and the normal of the first shading point.
[0128] The specific expression can be: total =w d w n w b , w d =exp(-λ d ||P b -P o ||), w n =exp(λ n (0.5ω b ·n-0.5)), w b =exp(λ b (0.5ω b ·(P o -P b )-0.5))
[0129] Among them, w d is the weight in the distance dimension. n is the weight in the direction dimension. b is the weight in the beam dimension. b The world space position of the second point on the object surface stored. o is the world space position of the first point on the stored object surface. n is the normal of the second shading point. Exp() represents the index function. d ,λ n ,λ b The value can be user-defined. · Represents the multiplication operator.
[0130] For example, in the embodiment of the present application, d ,λ n ,λ b It can be defined as 0.1, 0.01, and 0.8 respectively.
[0131] After the electronic device obtains the weights of the color values of the first shading point for each photon beam according to the above expression, the electronic device obtains the color values of each photon beam for the first shading point based on the weights and the color values of the corresponding shading points for each photon beam. The electronic device obtains the final color value of the first shading point based on the color values of each photon beam for the first shading point and the first color value. For example, based on the PBD model, the electronic device obtains the second color value and its weight for the second shading point for the second photon beam in screen space; and based on the PBD model, obtains the third color value and its weight for the third shading point for the third photon beam in screen space; and determines the final color value of the first shading point based on the first color value, the second color value and its weight, and the third color value and its weight.
[0132] Similarly, the electronic device obtains the final color value of each shading point. That is, after filtering the texture, the electronic device can obtain the complete subsurface scattering result of the first object. As can be seen, in the embodiments of the present application, the complex splats construction is avoided through texture filtering, significantly improving the computational speed of semi-transparent material rendering.
[0133] S506: The electronic device obtains the diffuse reflection result and the highlight result of the first object.
[0134] In a specific implementation manner, the electronic device uses an existing specular reflection model and a diffuse reflection model to respectively calculate the specular effect and the diffuse reflection effect of the first object to obtain a diffuse reflection result and a specular result of the first object.
[0135] S507: The electronic device draws an image of the first object according to the subsurface scattering result, the diffuse reflection result, and the highlight result.
[0136] In one specific implementation, to flexibly adjust the translucency of the material of the first object, the electronic device may combine the subsurface scattering result and the diffuse reflection result of the first object based on a linear relationship between the subsurface scattering result and the diffuse reflection result, and obtain a final color value for each shading point of the first object based on the blending result and the highlight result. The electronic device then draws the first object based on the color value.
[0137] In this way, the embodiment of the present application allows the use of a mixing factor, which can be understood as a mixing ratio value, to mix the subsurface scattering result with the diffuse reflection result to adjust the blurriness of the surface details of the object. At the same time, in some cases, the sampling of the object boundary in the photon map sometimes causes artifacts. The embodiment of the present application can solve the artifact problem through screen space (such as 7×7 screen space) Gaussian filtering. Finally, by adding the mixed result of the subsurface scattering result and the diffuse reflection result to the highlight result, the image of the first object drawn by the electronic device can be made more realistic and more accurate.
[0138] In practical applications, the present application provides an image drawing method that can be applied in the field of realistic translucent object rendering in computer games or three-dimensional rendering platforms. For example, Figure 7 is a flow chart of an application scenario of an image drawing method provided by the present application. Compared with the original image drawing process, in Figure 7, the electronic device needs to calculate the photon map before calculating the shadow map. The electronic device obtains the color value of each shading point on the surface of the translucent object based on the normal and position information of each shading point of the translucent object, and the photon map. The electronic device completes the high-precision rendering of the translucent object based on the color value of each shading point, thereby drawing the image of the translucent object. Finally, the image drawn by the electronic device presents the display effect shown in Figure 8.
[0139] However, on the one hand, its application direction should not be limited to games. For many fields involving the visualization of real translucent objects, such as furniture virtual visualization design, industrial real-time simulation and other application directions, medical virtual human simulation and visualization, this algorithm can be used for high-realistic presentation. On the other hand, since the main body of the technical solution of this application is the algorithm code, it should not be limited to a fixed computer platform, that is, it can be allowed to run on servers, various host platforms, mobile platforms, etc. However, it should be noted that for performance bottlenecks on different platforms, it is necessary to flexibly adjust parameters to ensure the calculation rate of this solution.
[0140] The specific implementation method of the embodiment of this application is detailed in the above-mentioned relevant content, and the embodiment of this application will not be repeated here.
[0141] The various solutions in the above embodiments of the present application can be combined under the premise that there is no contradiction.
[0142] The embodiment of the present application also provides an electronic device for implementing any of the above methods, for example, an electronic device is provided that includes a unit (or means) for implementing each step performed by the electronic device in the above method S501-S507. For example, please refer to Figure 9, which is a schematic diagram of an electronic device provided by an embodiment of the present application. The electronic device 900 may include: the electronic device 900 may include: an acquisition module 901, a determination module 902 and a drawing module 903; wherein,
[0143] Acquisition module 901 is used to acquire light source information and information about a first object in world space. The first object information includes material properties, including translucent materials and materials with scattering capabilities. The first object information also includes position information of various points on the first object's surface. Exemplarily, acquisition module 901 may execute steps S500-S501 above. Acquisition module 901 may be processor 110 shown in FIG. 3 .
[0144] Acquisition module 901 is configured to acquire diffuse reflection results, highlight results, and a photon map of the first object based on the light source information and the first object information. The photon map includes position information and intensity information of each point on the surface of the first object, as well as directional information of light after refraction on the surface of the first object. Exemplarily, acquisition module 901 executes steps S502 and S506 above.
[0145] The acquisition module 901 is used to acquire the normal and position information of each shading point on the first object in the screen space. Exemplarily, the acquisition module 901 may execute the above step S503.
[0146] Determination module 902 is configured to determine the color value of each shading point based on the normal and position information of each shading point and the photon map, to obtain a subsurface scattering result of the first object. Exemplarily, determination module 902 may execute steps S504-S505 described above. Determination module 902 may be processor 110 shown in FIG3 .
[0147] The rendering module 903 is used to render an image of the first object based on the subsurface scattering result, the diffuse reflection result, and the highlight result. For example, the rendering module 903 may execute the above-mentioned step S507. The rendering module 903 may be the processor 110 shown in FIG3.
[0148] In one example, the determination module 902 is configured to:
[0149] According to the normal and position information of each shading point and the photon map, the position information, direction and light intensity of each photon beam corresponding to each shading point are obtained;
[0150] The color value of each shading point is determined according to the position information, direction, and light intensity of each photon beam to obtain a subsurface scattering result of the first object.
[0151] In one example, the determination module 902 is configured to:
[0152] Calculate, in screen space, a first color value of a first shading point for a first photon beam according to a photon beam PBD model;
[0153] Determining parameters of a PBD model according to the position information, direction, light intensity, and first color value of the first photon beam;
[0154] After determining the parameters of the PBD model, obtaining, according to the PBD model, a color value of each shading point of the first object by each photon beam in the screen space;
[0155] A subsurface scattering result of the first object is obtained according to color values of the plurality of shading points of the first object.
[0156] In one example, the parameters of the PBD model include: a distance from the real source to the first shading point, a distance from the virtual source to the first shading point, a depth of the real source, and a depth of the virtual source;
[0157] Among them, the real source is each photon in the first photon beam; the distance from the real source to the first shading point is the distance between each photon in the first photon beam and the first shading point; the depth of the real source is obtained based on the distance from the real source to the first shading point; the virtual source is each photon in the theoretical photon beam; the distance from the virtual source to the first shading point is determined based on the depth of the real source; the depth of the virtual source is determined based on the depth of the real source.
[0158] In one example, the acquisition module 901 is configured to:
[0159] According to the PBD model, obtain a second color value and a weight thereof for a second shading point of a second photon beam in screen space;
[0160] According to the PBD model, obtain a third color value and a weight thereof for a third shading point of a third photon beam in screen space;
[0161] A final color value of the first shading point is determined according to the first color value, the second color value and its weight, and the third color value and its weight.
[0162] In an example, the electronic device may further include an adjustment module 904 configured to:
[0163] The parameters of the PBD model are adjusted based on the subsurface scattering results of the first object and the near-surface correction factor; the near-surface correction factor is used to correct the overestimation of near-surface photons.
[0164] In one example, the adjustment module 904 is further configured to:
[0165] The parameters of the PBD model are adjusted according to the subsurface scattering result of the first object and the extinction coefficient correction factor; the extinction coefficient correction factor is used to correct the error caused by the change of the extinction coefficient.
[0166] In one example, the adjustment module 904 is further configured to:
[0167] The parameters of the PBD model are adjusted according to the subsurface scattering result of the first object and the single scattering rate correction factor; the single scattering rate correction factor is used to correct the error caused by the change of the single scattering rate.
[0168] In an embodiment of the present application, an electronic device obtains light source information and information of a first object in world space. The electronic device obtains a photon map based on the light source information and the object information. The photon map includes position information, intensity information, and direction information of light after refraction on the surface of the object at each point on the surface of the object. The electronic device obtains the normal and position information of each shading point of the object in the screen space. Based on the normal and position information of each shading point and the photon map, the electronic device obtains the position information, direction, and light intensity of each photon beam of each shading point. The electronic device determines the subsurface scattering result of the object based on the position information, direction, and light intensity of each photon beam to draw an image of the object. The electronic device obtains the photon map and uses the direction information of light after refraction on the surface of the object in the photon map to obtain the color value of each shading point of the object with high accuracy, so that the drawn image has a high sense of immersion and experience quality.
[0169] An embodiment of the present application also provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enables the computer to execute any of the above methods.
[0170] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above methods.
[0171] An embodiment of the present application also provides a chip, which includes a processor and an interface circuit, the interface circuit is coupled to the processor, the processor is used to run a computer program or instruction to implement the above method, and the interface circuit is used to communicate with other modules outside the chip.
[0172] In the description of this application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, "at least one" means one or more, and "a plurality" means two or more. Words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not limit them to be necessarily different.
[0173] In the description of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0174] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0175] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0176] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0177] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0178] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0179] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. An image drawing method, characterized in that: The method comprises: Acquire light source information and information of a first object in world space; the information of the first object includes material properties, and the material properties include translucent materials and materials with scattering functions; the information of the first object also includes position information of each point on the surface of the first object; According to the light source information and the information of the first object, a diffuse reflection result, a highlight result and a photon map of the first object are obtained, wherein the photon map includes position information of each point on the surface of the first object, intensity information and direction information of light after refraction on the surface of the first object; Obtaining normal and position information of each shading point on the first object in screen space; Determine the color value of each shading point according to the normal and position information of each shading point and the photon map to obtain a subsurface scattering result of the first object; An image of the first object is drawn according to the subsurface scattering result, the diffuse reflection result, and the highlight result.
2. The method according to claim 1, characterized in that Determining the color value of each shading point according to the normal and position information of each shading point and the photon map to obtain the subsurface scattering result of the first object includes: According to the normal and position information of each shading point and the photon map, the position information, direction and light intensity of each photon beam corresponding to each shading point are obtained; The color value of each shading point is determined according to the position information, direction and light intensity of each photon beam to obtain a subsurface scattering result of the first object.
3. The method according to claim 2, characterized in that Determining the color value of each shading point according to the position information, direction and light intensity of each photon beam to obtain the subsurface scattering result of the first object includes: Calculate a first color value of a first shading point of a first photon beam in screen space according to a photon beam PBD model; Determine the parameters of the PBD model according to the position information, direction, light intensity, and first color value of the first photon beam; After determining the parameters of the PBD model, obtaining, according to the PBD model, the color value of each shading point of the first object by each photon beam in the screen space; A subsurface scattering result of the first object is obtained according to color values of a plurality of shading points of the first object.
4. The method according to claim 3, characterized in that: The parameters of the PBD model include: a distance from a real source to the first shading point, a distance from a virtual source to the first shading point, a depth of the real source, and a depth of the virtual source; Among them, the real source is each photon in the first photon beam; the distance from the real source to the first shading point is the distance between each photon in the first photon beam and the first shading point; the depth of the real source is obtained based on the distance from the real source to the first shading point; the virtual source is each photon in the theoretical photon beam; the distance from the virtual source to the first shading point is determined based on the depth of the real source; the depth of the virtual source is determined based on the depth of the real source.
5. The method according to claim 3, characterized in that: According to the PBD model, obtaining color values of each shading point of the first object by each photon beam in the screen space includes: According to the PBD model, obtaining a second color value and a weight thereof of a second shading point of a second photon beam in screen space; According to the PBD model, obtaining a third color value and a weight thereof of a third shading point of a third photon beam in screen space; A final color value of the first shading point is determined according to the first color value, the second color value and its weight, and the third color value and its weight.
6. The method according to any one of claims 1 to 5, characterized in that Also includes: Adjusting parameters of the PBD model according to a subsurface scattering result and a near-surface correction factor of the first object; The near-surface correction factor is used to correct for the overestimation of near-surface photons.
7. The method according to any one of claims 1 to 6, characterized in that Also includes: adjusting the parameters of the PBD model according to the subsurface scattering result and the extinction coefficient correction factor of the first object; The extinction coefficient correction factor is used to correct the error caused by the change of the extinction coefficient.
8. The method according to any one of claims 1 to 7, characterized in that Also includes: The parameters of the PBD model are adjusted according to the subsurface scattering result of the first object and a single scattering rate correction factor; the single scattering rate correction factor is used to correct the error caused by the change of the single scattering rate.
9. An electronic device, characterized in that: The electronic device comprises: an acquisition module, a determination module and a drawing module; wherein, The acquisition module is used to acquire light source information and information of the first object in the world space; the information of the first object includes material properties, and the material properties include translucent materials and materials with scattering functions; the information of the first object also includes position information of each point on the surface of the first object; The acquisition module is used to acquire the diffuse reflection result, highlight result and photon map of the first object according to the light source information and the information of the first object, wherein the photon map includes the position information of each point on the surface of the first object, the intensity information and the direction information of the light after refraction on the surface of the first object; The acquisition module is used to acquire normal and position information of each shading point on the first object in the screen space; The determination module is used to determine the color value of each shading point according to the normal and position information of each shading point and the photon map, so as to obtain the subsurface scattering result of the first object; The drawing module is used to draw the image of the first object according to the subsurface scattering result, the diffuse reflection result and the highlight result.
10. The electronic device according to claim 9, characterized in that: The determination module is used for: According to the normal and position information of each shading point and the photon map, the position information, direction and light intensity of each photon beam corresponding to each shading point are obtained; The color value of each shading point is determined according to the position information, direction and light intensity of each photon beam to obtain a subsurface scattering result of the first object.
11. The electronic device according to claim 10, characterized in that: The determination module is used for: Calculate a first color value of a first shading point of a first photon beam in screen space according to a photon beam PBD model; Determine the parameters of the PBD model according to the position information, direction, light intensity, and first color value of the first photon beam; After determining the parameters of the PBD model, obtaining, according to the PBD model, the color value of each shading point of the first object by each photon beam in the screen space; A subsurface scattering result of the first object is obtained according to color values of a plurality of shading points of the first object.
12. The electronic device according to claim 11, characterized in that: The parameters of the PBD model include: a distance from a real source to the first shading point, a distance from a virtual source to the first shading point, a depth of the real source, and a depth of the virtual source; Among them, the real source is each photon in the first photon beam; the distance from the real source to the first shading point is the distance between each photon in the first photon beam and the first shading point; the depth of the real source is obtained based on the distance from the real source to the first shading point; the virtual source is each photon in the theoretical photon beam; the distance from the virtual source to the first shading point is determined based on the depth of the real source; the depth of the virtual source is determined based on the depth of the real source.
13. The electronic device according to claim 12, characterized in that: The acquisition module is used for: According to the PBD model, obtaining a second color value and a weight thereof of a second shading point of a second photon beam in screen space; According to the PBD model, obtaining a third color value and a weight thereof of a third shading point of a third photon beam in screen space; A final color value of the first shading point is determined according to the first color value, the second color value and its weight, and the third color value and its weight.
14. The electronic device according to any one of claims 9 to 13, characterized in that: Also includes: An adjustment module, wherein the adjustment module is used to: The parameters of the PBD model are adjusted according to the subsurface scattering result of the first object and a near-surface correction factor; the near-surface correction factor is used to correct the overestimation of near-surface photons.
15. The electronic device according to any one of claims 9 to 14, characterized in that: The adjustment module is also used for: The parameters of the PBD model are adjusted according to the subsurface scattering result of the first object and the extinction coefficient correction factor; the extinction coefficient correction factor is used to correct the error caused by the change of the extinction coefficient.
16. The electronic device according to any one of claims 9 to 15, characterized in that: The adjustment module is also used for: The parameters of the PBD model are adjusted according to the subsurface scattering result of the first object and a single scattering rate correction factor; the single scattering rate correction factor is used to correct the error caused by the change of the single scattering rate.
17. An electronic device, characterized in that: The electronic device comprises: one or more processors; and a memory, wherein codes are stored in the memory; when the codes are executed by the processor, the electronic device executes the method according to any one of claims 1 to 8.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 8.
19. A chip system, characterized in that: The method comprises one or more processors. When the one or more processors execute instructions, the one or more processors perform the method according to any one of claims 1 to 8.
