Image rendering method based on multiple light sources and related equipment

Through the multi-light source-based picture rendering method, using multiple light sources to render images to be rendered in a hierarchical manner, the problem of lack of diversity and aesthetics in the lighting rendering effect in the prior art is solved, and efficient and beautiful lighting rendering effect is achieved.

CN116310052BActive Publication Date: 2025-05-20BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211092359.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-07
Publication Date
2025-05-20
Estimated Expiration
2042-09-07

AI Technical Summary

Technical Problem

The prior art is difficult to meet the beautification needs in lighting rendering, especially in multi-light source environments, where the lighting rendering effect lacks diversity and aesthetics.

Method used

The multi-light source-based picture rendering method is adopted, and the target light source data is determined by obtaining the data information of the multi-light source and the image to be rendered, and multiple renderings are performed according to the pre-set multiple-level rendering strategy to obtain multiple hierarchical rendering results. Then, these hierarchical rendering results are summed according to preset rules to obtain the sum result, and the summing results of each target light source data are superimposed to obtain the final overlay rendering result.

Benefits of technology

It realizes the diversity and aesthetics of lighting rendering, meets users' art needs for picture rendering, and does not require users to perform complex processing operations and is easy to use.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116310052B_ABST
    Figure CN116310052B_ABST
Patent Text Reader

Abstract

The present application provides a method for rendering a picture based on multiple light sources and related equipment. The method includes: obtaining data information of multiple light sources and an image to be rendered; determining at least one target light source data in the data information of multiple light sources; using the target light source data to render the image to be rendered multiple times according to multiple levels of rendering strategies set in advance to obtain multiple hierarchical rendering results, and summing the multiple hierarchical rendering results obtained according to preset rules to obtain a summed result, wherein each level of rendering strategy corresponds to a hierarchical rendering result, and each target light source data corresponds to multiple hierarchical rendering results; in response to determining that at least one target light source data has been fully rendered, superimposing the summed results corresponding to each target light source data to obtain a superimposed rendering result of the image to be rendered. The diversified needs of lighting rendering are guaranteed by performing hierarchical rendering on the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a method for rendering an image based on multiple light sources and related devices. Background Art

[0002] Most of the light rendering of an image is based on the approximation and simulation of the real light effect. During the simulation process, the law of the straight-line propagation of light needs to be followed. Therefore, the area on the surface of an object where the normal points towards the light source is the bright part, and the backlit part is the dark part. The light rendering is performed in this way.

[0003] However, the light rendering of the prior art distributes and renders the objects in an image based on one light source or multiple light sources, and the rendering results often cannot meet the beautification requirements. Summary of the Invention

[0004] In view of this, the purpose of this application is to propose a method for rendering an image based on multiple light sources and related devices to solve or partially solve the above technical problems.

[0005] Based on the above purpose, the first aspect of this application provides a method for rendering an image based on multiple light sources, including:

[0006] Obtain the data information of multiple light sources and the image to be rendered;

[0007] Determine at least one target light source data in the data information of the multiple light sources;

[0008] Use the target light source data to perform multiple renderings on the image to be rendered according to multiple preset level rendering strategies to obtain multiple hierarchical rendering results, and sum up the obtained multiple hierarchical rendering results according to a preset rule to obtain a summation result, where each level rendering strategy corresponds to a hierarchical rendering result, and each target light source data corresponds to multiple hierarchical rendering results;

[0009] In response to determining that all renderings of at least one of the target light source data are completed, superimpose the summation results corresponding to each of the target light source data to obtain the superimposed rendering result of the image to be rendered.

[0010] Based on the same inventive concept, the second aspect of this application proposes a device for rendering an image based on multiple light sources, including:

[0011] An obtaining module, configured to obtain the data information of multiple light sources and the image to be rendered;

[0012] A determining module, configured to determine at least one target light source data in the data information of the multiple light sources;

[0013] A rendering module, configured to perform multiple renderings on the image to be rendered according to a plurality of preset level rendering strategies using the target light source data to obtain multiple hierarchical rendering results, and sum up the obtained multiple hierarchical rendering results according to a preset rule to obtain a sum result, wherein each level rendering strategy corresponds to one hierarchical rendering result, and each target light source data corresponds to multiple hierarchical rendering results;

[0014] An overlay module, configured to determine that all renderings of at least one of the target light source data are completed, and overlay the sum results corresponding to each of the target light source data to obtain an overlay rendering result of the image to be rendered.

[0015] Based on the same inventive concept, a third aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the first aspect is implemented.

[0016] Based on the same inventive concept, a fourth aspect of the present application provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the method described in the first aspect.

