Method, device, storage medium and electronic device for processing illumination data
The virtual light source is used to simulate and adjust the lighting of the target model, which solves the problem of low lighting data processing efficiency in the existing technology, achieves a more efficient lighting fill-in effect, and reduces the situation of dead darkness in dark parts.
Patent Information
- Application Number
- CN202111040489.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-06
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2041-09-06
AI Technical Summary
The efficiency of lighting data processing in the prior art leads to problems such as dark darkness in the model or scene lighting, and users need to continuously debug and find it difficult to master the effect.
By obtaining the position of the target model, determine the position of the virtual light source, perform lighting simulation on the target model based on the virtual light source, obtain the simulation results, and adjust the light map according to the simulation results to obtain the target lighting data.
It realizes filling the target model with virtual light sources, reducing the blackness of dark parts, improving the efficiency of lighting data processing, and allowing users to adjust lighting effects more easily.
Smart Images

Figure CN113836705B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method, device, storage medium and electronic device for processing illumination data. Background Art
[0002] Currently, in the lighting data processing, the model can be baked for lighting, which may include the method of generating a lightmap. However, this usually requires the user to have strong lighting experience to adjust the lightmap appropriately, and inexperienced users usually cause the dark part of the model to be dead black when generating the lightmap, or even if the scene has been illuminated with a lot of light, the model still has problems such as not being bright.
[0003] Therefore, since it is difficult to master the processing effect of the illumination data, users are often required to continuously debug, resulting in a technical problem of low efficiency in processing the illumination data.
[0004] With respect to the technical problem of low efficiency in processing illumination data in the prior art, no effective solution has been proposed yet. Summary of the invention
[0005] The main purpose of the present invention is to provide a method, device, storage medium and electronic device for processing illumination data, so as to at least solve the technical problem of low efficiency in processing illumination data.
[0006] In order to achieve the above-mentioned object, according to one aspect of the present invention, a method for processing illumination data is provided. The method may include: obtaining a first position of a target model to be processed; determining a second position of a virtual light source based on the first position; simulating illumination of the target model based on the virtual light source at the second position to obtain a simulation result; adjusting the illumination map of the target model based on the simulation result to obtain target illumination data of the target model.
[0007] Optionally, simulating the illumination of the target model based on the virtual light source to obtain a simulation result includes: determining a grayscale image based on the target model and the virtual light source; coloring the grayscale image to obtain a color image; and determining the color image as the simulation result.
[0008] Optionally, the target model includes multiple vertices, and a grayscale image is determined based on the target model and the virtual light source, including: determining a first distance based on the second position of the virtual light source and the position of each vertex to obtain multiple first distances, wherein the multiple first distances correspond one-to-one to the multiple vertices; and representing the multiple first distances as a grayscale image.
[0009] Optionally, the method further includes: acquiring a radius of the virtual light source; and determining a first distance based on a second position of the virtual light source and a position of each vertex, including: determining the first distance based on the second position, the position of each vertex and the radius.
[0010] Optionally, the grayscale image is colorized to obtain a color image, including: converting the first distance into a second distance and a third distance based on a first parameter; determining a first color based on the second distance, and determining a second color based on the third distance; and determining a color image based on the first color and the second color, wherein the first color is the color of a first area of the color image, and the second color is the color of a second area of the color image.
[0011] Optionally, the method further includes: adjusting the color intensity of the color image from the first color intensity to the second color intensity; and determining the color image as the simulation result, including: determining the color image of the second color intensity as the simulation result.
[0012] Optionally, the method also includes: obtaining an original color map of the target model; adjusting the light map of the target model based on the simulation results to obtain target lighting data of the target model, including: adjusting the original color map based on the simulation results to obtain an adjustment result; superimposing the adjustment result and the light map to obtain the target lighting data.
[0013] Optionally, adjusting the original color map based on the simulation result to obtain the adjustment result includes: adjusting the original color map based on the second parameter and the simulation result to obtain the adjustment result.
[0014] Optionally, the adjustment result and the light map are superimposed to obtain target lighting data, including: obtaining the product of a third parameter, the adjustment result, the first channel data of the light map, and the second channel data of the light map; and determining the product as color data in the target lighting data.
[0015] Optionally, obtaining the first position of the target model to be processed includes: obtaining the axis position of the target model; and determining the axis position as the first position.
[0016] Optionally, determining the second position of the virtual light source based on the first position includes: acquiring a target offset, and determining the second position based on the first position and the target offset.
[0017] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a device for processing illumination data is also provided. The device may include: an acquisition unit, used to acquire a first position of a target model to be processed; a determination unit, used to determine a second position of a virtual light source based on the first position; a simulation unit, used to simulate illumination of the target model based on the virtual light source at the second position to obtain a simulation result; and an adjustment unit, used to adjust the illumination map of the target model based on the simulation result to obtain target illumination data of the target model.
[0018] In order to achieve the above object, according to another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the method for processing illumination data of an embodiment of the present invention.
[0019] To achieve the above object, according to another aspect of the present invention, an electronic device is provided, which includes a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the data processing method of the embodiment of the present invention.
[0020] In this embodiment, the first position of the target model to be processed is obtained; the second position of the virtual light source is determined based on the first position; at the second position, the illumination of the target model is simulated based on the virtual light source to obtain a simulation result; the illumination map of the target model is adjusted based on the simulation result to obtain the target illumination data of the target model. In other words, this embodiment sets a virtual light source in combination with the position of the target model, uses the virtual light source to simulate the illumination result of the target model, and then adjusts the illumination map of the target model to obtain the illumination data of the target model, thereby achieving the effect of filling light (brightening) the target model through the virtual light source, reducing the situation where the dark part of the target model appears dead black, thereby solving the technical problem of low efficiency in processing illumination data, and thus achieving the technical effect of improving the processing efficiency of illumination data. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings constituting a part of this application are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0022] Figure 1 It is a hardware structure block diagram of a mobile terminal of a method for processing illumination data according to an embodiment of the present invention;
[0023] Figure 2 is a flow chart of a method for processing illumination data according to an embodiment of the present invention;
[0024] Figure 3 It is a schematic diagram of baking a lighting scene according to the related art;
[0025] Figure 4 It is a schematic diagram of only direct illumination according to the related art;
[0026] Figure 5 It is a schematic diagram of direct illumination and indirect illumination according to the related art;
[0027] Figure 6 It is a schematic diagram of an effect before baking and an effect after baking according to a related art;
[0028] Figure 7 is a comparative schematic diagram of illumination data processing according to an embodiment of the present invention;
[0029] Figure 8 is a comparative schematic diagram of another illumination data processing according to an embodiment of the present invention;
[0030] Fig. 9 is a schematic diagram of a result of processing illumination data according to an embodiment of the present invention;
[0031] Fig.10 is a schematic diagram of a gray graph according to an embodiment of the present invention;
[0032] Fig.11 is a schematic diagram of another gray graph according to an embodiment of the present invention;
[0033] Fig.12 is a schematic diagram of converting a gray image into a color image according to an embodiment of the present invention;
[0034] Fig.13 is a schematic diagram of comparison between a gray image and a color image according to an embodiment of the present invention;
[0035] Fig.14 is a comparative schematic diagram of another illumination data processing according to an embodiment of the present invention;
[0036] Fig.15 is a schematic diagram of a device for processing illumination data according to an embodiment of the present invention. DETAILED DESCRIPTION
[0037] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0038] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings 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 ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0040] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a method for processing illumination data according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0041] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as a computer program corresponding to a method for data processing in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0042] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0043] In this embodiment, a method for processing illumination data running on the mobile terminal is provided. Figure 2 FIG. 1 is a flow chart of a method for processing illumination data according to an embodiment of the present invention. Figure 2 As shown, the method may include the following steps:
[0044] Step S202, obtaining the first position of the target model to be processed.
[0045] In the technical solution provided in the above step S202 of the present invention, the target model to be processed may be a scene model, for example, a scene model in a game scene, which may include but is not limited to a landscape model. This embodiment may determine the first position of the target model. Optionally, this embodiment obtains the pivot position of the target model, which may be represented by frag.pivot, and then determines the pivot position as the first position.
[0046] Step S204: determining a second position of the virtual light source based on the first position.
[0047] In the technical solution provided in the above step S204 of the present invention, after the first position of the target model to be processed is acquired, the second position of the virtual light source can be determined based on the first position.
[0048] In this embodiment, a virtual light source can be added to the renderer (shader). The virtual light source can be a fake point light source, which can be called a simulated point light source or a simulated light source, and is used to simulate the fill light effect of the target model. Optionally, based on the first position, the embodiment can determine the second position of the virtual light source according to the parameters related to the position. The second position can be the position of the center point of the virtual light source, which can be represented by (x0, y0, z0). Optionally, the above-mentioned parameters related to the position can be manually input by the user, so as to achieve the purpose of manually and flexibly adjusting the target model by the user.
[0049] Optionally, this embodiment can obtain a target offset, which is an adjustable parameter and can be represented by pivotoffest. The second position can be determined based on the first position and the target offset. For example, the first position is offset by the target offset to obtain the second position of the virtual light source. The second position of the virtual light source can be calculated as follows: first position + target offset. Thus, the second position can be represented by new_pivot = frag.pivot + pivotoffest.
[0050] Step S206: Simulate the illumination of the target model based on the virtual light source at the second position to obtain a simulation result.
[0051] In the technical solution provided in the above step S206 of the present invention, after the second position of the virtual light source is determined based on the first position, the lighting of the target model can be simulated based on the virtual light source at the second position to obtain a simulation result.
[0052] In this embodiment, at the second position, the virtual light source can be adjusted, and the illumination of the target model can be simulated based on the second position of the virtual light source, the radius of the virtual light source (Rx, Ry, Rz), etc., to obtain a simulation result, which can be represented by color, so that the simulation result is also the result of the simulated illumination. Optionally, the radius of the virtual light source can be manually input by the user and is an adjustable parameter, so that the range of the virtual light source can be adjusted by adjusting the radius of the virtual light source.
[0053] Step S208, adjusting the light map of the target model based on the simulation result to obtain target lighting data of the target model.
[0054] In the technical solution provided in the above step S208 of the present invention, after simulating the illumination of the target model based on the virtual light source and obtaining the simulation result, the illumination map of the target model can be adjusted based on the simulation result to obtain the target illumination data of the target model.
[0055] In this embodiment, the light map of the target model is a map generated by baking the target model, which can be implemented by a target engine, wherein the target engine can be a game engine. The light map can include color channel (RGB) data and gray channel (Alpha) data, and the simulation result can be superimposed and calculated with the color channel data and gray channel data of the light map to obtain the target lighting data of the target model, which can be the local lighting data of the target model, including the final color data.
[0056] Optionally, the light map of the target model in this embodiment is a map generated after the target model is subjected to scene baking lighting, which records the texture of the scene lighting data of the target model and can be used to increase the lighting atmosphere and artistic effects of the scene. Among them, the light map is essentially one or more maps applied to the target model, which contains indirect lighting, shadow and other information obtained by pre-calculation through light map baking (you can choose to only bake indirect lighting and not shadows during baking). The use of light maps in this embodiment can avoid real-time lighting and shadow calculations when the game is running, thereby improving the running performance of the game, and it can be suitable for use on computing platforms with weaker performance, such as mobile platforms.
[0057] The above method of this embodiment is applied in scene baking, which can be light scene baking, which is a processing method in the game scene, which can be used to simulate the lighting environment and generate light maps, thereby reducing the use of dynamic lighting in the game, thereby reducing a large amount of lighting calculations. Optionally, in game applications, the lighting of the light map and the dynamic direct lighting will work simultaneously.
[0058] Through the above steps S202 to S208 of the present application, the first position of the target model to be processed is obtained; the second position of the virtual light source is determined based on the first position; at the second position, the illumination of the target model is simulated based on the virtual light source to obtain a simulation result; the illumination map of the target model is adjusted based on the simulation result to obtain the target illumination data of the target model. In other words, this embodiment sets a virtual light source in combination with the position of the target model, uses the virtual light source to simulate the illumination result of the target model, and then adjusts the illumination map of the target model to obtain the illumination data of the target model, thereby achieving the effect of filling light (brightening) the target model with the virtual light source, reducing the situation where the dark part of the target model appears dead black, solving the technical problem of low efficiency in processing illumination data, and achieving the technical effect of improving the processing efficiency of illumination data.
[0059] The above method of this embodiment is further described below.
[0060] As an optional implementation, step S206, simulating the illumination of the target model based on the virtual light source to obtain a simulation result, includes: determining a grayscale image based on the target model and the virtual light source; coloring the grayscale image to obtain a color image; and determining the color image as the simulation result.
[0061] In this embodiment, when simulating the illumination of the target model based on the virtual light source to obtain the simulation result, a grayscale image may be first determined based on the target model and the virtual light source, and the grayscale image is also a gray image, and its grayscale value may change uniformly. After the grayscale image is determined, the grayscale image may be colorized to convert the grayscale image into a color image, that is, this embodiment converts the gray image obtained based on the target model and the virtual light source into a color image, and then determines the simulation result of simulating the target model based on the grayscale image.
[0062] As an optional implementation, the target model includes multiple vertices, and a grayscale image is determined based on the target model and the virtual light source, including: determining a first distance based on the second position of the virtual light source and the position of each vertex to obtain multiple first distances, wherein the multiple first distances correspond one-to-one to the multiple vertices; and representing the multiple first distances as a grayscale image.
[0063] In this embodiment, the target model includes multiple vertices, the position of each vertex can be determined, and then the first distance can be determined based on the second position of the virtual light source and the position of each vertex (x1, y1, z1). The first distance can be the position of the above-mentioned virtual light source to each vertex, thereby obtaining multiple first distances corresponding to multiple vertices one by one, and then representing the multiple first distances as a grayscale image, that is, the grayscale image of this embodiment can represent the above-mentioned multiple first distances.
[0064] As an optional implementation, the method further includes: obtaining the radius of the virtual light source; determining the first distance based on the second position of the virtual light source and the position of each vertex, including: determining the first distance based on the second position, the position of each vertex and the radius.
[0065] In this embodiment, the radius of the virtual light source can be obtained in response to the first operation instruction acting on the graphical user interface, that is, the parameter input by the user may include the radius of the virtual light source, which can be used to adjust the range of the virtual light source. Then, this embodiment can determine the first distance based on the second position (x0, y0, z0) of the virtual light source, the position of each vertex (x1, y1, z1) and the radius (Rx, Ry, Rz) of the virtual light source. The first distance can be represented by a0. Optionally, Thus, a grayscale image is generated through the first distance a0 corresponding to each vertex of the target model.
[0066] As an optional implementation, a grayscale image is colorized to obtain a color image, including: converting a first distance into a second distance and a third distance based on a first parameter; determining a first color based on the second distance, and determining a second color based on the third distance; and determining a color image based on the first color and the second color, wherein the first color is the color of a first area of the color image, and the second color is the color of a second area of the color image.
[0067] In this embodiment, when the grayscale image is colorized to obtain a color image, a first parameter may be obtained first, and the first parameter may be a parameter for controlling the distance, which may be represented by Mid. This embodiment may convert the first distance into a second distance based on the first parameter. For example, if the first distance is a0 and the second distance is a1, then a1=saturate(a0 / Mid). The second distance corresponds to the first area A1 of the color image and may be used to determine the first color of the first area of the color image. Optionally, the first color may be determined based on an interpolation function (lerp) and a1. The first color color=lerp(Color1.rgb*ColorIntensity.x, Color2.rgb*ColorIntensity.y, a1), wherein Color1.rgb and Color2.rgb are color parameters for determining the first color, and ColorIntensity.x and ColorIntensity.y are color intensities for determining the first color. The first color may include red and green. Optionally, the embodiment further converts the first distance into a third distance based on the first parameter. For example, the third distance is a2, then a2=saturate((a0-Mid) / (1.0-Mid)). The third distance may correspond to the second area A2 of the color image, and may be used to determine the second color of the second area of the color image. The second color may be determined based on the interpolation function (lerp) and a2. The second color color=lerp(Color.rgb, Color3.rgb*ColorIntensity.z, a2), wherein Color.rgb and Color3.rgb are color parameters for determining the second color, and ColorIntensity.z is a color intensity for determining the second color. The second color may include blue. Further, the embodiment may determine the color image based on the first color and the second color. The first area may be dyed with the first color first, and then the second area may be dyed with the second color to obtain a color image. The color image may be a three-color image (red, green, and blue image), with red at the center, green in the middle, and blue at the periphery.
[0068] Optionally, the first area and the second area of the embodiment are adjacent areas in the color image, wherein the second area may surround the first area, that is, the distance between the point in the first area and the center of the color image may be smaller than the distance between the point in the second area and the center of the color image. For example, the color image may be a circular (or approximately circular) color image, then the first area may be the inner circle of the color image, and the second area may be the outer circle of the color image, and then the color of the inner circle is determined by the second distance a1=saturate(a0 / Mid) corresponding to the inner circle, and the color of the outer circle is determined by the third distance a2=saturate((a0-Mid) / (1.0-Mid)) corresponding to the outer circle, thereby achieving the purpose of determining a circular (or approximately circular) color image.
[0069] It should be noted that the above-mentioned color image of this embodiment is obtained based on the coloring processing of the grayscale image determined by the target model and the virtual light source, and is used to represent the simulation result of simulating the lighting of the target model. The shape of the color image is a circle (or an approximate circle) is only an example of an embodiment of the present invention, and is not limited to the shape of the color image of the embodiment of the present invention being only the above-mentioned circle (or an approximate circle). It can also be other shapes, such as triangles, rectangles, squares or other shapes that can constitute an area, etc. Any shape of the color image that can be used to represent the simulation result of simulating the lighting of the target model is within the scope of this embodiment and is not specifically limited here.
[0070] As an optional implementation, the method further includes: adjusting the color intensity of the color image from the first color intensity to the second color intensity; determining the color image as a simulation result, including: determining the color image of the second color intensity as the simulation result.
[0071] In this embodiment, after the color image is determined based on the first color and the second color, the color intensity (ColorIntensity) of the color image can be adjusted, and the color intensity of the color image can be adjusted from the original first color intensity to the second color intensity. Optionally, this embodiment multiplies the color data of the color image by a coefficient to achieve the purpose of adjusting the color intensity. For example, the color data of the color image is (0.5, 0, 0), and the coefficient is 2. The color intensity can be adjusted based on the color data (0.5, 0, 0) of the color image. When it is multiplied by the coefficient 2, it becomes color data (1, 0, 0), and the value can even exceed 1. After the color intensity of the color image is adjusted from the first color intensity to the second color intensity, the color image of the second color intensity can be determined as a simulation result.
[0072] As an optional implementation, the method also includes: obtaining the original color map of the target model; adjusting the light map of the target model based on the simulation results to obtain target lighting data of the target model, including: adjusting the original color map based on the simulation results to obtain an adjustment result; superimposing the adjustment result and the light map to obtain the target lighting data.
[0073] In this embodiment, the original color map of the target model is obtained. The original color map can be called a basic color map (Diffuse map, which refers to the color map of the target model before baking and can be represented by Raw_data.tex0.rgb. This embodiment adds an algorithm of a virtual light source to the original color map, and can adjust the original color map based on the simulation result. For example, the adjustment result, the color channel data in the light map, and the gray channel data are superimposed to obtain the above-mentioned target lighting data.
[0074] As an optional implementation, adjusting the original color map based on the simulation result to obtain the adjustment result includes: adjusting the original color map based on the second parameter and the simulation result to obtain the adjustment result.
[0075] In this embodiment, a second parameter can be obtained in response to a second operation instruction on the graphical user interface, that is, the parameter input by the user can include a second parameter, which is an adjustable coloring parameter, which can be used to adjust the color of the virtual light source and can be represented by BaseColor. This embodiment can adjust the original color map Raw_data.tex0.rgb based on the second parameter BaseColor.rgb and the simulation result color to obtain an adjustment result, for example, the adjustment result mtl.albedo=srgb2linearf3(Raw_data.tex0.rgb*BaseColor.rgb)*color.
[0076] As an optional implementation, the adjustment result and the light map are superimposed to obtain target lighting data, including: obtaining the product of a third parameter, the adjustment result, the first channel data of the light map, and the second channel data of the light map; and determining the product as color data in the target lighting data.
[0077] In this embodiment, when superimposing the adjustment result and the light map to obtain the target lighting data, a third parameter can be obtained, and the third parameter can be 0.2. The first channel data and the second channel data of the light map can also be obtained, wherein the first channel number can be color channel data (RGB), and the second channel data can be grayscale channel data (Alpha). The product of the third parameter, the adjustment result, the first channel data of the light map, and the second channel data of the light map can be obtained. For example, 0.2*adjustment result*RGB of the light map*Alpha of the light map is the final color data in the target lighting data.
[0078] This embodiment makes some optimizations to the baked shader, by adjusting the second position of the virtual light source according to the input target offset, determining the range of the virtual light source by the input radius, determining the color of the virtual light source by the adjustable tinting parameters, and adding the above-mentioned virtual light source algorithm to the original color map of the target model, thereby achieving the effect of filling light (brightening) the target model with the virtual light source by manually inputting parameters. Even inexperienced art students can make the final effect look better and more controllable through adjustments, reducing the situation where dark parts of the target model appear dead black, solving the technical problem of low efficiency in processing lighting data, and achieving the technical effect of improving the processing efficiency of lighting data.
[0079] The technical solution of the embodiment of the present invention is further introduced below by way of examples in conjunction with preferred implementation modes, specifically by way of examples of game scenarios in game applications.
[0080] Lighting scene baking is a technique in game scenes, such as Figure 3 As shown. Among them, Figure 3 It is a schematic diagram of a lighting scene baking according to the related technology, which can simulate the lighting environment and generate a light map. The light map can be a collection of multiple light maps, thereby reducing the use of dynamic lighting in the game and greatly reducing lighting calculations.
[0081] Figure 4 It is a schematic diagram of only direct lighting according to the related art. Figure 5 FIG. 1 is a schematic diagram of direct illumination and indirect illumination according to the related art. Figure 4 and Figure 5 As shown, the lighting range of direct and indirect lighting is larger than the range of direct light alone. In the game, the lighting baked by lightmap will work at the same time as the dynamic direct lighting.
[0082] Light baking usually requires users to have strong lighting experience to adjust it well. Inexperienced users may cause the model to appear dark in the dark areas when baking, or the scene may not be bright even if a lot of light is added.
[0083] In the related art, there are some differences between the effect before baking and the effect after baking, such as Figure 6 As shown. Among them, Figure 6 It is a schematic diagram of the effect before and after baking according to the related technology. The scene model is a room scene model. The lighting, shadow and other information of the room scene model have different effects before and after baking. It is difficult to grasp the actual baking effect, and continuous baking debugging is often required. It is not very friendly to inexperienced users.
[0084] In order to improve the user's work efficiency, this embodiment optimizes the baked shader. By adding a virtual light source in the shader to simulate the effect of fill light for the model, a manual local brightening function is added. The model is fine-tuned while the lighting arrangement of the baked light map remains unchanged, which can effectively reduce the problem of dark areas in the dark parts and bright areas in the bright parts of the model.
[0085] Figure 7 FIG. 1 is a comparative schematic diagram of illumination data processing according to an embodiment of the present invention. Figure 7 The following are the models before processing, the model with added manual fill light parameters, and the model after adding dark area adjustment.
[0086] Lightmaps are essentially one or more textures applied to the scene model. They contain indirect lighting, shadows and other information obtained by pre-calculating lightmap baking (you can choose to bake only indirect lighting and not shadows when baking). Using lightmaps can avoid real-time lighting and shadow calculations when the game is running, improve the game's running performance, and can be applied to computing platforms with weaker performance, such as mobile platforms.
[0087] Figure 8 FIG. 2 is a comparative schematic diagram of another illumination data processing according to an embodiment of the present invention. Figure 8 As shown in the figure, by adding a virtual light source in the shader to simulate the fill light effect of the target model to be processed, the function of local brightening is realized; by fine-tuning the target model while keeping the light arrangement of the light map of the baked target model unchanged, the problem of dead black in dark areas and brightening in bright areas can be greatly reduced.
[0088] The above method of this embodiment is further introduced below.
[0089] This embodiment can add an algorithm for simulating point light sources to the basic color map (Diiffuse map) of the target model according to the input parameters, and can adjust the position, color and range of the virtual light source to achieve the purpose of processing the illumination data of the target model. For example, a ball can be made red in the center, green in the middle, and blue in the periphery. Fig. 9 As shown. Among them, Fig. 9 is a schematic diagram of a result of processing illumination data according to an embodiment of the present invention.
[0090] This embodiment can determine the position of the virtual light source by performing an offset according to the pivot axis position frag.pivo of the target model according to the offset pivotoffest, wherein the offset is an adjustable parameter, for example, the position of the virtual light source can be new_pivot=frag.pivot+pivotoffest.
[0091] This embodiment calculates the distance from each vertex on the target model to the virtual light source. Optionally, the vertex position of the target model is (x1, y1, z1), the position of the center point of the virtual light source is (x0, y0, z0), and the radius of the virtual light source is (Rx, Ry, Rz). Then, the distance a0 from each vertex on the target model to the virtual light source can be expressed as follows:
[0092]
[0093] This embodiment can represent the distance from each vertex to the virtual light source as a gray graph, such as Fig.10 As shown, Fig.10 It is a schematic diagram of a gray graph according to an embodiment of the present invention, and the result of a0 changes uniformly.
[0094] This embodiment can color the gray image according to the result of the previous step, a1 = saturate (a0 / Mid), a2 = saturate ((a0-Mid) / (1.0-Mid)), where Mid is a parameter for controlling the distance, A1 is the inner circle, and A2 is the outer circle. After coloring A1 through color = lerp (Color1.rgb*ColorIntensity.x, Color2.rgb*ColorIntensity.y, a1), and then coloring A2 through color = lerp (Color.rgb, Color3.rgb*ColorIntensity.z, a2), a three-color image can be obtained, as shown in FIG. Fig.11 As shown, Fig.11 is a schematic diagram of another gray graph according to an embodiment of the present invention, which includes an inner circle A1 and an outer circle A2.
[0095] This embodiment can be colored according to the gray image in the previous step, and the gray image can be turned into a colored image, such as Fig.12 As shown, Fig.12 This is a schematic diagram of converting a gray image into a color image according to an embodiment of the present invention. This embodiment can adjust the intensity of the color. For example, the color (0.5, 0, 0) can adjust the intensity. Multiplying it by 2 can obtain the color (1, 0, 0), and even the value exceeds 1.
[0096] Fig.13 FIG. 1 is a schematic diagram of a comparison between a gray image and a color image according to an embodiment of the present invention. Fig.13 As shown, a color image can be a three-color image, whereby the inner side can be red, the outer side can be green, and the inner side can be blue.
[0097] Optionally, mtl.albedo = srgb2linearf3 (Raw_data.tex0.rgb*BaseColor.rgb)*color, where Raw_data.tex0.rgb is used to represent the base color map, BaseColor is an adjustable tinting parameter that can be used to adjust the color of the virtual light source, and color is the result of the simulated illumination calculated above (a color image).
[0098] This embodiment can superimpose the above calculation result mtl.albedo and lightmap to obtain the final color = 0.2*the above calculation result*rgb of lightmap*alpha of lightmap, wherein lightmap refers to the map generated after the scene is baked for lighting, which can be provided by the game engine.
[0099] Fig.14 FIG. 2 is a comparative schematic diagram of another illumination data processing according to an embodiment of the present invention. Fig.14 As shown, through the above method, even inexperienced art students can make the final effect of the target model look better and more controllable by adjustment, and can manually adjust the local lighting after baking; this embodiment can also manually add fill light, and make fine adjustments while the lighting arrangement of the baked light map remains unchanged, thereby achieving the purpose of adjusting the dark part.
[0100] This embodiment makes some optimizations to the baked shader, by adjusting the position of the virtual light source according to the input offset, determining the range of the virtual light source by the input radius, determining the color of the virtual light source by the adjustable tinting parameters, and adding the above-mentioned virtual light source algorithm to the original color map of the target model, so as to achieve the effect of filling light (brightening) for the target model by the virtual light source through manual input parameters. Even inexperienced art students can make the final effect look better and more controllable through adjustments, reduce the situation of dark parts of the target model, solve the technical problem of low efficiency in processing lighting data, and achieve the technical effect of improving the processing efficiency of lighting data.
[0101] The embodiment of the present invention further provides a device for processing illumination data. It should be noted that the device of this embodiment can be used to execute the embodiment of the present invention. Figure 2 The method for processing lighting data shown.
[0102] Fig.15 FIG. 1 is a schematic diagram of a device for processing illumination data according to an embodiment of the present invention. Fig.15 As shown, the illumination data processing device 150 includes: an acquisition unit 151 , a determination unit 152 , a simulation unit 153 and an adjustment unit 154 .
[0103] The acquisition unit 151 is used to acquire a first position of the target model to be processed.
[0104] The determining unit 152 is configured to determine a second position of the virtual light source based on the first position.
[0105] The simulation unit 153 is used to simulate the illumination of the target model based on the virtual light source at the second position to obtain a simulation result.
[0106] The adjustment unit 154 is used to adjust the light map of the target model based on the simulation result to obtain the target light data of the target model.
[0107] In this embodiment, a virtual light source is set in combination with the position of the target model, and the virtual light source is used to simulate the lighting result of the target model, and then the lighting map of the target model is adjusted to obtain the lighting data of the target model, thereby achieving the effect of supplementary lighting (brightening) the target model through the virtual light source, reducing the dark areas of the target model, solving the technical problem of low efficiency in processing lighting data, and achieving the technical effect of improving the processing efficiency of lighting data.
[0108] An embodiment of the present invention further provides a computer-readable storage medium in which a computer program is stored, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the method for processing illumination data of an embodiment of the present invention.
[0109] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0110] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0111] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0112] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0113] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for processing illumination data, characterized in that: include: Get the first position of the target model to be processed; determining a second position of the virtual light source based on the first position; At the second position, simulating illumination of the target model based on the virtual light source to obtain a simulation result; Adjusting the light map of the target model based on the simulation result to obtain target light data of the target model; Among them, adjusting the light map of the target model based on the simulation result to obtain the target lighting data of the target model includes: superimposing the simulation result and the light map to obtain the target lighting data, wherein the light map includes color channel data and grayscale channel data.
2. The method according to claim 1, characterized in that: The illumination of the target model is simulated based on the virtual light source to obtain a simulation result, including: determining a grayscale image based on the target model and the virtual light source; Coloring the grayscale image to obtain a color image; The color image is determined as the simulation result.
3. The method according to claim 2, characterized in that The target model includes a plurality of vertices, and determining a grayscale image based on the target model and the virtual light source includes: Determine a first distance based on the second position of the virtual light source and the position of each of the vertices to obtain a plurality of first distances, wherein the plurality of first distances correspond one-to-one to the plurality of vertices; The plurality of first distances are represented as the grayscale image.
4. The method according to claim 3, characterized in that The method further comprises: obtaining a radius of the virtual light source; Determining the first distance based on the second position of the virtual light source and the position of each of the vertices includes: determining the first distance based on the second position, the position of each of the vertices and the radius.
5. The method according to claim 4, characterized in that Coloring the grayscale image to obtain a color image includes: converting the first distance into a second distance and a third distance based on a first parameter; determining a first color based on the second distance, and determining a second color based on the third distance; The color image is determined based on the first color and the second color, wherein the first color is a color of a first area of the color image, and the second color is a color of a second area of the color image.
6. The method according to claim 2, characterized in that The method further includes: adjusting the color intensity of the color image from a first color intensity to a second color intensity; Determining the color image as the simulation result includes: determining the color image of the second color intensity as the simulation result.
7. The method according to claim 1, characterized in that The method further comprises: obtaining an original color map of the target model; The simulation result is superimposed on the light map to obtain the target light data, including: The original color map is adjusted based on the simulation result to obtain an adjustment result; and the adjustment result and the light map are superimposed to obtain the target light data.
8. The method according to claim 7, characterized in that The original color map is adjusted based on the simulation result to obtain an adjustment result, including: The original color map is adjusted based on the second parameter and the simulation result to obtain the adjustment result.
9. The method according to claim 7, characterized in that: The adjustment result and the light map are superimposed to obtain the target light data, including: Obtaining a product of a third parameter, the adjustment result, first channel data of the light map, and second channel data of the light map, wherein the first channel data is the color channel data, and the second channel data is the grayscale channel data; The product is determined as color data in the target illumination data.
10. The method according to any one of claims 1 to 9, characterized in that Get the first position of the target model to be processed, including: Obtaining the axis position of the target model; The axis position is determined as the first position.
11. The method according to any one of claims 1 to 9, characterized in that Determining a second position of the virtual light source based on the first position includes: A target offset is obtained, and the second position is determined based on the first position and the target offset.
12. A device for processing illumination data, characterized in that: include: An acquisition unit, used for acquiring a first position of a target model to be processed; a determining unit, configured to determine a second position of the virtual light source based on the first position; a simulation unit, configured to simulate illumination of the target model at the second position based on the virtual light source to obtain a simulation result; An adjustment unit, configured to adjust the light map of the target model based on the simulation result to obtain target light data of the target model; The adjustment unit is further used for: superimposing the simulation result and the light map to obtain the target lighting data, wherein the light map includes color channel data and grayscale channel data.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the method described in any one of claims 1 to 11.
14. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the computer program to perform the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Shadow map generation method and device
CN111724313A
Crystal stone model rendering method and device, electronic equipment and storage medium
CN111899325A