Lighting rendering method, device, computer equipment and storage medium for multi-point light sources
By interpolation and color accumulation according to the attenuation coefficients of reflection and dyed point light sources in multi-point light source lighting rendering, the problem of overexposure and color chaos in multi-point light source lighting rendering is solved, and a more realistic light receiving effect is achieved.
Patent Information
- Application Number
- CN202111583893.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2041-12-22
AI Technical Summary
The prior art can easily lead to overexposure and color confusion of the model when rendering light from multiple points light sources, resulting in a single light receiving effect and not realistic enough.
By determining the pixel to be rendered and the multiple target point light sources covering it in the scene to be rendered, interpolation is performed according to the attenuation coefficients of the reflection and dyed point light sources, and color accumulation is performed to obtain the final rendered color.
It effectively avoids overexposure and color confusion of the model, improves the richness of the light-receiving effect of the model, and makes the picture more realistic.
Smart Images

Figure CN114241115B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, computer equipment and storage medium for rendering illumination of multiple light sources. Background Art
[0002] In recent years, image processing technology has been developing continuously, and both users and developers have higher and higher requirements for image quality. In many large models, there are thousands or even tens of thousands of point light sources, and each point light source has a different degree of influence on each small model in the large model. Therefore, in order to improve the quality of computer animation and enhance its realism, multi-point light source lighting rendering has become a key point in image processing.
[0003] In the related technology, when processing the lighting rendering of multiple light sources, the Blinn-Phong (reflected light model) lighting model and the exponential attenuation coefficient are usually used to process the multiple light sources, accumulate the multiple light sources, and determine the final rendering color to the current pixel in the scene to realize the lighting rendering of multiple light sources.
[0004] In the process of implementing this application, the applicant found that the related technology has at least the following problems:
[0005] Different point light sources illuminate the dark parts of the model differently. Using the Blinn-Phong lighting model for lighting rendering can easily cause overexposure of the model and color confusion, resulting in a single lighting effect for the model in the scene and an unrealistic picture. Summary of the invention
[0006] In view of this, the present application provides a multi-point light source lighting rendering method, device, computer equipment and storage medium, the main purpose of which is to solve the current problem of overexposure of the model and color confusion of the model, resulting in a single lighting effect of the model in the scene and the picture is not realistic enough.
[0007] According to a first aspect of the present application, a method for illumination rendering of a multi-point light source is provided, the method comprising:
[0008] Determine a pixel to be rendered in a scene to be rendered and a plurality of target point light sources whose illumination range covers the pixel to be rendered, wherein the pixel to be rendered is any pixel point in the scene to be rendered in a current frame;
[0009] Interpolate the pixel to be rendered according to the attenuation coefficient of at least one first point light source to obtain a first interpolated pixel, wherein the at least one first point light source is a target point light source among the multiple target point light sources, the light source label of which indicates that the target point light source belongs to a reflection type point light source;
[0010] Interpolating the pixel to be rendered according to the attenuation coefficient of at least one second point light source to obtain a second interpolated pixel, wherein the at least one second point light source is a target point light source among the multiple target point light sources, the light source label of which indicates that the target point light source belongs to a dyeing type point light source; and
[0011] Accumulate the colors of the first interpolated pixel and the second interpolated pixel to obtain a color to be covered, and use the color to be covered to cover the pixel to be rendered to obtain a lighting rendering result of the pixel to be rendered.
[0012] Optionally, determining pixels to be rendered in the scene to be rendered and multiple target point light sources whose illumination ranges cover the pixels to be rendered includes:
[0013] Determine the scene to be rendered, obtain a scene map of the scene to be rendered in the current frame, and extract any pixel point in the scene map as the pixel to be rendered;
[0014] Determining a plurality of candidate point light sources in the scene to be rendered; and
[0015] The illumination range of each candidate point light source among the multiple candidate point light sources is calculated respectively, and the candidate point light sources whose illumination range covers the pixel to be rendered are extracted to obtain the multiple target point light sources.
[0016] Optionally, interpolating the pixel to be rendered according to the attenuation coefficient of at least one first point light source to obtain a first interpolated pixel includes:
[0017] Querying the light source label of each target point light source among the multiple target point light sources, extracting the target point light source indicated by the light source label belonging to the reflective point light source from the multiple target point light sources, and obtaining the at least one first point light source;
[0018] Extracting a preset number of first point light sources from the at least one first point light source, wherein the illumination intensities of the preset number of first point light sources and the position distances between the first point light sources and the pixels to be rendered meet preset conditions;
[0019] Performing the following processing on each of the preset number of first point light sources: querying the attenuation coefficient, the first light source position, and the first light source color of the first point light source, and interpolating the first light source color and the pixel to be rendered according to the first light source position of the first point light source and the attenuation coefficient of the first point light source to obtain an interpolated pixel corresponding to the first point light source; and
[0020] The obtained preset number of interpolation pixels is used as the first interpolation pixels.
[0021] Optionally, extracting a preset number of first point light sources from the at least one first point light source includes:
[0022] Respectively counting the position distance between each of the at least one first point light source and the pixel to be rendered, and based on the indication of the preset condition, sorting the at least one first point light source in descending order of position distance to obtain a sorting result; and
[0023] An intensity threshold indicated by the preset condition is obtained, and a preset number of first point light sources having illumination intensities greater than the intensity threshold are extracted from the head of the queue of the sorting result.
[0024] Optionally, interpolating the pixel to be rendered according to the attenuation coefficient of at least one second point light source to obtain a second interpolated pixel includes:
[0025] Querying the light source label of each target point light source among the multiple target point light sources, extracting the target point light source indicated by the light source label belonging to the dyeing type point light source from the multiple target point light sources, and obtaining the at least one second point light source;
[0026] The following processing is performed on each of the at least one second point light source: querying the attenuation coefficient, the second light source position, and the second light source color of the second point light source, and interpolating the second light source color and the pixel to be rendered according to the second light source position of the second point light source and the attenuation coefficient of the second point light source to obtain an interpolated pixel corresponding to the second point light source; and
[0027] The obtained at least one interpolated pixel is used as the second interpolated pixel.
[0028] Optionally, before determining pixels to be rendered in the scene to be rendered and multiple target point light sources whose illumination ranges cover the pixels to be rendered, the method further includes:
[0029] In response to a light source adding operation, determining a target position indicated by the light source adding operation in the scene to be rendered and a selected light source to be added;
[0030] In response to the adding end instruction, all point light sources in the scene to be rendered are counted, the light source position of each point light source in all the point light sources is respectively identified, and the point light sources are marked by the light source position.
[0031] Optionally, the method further comprises:
[0032] querying the light source label of each point light source respectively, dividing all the marked point light sources into the reflection type point light source group and the dyeing type point light source group according to the light source label, and adding the reflection type point light source group and the dyeing type point light source group to the rendering pipeline, so that the rendering pipeline performs lighting calculation for the reflection type point light source group and the dyeing type point light source group; and
[0033] The reflection type point light source group and the dyeing type point light source group are filtered, and the filtered reflection type point light source group and the dyeing type point light source group are written into the shader of the scene to be rendered, so as to perform interpolation processing of the point light sources based on the written shader.
[0034] According to a second aspect of the present application, a lighting rendering device for multiple light sources is provided, the device comprising:
[0035] A determination module is used to determine a pixel to be rendered in a scene to be rendered and a plurality of target point light sources whose illumination range covers the pixel to be rendered, wherein the pixel to be rendered is any pixel point in the scene to be rendered in a current frame;
[0036] an interpolation module, configured to interpolate the pixel to be rendered according to an attenuation coefficient of at least one first point light source to obtain a first interpolated pixel, wherein the at least one first point light source is a target point light source among the multiple target point light sources, the light source label of which indicates that the target point light source belongs to a reflection type point light source;
[0037] The interpolation module is further used to interpolate the pixel to be rendered according to the attenuation coefficient of at least one second point light source to obtain a second interpolated pixel, wherein the at least one second point light source is a target point light source among the multiple target point light sources, and the light source label indicates that the target point light source belongs to a dyeing type point light source; and
[0038] The accumulation module is used to accumulate the colors of the first interpolation pixel and the second interpolation pixel to obtain a color to be covered, and use the color to be covered to cover the pixel to be rendered to obtain a lighting rendering result of the pixel to be rendered.
[0039] Optionally, the determination module is used to determine the scene to be rendered, obtain the scene map of the scene to be rendered in the current frame, extract any pixel in the scene map as the pixel to be rendered; determine multiple candidate point light sources in the scene to be rendered; and respectively calculate the illumination range of each of the multiple candidate point light sources, extract the candidate point light sources whose illumination range covers the pixel to be rendered, and obtain the multiple target point light sources.
[0040] Optionally, the interpolation module is used to query the light source label of each target point light source among the multiple target point light sources, extract the target point light source whose light source label indicates that it belongs to the reflective point light source from the multiple target point light sources, and obtain the at least one first point light source; extract a preset number of first point light sources from the at least one first point light source, and the illumination intensity of the preset number of first point light sources and the position distance between the pixel to be rendered meet preset conditions; perform the following processing on each first point light source among the preset number of first point light sources: query the attenuation coefficient, the first light source position and the first light source color of the first point light source, and interpolate the first light source color and the pixel to be rendered according to the first light source position of the first point light source and the attenuation coefficient of the first point light source to obtain the interpolated pixels corresponding to the first point light source; and use the obtained preset number of interpolated pixels as the first interpolated pixels.
[0041] Optionally, the interpolation module is used to respectively count the position distance between each of the at least one first point light source and the pixel to be rendered, and based on the indication of the preset condition, sort the at least one first point light source in order of position distance from large to small to obtain a sorting result; and obtain the intensity threshold indicated by the preset condition, and extract the preset number of first point light sources whose light intensity is greater than the intensity threshold at the head of the queue of the sorting result.
[0042] Optionally, the interpolation module is used to query the light source label of each target point light source among the multiple target point light sources, extract the target point light source whose light source label indicates that it belongs to the dyeing type point light source from the multiple target point light sources, and obtain the at least one second point light source; perform the following processing on each second point light source among the at least one second point light source: query the attenuation coefficient, the second light source position and the second light source color of the second point light source, and interpolate the second light source color and the pixel to be rendered according to the second light source position of the second point light source and the attenuation coefficient of the second point light source to obtain the interpolated pixel corresponding to the second point light source; and use the obtained at least one interpolated pixel as the second interpolated pixel.
[0043] Optionally, the device further comprises:
[0044] An adding module, configured to, in response to a light source adding operation, determine a target position indicated by the light source adding operation in the scene to be rendered and a selected light source to be added;
[0045] The marking module is used to count all point light sources in the scene to be rendered in response to the adding end instruction, respectively identify the light source position of each point light source in all the point light sources, and mark the point light sources using the light source position.
[0046] Optionally, the adding module is further used to query the light source label of each point light source respectively, divide all the marked point light sources into the reflection type point light source group and the dyeing type point light source group according to the light source label, and add the reflection type point light source group and the dyeing type point light source group to the rendering pipeline, so that the rendering pipeline performs lighting calculations on the reflection type point light source group and the dyeing type point light source group; and
[0047] The adding module is also used to filter the reflection type point light source group and the dyeing type point light source group, and write the filtered reflection type point light source group and the dyeing type point light source group into the shader of the scene to be rendered, so as to perform interpolation processing of the point light source based on the written shader.
[0048] According to a third aspect of the present application, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the methods described in the first aspect when executing the computer program.
[0049] According to a fourth aspect of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.
[0050] By means of the above technical scheme, the present application provides a method, device, computer equipment and storage medium for illumination rendering of multiple point light sources. The present application determines pixels to be rendered in a scene to be rendered, and multiple target point light sources whose illumination range covers the pixels to be rendered, interpolates the pixels to be rendered according to the attenuation coefficient of the first point light source belonging to the reflection type point light source to obtain the first interpolated pixel, and interpolates the pixels to be rendered according to the attenuation coefficient of the second point light source belonging to the dyeing type point light source to obtain the second interpolated pixel, accumulates the colors of the first interpolated pixel and the second interpolated pixel to obtain the color to be covered, and covers the pixels to be rendered with the color to be covered to obtain the illumination rendering result of the pixels to be rendered, and uses the Blin-Phong illumination model to adjust the accumulation relationship of the point light sources belonging to the reflection type point light sources when illuminating the character to be a covering relationship, and for the point light sources belonging to the dyeing type point light sources, the color tendency of this type of point light sources affecting the character is determined according to the attenuation relationship, and no illumination calculation is performed, so as to satisfy the accumulation relationship of the multiple point light sources on the current pixel color, avoid overexposure of the model and color confusion of the model, and the lighting effect of the model displayed in the scene is rich, and the picture is more realistic.
[0051] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0053] Figure 1 A schematic diagram of a lighting rendering method for multiple light sources provided in an embodiment of the present application is shown;
[0054] Figure 2A A schematic diagram of a lighting rendering method for multiple light sources provided in an embodiment of the present application is shown;
[0055] Figure 2B A schematic diagram of a lighting rendering method for multiple light sources provided in an embodiment of the present application is shown;
[0056] Figure 2C A schematic diagram of a lighting rendering method for multiple light sources provided in an embodiment of the present application is shown;
[0057] Figure 2D A schematic diagram of a lighting rendering method for multiple light sources provided in an embodiment of the present application is shown;
[0058] Figure 3 A schematic structural diagram of a lighting rendering device with multiple light sources provided in an embodiment of the present application is shown;
[0059] Figure 4 A schematic diagram of the device structure of a computer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0060] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0061] The present application embodiment provides a method for rendering illumination of multiple light sources, such as Figure 1 As shown, the method includes:
[0062] 101. Determine a pixel to be rendered and a plurality of target point light sources whose illumination range covers the pixel to be rendered in a scene to be rendered. The pixel to be rendered is any pixel point in the scene to be rendered in a current frame.
[0063] 102. Interpolate pixels to be rendered according to an attenuation coefficient of at least one first point light source to obtain first interpolated pixels, wherein the at least one first point light source is a target point light source among a plurality of target point light sources, the light source label of which indicates that the light source is a reflection point light source.
[0064] 103. Interpolate pixels to be rendered according to an attenuation coefficient of at least one second point light source to obtain second interpolated pixels, wherein the at least one second point light source is a target point light source among a plurality of target point light sources, the light source label of which indicates that the light source belongs to a dyeing point light source.
[0065] 104. Accumulate the colors of the first interpolated pixel and the second interpolated pixel to obtain a color to be covered, and use the color to be covered to cover the pixel to be rendered to obtain a lighting rendering result of the pixel to be rendered.
[0066] The method provided by the embodiment of the present application determines pixels to be rendered in a scene to be rendered and multiple target point light sources whose illumination range covers the pixels to be rendered, interpolates the pixels to be rendered according to the attenuation coefficient of the first point light source belonging to the reflection type point light source to obtain the first interpolated pixel, and interpolates the pixels to be rendered according to the attenuation coefficient of the second point light source belonging to the dyeing type point light source to obtain the second interpolated pixel, accumulates the colors of the first interpolated pixel and the second interpolated pixel to obtain the color to be covered, covers the pixels to be rendered with the color to be covered, and obtains the illumination rendering result of the pixels to be rendered, uses the Blin-Phong illumination model to adjust the accumulation relationship of the point light sources belonging to the reflection type point light sources when illuminating the character to be a covering relationship, and for the point light sources belonging to the dyeing type point light sources, determines the color tendency of this type of point light sources affecting the character according to the attenuation relationship, does not perform illumination calculation, satisfies the accumulation relationship of multiple point light sources to the current pixel color, avoids overexposure of the model and color confusion of the model, and the lighting effect of the model displayed in the scene is rich, and the picture is more realistic.
[0067] The present application embodiment provides a method for rendering illumination of multiple light sources, such as Figure 2A As shown, the method includes:
[0068] 201. Add light sources to the scene to be rendered, and divide the light sources added to the scene to be rendered into reflection point light sources and dyeing point light sources.
[0069] At present, in some cartoon-rendered games or film and television works, when artists deal with the impact of multiple point light sources on characters, they generally use the Blinn-Phong lighting model and exponential attenuation coefficient to accumulate the point light sources and render the final accumulated color to the current pixel. However, the applicant has realized that only using the Blin-Phong lighting model for lighting rendering will result in a relatively simple lighting effect of the point light source in the cartoon rendering, and it is impossible to reasonably handle the lighting of the dark part of the character by multiple point light sources, and it is impossible to meet the requirements of stylized cartoon rendering for point light sources. In particular, the situation of multiple point light sources will cause the character to be overexposed and the relationship between the light sources cannot be judged. For details, please refer to Figure 2B , the reflective point light source truly illuminates the dark and highlight parts of the character, and uses the Blin-Phong lighting model for shading. Placing it under the street lights in the scene will cause the light and shadow of the character to "jump". Figure 2C The point light source of the dyeing type will dye the character, without affecting the position of the boundary between light and dark, and the attenuation coefficient is linear, and the highlight is not calculated. Therefore, the purpose of interpolation based on the linear attenuation coefficient is to highlight the impact of the environmental atmosphere on the character and avoid the "jump" of the character's light and shadow.
[0070] Therefore, the present application proposes a lighting rendering method for multiple point light sources, which determines pixels to be rendered and multiple target point light sources whose lighting range covers the pixels to be rendered in a scene to be rendered, interpolates the pixels to be rendered according to the attenuation coefficient of the first point light source belonging to the reflection type point light source to obtain a first interpolated pixel, and interpolates the pixels to be rendered according to the attenuation coefficient of the second point light source belonging to the dyeing type point light source to obtain a second interpolated pixel, accumulates the colors of the first interpolated pixel and the second interpolated pixel to obtain a color to be covered, and uses the color to be covered to cover the pixels to be rendered to obtain a lighting rendering result of the pixels to be rendered, and uses the Blin-Phong lighting model to adjust the cumulative relationship of the point light sources belonging to the reflection type point light sources when illuminating the character to be a covering relationship, and for the point light sources belonging to the dyeing type point light sources, the color tendency of this type of point light sources affecting the character is determined according to the attenuation relationship, and no lighting calculation is performed, so as to satisfy the cumulative relationship of the multiple point light sources on the current pixel color, avoid overexposure of the model and color confusion of the model, and the lighting effect of the model displayed in the scene is rich, and the picture is more realistic.
[0071] Among them, the embodiments of the present application can be applied in an image processing engine, and in order to realize the lighting rendering of the scene, it is necessary to add a light source to the scene to be rendered, and the light source added to the scene to be rendered is divided into a reflection point light source and a dyeing point light source. In an optional implementation scheme, in response to the light source adding operation, the image processing engine determines the target position indicated by the light source adding operation in the scene to be rendered and the selected light source to be added, so as to add the light source to be added to the scene to be rendered. In an optional implementation scheme, the light source to be added can be directly displayed at the target position of the scene to be rendered to complete the addition of the light source; or the scene parameters of the scene to be rendered can be modified, and parameters related to the light source to be added are added to the light source parameters to realize the addition of the light source. In addition, in another optional implementation scheme, the light source adding operation can be manually initiated by the artist, and when placing the light source, the artist can place it according to the atmosphere of the scene. For example, point light sources such as "street lights" and "bonfires" are dyeing point light sources, which can dye the characters. Therefore, it is necessary to highlight the impact of the scene on the characters based on this type of point light source. See Figure 2D , Figure 2D The point in the figure is the point light source added by the artist, and the arc where the point is located is the lighting range of the point light source.
[0072] When the light sources are placed, in response to the addition end instruction, the image processing engine counts all the point light sources in the scene to be rendered, identifies the light source position of each point light source in all the point light sources, and marks the point light sources using the light source position. Moreover, each point light source has a corresponding light source label, which indicates the light source type of the point light source and describes whether the point light source belongs to a reflective light source or a dyed light source. Therefore, in an optional implementation, the image processing engine can query the light source label of each point light source separately, and divide all the marked point light sources into a reflective point light source group and a dyed point light source group according to the light source label, so that different groups of light sources can be interpolated in different ways later.
[0073] In another optional implementation scheme, after completing the grouping of point light sources, the image processing engine will add the reflection type point light source group and the dyeing type point light source group to the rendering pipeline, so that the two types of light sources are declared as two groups of arrays in the rendering pipeline, so that the rendering pipeline traverses all visible light sources when rendering the current frame, and puts the visible light sources into the two groups of point light source arrays according to the light source labels, and then passes them to the character Shader (shader) of the scene to calculate and color the two groups of point light source arrays, so as to realize the lighting calculation of the reflection type point light source group and the dyeing type point light source group. Among them, when transmitting the two groups of point light source arrays to the Shader, the image processing engine will filter the reflection type point light source group and the dyeing type point light source group, and write the filtered reflection type point light source group and the dyeing type point light source group into the shader of the scene to be rendered, so as to perform interpolation processing of the point light sources based on the written shader. The specific image processing engine can use the two groups of point light source arrays after culling on the CPU (Central Processing Unit / Processor) side as filtered reflection point light source group and dyeing point light source group, so that the filtered reflection point light source group and dyeing point light source group can be passed to the GPU (Graphics Processing Unit) side for Shader calculation.
[0074] 202. Determine, in a scene to be rendered, pixels to be rendered and a plurality of target point light sources whose illumination ranges cover the pixels to be rendered.
[0075] In an embodiment of the present application, the pixel to be rendered is any pixel in the scene to be rendered in the current frame. In an optional implementation scheme, the image processing engine determines the scene to be rendered, obtains the scene map of the scene to be rendered in the current frame, and extracts any pixel in the scene map as the pixel to be rendered. Next, the image processing engine determines multiple candidate point light sources in the scene to be rendered, and calculates the illumination range of each candidate point light source in the multiple candidate point light sources respectively, extracts the candidate point light sources whose illumination range covers the pixel to be rendered, and obtains multiple target point light sources.
[0076] 203. Interpolate the pixels to be rendered according to the attenuation coefficient of at least one first point light source to obtain first interpolated pixels.
[0077] In an embodiment of the present application, at least one first point light source is a target point light source among multiple target point light sources, and the light source label indicates that the target point light source belongs to a reflective point light source. Since the present application performs different interpolation operations for different types of point light sources, the image processing engine interpolates the pixels to be rendered according to the attenuation coefficient of the first point light source to obtain the first interpolated pixel. In an optional implementation scheme, the process of determining at least one first point light source and performing interpolation is as follows:
[0078] First, the image processing engine queries the light source label of each target point light source among multiple target point light sources, extracts the target point light sources whose light source labels indicate that they belong to the reflective point light source among the multiple target point light sources, and obtains at least one first point light source.
[0079] Subsequently, the image processing engine extracts a preset number of first point light sources from at least one first point light source, wherein the illumination intensity of the preset number of first point light sources and the position distance between the pixel to be rendered meet the preset conditions. The reason for extracting the preset number of first point light sources is that the light source with a long distance from the pixel to be rendered and poor intensity has little or no effect on the pixel to be rendered. Therefore, in order to ensure the accuracy of rendering, the preset number of first point light sources closest to the pixel to be rendered and with the largest color intensity are selected in the embodiment of the present application for illumination rendering to ensure the authenticity of the rendering. Wherein, when extracting the preset number of first point light sources, the image processing engine respectively counts the position distance between each first point light source in at least one first point light source and the pixel to be rendered, and sorts the at least one first point light source in the order of position distance from large to small based on the indication of the preset condition, obtains the sorting result, and obtains the intensity threshold indicated by the preset condition, and extracts the preset number of first point light sources with illumination intensity greater than the intensity threshold at the head of the sorting result. In the actual application process, the preset number can be any value from 4 to 8, that is, 4 to 8 point light sources with the closest distance to the pixel to be rendered and the largest color intensity are extracted for subsequent interpolation operations.
[0080] Next, for each of the preset number of first point light sources, the image processing engine queries the attenuation coefficient, the first light source position, and the first light source color of the first point light source, and interpolates the first light source color and the pixel to be rendered according to the first light source position of the first point light source and the attenuation coefficient of the first point light source to obtain the interpolated pixel corresponding to the first point light source. Specifically, the attenuation coefficient can be an exponential attenuation coefficient of the first point light source or a linear attenuation coefficient, which is not specifically limited in this application.
[0081] By repeatedly executing the above process, the image processing engine interpolates each first point light source respectively to obtain a preset number of interpolated pixels, and uses the preset number of interpolated pixels as the first interpolated pixels, so that when the pixel to be rendered is subsequently covered based on the first interpolated pixels, the pixel to be rendered is interpolated by all the light sources that illuminate this pixel according to the degree of attenuation intensity, and the original Diffuse color of the pixel to be rendered is covered with the final calculated color.
[0082] 204. Interpolate the pixels to be rendered according to the attenuation coefficient of at least one second point light source to obtain second interpolated pixels.
[0083] In an embodiment of the present application, at least one second point light source is a target point light source among multiple target point light sources, and the light source label indicates that the target point light source belongs to a dyed point light source. Since the present application performs different interpolation operations for different types of point light sources, the image processing engine interpolates the pixels to be rendered according to the attenuation coefficient of the at least one second point light source to obtain a second interpolated pixel. In an optional implementation scheme, the process of determining at least one second point light source and performing interpolation is as follows:
[0084] First, the image processing engine queries the light source label of each target point light source among multiple target point light sources, extracts the target point light sources whose light source labels indicate that they belong to dyed point light sources among the multiple target point light sources, and obtains at least one second point light source.
[0085] Subsequently, for each second point light source in the at least one second point light source, the image processing engine queries the attenuation coefficient, the second light source position, and the second light source color of the second point light source, and interpolates the second light source color and the pixel to be rendered according to the second light source position of the second point light source and the attenuation coefficient of the second point light source to obtain an interpolated pixel. Specifically, the attenuation coefficient can be a linear attenuation coefficient of the second point light source or an exponential attenuation coefficient, which is not specifically limited in this application.
[0086] The above process is repeated, and the image processing engine performs interpolation processing on each second point light source respectively to obtain at least one interpolated pixel, and uses the at least one interpolated pixel as the second interpolated pixel, so that the color of the pixel to be rendered and the color of the light source are uniformly filtered according to the linear attenuation degree of this type of point light source.
[0087] 205 . Accumulate the colors of the first interpolated pixel and the second interpolated pixel to obtain a color to be covered, and use the color to be covered to cover the pixel to be rendered to obtain a lighting rendering result of the pixel to be rendered.
[0088] In an embodiment of the present application, after obtaining the first interpolation pixel and the second difference pixel through the above process, the image processing engine accumulates the colors of the first interpolation pixel and the second interpolation pixel to obtain the color to be covered, and uses the color to be covered to cover the pixel to be rendered to obtain the lighting rendering result of the pixel to be rendered, so that the two point light source arrays are calculated according to different types in the character shader, and finally colored to the pixel to be rendered.
[0089] In this way, for games that need to perform lighting rendering according to the expression rules of cartoon rendering and have point light sources that require multiple forms of expression, a point light source with a "dying" effect is used to express the character under a street lamp, and the character's own color in front of a bonfire tends to gradually approach the color of the point light source according to the distance; and another type of point light uses the Blin-Phong lighting model to illuminate the character and generate the bright and dark parts of the character, and when multiple point light sources of this type illuminate the character at the same time, the dark area can be illuminated by other point light sources. Through the method in the embodiment of the present application, the interaction effect between the character and the light source in different environments such as street lamps, bonfires, special effects explosions, etc. can be extended according to the stylized rules of cartoon rendering, enriching the picture, forming a varied and unified 3D (3Dimensions, three-dimensional) picture style, meeting the diverse needs of players for picture aesthetics, avoiding the overexposure of the picture and color confusion caused by multiple point light sources, and enriching the creative means of art production personnel.
[0090] In summary, the logical process of the illumination rendering method of multiple light sources proposed in this application is as follows:
[0091] The image processing engine adds different types of light sources to the scene to be rendered, groups the added light sources, and obtains a reflection point light source group and a dye point light source group. Subsequently, the image processing engine declares two groups of point light source groups in the rendering pipeline, passes the point light source groups after culling to the GPU, and declares two groups of point light source groups in the Shader. Next, the image processing engine calculates the two groups of point light source groups separately. For the reflection point light source, the maximum illumination range is calculated, and the color of the light source to be rendered is determined according to the intensity of the point light source, and the pixels to be rendered are interpolated according to the attenuation coefficient; for the dye point light source, the pixels to be rendered are interpolated according to the attenuation coefficient, the color of the pixels to be rendered and the color of this type of light source are evenly filtered, and the calculation results of multiple light sources are accumulated to finally obtain the lighting rendering results of the pixels to be rendered.
[0092] The method provided by the embodiment of the present application determines pixels to be rendered in a scene to be rendered and multiple target point light sources whose illumination range covers the pixels to be rendered, interpolates the pixels to be rendered according to the attenuation coefficient of the first point light source belonging to the reflection type point light source to obtain the first interpolated pixel, and interpolates the pixels to be rendered according to the attenuation coefficient of the second point light source belonging to the dyeing type point light source to obtain the second interpolated pixel, accumulates the colors of the first interpolated pixel and the second interpolated pixel to obtain the color to be covered, covers the pixels to be rendered with the color to be covered, and obtains the illumination rendering result of the pixels to be rendered, uses the Blin-Phong illumination model to adjust the accumulation relationship of the point light sources belonging to the reflection type point light sources when illuminating the character to be a covering relationship, and for the point light sources belonging to the dyeing type point light sources, determines the color tendency of this type of point light sources affecting the character according to the attenuation relationship, does not perform illumination calculation, satisfies the accumulation relationship of multiple point light sources to the current pixel color, avoids overexposure of the model and color confusion of the model, and the lighting effect of the model displayed in the scene is rich, and the picture is more realistic.
[0093] Further, as Figure 1 In a specific implementation of the method, the present application provides a lighting rendering device with multiple light sources, such as Figure 3 As shown, the device includes: a determination module 301, an interpolation module 302 and an accumulation module 303.
[0094] The determination module 301 is used to determine a pixel to be rendered and a plurality of target point light sources whose illumination range covers the pixel to be rendered in the scene to be rendered, wherein the pixel to be rendered is any pixel point in the scene to be rendered in the current frame;
[0095] The interpolation module 302 is used to interpolate the pixel to be rendered according to the attenuation coefficient of at least one first point light source to obtain a first interpolated pixel, wherein the at least one first point light source is a target point light source among the multiple target point light sources, and the light source label indicates that the target point light source belongs to a reflection type point light source;
[0096] The interpolation module 302 is further configured to interpolate the pixel to be rendered according to an attenuation coefficient of at least one second point light source to obtain a second interpolated pixel, wherein the at least one second point light source is a target point light source among the multiple target point light sources, the light source label of which indicates that the target point light source belongs to a dyeing type point light source; and
[0097] The accumulation module 303 is used to accumulate the colors of the first interpolation pixel and the second interpolation pixel to obtain a color to be covered, and use the color to be covered to cover the pixel to be rendered to obtain a lighting rendering result of the pixel to be rendered.
[0098] In a specific application scenario, the determination module 301 is used to determine the scene to be rendered, obtain the scene map of the scene to be rendered in the current frame, extract any pixel point in the scene map as the pixel to be rendered; determine multiple candidate point light sources in the scene to be rendered; and calculate the illumination range of each candidate point light source in the multiple candidate point light sources respectively, extract the candidate point light sources whose illumination range covers the pixel to be rendered, and obtain the multiple target point light sources.
[0099] In a specific application scenario, the interpolation module 302 is used to query the light source label of each target point light source among the multiple target point light sources, extract the target point light source whose light source label indicates that it belongs to the reflective point light source from the multiple target point light sources, and obtain the at least one first point light source; extract a preset number of first point light sources from the at least one first point light source, and the illumination intensity of the preset number of first point light sources and the position distance between the pixel to be rendered meet preset conditions; perform the following processing on each first point light source among the preset number of first point light sources: query the attenuation coefficient, the first light source position and the first light source color of the first point light source, and interpolate the first light source color and the pixel to be rendered according to the first light source position of the first point light source and the attenuation coefficient of the first point light source to obtain the interpolated pixel corresponding to the first point light source; and use the obtained preset number of interpolated pixels as the first interpolated pixels.
[0100] In a specific application scenario, the interpolation module 302 is used to respectively count the position distance between each of the at least one first point light source and the pixel to be rendered, and based on the indication of the preset condition, sort the at least one first point light source in order of position distance from large to small to obtain a sorting result; and obtain the intensity threshold indicated by the preset condition, and extract the preset number of first point light sources whose illumination intensity is greater than the intensity threshold at the head of the queue of the sorting result.
[0101] In a specific application scenario, the interpolation module 302 is used to query the light source label of each target point light source among the multiple target point light sources, extract the target point light source whose light source label indicates that it belongs to the dyed point light source from the multiple target point light sources, and obtain the at least one second point light source; perform the following processing on each second point light source among the at least one second point light source: query the attenuation coefficient, the second light source position and the second light source color of the second point light source, and interpolate the second light source color and the pixel to be rendered according to the second light source position of the second point light source and the attenuation coefficient of the second point light source to obtain the interpolated pixel corresponding to the second point light source; and use the obtained at least one interpolated pixel as the second interpolated pixel.
[0102] In a specific application scenario, the device also includes:
[0103] An adding module, configured to, in response to a light source adding operation, determine a target position indicated by the light source adding operation in the scene to be rendered and a selected light source to be added;
[0104] The marking module is used to count all point light sources in the scene to be rendered in response to the adding end instruction, respectively identify the light source position of each point light source in all the point light sources, and mark the point light sources using the light source position.
[0105] In a specific application scenario, the adding module is further used to query the light source label of each point light source respectively, divide all the marked point light sources into the reflection type point light source group and the dyeing type point light source group according to the light source label, and add the reflection type point light source group and the dyeing type point light source group to the rendering pipeline, so that the rendering pipeline performs lighting calculations on the reflection type point light source group and the dyeing type point light source group; and
[0106] The adding module is also used to filter the reflection type point light source group and the dyeing type point light source group, and write the filtered reflection type point light source group and the dyeing type point light source group into the shader of the scene to be rendered, so as to perform interpolation processing of the point light source based on the written shader.
[0107] The device provided by the embodiment of the present application determines pixels to be rendered in a scene to be rendered and multiple target point light sources whose illumination range covers the pixels to be rendered, interpolates the pixels to be rendered according to the attenuation coefficient of the first point light source belonging to the reflection type point light source to obtain the first interpolated pixel, and interpolates the pixels to be rendered according to the attenuation coefficient of the second point light source belonging to the dyeing type point light source to obtain the second interpolated pixel, accumulates the colors of the first interpolated pixel and the second interpolated pixel to obtain the color to be covered, covers the pixels to be rendered with the color to be covered, and obtains the illumination rendering result of the pixels to be rendered, uses the Blin-Phong illumination model to adjust the accumulation relationship of the point light sources belonging to the reflection type point light sources when illuminating the character to be a covering relationship, and for the point light sources belonging to the dyeing type point light sources, determines the color tendency of this type of point light sources affecting the character according to the attenuation relationship, does not perform illumination calculation, satisfies the accumulation relationship of multiple point light sources to the current pixel color, avoids overexposure of the model and color confusion of the model, and the lighting effect of the model displayed in the scene is rich, and the picture is more realistic.
[0108] It should be noted that for other corresponding descriptions of the functional units involved in the illumination rendering device for multiple point light sources provided in the embodiment of the present application, reference can be made to Figure 1 and Figure 2A The corresponding description in will not be repeated here.
[0109] In an exemplary embodiment, see Figure 4 , and also provides a computer device, which includes a bus, a processor, a memory and a communication interface, and may also include an input and output interface and a display device, wherein each functional unit can communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the illumination rendering method of the multi-point light source in the above embodiment.
[0110] A computer-readable storage medium stores a computer program, which implements the steps of the illumination rendering method of multiple light sources when executed by a processor.
[0111] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by hardware, or by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0112] Those skilled in the art will appreciate that the accompanying drawings are merely schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily required for implementing the present application.
[0113] Those skilled in the art will appreciate that the modules in the device in the implementation scenario can be distributed in the device in the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules in the above implementation scenario can be combined into one module, or can be further split into multiple sub-modules.
[0114] The above application serial numbers are for description only and do not represent the advantages or disadvantages of the implementation scenarios.
[0115] The above disclosure only discloses several specific implementation scenarios of the present application. However, the present application is not limited thereto, and any changes that can be conceived by technicians in this field should fall within the scope of protection of the present application.
Claims
1. A method for illumination rendering of multiple point light sources, characterized in that: include: Determine a pixel to be rendered in a scene to be rendered and a plurality of target point light sources whose illumination range covers the pixel to be rendered, wherein the pixel to be rendered is any pixel point in the scene to be rendered in a current frame; Interpolate the pixel to be rendered according to the attenuation coefficient of at least one first point light source to obtain a first interpolated pixel, wherein the at least one first point light source is a target point light source among the multiple target point light sources, the light source label of which indicates that the target point light source belongs to a reflection type point light source; Interpolating the pixel to be rendered according to the attenuation coefficient of at least one second point light source to obtain a second interpolated pixel, wherein the at least one second point light source is a target point light source among the multiple target point light sources, the light source label of which indicates that the target point light source belongs to a dyeing type point light source; and Accumulate the colors of the first interpolated pixel and the second interpolated pixel to obtain a color to be covered, and use the color to be covered to cover the pixel to be rendered to obtain a lighting rendering result of the pixel to be rendered.
2. The method according to claim 1, characterized in that The step of determining pixels to be rendered in the scene to be rendered and a plurality of target point light sources whose illumination ranges cover the pixels to be rendered includes: Determine the scene to be rendered, obtain a scene map of the scene to be rendered in the current frame, and extract any pixel point in the scene map as the pixel to be rendered; Determining a plurality of candidate point light sources in the scene to be rendered; and The illumination range of each candidate point light source among the multiple candidate point light sources is calculated respectively, and the candidate point light sources whose illumination range covers the pixel to be rendered are extracted to obtain the multiple target point light sources.
3. The method according to claim 1, characterized in that The interpolating the pixel to be rendered according to the attenuation coefficient of at least one first point light source to obtain a first interpolated pixel includes: Querying the light source label of each target point light source among the multiple target point light sources, extracting the target point light source indicated by the light source label belonging to the reflective point light source from the multiple target point light sources, and obtaining the at least one first point light source; Extracting a preset number of first point light sources from the at least one first point light source, wherein the illumination intensities of the preset number of first point light sources and the position distances between the first point light sources and the pixels to be rendered meet preset conditions; Performing the following processing on each of the preset number of first point light sources: querying the attenuation coefficient, the first light source position, and the first light source color of the first point light source, and interpolating the first light source color and the pixel to be rendered according to the first light source position of the first point light source and the attenuation coefficient of the first point light source to obtain an interpolated pixel corresponding to the first point light source; and The obtained preset number of interpolation pixels is used as the first interpolation pixels.
4. The method according to claim 3, characterized in that The step of extracting a preset number of first point light sources from the at least one first point light source comprises: Respectively counting the position distance between each of the at least one first point light source and the pixel to be rendered, and based on the indication of the preset condition, sorting the at least one first point light source in descending order of position distance to obtain a sorting result; and An intensity threshold indicated by the preset condition is obtained, and a preset number of first point light sources having illumination intensities greater than the intensity threshold are extracted from the head of the queue of the sorting result.
5. The method according to claim 1, characterized in that The interpolating the pixel to be rendered according to the attenuation coefficient of at least one second point light source to obtain a second interpolated pixel comprises: Querying the light source label of each target point light source among the multiple target point light sources, extracting the target point light source indicated by the light source label belonging to the dyeing type point light source from the multiple target point light sources, and obtaining the at least one second point light source; The following processing is performed on each of the at least one second point light source: querying the attenuation coefficient, the second light source position, and the second light source color of the second point light source, and interpolating the second light source color and the pixel to be rendered according to the second light source position of the second point light source and the attenuation coefficient of the second point light source to obtain an interpolated pixel corresponding to the second point light source; and The obtained at least one interpolated pixel is used as the second interpolated pixel.
6. The method according to claim 1, characterized in that Before determining pixels to be rendered in the scene to be rendered and multiple target point light sources whose illumination ranges cover the pixels to be rendered, the method further includes: In response to a light source adding operation, determining a target position indicated by the light source adding operation in the scene to be rendered and a selected light source to be added; In response to the adding end instruction, all point light sources in the scene to be rendered are counted, the light source position of each point light source in all the point light sources is respectively identified, and the point light sources are marked by the light source position.
7. The method according to claim 6, characterized in that The method further comprises: Query the light source label of each point light source respectively, divide all the marked point light sources into the reflection type point light source group and the dyeing type point light source group according to the light source label, and add the reflection type point light source group and the dyeing type point light source group to the rendering pipeline, so that the rendering pipeline performs lighting calculation for the reflection type point light source group and the dyeing type point light source group; as well as The reflection type point light source group and the dyeing type point light source group are filtered, and the filtered reflection type point light source group and the dyeing type point light source group are written into the shader of the scene to be rendered, so as to perform interpolation processing of the point light sources based on the written shader.
8. A lighting rendering device with multiple light sources, characterized in that: include: A determination module is used to determine a pixel to be rendered in a scene to be rendered and a plurality of target point light sources whose illumination range covers the pixel to be rendered, wherein the pixel to be rendered is any pixel point in the scene to be rendered in a current frame; an interpolation module, configured to interpolate the pixel to be rendered according to an attenuation coefficient of at least one first point light source to obtain a first interpolated pixel, wherein the at least one first point light source is a target point light source among the multiple target point light sources, the light source label of which indicates that the target point light source belongs to a reflection type point light source; The interpolation module is further used to interpolate the pixel to be rendered according to the attenuation coefficient of at least one second point light source to obtain a second interpolated pixel, wherein the at least one second point light source is a target point light source among the multiple target point light sources, and the light source label indicates that the target point light source belongs to a dyeing type point light source; as well as The accumulation module is used to accumulate the colors of the first interpolation pixel and the second interpolation pixel to obtain a color to be covered, and use the color to be covered to cover the pixel to be rendered to obtain a lighting rendering result of the pixel to be rendered.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Picture rendering method and device, storage medium and electronic device
CN110211218A
Method and apparatus for processing a 3D scene
EP3352137A1