[0017] As can be seen from the above, for the multi-light-source-based screen rendering method and related devices provided in the present application, users can adjust multiple light sources according to their own needs, and perform hierarchical rendering on the image to be rendered using each light source respectively. In this way, each light source corresponds to multiple hierarchical rendering results, thus ensuring the diversification of light rendering. Then, the multiple hierarchical rendering results are summed up according to a preset rule to obtain a sum result after rendering by one light source. Finally, the sum results obtained after rendering each target light source data are overlaid to obtain the required overlay rendering result, meeting the user's artistic requirements for screen rendering without the need for the user to perform other complex processing operations, which is convenient for the user to use. Description of the Drawings

[0018] In order to more clearly illustrate the technical solutions in the present application or related technologies, the following will briefly introduce the drawings required for use in the embodiments or related technology descriptions. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0019] Figure 1 It is a schematic diagram of the application scenario of the embodiment of the present application;

[0020] Figure 2A It is a flowchart of the multi-light-source-based screen rendering method of the embodiment of the present application;

[0021] Figure 2B A two-dimensional schematic diagram of the spatial conversion of the brightness according to an embodiment of the present application;

[0022] Figure 3 A structural block diagram of a screen rendering device based on multiple light sources according to an embodiment of the present application;

[0023] Figure 4 A structural schematic diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners

[0024] The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and then implement the present application, rather than limiting the scope of the present application in any way. On the contrary, these embodiments are provided to make the present application more thorough and complete, and to be able to fully convey the scope of the present application to those skilled in the art.

[0025] In this document, it should be understood that any number of elements in the drawings is for illustration rather than limitation, and any naming is only for distinction and does not have any limiting meaning.

[0026] Based on the above description of the background technology, the following situations also exist in the related art:

[0027] In light rendering simulation, a directional light source is generally used for light rendering. A directional light source (DirectionalLight) simulates light rays emitted from an infinitely far and infinitely large source. This means that the shadows projected by this light source are all parallel, so it is very suitable for simulating sunlight. The only visible indicator on the directional light source is an arrow pointing in the direction in which the light will propagate.

[0028] In addition to the most common parallel light illumination, the several commonly used light source simulations in rendering cuts also include point light sources and spotlight sources. No matter which light type, it follows the law that light travels in a straight line. Therefore, the area where the surface normal of the object faces the light source position is the bright part, and the backlit part is the dark part.

[0029] Although the accurate lighting model is applicable to the vast majority of situations, for the current rich style types of NPR (Non-photorealistic rendering) rendering, especially in the performance of NPR characters, many inadaptabilities will be reflected.

[0030] In addition to non-realistic light and shadow generalization, in order to control the bright and dark areas, artists have also designed many solutions to avoid bad shadow shapes, especially for the face.

[0031] For the diffuse reflection part: Some improve the shape of the illuminated area by modifying the normal vectors, and some borrow the information of the SDF (SDF is a kind of graphics format) map to customize the area with changing brightness. Generally speaking, the common purpose is to avoid the illumination effect of the classical lighting model.

[0032] In the related technologies, the discussed solutions are all for the case of the main light source illumination. However, there is no clear idea on what kind of solutions should be designed for NPR with multiple light sources. In terms of the effects of multiple-light-source illumination, there are basically the following several types:

[0033] 1. Continue to use the classical lighting;

[0034] 2. Convert the classical lighting to second-order;

[0035] 3. Overall cover weak performance solutions such as solid colors.

[0036] Therefore, there has never been a systematic and easy-to-use solution for the requirements often put forward by the art.

[0037] For example, for the pictures in CG (Computer-generated) animations or game renders, the characteristics of these pictures are that the lights are arranged in a well-designed way, with professional lighting engineers providing guidance on the lighting positions and adjusting and correcting each frame. Under such specific angles, the multiple-light-source illumination performance that the art likes can be obtained. However, in real-time games, the application of dynamic lights is very unpredictable, and the positions of the light sources often depend on the positions where skills are released. Therefore, the uncertain lighting positions cannot illuminate the well-designed illuminated angles.

[0038] Based on the above-described situations, below, with reference to several representative embodiments of the present application, the principles and spirits of the present application will be elaborated in detail.

[0039] The present application provides a method for rendering a picture based on multiple light sources and related devices, which can respectively use each light source to perform hierarchical rendering on the image to be rendered. In this way, each light source correspondingly obtains multiple hierarchical rendering results, thereby ensuring the diversification of lighting rendering. Then, according to a preset rule, the multiple hierarchical rendering results are summed up to obtain a summed result after the rendering of one light source. Then, by superimposing the summed results obtained after the rendering of each target light source data, the required superimposed rendering result can be obtained. In this way, the user can adjust the multiple light sources according to his own needs and meet the user's artistic requirements for picture rendering based on hierarchical rendering, without the user having to perform other complex processing operations, which is convenient for the user to use.

