Lighting processing method, device, electronic device, and storage medium
By baking the point light data and indirect light data to generate a light map, the problem of difficult day and night light effect transformation in the prior art is solved, and efficient day and night light effect transformation is achieved.
Patent Information
- Application Number
- CN202210387956.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-13
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2042-04-13
AI Technical Summary
The prior art is difficult to effectively realize the transformation of day and night lighting effects, especially because the data of the light map is difficult to change, making the transformation effects difficult to achieve.
By baking the point light data and indirect light data, the first light information and the second light information corresponding to it are obtained, and a light map is generated based on these information to achieve the day-night transformation effect.
The light map is generated by pre-baked lighting data, thereby reducing calculation overhead in real-time operation and effectively realizing the transformation of day and night lighting effects.
Smart Images

Figure CN114742936B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer graphics, and in particular to a lighting processing method, device, electronic device and storage medium. Background Art
[0002] Global illumination is used to simulate the lighting interaction between geometry and material surfaces, adding realistic lighting effects to scenes and projects. Currently, many games need to present the light and shadow transformation effects of day and night. Usually, real-time lighting methods can be used to simulate the activity of light to achieve the lighting effects of day and night transformations.
[0003] However, the real-time lighting method requires real-time calculation of lighting information, which has a high computational overhead. Another way to simulate the activity of light is to pre-calculate the lighting information, that is, bake it, and store this lighting information as a light map. By pre-calculating in advance, the computational overhead in real-time operation can be reduced. However, this method usually bakes all lighting information into the light map, making it difficult to change the data of the light map, and thus it is difficult to use the light map to achieve the lighting effect of day and night change. Summary of the invention
[0004] The embodiments of the present application provide a lighting processing method, device, electronic device and storage medium, which can use the baked lighting map to achieve the effect of day and night change.
[0005] An embodiment of the present application provides a lighting processing method, including: obtaining lighting data to be processed, the lighting data to be processed including point light data and indirect light data; baking the point light data to obtain first lighting information corresponding to the point light data, the first lighting information including a color value and an intensity value; baking the indirect light data to obtain second lighting information corresponding to the indirect light data, the second lighting information including an intensity value; generating a lighting map based on the first lighting information and the second lighting information.
[0006] An embodiment of the present application also provides a lighting processing device, including: an acquisition module, used to acquire lighting data to be processed, the lighting data including point light data and indirect light data; a point light baking module, used to bake the point light data to obtain first lighting information corresponding to the point light data, the first lighting information including a color value and an intensity value; an indirect light baking module, used to bake the indirect light data to obtain second lighting information corresponding to the indirect light data, the second lighting information including an intensity value; a generation module, used to generate a lighting map according to the first lighting information and the second lighting information.
[0007] In some embodiments, the indirect light data includes first indirect light data and second indirect light data, the first indirect light data is indirect light data of parallel light, the second indirect light data is indirect light data of sky light, and the indirect light baking module includes a parallel light baking unit, a sky light baking unit, and a second determination unit:
[0008] A parallel light baking unit, configured to perform a baking process on the first indirect light data to obtain parallel light indirect light information corresponding to the first indirect light data;
[0009] A skylight baking unit, configured to perform baking processing on the second indirect light data to obtain skylight indirect light information corresponding to the second indirect light data;
[0010] The second determining unit is used to determine the parallel light indirect light information and the skylight indirect light information as the second illumination information.
[0011] In some embodiments, the first indirect light data includes first indirect light data in different directions, and the parallel light baking unit is further used to: bake the first indirect light data in each direction respectively to obtain a parallel light color value corresponding to the first indirect light data in each direction; convert each of the parallel light color values into a parallel light intensity value according to a preset conversion rule; and determine the parallel light intensity value corresponding to the first indirect light data in each direction as parallel light indirect light information.
[0012] In some embodiments, the skylight baking unit is also used to obtain second indirect light data; bake the second indirect light data to obtain skylight color values and skylight shading data corresponding to the second indirect light data, the skylight shading data including a skylight shading direction and a skylight shading intensity value; convert the skylight color value into a skylight intensity value according to a preset conversion rule; and determine the skylight intensity value, skylight shading direction and skylight shading intensity value as the skylight indirect light information.
[0013] In some embodiments, the point light data includes first point light data and second point light data, the first point light data represents point light during the day, the second point light data represents point light at night, and the point light baking module includes a first point light baking unit, a second point light baking unit, and a first determining unit:
[0014] A first point light baking unit, configured to perform baking processing on the first point light data to obtain a first color value and a first intensity value corresponding to the first point light data;
[0015] A second point light baking unit, used for baking the second point light data to obtain a second color value, a second intensity value and a point light direction corresponding to the second point light data;
[0016] The first determining unit is configured to determine the first color value, the first intensity value, the second color value, the second intensity value, and the point light direction as the first illumination information.
[0017] In some embodiments, the first illumination information includes a first color value, a first intensity value, a second color value, a second intensity value, and a point light direction, the second illumination information includes a parallel light intensity value, a sky light intensity value, a sky light shielding direction, and a sky light shielding intensity value, and the generation module further includes a first mapping unit, a second mapping unit, and a generation unit:
[0018] A first mapping unit, configured to store the first color value, the first intensity value, the second color value, the second intensity value, the point light direction, the parallel light intensity value, and the sky light intensity value as a first light map;
[0019] A second mapping unit, used for storing the skylight shading direction and the skylight shading intensity value as a second light map;
[0020] A generating unit is used to generate the light map according to the first light map and the second light map.
[0021] In some embodiments, the first mapping unit is also used to store the first color value and the first intensity value as a first color space; store the second color value and the second intensity value as a second color space; store the point light direction as a third color space; store the parallel light intensity value and the sky light intensity value as a fourth color space; and obtain the first light map according to the first color space, the second color space, the third color space and the fourth color space.
[0022] In some embodiments, the lighting processing device also includes a rendering module. After generating a lighting map according to the first lighting information and the second lighting information, the rendering module is used to obtain a current parallel light color value and a current sky light color value; multiply the current parallel light color value by the parallel light intensity value to obtain parallel light indirect light information; multiply the current sky light color value by the sky light intensity value to obtain the sky light indirect light information; calculate the current lighting information based on the parallel light indirect light information, the sky light indirect light information, the first lighting information, the sky light shading direction and the sky light shading intensity value; and render the picture based on the current lighting information.
[0023] An embodiment of the present application also provides an electronic device, including a memory storing multiple instructions; the processor loads instructions from the memory to execute the steps in any one of the illumination processing methods provided in the embodiments of the present application.
[0024] The embodiment of the present application also provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in any one of the illumination processing methods provided in the embodiment of the present application.
[0025] The embodiment of the present application bakes the point light data and the indirect light data separately to obtain first lighting information corresponding to the point light data and second lighting information corresponding to the indirect light data, and generates a lighting map based on the first lighting information and the second lighting information, so that the image can be rendered based on the lighting map later. The point light data and the indirect light data are baked separately to separate and bake the elements that change with time in the day and night transformation, so as to facilitate the subsequent real-time calculation according to the corresponding baking results to restore a more realistic day and night transformation effect. In addition, after baking the indirect light data, only the intensity value is retained, which can reduce the memory occupied by the lighting map, thereby reducing the configuration requirements for the device to achieve the day and night transformation effect, and facilitating operation on devices with lower configurations. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 is a scene schematic diagram of the illumination processing method provided in an embodiment of the present application;
[0028] Figure 2 It is a flow chart of the illumination processing method provided in the embodiment of the present application;
[0029] Figure 3 This is a schematic diagram of storing various data in the first light map provided in an embodiment of the present application;
[0030] Figure 4 is a schematic diagram of restoring parallel light and indirect light provided by an embodiment of the present application;
[0031] Figure 5 is a flow chart of a light processing method provided by another embodiment of the present application;
[0032] Figure 6 is a schematic diagram of a rendering result obtained according to parallel light indirect light information provided by an embodiment of the present application;
[0033] Figure 7 is a schematic diagram of a rendering result obtained according to skylight indirect light information provided by an embodiment of the present application;
[0034] Figure 8 is a structural schematic diagram of a light processing device provided in an embodiment of the present application;
[0035] Fig. 9 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0037] Embodiments of the present application provide a light processing method, device, electronic device, and storage medium.
[0038] The light processing device can be integrated into an electronic device, which can be a terminal, a server, or other devices. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, or a personal computer (PC), etc. The server can be a single server or a server cluster composed of multiple servers.
[0039] In some embodiments, the illumination processing device may also be integrated into multiple electronic devices. For example, the illumination processing device may be integrated into multiple servers, and the illumination processing method of the present application may be implemented by multiple servers.
[0040] In some embodiments, the server may also be implemented in the form of a terminal.
[0041] For example, refer to Figure 1, shows a scene schematic diagram of the illumination processing method provided by an embodiment of the present application, and the scene may include at least one terminal 1000, at least one server 2000, at least one database 3000, and a network 4000. The terminal 1000 held by the user can be connected to the server 2000 through the network 4000. Among them, the terminal 1000 is any device with computing hardware that can support and execute software products corresponding to the game; the server 2000 can be a single server or a server cluster; the network 4000 can be a wireless network or a wired network, such as a wireless network such as a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. In addition, different terminals 1000 can also use their own Bluetooth network or hotspot network to connect to other terminals or to the server 2000. In addition, the system may also include at least one database 3000, which is used to store game data generated when the user uses the terminal 1000.
[0042] Among them, an application can be installed on the terminal 1000. When the application is run on the terminal 1000, the game scene provided by the application can achieve the effect of day and night change. Specifically, it can be to obtain the lighting data to be processed on the terminal 1000, wherein the lighting data to be processed includes point light data and indirect light data; bake the point light data to obtain the first lighting information corresponding to the point light data, and the first lighting information includes a color value and an intensity value; bake the indirect light data to obtain the second lighting information corresponding to the indirect light data, and the second lighting information includes an intensity value; generate a lighting map according to the first lighting information and the second lighting information. When the application is run on the terminal 1000, the picture can be rendered according to the lighting map to achieve the lighting change effect.
[0043] In some embodiments, the generation of the light map can be performed in the server 2000. The server 2000 can provide an application download service, encapsulate the light map in the application installation package, and store the light map in the terminal 1000 when the application is installed on the terminal 1000. Therefore, when the application is run on the terminal 1000, the light map can be used for real-time rendering of the picture to achieve a day and night change effect in the game scene.
[0044] The following are detailed descriptions of each.
[0045] In this embodiment, a light processing method is provided, such as Figure 2 As shown, the specific process of the illumination processing method can be as follows:
[0046] S110, obtaining illumination data to be processed, wherein the illumination data includes point light data and indirect light data.
[0047] The illumination data to be processed refers to the illumination data that needs to be pre-calculated. Global illumination can include direct illumination and indirect illumination. Direct illumination refers to the illumination that hits the surface of an object for the first time, and indirect illumination refers to the illumination obtained by bounce. Usually, indirect illumination is obtained through multiple bounces and illumination superposition. In order to reduce the amount of calculation during image rendering, indirect illumination can be pre-calculated and stored in the light map.
[0048] In game engines, three types of light sources are usually provided, namely point light, sky light and parallel light. Point light is an idealized point light source, similar to an artificial light bulb; sky light refers to the use of objects such as the atmosphere, clouds, and mountains as illumination to simulate global brightness, such as the brightness of a dark surface; parallel light, also known as directional light or directional light, refers to parallel light without attenuation, similar to sunlight. Each light source can set its mobility type. The mobility types provided in the game engine include fixed light sources. Fixed light sources refer to light sources whose positions remain fixed during runtime, but whose colors and brightness can be modified, creating possibilities for the entire day and night transformation effect.
[0049] In order to achieve the effect of day and night changes in the game scene, it is necessary to flexibly split and bake the data that changes with the time dimension, such as the direction, color, brightness, etc. of the light, and record them in the light map.
[0050] Among them, point lights can refer to artificial light sources such as lanterns and lights in the scene. These artificial light sources are usually turned off during the day and turned on at night, so they have switching logic. In order to obtain the effect of day and night change, the point lights need to record the on and off states, that is, the color and intensity of the point lights during the day, as well as the point lights and colors at night, need to be recorded.
[0051] Similarly, since the direction of the main light changes with time, the color, bounce, and propagation of the parallel light also change with time. In order to obtain more scientific results, you can choose to bake these lights that change in the time dimension separately. Therefore, the lighting data to be processed can include point light data and indirect light data.
[0052] The point light data may include first point light data and second point light data, the first point light data is used to represent point light during the day, and the second point light data is used to represent point light at night. The indirect light data may include first indirect light data and second indirect light data, wherein the first indirect light data refers to light data obtained by bouncing and superimposing parallel light, and the second indirect light data refers to light data obtained by bouncing and superimposing skylight.
[0053] S120: Bake the point light data to obtain first lighting information corresponding to the point light data, where the first lighting information includes a color value and an intensity value.
[0054] After obtaining the point light data, the point light data may be baked to obtain first lighting information corresponding to the point light data. Baking refers to pre-calculating the point light data in advance to calculate the lighting effect generated by the point light data, i.e., the first lighting information. The first lighting information may represent the color corresponding to the lighting effect generated by the point light data and the intensity information of the lighting, i.e., the first lighting information may include a color value and an intensity value.
[0055] In some embodiments, in order to achieve the effect of day and night conversion, it is necessary to obtain the lighting effect during the day and the lighting effect at night. Since the point light data may include first point light data and second point light data, wherein the first point light data represents the point light during the day and the second point light data represents the point light at night, the first point light data and the second point light data may be baked respectively to obtain corresponding baking results. Therefore, when the point light data is baked to obtain the first lighting information, the first point light data may be baked to obtain the first color value and the first intensity value corresponding to the first point light data; the second point light data may be baked to obtain the second color value, the second intensity value and the point light direction corresponding to the second point light data; and the first color value, the first intensity value, the second color value, the second intensity value and the point light direction are determined as the first lighting information.
[0056] Usually, after baking the lighting, you can get the color value, intensity value and direction information. If all the above information needs to be saved for each baking result, the memory and package size of the lighting map will be larger. In order to reduce the memory of the final lighting map, you can selectively retain a part of the data for storage, which is convenient for running on devices with poor hardware configuration and reducing the requirements of the day and night effect on the hardware configuration of the device.
[0057] Since the first point light data refers to the point light during the day, and the point light direction during the day is usually dominated by skylight, when there is only the first point light data, the corresponding lighting effect can be calculated based on the first point light data, and the color value and intensity value used to express the lighting effect can be used as the corresponding baking result. That is, after the first point light data is baked, the first color value and the first intensity value obtained by the baking process can be stored to obtain the baking result corresponding to the first point light data, so that the lighting effect during the day can be obtained.
[0058] When there is only the second point light data, the corresponding lighting effect can be calculated according to the second point light data, and the color value, intensity value and point light direction used to express the lighting effect are used as the baking result corresponding to the second point light data. That is, after the second point light data is baked, the second color value, second intensity value and point light direction obtained by the baking process can be stored to obtain the baking result corresponding to the second point light data, so as to obtain the lighting effect at night.
[0059] From the above, it can be seen that the first lighting information may include a first color value, a first intensity value, a second color value, a second intensity value and a point light direction, wherein the first color value and the first intensity value are the lighting effects corresponding to the point light during the day, and the second color value and the second intensity value are the lighting effects corresponding to the point light at night with the point light direction.
[0060] S130. Bake the indirect light data to obtain second lighting information corresponding to the indirect light data, where the second lighting information includes an intensity value.
[0061] After obtaining the indirect light data, the indirect light data may be baked to obtain second lighting information corresponding to the indirect light data. The baking process refers to precalculating the indirect light data in advance to calculate the lighting effect generated by the indirect light data, i.e., the second lighting information. The second lighting information may represent intensity information corresponding to the lighting effect generated by the indirect light data, i.e., the second lighting information may include an intensity value.
[0062] In some embodiments, the indirect light data may include first indirect light data and second indirect light data, wherein the first indirect light data is indirect light data of parallel light, and the second indirect light data is indirect light data of skylight. When the indirect light data is baked to obtain the second illumination information, the first indirect light data and the second indirect light data may be baked separately, and the corresponding baking results may be used as the second illumination information. In some embodiments, when the first indirect light data and the second indirect light data are baked separately to obtain the second illumination information, the first indirect light data may be baked to obtain parallel light indirect light information corresponding to the first indirect light data; the second indirect light data may be baked to obtain skylight indirect light information corresponding to the second indirect light data; and the parallel light indirect light information and the skylight indirect light information may be determined as the second illumination information.
[0063] Among them, parallel light is used to simulate sunlight in the scene. In 24 hours a day, the direction of parallel light is different at different times. Usually, in order to obtain a more realistic lighting effect, the parallel light of each hour can be baked. However, in order to take into account the performance of the device, the parallel light of several key hours can be baked. Therefore, in some embodiments, the first indirect light data includes first indirect light data of different directions. When baking the first indirect light data, the first indirect light data of each direction can be baked separately to obtain the parallel light color value corresponding to the first indirect light data of each direction; according to the preset conversion rule, each of the parallel light color values is converted into a parallel light intensity value; the parallel light intensity value corresponding to the first indirect light data of each direction is determined as the parallel light indirect light information.
[0064] Parallel light is used to simulate sunlight, and the direction of the parallel light of sunlight at sunrise and sunset is different. In order to improve the realism of the lighting effect, you can also obtain the first indirect light data corresponding to the middle time between sunrise and sunset. For example, if the sunrise time is 8 o'clock and the sunset time is 18 o'clock, you can choose 12 o'clock as the middle time, that is, the first indirect light in different directions can refer to the parallel light corresponding to 8 o'clock, 12 o'clock, and 18 o'clock.
[0065] In some implementations, in order to improve the realism of the lighting effect, the parallel light corresponding to each moment may be obtained, and the parallel light corresponding to each moment may be baked to obtain the corresponding parallel light indirect light information.
[0066] After obtaining the first indirect light data in different directions, the first indirect light data in each direction can be baked respectively to obtain the parallel light color value corresponding to the first indirect light data in each direction. That is, the number of baking times is the same as the number of first indirect light data in different directions. If there are first indirect light data in three directions, bake three times to obtain the parallel light color values corresponding to the three directions. For example, the three directions are direction A, direction B, and direction C. After three bakings, the parallel light color value a corresponding to direction A, the parallel light color value b corresponding to direction B, and the parallel light color value c corresponding to direction C can be obtained.
[0067] After obtaining the parallel light color value corresponding to the parallel light in each direction, in order to further reduce the memory size occupied by the illumination map, the parallel light color value can be converted into a parallel light intensity value. Specifically, the parallel light color value can be converted into a parallel light intensity value according to a preset conversion rule, so as to obtain the parallel light intensity value corresponding to the first indirect light data in each direction, and all parallel light intensity values constitute the parallel light indirect light information.
[0068] When baking the second indirect light data to obtain the skylight indirect light information, the second indirect light data can be baked to obtain the skylight color value and skylight shielding data corresponding to the second indirect light data, the skylight shielding data including the skylight shielding direction and the skylight shielding intensity value; according to a preset conversion rule, the skylight color value is converted into the skylight intensity value; the skylight intensity value, the skylight shielding direction and the skylight shielding intensity value are determined as the skylight indirect light information.
[0069] After baking the second indirect light, the skylight color value and skylight occlusion data in the baking result may be retained. The skylight occlusion data may include a skylight occlusion direction and a skylight occlusion intensity value. After obtaining the skylight color value, in order to further reduce the memory size occupied by the light map and facilitate running on devices with low hardware configurations such as mobile devices, the skylight color value may be converted into a skylight intensity value according to a preset conversion rule.
[0070] The preset conversion rule may be a preset mapping relationship between color values and intensity values. The color value is usually described in RGB color space, with data of R channel, G channel and B channel respectively, and the intensity value channel is a single channel. Therefore, converting the color value to the intensity value is to convert the three channels into a single channel. Specifically, the preset conversion rule may be to normalize the color value to obtain a normalized result, perform a dot product of the normalized result and the color value, and divide the result by the length of the color value to obtain the intensity value.
[0071] It can be known from the above content that the second illumination information may include parallel light intensity value, sky light intensity value, sky light shielding direction and sky light shielding intensity value. There may be multiple parallel light intensity values, i.e., multiple parallel light intensity values obtained by baking the first indirect light data in multiple different directions, the sky light intensity value is obtained by baking the second indirect light data, and the sky light shielding direction and the sky light shielding intensity value are the default results obtained by the game engine when baking the second indirect light data.
[0072] S140: Generate a lighting map according to the first lighting information and the second lighting information.
[0073] After obtaining the first illumination information and the second illumination information, a illumination map may be generated using the first illumination information and the second illumination information. An illumination map is also called a light map, which refers to a map that stores effect data calculated in advance for the effect of illumination on a model, wherein the illumination map may refer to a single light map or may be composed of multiple light maps.
[0074] After obtaining the first illumination information and the second illumination information, in order to generate an illumination map, it is usually necessary to store the first illumination information and the second illumination information at corresponding positions in the illumination map, so as to obtain an illumination map including the first illumination information and the second illumination information.
[0075] In some implementations, the first lighting information and the second lighting information may be stored as a light map.
[0076] In some implementations, the first lighting information and the second lighting information may be stored as a plurality of light maps.
[0077] As an implementation method, the first lighting information includes a first color value, a first intensity value, a second color value, a second intensity value, and a point light direction, and the second lighting information includes a parallel light intensity value, a sky light intensity value, a sky light shading direction, and a sky light shading intensity value. When generating a lighting map, the first color value, the first intensity value, the second color value, the second intensity value, the point light direction, the parallel light intensity value, and the sky light intensity value may be stored as a first light map; the sky light shading direction and the sky light shading intensity value may be stored as a second light map; and the lighting map may be generated based on the first light map and the second light map.
[0078] That is, the skylight intensity values in the first lighting information and the second lighting information are stored in the same light map, and the skylight shading direction and the skylight shading intensity value in the second lighting information are stored in another light map.
[0079] When storing the skylight intensity values in the first lighting information and the second lighting information as the first light map, in order to ensure that the memory occupied by the first light map is not too large, the specific storage method can be: storing the first color value and the first intensity value as a first color space; storing the second color value and the second intensity value as a second color space; storing the point light direction as a third color space; storing the parallel light intensity value and the skylight intensity value as a fourth color space; and obtaining the first light map according to the first color space, the second color space, the third color space and the fourth color space.
[0080] Each color space includes four channels, namely R channel, G channel, B channel and Alpha channel. Figure 3 , shows a schematic diagram of the storage of various data in the first light map. Figure 3Each grid in represents an RGBA, and the first color value and the first intensity value are stored as the first color space, that is, the first color value occupies the three RGB channels, and the first intensity value occupies the Alpha channel. The second color value and the second intensity value are stored as the second color space, that is, the second color value occupies the three RGB channels, and the second intensity value occupies the Alpha channel. The point light direction is stored in the third color space, that is, the point light direction occupies the three RGB channels, and there is no data in the Alpha channel. The parallel light intensity value and the skylight intensity value are stored in the fourth color space, that is, the four RGBA channels are all intensity values. It can be seen from this that the first light paste Figure 1 A total of 4 RGBA are occupied.
[0081] The skylight occlusion direction and the skylight occlusion intensity value in the second lighting information are stored in the second light map. The skylight occlusion direction occupies three RBG channels, and the skylight occlusion intensity value occupies the Alpha channel.
[0082] The first light map and the second light map together constitute a light map. In some embodiments, after the light map is generated, the light map can be used to render the picture.
[0083] When using the illumination map for rendering, the current parallel light color value and the current sky light color value can be obtained; the current parallel light color value is multiplied by the parallel light intensity value to obtain the parallel light indirect light information; the current sky light color value is multiplied by the sky light intensity value to obtain the sky light indirect light information; based on the parallel light indirect light information, the sky light indirect light information, the first illumination information, the sky light shielding direction and the sky light shielding intensity value, the current illumination information is calculated; and the image is rendered based on the current illumination information. For example, you can refer to Figure 4 , showing a schematic diagram of restoring parallel light indirect light, Figure 4 According to the baking method of the embodiment of the present application, the parallel light intensity can be obtained, and the parallel light intensity is used to replace the original baking result. The parallel light intensity is multiplied by the current parallel light color to obtain the current parallel light indirect light.
[0084] When rendering a picture based on the illumination map, the current parallel light color value and the current sky light color value can be obtained, which refer to the parallel light color value and the sky light color value obtained at the current moment. The parallel light information included in the second illumination information can be the parallel light intensity values corresponding to three hours, and the parallel light intensity value corresponding to the three hours can be interpolated to obtain the parallel light intensity value corresponding to the current moment.
[0085] By multiplying the parallel light intensity value corresponding to the current moment with the current parallel light color value, the parallel light indirect lighting effect corresponding to the current moment can be restored. Similarly, by multiplying the skylight intensity value obtained from the first lightmap with the current skylight color value corresponding to the current moment, the skylight indirect lighting effect corresponding to the current moment can be restored.
[0086] Finally, based on the parallel light indirect light information, the skylight indirect light information, the first lighting information, the skylight shading direction and the skylight shading intensity value, the current lighting information is calculated, and rendering is performed based on the current lighting information to obtain the final day and night transformation effect.
[0087] Through the lighting processing method provided in the embodiment of the present application, the point light data and the indirect light data are baked separately to obtain the first lighting information corresponding to the point light data and the second lighting information corresponding to the indirect light data, and a lighting map is generated based on the first lighting information and the second lighting information, so that the image can be rendered based on the lighting map later. By baking the point light data and the indirect light data separately, the elements that change with time in the day and night transformation can be split and baked separately, which is convenient for subsequent real-time calculation according to the corresponding baking results to restore a more realistic day and night transformation effect. And the split baking method makes the amount of data baked each time smaller, which can reduce the requirements for computing power and save computing power.
[0088] In addition, in the embodiment of the present application, parallel light in different directions corresponding to three hours are baked respectively, and three sets of parallel light indirect light information can be obtained. The current mainstream baking is to bake all the information together, and the obtained parallel light indirect light information is also one hour. When the picture is rendered, the parallel light indirect light information cannot match most of the hours, resulting in poor results. In this application, in order to take into account the performance of the device and the effect of day and night change, the parallel light indirect light information of three hours is used. When the picture is rendered, the accurate parallel light indirect light information corresponding to each hour can be obtained by interpolation, which can not only improve the effect of day and night change and present a more realistic picture, but also run on devices with lower configurations.
[0089] The method described in the above embodiment will be further described in detail below.
[0090] In this embodiment, a Massive Multiplayer Online Game (MMOG) is taken as an example. In such games, it is usually necessary to implement day and night changes, that is, the game scene needs to simulate the light and shadow effects of the day and night changes in the real environment to enhance the authenticity of the game scene. The following takes the first point light data as daytime point light data, the second point light data as nighttime point light data, the first indirect light data as parallel light indirect light data in three directions, and the second indirect light as skylight indirect light data as an example to describe the method of the embodiment of the present application in detail.
[0091] like Figure 5 As shown, the specific process of a lighting processing method is as follows:
[0092] S210, acquiring daytime point light data, nighttime point light data, parallel light indirect light data in three directions, and skylight indirect light data.
[0093] S220, baking the daytime point light data and the nighttime point light data respectively to obtain a first color value and a first intensity value corresponding to the daytime point light data, and a second color value, a second intensity value, and a point light direction corresponding to the nighttime point light data.
[0094] S230 , respectively bake the parallel light indirect light data in three directions to obtain the parallel light intensity value corresponding to the parallel light indirect light data in each direction.
[0095] S240, baking the skylight indirect light data to obtain the skylight intensity value, the skylight shielding direction, and the skylight shielding intensity value.
[0096] S250, storing the first color value, the first intensity value, the second color value, the second intensity value, the point light direction, the parallel light intensity value corresponding to the parallel light indirect light data in three directions, and the skylight intensity value as a first light map.
[0097] S260: Store the skylight shading direction and the skylight shading intensity value as a second light map.
[0098] S270 , rendering the picture according to the first light map and the second light map.
[0099] Before performing lighting processing, we need to clarify the data we need to bake, which are daytime point light data, nighttime point light data, parallel light indirect light data in three directions, and skylight indirect light data.
[0100] Among them, the parallel light indirect light data in three directions respectively represent the parallel light indirect light at 8 am, 12 noon and 16 pm.
[0101] As can be seen from the above, in order to bake the above data, a total of 6 baking times are required. In specific implementation, the total number of baking times can be set to 6 in advance, and then the baking parameters for each round of baking can be set. As for the results of each round of baking, the storage information of the result of each round of baking can also be configured in advance to realize the storage of the baking data obtained by each baking, for example, in which part of the map the baked data is stored, whether it is the color value, the direction value, or the gray value, etc., and in which channel it is stored.
[0102] The following will explain each round of baking in detail. If the baking order is set to: daytime point light data, nighttime point light data, 8-point parallel light indirect light data, 12-point parallel light indirect light data, 16-point parallel light indirect light data, skylight indirect light data.
[0103] 1. After baking the daytime point light data, the first color value and the first intensity value may be stored in a channel corresponding to an RGBA in the first light map.
[0104] 2. After baking the night point light data, the obtained second color value and second intensity value can be stored in a channel corresponding to one RGBA in the first light map, and the point light direction can be stored in a channel corresponding to another RGBA.
[0105] 3. When baking the 8-point parallel light indirect light data, the 12-point parallel light indirect light data, and the 18-point parallel light indirect light data, you can bake the information associated with the parallel light, close irrelevant content, and convert the baking results into grayscale information of the intensity of the parallel light associated with the baking at that time. Share the daytime indirect light information at night. Specifically, turn on the parallel light for projected self-luminescence and the point light representing indirect light to obtain the corresponding baking results, convert the obtained parallel light color value into intensity, so that after three bakings, you can get three parallel light intensity values. Store these three parallel light intensity values in three channels in an RGBA of the first light map.
[0106] 4. When baking the skylight indirect light data, you can bake the information associated with the skylight, close irrelevant content, and convert the baking results into grayscale information of the intensity of the skylight associated with the baking at that time. Since the skylight shading direction does not change over time, there is no need to bake multiple times. The direction of the indirect light is obtained from the skylight shading direction. Specifically, turn on the skylight, standardize the skylight intensity and set the environment to pure white to obtain the corresponding baking result, and convert the obtained skylight color value into a skylight intensity value. The skylight intensity value is stored in one channel in an RGBA. That is to say, after baking the parallel light indirect light and the skylight indirect light, four intensity values can be obtained. These four intensity values can be stored in the corresponding channel of one RGBA in the first light map.
[0107] When baking skylight, the game engine can automatically generate a skylight occlusion data, that is, the skylight occlusion direction and skylight occlusion intensity can be obtained. The skylight occlusion direction and skylight occlusion intensity are stored in a channel corresponding to 1 RGBA of the second light map.
[0108] Therefore, the first light map and the second light map can be obtained by baking, so that the picture can be rendered according to the first light map and the second light map later.
[0109] In some embodiments, when rendering the picture, the parallel light color value and the skylight color value at the current moment can be obtained in real time. Since there are parallel light intensity values corresponding to three hours, the parallel light intensity value corresponding to the three hours can be interpolated and calculated to obtain the parallel light intensity value corresponding to the current moment. As mentioned above, the parallel light indirect light of the three hours of 8 o'clock, 12 o'clock, and 16 o'clock are baked respectively. When realizing the day and night transformation, these data can be recycled. For example, one cycle is from 6 am to 18 o'clock in the evening, and another cycle is from 18 o'clock in the evening to 6 o'clock the next day. The usage rule with time can be that 8 o'clock is exactly the first copy, 12 o'clock is the second copy, and 16 o'clock is the third copy. At 20 o'clock in the evening, it changes back to the first copy, 24 o'clock is the second copy, 4 o'clock the next day is the third copy, and it changes back to the first copy at 8 o'clock the next day.
[0110] By multiplying the parallel light intensity value corresponding to the current moment with the parallel light color value at the current moment, the parallel light indirect light at the current moment can be restored. Figure 6 , which shows a schematic diagram of the rendering result obtained based on the indirect light information of parallel light.
[0111] Similarly, multiplying the skylight intensity value obtained from the first lightmap with the current skylight color value corresponding to the current moment can restore the skylight indirect lighting effect corresponding to the current moment. Figure 7 , which shows a schematic diagram of the rendering results obtained based on the indirect light information of the skylight.
[0112] The intensity of the point light during the day, that is, the first intensity value, is used as a mask to calculate the switching logic of the point light during the day and at night. The direction of the point light is an indispensable part of describing the point light information, and is used to calculate the illumination range and highlight of the point light. Among them, the direction of the light during the day is mainly based on skylight, so the highlight simulation is mainly calculated based on the skylight shading direction in the second light map.
[0113] The intensity of the point light during the day can be used as a mask to calculate the logic of the point light switch during the day and at night. The lighting during the day is mainly based on skylight, so the highlight simulation is mainly calculated based on the skylight occlusion direction in the second light map. At night, the point light direction is mainly used, and the strongest comparison length is taken; skylight occlusion is used to improve the light leakage phenomenon indoors, such as the bottom of the eaves, corners, etc.
[0114] Finally, the calculated direct and indirect light parts of point light, sky light, and parallel light are added together to obtain the final lighting information. Rendering based on this lighting information can achieve the day and night change effect in the game scene.
[0115] For ease of use, the corresponding editing tools are provided. Users can set the parameters of the keyframes through the editing tools to restore the real-time lighting effects corresponding to the current moment. These parameters may include: overall brightness, overall contrast, skylight color, height fog density, height fog attenuation, etc. And based on the idea of splitting, debugging tools are provided. Users can split the final picture through the debugging tools to quickly locate the problem. Specifically, it can be split into pictures with only parallel light indirect light, split into pictures with only skylight direct light, etc.
[0116] As can be seen from the above, the embodiment of the present application bakes point light, parallel light, and sky light respectively to obtain first lighting information and second lighting information, and generates a lighting map based on the first lighting information and the second lighting information, so that the image can be rendered based on the lighting map later. The elements that change with time during the day and night change are separated and baked separately, so that it is convenient to perform real-time calculations based on the corresponding baking results to restore a more realistic day and night change effect. In addition, using the parallel light indirect light information of 3 hours, when rendering the picture, the accurate parallel light indirect light information corresponding to each hour can be obtained by interpolation, thereby improving the effect of day and night change and presenting a more realistic picture.
[0117] In order to better implement the above method, the embodiment of the present application also provides a light processing device, which can be integrated in an electronic device, and the electronic device can be a terminal, a server, etc. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.
[0118] For example, in this embodiment, the method of the embodiment of the present application is described in detail by taking the specific integration of the light processing device in the terminal as an example.
[0119] For example, Figure 8As shown, the lighting processing device 300 may include an acquisition module 310 , a point light baking module 320 , an indirect light baking module 330 and a generation module 340 .
[0120] An acquisition module 310 is used to acquire lighting data to be processed, wherein the lighting data includes point light data and indirect light data; a point light baking module 320 is used to bake the point light data to obtain first lighting information corresponding to the point light data, wherein the first lighting information includes a color value and an intensity value; an indirect light baking module 330 is used to bake the indirect light data to obtain second lighting information corresponding to the indirect light data, wherein the second lighting information includes an intensity value; a generation module 340 is used to generate a lighting map based on the first lighting information and the second lighting information.
[0121] In some embodiments, the indirect light data includes first indirect light data and second indirect light data, the first indirect light data is indirect light data of parallel light, the second indirect light data is indirect light data of sky light, and the indirect light baking module 330 includes a parallel light baking unit, a sky light baking unit, and a second determination unit:
[0122] A parallel light baking unit, configured to perform a baking process on the first indirect light data to obtain parallel light indirect light information corresponding to the first indirect light data;
[0123] A skylight baking unit, configured to perform baking processing on the second indirect light data to obtain skylight indirect light information corresponding to the second indirect light data;
[0124] The second determining unit is used to determine the parallel light indirect light information and the skylight indirect light information as the second illumination information.
[0125] In some embodiments, the first indirect light data includes first indirect light data in different directions, and the parallel light baking unit is further used to: bake the first indirect light data in each direction respectively to obtain a parallel light color value corresponding to the first indirect light data in each direction; convert each of the parallel light color values into a parallel light intensity value according to a preset conversion rule; and determine the parallel light intensity value corresponding to the first indirect light data in each direction as parallel light indirect light information.
[0126] In some embodiments, the skylight baking unit is also used to obtain second indirect light data; bake the second indirect light data to obtain skylight color values and skylight shading data corresponding to the second indirect light data, the skylight shading data including a skylight shading direction and a skylight shading intensity value; convert the skylight color value into a skylight intensity value according to a preset conversion rule; and determine the skylight intensity value, skylight shading direction and skylight shading intensity value as the skylight indirect light information.
[0127] In some embodiments, the point light data includes first point light data and second point light data, the first point light data represents point light during the day, and the second point light data represents point light at night, and the point light baking module 320 includes a first point light baking unit, a second point light baking unit, and a first determining unit:
[0128] A first point light baking unit, configured to perform baking processing on the first point light data to obtain a first color value and a first intensity value corresponding to the first point light data;
[0129] A second point light baking unit, used for baking the second point light data to obtain a second color value, a second intensity value and a point light direction corresponding to the second point light data;
[0130] The first determining unit is configured to determine the first color value, the first intensity value, the second color value, the second intensity value, and the point light direction as the first illumination information.
[0131] In some embodiments, the first illumination information includes a first color value, a first intensity value, a second color value, a second intensity value, and a point light direction, the second illumination information includes a parallel light intensity value, a sky light intensity value, a sky light shielding direction, and a sky light shielding intensity value, and the generation module 340 further includes a first mapping unit, a second mapping unit, and a generation unit:
[0132] A first mapping unit, configured to store the first color value, the first intensity value, the second color value, the second intensity value, the point light direction, the parallel light intensity value, and the sky light intensity value as a first light map;
[0133] A second mapping unit, used for storing the skylight shading direction and the skylight shading intensity value as a second light map;
[0134] A generating unit is configured to generate the light map according to the first light map and the second light map.
[0135] In some embodiments, the first mapping unit is also used to store the first color value and the first intensity value as a first color space; store the second color value and the second intensity value as a second color space; store the point light direction as a third color space; store the parallel light intensity value and the sky light intensity value as a fourth color space; and obtain the first light map according to the first color space, the second color space, the third color space and the fourth color space.
[0136] In some embodiments, the lighting processing device 300 also includes a rendering module. After generating a lighting map according to the first lighting information and the second lighting information, the rendering module is used to obtain a current parallel light color value and a current sky light color value; multiply the current parallel light color value by the parallel light intensity value to obtain parallel light indirect light information; multiply the current sky light color value by the sky light intensity value to obtain the sky light indirect light information; calculate the current lighting information based on the parallel light indirect light information, the sky light indirect light information, the first lighting information, the sky light shading direction and the sky light shading intensity value; and render the picture based on the current lighting information.
[0137] In specific implementation, the above modules or units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above modules or units can refer to the previous method embodiments, which will not be repeated here.
[0138] Therefore, the embodiment of the present application can bake the point light data and the indirect light data separately to obtain the first lighting information corresponding to the point light data and the second lighting information corresponding to the indirect light data, and generate a lighting map based on the first lighting information and the second lighting information, so that the image can be rendered based on the lighting map later. The point light data and the indirect light data are baked separately to separate and bake the elements that change with time in the day and night transformation, so as to facilitate the subsequent real-time calculation according to the corresponding baking results to restore a more realistic day and night transformation effect. In addition, in the embodiment of the present application, only the intensity value is retained after baking the indirect light data, which can reduce the memory occupied by the lighting map to reduce the configuration requirements of the device for the day and night effect.
[0139] Correspondingly, an embodiment of the present application also provides an electronic device, which may be a terminal or a server, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer, a personal digital assistant (PDA), or other terminal devices.
[0140] like Fig. 9 As shown, Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, wherein the electronic device 400 includes a processor 401 having one or more processing cores, a memory 402 having one or more computer-readable storage media, and a computer program stored in the memory 402 and executable on the processor. The processor 401 is electrically connected to the memory 402. It will be understood by those skilled in the art that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
[0141] The processor 401 is the control center of the electronic device 400. It uses various interfaces and lines to connect various parts of the entire electronic device 400, executes various functions of the electronic device 400 and processes data by running or loading software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, thereby monitoring the electronic device 400 as a whole.
[0142] In the embodiment of the present application, the processor 401 in the electronic device 400 will load instructions corresponding to the processes of one or more application programs into the memory 402 according to the following steps, and the processor 401 will run the application programs stored in the memory 402 to implement various functions:
[0143] Acquire illumination data to be processed, wherein the illumination data to be processed includes point light data and indirect light data;
[0144] Baking the point light data to obtain first lighting information corresponding to the point light data, wherein the first lighting information includes a color value and an intensity value;
[0145] performing baking processing on the indirect light data to obtain second lighting information corresponding to the indirect light data, wherein the second lighting information includes an intensity value;
[0146] A lighting map is generated according to the first lighting information and the second lighting information.
[0147] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0148] Optional, such as Fig. 9 As shown, the electronic device 400 further includes: a touch screen 403, a radio frequency circuit 404, an audio circuit 405, an input unit 406, and a power supply 407. The processor 401 is electrically connected to the touch screen 403, the radio frequency circuit 404, the audio circuit 405, the input unit 406, and the power supply 407, respectively. Those skilled in the art can understand that Fig. 9 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0149] The touch display screen 403 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 403 may include a display panel and a touch panel. Among them, the display panel may be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces may be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel may be used to collect the user's touch operation on or near it (such as the user using any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts, a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 401, and can receive the command sent by the processor 401 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 401 to determine the type of touch event, and then the processor 401 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 403 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 403 can also be used as a part of the input unit 406 to realize the input function.
[0150] In the embodiment of the present application, the processor 401 executes the game application to generate a graphical user interface on the touch screen 403, and the graphical user interface includes a virtual scene. The touch screen 403 is used to present the graphical user interface and receive operation instructions generated by the user acting on the graphical user interface.
[0151] The radio frequency circuit 404 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device or other electronic devices.
[0152] The audio circuit 405 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 405 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 405 and converted into audio data, and then the audio data is output to the processor 401 for processing, and then sent to another electronic device through the radio frequency circuit 404, or the audio data is output to the memory 402 for further processing. The audio circuit 405 may also include an earplug jack to provide communication between an external headset and an electronic device.
[0153] The input unit 406 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0154] The power supply 407 is used to supply power to various components of the electronic device 400. Optionally, the power supply 407 can be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 407 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0155] although Fig. 9 Not shown, the electronic device 400 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0156] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0157] As can be seen from the above, the electronic device provided in this embodiment can bake the point light data and the indirect light data separately, obtain the first lighting information corresponding to the point light data and the second lighting information corresponding to the indirect light data, and generate a lighting map based on the first lighting information and the second lighting information, so that the image can be rendered based on the lighting map later. The point light data and the indirect light data are baked separately to separate and bake the elements that change with time in the day and night transformation, so as to facilitate the subsequent real-time calculation according to the corresponding baking results to restore a more realistic day and night transformation effect. In addition, after baking the indirect light data, only the intensity value is retained, which can reduce the memory occupied by the lighting map, so as to reduce the configuration requirements of the device for the day and night effect.
[0158] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0159] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of computer programs are stored, and the computer program can be loaded by a processor to execute the steps in any one of the illumination processing methods provided in the embodiments of the present application. For example, the computer program can execute the following steps:
[0160] Acquire illumination data to be processed, wherein the illumination data to be processed includes point light data and indirect light data;
[0161] Baking the point light data to obtain first lighting information corresponding to the point light data, where the first lighting information includes a color value and an intensity value;
[0162] performing baking processing on the indirect light data to obtain second lighting information corresponding to the indirect light data, wherein the second lighting information includes an intensity value;
[0163] A lighting map is generated according to the first lighting information and the second lighting information.
[0164] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0165] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0166] Since the computer program stored in the storage medium can execute the steps in any one of the illumination processing methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the illumination processing methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0167] The above is a detailed introduction to a light processing method, device, storage medium and electronic device provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A light treatment method, It is characterized in that The method comprises: Acquire illumination data to be processed, wherein the illumination data to be processed includes point light data and indirect light data; Baking the point light data to obtain first lighting information corresponding to the point light data, wherein the first lighting information includes a color value and an intensity value; performing baking processing on the indirect light data to obtain second lighting information corresponding to the indirect light data, wherein the second lighting information includes an intensity value; generating a lighting map according to the first lighting information and the second lighting information; The first illumination information includes a first color value, a first intensity value, a second color value, a second intensity value, and a point light direction; the second illumination information includes a parallel light intensity value, a sky light intensity value, a sky light shielding direction, and a sky light shielding intensity value; the first color value and the first intensity value are illumination effects corresponding to the point light during the day; and the second color value and the second intensity value are illumination effects corresponding to the point light at night; The step of generating a lighting map according to the first lighting information and the second lighting information includes: storing the first color value, the first intensity value, the second color value, the second intensity value, the point light direction, the directional light intensity value, and the sky light intensity value as a first light map; Storing the skylight occlusion direction and the skylight occlusion intensity value as a second light map; The light map is generated based on the first light map and the second light map.
2. The method according to claim 1, It is characterized in that The indirect light data includes first indirect light data and second indirect light data, the first indirect light data is indirect light data of parallel light, and the second indirect light data is indirect light data of skylight; The baking process of the indirect light data to obtain second illumination information corresponding to the indirect light data includes: Performing baking processing on the first indirect light data to obtain parallel light indirect light information corresponding to the first indirect light data; performing baking processing on the second indirect light data to obtain skylight indirect light information corresponding to the second indirect light data; The parallel light indirect light information and the skylight indirect light information are determined as the second illumination information.
3. The method according to claim 2, It is characterized in that The first indirect light data includes first indirect light data in different directions; The baking process is performed on the first indirect light data to obtain parallel light indirect light information corresponding to the first indirect light data, including: The first indirect light data in each direction is baked respectively to obtain the parallel light color value corresponding to the first indirect light data in each direction; According to a preset conversion rule, each of the parallel light color values is converted into a parallel light intensity value; The parallel light intensity value corresponding to the first indirect light data in each direction is determined as the parallel light indirect light information.
4. The method according to claim 2, It is characterized in that The baking process is performed on the second indirect light data to obtain skylight indirect light information corresponding to the second indirect light data, including: The second indirect light data is baked to obtain a skylight color value and skylight shielding data corresponding to the second indirect light data, wherein the skylight shielding data includes a skylight shielding direction and a skylight shielding intensity value; According to a preset conversion rule, the skylight color value is converted into a skylight intensity value; The skylight intensity value, the skylight shielding direction, and the skylight shielding intensity value are determined as the skylight indirect light information.
5. The method according to claim 1, It is characterized in that The point light data includes first point light data and second point light data, the first point light data represents point light during the day, and the second point light data represents point light at night; The baking process of the point light data to obtain first illumination information corresponding to the point light data includes: Performing baking processing on the first point light data to obtain a first color value and a first intensity value corresponding to the first point light data; Performing baking processing on the second point light data to obtain a second color value, a second intensity value, and a point light direction corresponding to the second point light data; The first color value, the first intensity value, the second color value, the second intensity value, and the point light direction are determined as the first lighting information.
6. The method according to claim 1, It is characterized in that The storing the first color value, the first intensity value, the second color value, the second intensity value, the point light direction, the parallel light intensity value, and the sky light intensity value as a first light map includes: storing the first color value and the first intensity value as a first color space; storing the second color value and the second intensity value as a second color space; storing the point light direction as a third color space; storing the parallel light intensity value and the sky light intensity value as a fourth color space; The first light map is obtained according to the first color space, the second color space, the third color space and the fourth color space.
7. The method according to claim 1, It is characterized in that After generating a lighting map according to the first lighting information and the second lighting information, the method further includes: Get the current parallel light color value and the current sky light color value; Multiply the current parallel light color value by the parallel light intensity value to obtain the parallel light indirect light information; Multiplying the current skylight color value by the skylight intensity value to obtain the skylight indirect light information; Based on the parallel light indirect light information, the skylight indirect light information, the first light information, the skylight shielding direction and the skylight shielding intensity value, current light information is calculated; The image is rendered based on the current lighting information.
8. A light processing device, It is characterized in that The device comprises: An acquisition module, used for acquiring illumination data to be processed, wherein the illumination data includes point light data and indirect light data; a point light baking module, configured to bake the point light data to obtain first illumination information corresponding to the point light data, wherein the first illumination information includes a color value and an intensity value; an indirect light baking module, configured to bake the indirect light data to obtain second illumination information corresponding to the indirect light data, wherein the second illumination information includes an intensity value; A generating module, configured to generate a lighting map according to the first lighting information and the second lighting information; The first illumination information includes a first color value, a first intensity value, a second color value, a second intensity value and a point light direction; the second illumination information includes a parallel light intensity value, a sky light intensity value, a sky light shielding direction and a sky light shielding intensity value; the first color value and the first intensity value are illumination effects corresponding to the point light during the day; the second color value and the second intensity value are illumination effects corresponding to the point light at night; and the generation module includes a first mapping unit, a second mapping unit and a generation unit: The first mapping unit is used to store the first color value, the first intensity value, the second color value, the second intensity value, the point light direction, the parallel light intensity value and the sky light intensity value as a first light map; The second mapping unit is used to store the skylight shading direction and the skylight shading intensity value as a second light map; The generating unit is configured to generate the light map according to the first light map and the second light map.
9. An electronic device, It is characterized in that The invention comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the illumination processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the illumination processing method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Rendering method and rendering device
CN109603156A
Light and shadow data processing method and device for game and game equipment
CN111489430A
Generation method and device of reflection illumination data in game and computer equipment
CN112215938A