[0040] Reference Figure 1, which is a schematic diagram of the application scenario of the multi-light-source-based screen rendering method provided by the embodiments of the present application. This application scenario includes a terminal device 101, a server 102, and a data storage system 103. Among them, the terminal device 101, the server 102, and the data storage system 103 can all be connected through a wired or wireless communication network. The terminal device 101 includes, but is not limited to, a desktop computer, a mobile phone, a mobile computer, a tablet computer, a media player, a smart wearable device, a personal digital assistant (PDA), or other electronic devices capable of implementing the above functions. The server 102 and the data storage system 103 can both be independent physical servers, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.

[0041] The server 102 is used to provide a screen rendering service to the user of the terminal device 101. A client for communicating with the server 102 is installed in the terminal device 101. The user can send the data information of multiple light sources required for screen rendering and the image to be rendered to the server 102 through the client. The server 102 filters at least one target light source data from the data information of the multiple light sources, performs hierarchical rendering on the image to be rendered, sums up the obtained multiple hierarchical rendering results according to a preset rule to obtain a summation result, continuously replaces the target light source data and repeats the above process until all the light source data has completed the rendering process, superimposes the summation results corresponding to each light source data to obtain the superimposed rendering result of the image to be rendered, and sends the superimposed rendering result to the terminal device 101 for presentation to the user. The data storage system 103 provides data storage support for the operation of the server 102, such as storing the code program for executing the above process, as well as storing the data information of multiple light sources, the image to be rendered, and the temporary data obtained during the rendering process.

[0042] Next, in combination with Figure 1 the application scenario, the multi-light-source-based screen rendering method according to the exemplary embodiments of the present application will be described. It should be noted that the above application scenario is only shown for the convenience of understanding the spirit and principle of the present application, and the embodiments of the present application are not limited in this regard. On the contrary, the embodiments of the present application can be applied to any applicable scenario.

[0043] This patent proposes a set of multi-light source-based scene rendering methods, which are mainly applied to servers. Users can adjust the multi-light sources according to their own needs, and use each light source to perform hierarchical rendering on the image to be rendered. In this way, each light source obtains multiple hierarchical rendering results, thus ensuring the diversification of light rendering. Then, the multiple hierarchical rendering results are added according to the preset rules to obtain an added result after light source rendering. Finally, the added results obtained after rendering each target light source data are superimposed to obtain the required superimposed rendering result, meeting the user's artistic requirements for scene rendering without the need for the user to perform other complex processing operations, which is convenient for the user to use.

[0044] The embodiment of the present application provides a multi-light source-based scene rendering method, which can perform light rendering on the scene of an image.

[0045] As Figure 2A shown, based on the above application scenarios, this method can be applied to servers or computer devices. The specific execution process includes:

[0046] Step 201, obtain the data information of the multi-light sources and the image to be rendered.

[0047] Specifically, when implemented, the user can select or set the light sources according to their own needs. Specifically, at least one of the number, position, light intensity, emission color, and emission form of the light sources can be set. After the user's settings are completed, according to the user's settings, obtain the data information corresponding to each light source. Store the data information corresponding to each light source in the database.

[0048] Among them, the data information of the multi-light sources can be obtained first, and then the image to be rendered can be obtained, or the image to be rendered can be obtained first, and then the data information of the multi-light sources can be obtained, or both can be obtained simultaneously. The specific order can be changed according to the actual situation and is not specifically limited here.

[0049] In some embodiments, the types of the multi-light sources include at least one of the following: directional light sources, point light sources, and spot light sources. Specifically, all the multi-light sources can be one of them, the multi-light sources can also be a mixture of two of the above three, or the multi-light sources can be a mixture of the above three.

[0050] In some embodiments, the image to be rendered is an NPR image. This embodiment preferably performs light source rendering on cartoon or game anime characters.

[0051] Step 202, determine at least one target light source data in the data information of the multi-light sources.

[0052] During specific implementation, at least one piece of target light source data obtained through screening can be formed into a queue, and rendering is performed according to the process of the following steps. After each rendering is completed, the rendered target light source data is deleted from the queue. In this way, when the queue is empty, it proves that all the target light source data has been completely rendered.

[0053] In some embodiments, step 202 includes:

[0054] Step 2021, determining the pixel information of the image to be rendered.

[0055] Step 2022, obtaining the light source irradiation range of each light source in the data information of the multiple light sources.

[0056] Step 2023, matching the pixel information with each of the light source irradiation ranges.

[0057] Step 2024, using the data information of the light source corresponding to the pixel information within the light source irradiation range as the target light source data.

[0058] During specific implementation, determine the matching between the image to be rendered and the light source irradiation ranges of each light source, use the data information of the light sources whose all or part of the image to be rendered is within the corresponding light source irradiation ranges as the target light source data, and enter step 203 below to start rendering. For the data information of the light sources outside the light source irradiation ranges, directly stop the rendering process.

[0059] Step 203, using the target light source data to perform multiple renderings on the image to be rendered according to a plurality of preset level rendering strategies to obtain a plurality of hierarchical rendering results, and adding up the obtained plurality of hierarchical rendering results according to a preset rule to obtain an addition result, where each level rendering strategy corresponds to a hierarchical rendering result, and each target light source data corresponds to a plurality of hierarchical rendering results.

[0060] During specific implementation, the specific number of levels for the corresponding hierarchical rendering, as well as the rendering strategies for different levels, can be formulated in advance. In this embodiment, it is preferably divided into two levels, namely important light source rendering and secondary light source rendering.

[0061] After each level of rendering, a hierarchical rendering result can be obtained. The renderings of different levels can be performed simultaneously or in sequence. In this embodiment, for the sake of accelerating the processing speed, it is preferably to perform the renderings simultaneously. The corresponding preset rule can be: adding up the respective hierarchical rendering results according to the corresponding preset ratio (or preset percentage coefficient), or adding up the respective hierarchical rendering results after multiplying them by the corresponding weight coefficients.

[0062] The method of summing according to a preset ratio includes: multiplying each obtained hierarchical rendering result by the preset ratio value corresponding to the corresponding level and then summing them to obtain a summation result. The preset ratio value can be set by the user according to the actual situation of the light source and the situation of light rendering. That is to say, the same preset ratio value can be set for each light source, or different preset ratio values can be set. For example, the rendering result A for rendering the important light source is multiplied by 60%, and the rendering result B for rendering the secondary light source is multiplied by 40%. In this way, the final summation result is A*60% + B*40%. After obtaining the summation result, the summation result can be sent to the display interface for display, and the user can modify and adjust the preset ratio value according to the actual display situation.

[0063] In some embodiments, step 203 includes:

[0064] Step 2030, determine the light source color value in the target light source data, and perform spatial conversion processing on the light source color value for the brightness value according to the preset important conversion parameter or secondary conversion parameter to obtain the important light source color value or the secondary light source color value respectively.

[0065] Specifically, the user can preset the specific values of the important conversion parameter and the secondary conversion parameter according to the actual light rendering requirements. These two parameters are used for spatial conversion processing of the brightness value to ensure that the brightness limit value of the light source will not be overexposed and affect the light rendering result.

[0066] In some embodiments, this step 2030 specifically includes:

[0067] Step 20301, convert the light source color data in the target light source data into HSV (Hue, Saturation, Value) color values.

[0068] Among them, the light source color data is RGB (Red, Green, Blue) color data. The RGB color data is converted into HSV color values according to a preset conversion algorithm, so that the subsequent brightness space conversion can be facilitated using HSV.

[0069] Step 20302, determine the corresponding first conversion function according to the preset important conversion parameter, or determine the corresponding second conversion function according to the preset secondary conversion parameter.

[0070] Specifically, the important conversion parameter or the secondary conversion parameter can be the limit value of the spatial conversion of the brightness value (for example, set to 2). In this way, the curve images corresponding to the determined first conversion function or the second conversion function will infinitely approach but not exceed this limit value. Furthermore, it is ensured that the light rendering will not have the situation of too high brightness and overexposure.

[0071] Step 20303: Perform spatial conversion of the brightness values in the HSV color values according to the first conversion function or the second conversion function respectively to obtain important HSV color values or secondary HSV color values.

[0072] During specific implementation, the following program algorithm can be used for spatial conversion of the brightness values:

[0073]

[0074] The brightness conversion diagram corresponding to the above program is as Figure 2B shown. In the figure, both the abscissa and the ordinate are brightness values. The straight line is the brightness line before conversion, and the curve is the brightness curve after spatial conversion of the brightness values. It can be seen from the brightness curve that as the brightness value increases, the converted brightness value continuously approaches 2, but does not exceed 2.

[0075] After converting the brightness values in the HSV color values according to the first conversion function or the second conversion function respectively in this way, and then replacing the original brightness values in the HSV, important HSV color values and secondary HSV color values are obtained.

[0076] Step 20304: Convert the important HSV color values or the secondary HSV color values into important light source color values or secondary light source color values.

[0077] During specific implementation, convert the obtained important HSV color values and secondary HSV color values back to RGB color data (i.e., important light source color values or secondary light source color values), so as to maintain the hue and saturation of the color.

[0078] Through the above solution, the process of spatial conversion of the brightness values can be completed, so that the brightness corresponding to the important light source and the secondary light source will never exceed the corresponding limit values, making the light of each light source relatively soft, avoiding the situation of too high brightness and overexposure during light source rendering, and further ensuring the artistic effect of light source rendering.

[0079] Step 2031: Use the target light source data to perform important light source rendering processing on the image to be rendered according to the important light source processing strategy to obtain the first rendering result.

[0080] During specific implementation, the types of the target light source data are not distinguished at the beginning. Therefore, for the target light source data, the important light source rendering processing process and the secondary light source rendering processing process can be carried out simultaneously or in sequence. In this embodiment, in order to ensure the speed of light source rendering processing, the two light source rendering processes are selected to be carried out simultaneously.

[0081] In some embodiments, the process of rendering the important light source in step 2031 specifically includes:

[0082] Step 20311: Determine the normal line of the target light source and the light source direction of the target light source according to the target light source data.

[0083] Among them, the normal line of the target light source can be determined according to the position and light-emitting range of the target light source. The light source direction of the target light source is the light direction of the target light source.

[0084] Step 20312: Determine the relative angle between the normal line of the target light source and the light source direction of the target light source.

[0085] Step 20313: Determine the bright surface image and the dark surface image of the image to be rendered according to the relative angle.

[0086] In specific implementation, determine people, animals, plants, and objects in the image to be rendered as rendering objects. For the corresponding rendering objects, the user can specify or select them automatically. If it is automatically selected, all renderable rendering objects will be selected. If it is user-selected, at least one category (for example, people) can be specified from these rendering objects, or manual selection can be made from the rendering objects. It can be specifically set or selected according to actual needs, and the selected rendering objects can also be changed and adjusted.

[0087] After determining the rendering objects, according to the relative angle obtained in the above steps and the rendering positions, determine the bright and dark surfaces of the rendering objects, combine the bright surfaces of all rendering objects together to form a bright surface image, and combine the dark surfaces of all rendering objects together to form a dark surface image.

[0088] Step 20314: Multiply the base color of the bright surface image by the important light source color value to obtain the first rendering result.

[0089] In specific implementation, multiply the base color (for example, RGB value) of each pixel point of the bright surface image by the important light source color value, and combine the pixel points obtained after multiplication to form the first rendering result.

[0090] Through the above solution, the process of rendering the important light source can be completed. For the important light source, the bright surface of the main body needs to be rendered, so that the bright surface can achieve the purpose of brightening the color under the action of the important light source.

[0091] Step 2032: Use the target light source data to perform secondary light source rendering processing on the image to be rendered according to the secondary light source processing strategy to obtain a second rendering result.

[0092] In specific implementation, the secondary light source rendering mainly brightens the colors of some edges that need to be brightened, so that the colors at the edges are not covered by other light sources, thereby improving the aesthetic effect of the overall image.

[0093] In some embodiments, step 2032 includes:

[0094] Step 20321, determining the direction of the perspective space of the target light source according to the target light source data.

[0095] In some embodiments, the direction of the perspective space includes at least one of the following: the upper perspective direction, the lower perspective direction, the left perspective direction, and the right perspective direction.

[0096] In specific implementation, since the perspective of the image itself is divided into four directions: up, down, left, and right, the perspective space of the target light source required for secondary light source rendering is also determined as these four directions, so that the entire image to be rendered can be divided into four parts.

[0097] Step 20322, determining the edge range capable of secondary light source rendering in the image to be rendered according to the direction of the perspective space.

[0098] In specific implementation, the edge ranges in each direction can be determined according to the four directions obtained above. For example, the image within a predetermined area at the end of the selected direction is used as the edge range. And the edge ranges determined in each direction are integrated together.

[0099] Step 20323, multiplying the base color of the edge range by the secondary light source color value to obtain the second rendering result.

[0100] In specific implementation, the base color (for example, RGB value) of each pixel point in the edge range is multiplied by the secondary light source color value, and the pixel points obtained after multiplication are combined to form the second rendering result.

[0101] Through the above solution, the process of secondary light source rendering can be completed. For the secondary light source, edge rendering of the image is required, so that the image at the edge can be brightened in color under the action of the secondary light source.

[0102] Step 2033, adding the first rendering result and the second rendering result according to a preset rule to obtain an addition result.

[0103] Among them, the preset rules can be preset according to actual needs, or after obtaining the first rendering result and the second rendering result, the two can be displayed separately, and the user can then set the corresponding preset rules based on the display results. For example, the preset rule is set to select 50% for the first rendering result and 50% for the second rendering result. In this way, the first rendering result is multiplied by 50%, the second rendering result is multiplied by 50%, and then the two are added together to obtain the sum result.

[0104] In addition, there is no specific order for steps 2031 and 2032. They can be carried out simultaneously or in an orderly manner, and no specific limitation is made here.

[0105] Step 204, in response to determining that all of the at least one target light source data has been completely rendered, superimpose the sum results corresponding to each of the target light source data to obtain the superimposed rendering result of the to-be-rendered image.

[0106] In some embodiments, the method further includes:

[0107] Step 205, if there is a main light source, add the superimposed rendering result to the main light rendering result obtained after rendering the main light source to obtain the final rendering result. If there is no main light source, directly use the superimposed result as the final rendering result.

[0108] Step 205 specifically includes:

[0109] Step 2051, in response to determining that there is main light source data in the data information of the multiple light sources.

[0110] Step 2052, perform main light rendering on the to-be-rendered image using the main light source data to obtain the main light rendering result.

[0111] Step 2053, add the main light rendering result to the superimposed rendering result to obtain the addition result.

[0112] Step 2054, perform brightness value space conversion on the addition result to obtain the final rendering result of the to-be-rendered image.

[0113] Among them, the main light source types include at least one of the following: directional light source, point light source, and spot light source. Generally, in order to imitate sunlight, it is preferred that the main light source is a directional light source.

[0114] The main light source is used to render the whole image, with a relatively high brightening degree. The important light source has a smaller rendering effect than the main light source and is used to assist the main light source in brightening the whole image. The secondary light source is mainly used for rendering the edge range, with the smallest brightening effect. Through the above solution, the rendering results of the three light sources can be accumulated to obtain the final rendering result, making the overall rendering effect of the image better. Moreover, the rendering ratio, light intensity, rendering range, etc. of each light source can be set and adjusted, thus making the finally obtained rendering result more beautiful and simple and convenient to use.

[0115] Through the solutions of the above embodiments, users can adjust multiple light sources according to their own needs, and use each light source to perform hierarchical rendering on the image to be rendered. In this way, each light source corresponds to multiple hierarchical rendering results, thus ensuring the diversity of light rendering. Then, according to the preset rules, the multiple hierarchical rendering results are added together to obtain an added result after the rendering of one light source. Then, the added results obtained after the rendering of each target light source data are superimposed to obtain the required superimposed rendering result, meeting the user's artistic requirements for the picture rendering, without the user having to perform other complex processing operations, which is convenient for the user to use.

[0116] It should be noted that the method of the embodiments of the present application can be executed by a single device, such as a computer or a server, etc. The method of this embodiment can also be applied to a distributed scenario and completed by the cooperation of multiple devices. In this case of a distributed scenario, one of the multiple devices can only execute one or more steps of the method of the embodiments of the present application, and these multiple devices will interact with each other to complete the described method.

[0117] It should be noted that some embodiments of the present application have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be executed in a different order from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0118] Based on the same inventive concept, corresponding to the method for rendering a picture based on multiple light sources in any of the above embodiments, the present application also provides a device for rendering a picture based on multiple light sources.

[0119] Refer to Figure 3 and the device includes:

[0120] An acquisition module 31, configured to acquire data information of multiple light sources and an image to be rendered;

[0121] A determination module 32, configured to determine at least one target light source data in the data information of the multi-light source;

[0122] A rendering module 33, configured to perform multiple renderings on the image to be rendered according to a plurality of preset level rendering strategies by using the target light source data to obtain a plurality of hierarchical rendering results, and sum up the obtained plurality of hierarchical rendering results according to a preset rule to obtain a summation result, where each level rendering strategy corresponds to obtaining a hierarchical rendering result, and each target light source data corresponds to obtaining a plurality of hierarchical rendering results;

[0123] An overlay module 34, configured to determine that all of at least one of the target light source data is rendered, and overlay the summation results corresponding to each of the target light source data to obtain an overlay rendering result of the image to be rendered.

[0124] In some embodiments, the rendering module 33 includes:

[0125] A key light source rendering unit, configured to perform key light source rendering processing on the image to be rendered according to a key light source processing strategy by using the target light source data to obtain a first rendering result; and

[0126] A secondary light source rendering unit, configured to perform secondary light source rendering processing on the image to be rendered according to a secondary light source processing strategy by using the target light source data to obtain a second rendering result;

[0127] A summation unit, configured to sum up the first rendering result and the second rendering result according to a preset rule to obtain a summation result.

[0128] In some embodiments, the key light source rendering unit is specifically configured to:

[0129] Determine the normal line of the target light source and the light source direction of the target light source according to the target light source data; determine the relative angle between the normal line of the target light source and the light source direction of the target light source; determine the bright surface image and the dark surface image of the image to be rendered according to the relative angle; multiply the base color of the bright surface image by the key light source color value to obtain the first rendering result.

[0130] In some embodiments, the secondary light source rendering unit is specifically configured to:

[0131] Determine the direction of the target light source in the view space according to the target light source data; determine the edge range capable of performing secondary light source rendering in the image to be rendered according to the direction of the view space; multiply the base color of the edge range by the secondary light source color value to obtain the second rendering result.

[0132] In some embodiments, the rendering module 33 further includes:

[0133] A brightness conversion processing unit, configured to determine a light source color value in the target light source data, and perform a spatial conversion process on the light source color value according to a preset primary conversion parameter or secondary conversion parameter to obtain a primary light source color value or a secondary light source color value respectively.

[0134] In some embodiments, the brightness conversion processing unit is specifically configured to:

[0135] Convert the light source color data in the target light source data into an HSV color value; determine a corresponding first conversion function according to a preset primary conversion parameter, or determine a corresponding second conversion function according to a preset secondary conversion parameter; perform a spatial conversion on the brightness information in the HSV color value according to the first conversion function or the second conversion function respectively to obtain a primary HSV color value or a secondary HSV color value; perform a color conversion on the primary HSV color value or the secondary HSV color value to convert it into a primary light source color value or a secondary light source color value.

[0136] In some embodiments, the determination module 32 includes:

[0137] A pixel determination unit, configured to determine pixel information of the to-be-rendered image;

[0138] An illumination range acquisition unit, configured to acquire an illumination range of each light source in the data information of the multi-light source;

[0139] A range matching unit, configured to match the pixel information with each of the illumination ranges of the light sources;

[0140] A target light source determination unit, configured to use the data information of the light source corresponding to the pixel information within the illumination range of the light source as the target light source data.

[0141] In some embodiments, the device further includes: a main light rendering result accumulation module, configured to:

[0142] In response to determining that there is main light source data in the data information of the multi-light source; perform main light rendering on the to-be-rendered image using the main light source data to obtain a main light rendering result; accumulate the main light rendering result and the superimposed rendering result to obtain an accumulation result; perform a spatial conversion on the accumulation result for the brightness value to obtain the final rendering result of the to-be-rendered image.

[0143] For convenience of description, when describing the above device, it is divided into various modules according to functions for separate description. Of course, when implementing the present application, the functions of each module can be implemented in one or more software and / or hardware.

[0144] The device of the above embodiments is used to implement the corresponding method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated herein.

[0145] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the method described in any of the above embodiments.

[0146] Figure 4 FIG. shows a more specific schematic diagram of the hardware structure of the electronic device provided in this embodiment. The device may include: a processor 410, a memory 420, an input / output interface 430, a communication interface 440, and a bus 450. Among them, the processor 410, the memory 420, the input / output interface 430, and the communication interface 440 are communicatively connected to each other inside the device through the bus 450.

[0147] The processor 410 may be implemented in a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0148] The memory 420 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory 420 may store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 420 and are called and executed by the processor 410.

[0149] The input / output interface 430 is used to connect to an input / output module to implement information input and output. The input / output module may be configured as a component in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Among them, the input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0150] The communication interface 440 is used to connect to a communication module (not shown in the figure) to achieve communication and interaction between this device and other devices. The communication module can communicate through a wired method (such as USB, network cable, etc.) or through a wireless method (such as mobile network, WIFI, Bluetooth, etc.).

[0151] The bus 450 includes a passage for transmitting information between various components of the device (such as the processor 410, the memory 420, the input / output interface 430, and the communication interface 440).

[0152] It should be noted that although the above device only shows the processor 410, the memory 420, the input / output interface 430, the communication interface 440, and the bus 450, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solution of the embodiments of this specification, and does not necessarily include all the components shown in the figure.

[0153] The electronic device of the above embodiment is used to implement the corresponding multi-light-source-based screen rendering method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0154] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present application also provides a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the multi-light-source-based screen rendering method described in any of the foregoing embodiments.

[0155] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.

[0156] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to execute the method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0157] Those of ordinary skill in the art should understand that: the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the present application (including the claims) is limited to these examples; under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of brevity.

[0158] In addition, for the sake of simplicity of explanation and discussion, and in order not to make the embodiments of the present application difficult to understand, the well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. In addition, the devices may be shown in block diagram form in order not to make the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application are to be implemented (that is, these details should be completely within the understanding of those skilled in the art). In the case where specific details (such as circuits) are set forth to describe the exemplary embodiments of the present application, it will be apparent to those skilled in the art that the embodiments of the present application can be implemented without these specific details or with variations of these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0159] Although the present application has been described in connection with specific embodiments of the present application, many alternatives, modifications, and variations of these embodiments will be apparent to those of ordinary skill in the art based on the foregoing description. For example, other memory architectures (such as dynamic RAM (DRAM)) may be used with the embodiments discussed.

[0160] The embodiments of the present application are intended to cover all such alternatives, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the embodiments of the present application shall be included within the protection scope of the present application.

Claims

1. A method for rendering a picture based on multiple light sources, characterized in that: include: Obtain data information of multiple light sources and images to be rendered; Determine at least one target light source data in the data information of the multiple light sources; Using the target light source data, performing important light source rendering processing on the image to be rendered according to an important light source processing strategy to obtain a first rendering result; as well as Using the target light source data, performing secondary light source rendering processing on the image to be rendered according to a secondary light source processing strategy to obtain a second rendering result; Adding the first rendering result and the second rendering result according to a preset rule to obtain a sum result; wherein each target light source data corresponds to a sum result; In response to determining that at least one of the target light source data has been completely rendered, summation results corresponding to the respective target light source data are superimposed to obtain a superimposed rendering result of the image to be rendered.

2. The method according to claim 1, characterized in that The step of performing important light source rendering processing on the image to be rendered according to an important light source processing strategy using the target light source data to obtain a first rendering result includes: Determine the normal of the target light source and the light source direction of the target light source according to the target light source data; Determining a relative angle between a normal line of the target light source and a light source direction of the target light source; Determining a bright side image and a dark side image of the image to be rendered according to the relative angle; The first rendering result is obtained by multiplying the basic color of the bright surface image by the important light source color value.

3. The method according to claim 1, characterized in that The step of performing secondary light source rendering processing on the image to be rendered according to the secondary light source processing strategy using the target light source data to obtain a second rendering result includes: Determine the direction of the viewing angle space of the target light source according to the target light source data; Determining, according to the direction of the viewing angle space, an edge range in the image to be rendered in which secondary light source rendering can be performed; The base color of the edge range is multiplied by the secondary light source color value to obtain the second rendering result.

4. The method according to claim 3, characterized in that The direction of the viewing space includes at least one of the following: Upward viewing direction, downward viewing direction, left viewing direction and right viewing direction.

5. The method according to claim 2 or 3, characterized in that: The process of determining the color value of the important light source or the color value of the secondary light source includes: The light source color value in the target light source data is determined, and according to a preset important conversion parameter or a secondary conversion parameter, a space conversion process of a brightness value is performed on the light source color value to obtain an important light source color value or a secondary light source color value.

6. The method according to claim 5, characterized in that The determining of the light source color value in the target light source data, and performing a spatial conversion process of the brightness value on the light source color value according to a preset important conversion parameter or a secondary conversion parameter to obtain an important light source color value or a secondary light source color value, includes: Converting the light source color data in the target light source data into HSV color values; Determine a corresponding first conversion function according to a preset important conversion parameter, or determine a corresponding second conversion function according to a preset minor conversion parameter; For the brightness information in the HSV color value, perform spatial conversion of the brightness value according to the first conversion function or the second conversion function to obtain an important HSV color value or a secondary HSV color value; The important HSV color value or the secondary HSV color value is converted into an important light source color value or a secondary light source color value.

7. The method according to claim 1, characterized in that The determining of at least one target light source data in the data information of the multiple light sources comprises: Determining pixel information of the image to be rendered; Acquire the light source illumination range of each light source in the data information of the multiple light sources; Matching the pixel information with the illumination range of each light source; The data information of the light source corresponding to the pixel information within the illumination range of the light source is used as the target light source data.

8. The method according to claim 1, characterized in that Also includes: In response to determining that main light source data exists in the data information of the multiple light sources; Performing main light rendering on the image to be rendered using the main light source data to obtain a main light rendering result; Accumulate the main light rendering result and the superposition rendering result to obtain an accumulation result; The accumulated result is converted into a brightness value space to obtain a final rendering result of the image to be rendered.

9. A picture rendering device based on multiple light sources, characterized in that: include: An acquisition module is used to obtain data information of multiple light sources and images to be rendered; A determination module, used to determine at least one target light source data in the data information of the multiple light sources; A rendering module, configured to perform important light source rendering processing on the image to be rendered according to an important light source processing strategy using the target light source data to obtain a first rendering result; Using the target light source data, performing secondary light source rendering processing on the image to be rendered according to a secondary light source processing strategy to obtain a second rendering result; Adding the first rendering result and the second rendering result according to a preset rule to obtain a sum result; wherein each target light source data corresponds to a sum result; The superposition module is used to determine whether at least one of the target light source data has been fully rendered, and to superimpose the summation results corresponding to the respective target light source data to obtain a superimposed rendering result of the image to be rendered.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.

11. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Game scene rendering method, device and equipment and storage medium

    CN112190936A

  • Multi-point light source illumination rendering method and device, computer equipment and storage medium

    CN114241115A