Cartoon style rendering method and device, electronic equipment and storage medium

By defining the light and shadow boundary and processing the lighting parameters, the problems of lost shadow and lighting layers and multi-light source fusion in cartoon-style rendering were solved, achieving a rendering effect with a hard light and shadow transition and environmental blending.

CN115845369BActive Publication Date: 2026-05-01BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING ZITIAO NETWORK TECH CO LTD
Filing Date
2022-12-27
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing cartoon-style rendering techniques struggle to effectively handle the loss of lighting levels under shadows and the effects of multiple light sources, making it impossible to achieve the sharp transitions between light and shadow and the blending of the environment in a cartoon style.

Method used

By determining the first and second light-dark boundaries and combining direct and indirect lighting parameters, the base color of the target object is processed to enhance the cartoon-style rendering effect.

Benefits of technology

By reducing the recurrence of light and shadow boundaries, the lighting levels of the target object under shadow are clearly defined, allowing it to blend into the surrounding environment and enhancing the rendering effect of the cartoon style.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115845369B_ABST
    Figure CN115845369B_ABST
Patent Text Reader

Abstract

The present disclosure provides a cartoon style rendering method, device, electronic equipment and storage medium, the cartoon style rendering method comprises: obtaining model information, illumination parameter information and shadow information of a target object model; the illumination information comprises direct light illumination parameters and indirect light illumination parameters; determining a first light-dark boundary based on the model information, the direct light illumination parameter information and the shadow information; processing the direct light illumination parameter according to the first light-dark boundary and the indirect light illumination parameter to obtain a target direct light illumination parameter; performing illumination information processing on the base color of the target object based on the target direct light illumination parameter and the indirect light illumination parameter to obtain the diffuse reflection color of the target object, and rendering the target object model based on the diffuse reflection color to obtain the diffuse reflection rendering result of the target object. The present application embodiment can improve the rendering effect of the cartoon rendering style.
Need to check novelty before this filing date? Find Prior Art

Description

Cartoon-style rendering methods, devices, electronic equipment, and storage media Technical Field

[0001] This disclosure relates to the field of model rendering technology, and more specifically, to a cartoon-style rendering method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the continuous development of computer technology, more and more online games are improving user experience by constructing large-scale 3D game scenes and 3D game characters. Different types of games have different game scene styles, and through different stylized rendering, such as realistic rendering and cartoon rendering, rich game scenes and game characters can be presented to users.

[0003] Regardless of the rendering style, lighting and shadow are crucial factors affecting visual effects. Realistic rendering, on the other hand, calculates lighting and shadow based on the model's surface information and the physical properties of light, typically resulting in rich detail and smooth transitions. Cartoon style, however, demands the opposite: on one hand, it requires minimal detail, as excessive detail would disrupt the cleanliness of the image; on the other hand, it demands sharp transitions between light and shadow, with clear and well-defined outlines for shadows and highlights. Therefore, improving the rendering quality of cartoon-style images has been a constant pursuit in the industry. Summary of the Invention

[0004] This disclosure provides at least one cartoon-style rendering method, apparatus, electronic device, and storage medium, which can improve the rendering effect of cartoon-style rendering.

[0005] This disclosure provides a cartoon-style rendering method, including:

[0006] Obtain model information, lighting parameter information, and shadow information of the target object model; the lighting information includes direct light lighting parameters and indirect light lighting parameters;

[0007] Based on the model information, the direct light illumination parameter information, and the shadow information, a first light-dark boundary line is determined; wherein, the shadow information refers to the shadow information generated by other models in the scene to be rendered on the target object model;

[0008] Based on the first light-dark boundary line and the indirect light illumination parameters, the direct light illumination parameters are processed to obtain the target direct light illumination parameters.

[0009] Based on the direct light illumination parameters and the indirect light illumination parameters of the target object, the basic color of the target object is processed to obtain the diffuse color of the target object, and the target object model is rendered based on the diffuse color to obtain the diffuse rendering result of the target object.

[0010] In this embodiment, since the first light-dark boundary line takes shadow information into account, the problem of multiple light-dark boundary lines caused by shadows can be reduced in subsequent rendering processes. Furthermore, by processing the direct light lighting parameters using the first light-dark boundary line and the indirect light lighting parameters, it is possible not only to distinguish whether the target object is in backlight or shadow, but also to integrate the direct lighting with the ambient lighting, thereby allowing the target object to blend into its surroundings and improving the cartoon-style rendering effect.

[0011] In one possible implementation, the model information includes the model surface normal information, and the direct lighting parameters include the direct lighting direction; determining the first light-dark boundary line based on the model information, the direct lighting parameter information, and the shadow information includes:

[0012] Based on the direct lighting parameters, the real-time shadow information generated on the target object model by at least one of the other models in the scene to be rendered is calculated in real time.

[0013] The first light-dark boundary line is determined based on the preset light-dark boundary line function, the model surface normal information, the direct light illumination direction, and the real-time shadow information.

[0014] In this embodiment of the disclosure, by substituting the model surface normal information, the direct light illumination direction, and the shadow information into the preset light-dark boundary function, not only can the determination of the first light-dark boundary be realized, but the determination efficiency of the first light-dark boundary can also be improved.

[0015] In one possible implementation, the direct light illumination parameters include direct light intensity and direct light color, and the indirect light illumination parameters include indirect light intensity; the step of processing the direct light illumination parameters based on the first light-dark boundary line and the indirect light illumination parameters to obtain target direct light illumination parameters includes:

[0016] Based on the first light-dark boundary line and the indirect light intensity, the direct light intensity in the direct light illumination parameters is processed to obtain the target direct light illumination parameters.

[0017] In this embodiment of the disclosure, by processing the direct light intensity in the direct light illumination parameters through indirect light intensity, the light intensity received by the target object can be affected by the ambient light, thereby ensuring that the target object can blend into the surrounding environment.

[0018] In one possible implementation, the indirect light intensity includes the R-channel indirect light intensity, the G-channel indirect light intensity, and the B-channel indirect light intensity; the step of processing the direct light intensity in the direct light illumination parameters based on the first light-dark boundary line and the indirect light intensity to obtain the target direct light illumination parameters includes:

[0019] The maximum light intensity among the indirect light intensity of the R channel, the indirect light intensity of the G channel, and the indirect light intensity of the B channel is taken as the target indirect light intensity.

[0020] The first light-dark boundary line and the indirect light intensity of the target are subjected to difference processing to obtain the difference processing result. Based on the difference processing result, the direct light intensity in the direct light illumination parameters is processed to obtain the direct light illumination parameters of the target.

[0021] In this embodiment of the disclosure, the processing effect of direct light intensity can be improved by using the strongest light intensity among the three RGB channels of indirect light to process the direct light intensity.

[0022] In one possible implementation, before processing the basic color of the target object based on the target direct light illumination parameters and the indirect light illumination parameters to obtain the diffuse color of the target object, the method further includes:

[0023] Based on the model information and the direct light illumination parameter information, the second light-dark boundary line is determined;

[0024] Based on the first light and dark boundary line and the second light and dark boundary line, the base color of the target object is processed to obtain the target base color of the target object.

[0025] The step of processing the basic color of the target object based on the direct light illumination parameters and the indirect light illumination parameters to obtain the diffuse color of the target object includes:

[0026] Based on the target direct light illumination parameters and the indirect light illumination parameters, the target basic color of the target object is processed to obtain the diffuse color of the target object.

[0027] In this embodiment of the disclosure, the basic color of the target object is processed by using the first light and dark boundary line and the second light and dark boundary line to obtain the lighting details of the target object under the shadow, thereby further improving the rendering effect of the cartoon style.

[0028] In one possible implementation, the step of performing shading processing on the base color of the target object based on the first and second shading lines to obtain the target base color of the target object includes:

[0029] Determine the color ratio between the backlight color and the light-receiving color in the base color of the target object. The color ratio is used to indicate the degree of color change of the base color of the target object from the light-receiving side to the backlight side.

[0030] Based on the color ratio and the second light-dark boundary line, the backlight color of the target object under the shadow is processed to further darken the dark part of the backlight color under the shadow, thus obtaining the processed backlight color.

[0031] The target base color of the target object is obtained by performing difference processing on the processed backlight color and the light-receiving color using the first light-dark boundary line.

[0032] In this embodiment of the disclosure, the dark colors under the shadow are further darkened by the color ratio and the second light-dark boundary line, which can ensure the difference between the light and dark colors of the base color. The light color and the processed backlight color are interpolated by the first light-dark boundary line, which can improve the light and dark effect of the base color.

[0033] In one possible implementation, the target object also receives illumination from other light sources, and the method further includes:

[0034] The base color is processed using the illumination parameters of the other light source to obtain other colors, and these other colors are mixed with the diffuse color to obtain the final diffuse color of the target object;

[0035] The rendering of the target object model based on diffuse color to obtain a diffuse rendering result includes:

[0036] The target object model is rendered based on the final diffuse color to obtain the diffuse rendering result of the target object.

[0037] In this embodiment of the disclosure, when other light sources are present, the base color can be processed using the lighting parameters of the other light sources to obtain other colors. Then, the other colors are mixed with the diffuse colors originally obtained from direct and indirect light to obtain the final diffuse color. This makes the rendering effect of the target object present a multi-light source lighting effect, further improving the effect of cartoon-style rendering.

[0038] This disclosure provides a cartoon-style rendering apparatus, including:

[0039] The acquisition module is used to acquire model information, lighting parameter information, and shadow information of the target object model; the lighting information includes direct light lighting parameters and indirect light lighting parameters.

[0040] The determination module is used to determine a first light-dark boundary line based on the model information, the direct light illumination parameter information, and the shadow information; wherein, the shadow information refers to the shadow information generated by other models in the scene to be rendered on the target object model;

[0041] The processing module is used to process the direct light illumination parameters based on the first light-dark boundary line and the indirect light illumination parameters to obtain the target direct light illumination parameters.

[0042] The rendering module is used to process the lighting information of the base color of the target object based on the direct light illumination parameters and the indirect light illumination parameters of the target object, to obtain the diffuse color of the target object, and to render the target object model based on the diffuse color, so as to obtain the diffuse rendering result of the target object.

[0043] In one possible implementation, the model information includes the model surface normal information, and the direct lighting parameters include the direct lighting direction; the determining module is specifically used for:

[0044] Based on the direct lighting parameters, the real-time shadow information generated on the target object model by at least one of the other models in the scene to be rendered is calculated in real time.

[0045] The first light-dark boundary line is determined based on the preset light-dark boundary line function, the model surface normal information, the direct light illumination direction, and the real-time shadow information.

[0046] In one possible implementation, the direct light illumination parameters include direct light intensity and direct light color, and the indirect light illumination parameters include indirect light intensity; the processing module is specifically used for:

[0047] Based on the first light-dark boundary line and the indirect light intensity, the direct light intensity in the direct light illumination parameters is processed to obtain the target direct light illumination parameters.

[0048] In one possible implementation, the indirect light intensity includes the R-channel indirect light intensity, the G-channel indirect light intensity, and the B-channel indirect light intensity; the processing module is specifically used for:

[0049] The maximum light intensity among the indirect light intensity of the R channel, the indirect light intensity of the G channel, and the indirect light intensity of the B channel is taken as the target indirect light intensity.

[0050] The first light-dark boundary line and the indirect light intensity of the target are subjected to difference processing to obtain the difference processing result. Based on the difference processing result, the direct light intensity in the direct light illumination parameters is processed to obtain the direct light illumination parameters of the target.

[0051] In one possible implementation, the determining module is further configured to:

[0052] Based on the model information and the direct light illumination parameter information, the second light-dark boundary line is determined;

[0053] The processing module is also used for:

[0054] Based on the first light and dark boundary line and the second light and dark boundary line, the base color of the target object is processed to obtain the target base color of the target object.

[0055] The rendering module is specifically used for:

[0056] Based on the target direct light illumination parameters and the indirect light illumination parameters, the target basic color of the target object is processed to obtain the diffuse color of the target object.

[0057] In one possible implementation, the processing module is further specifically used for:

[0058] Determine the color ratio between the backlight color and the light-receiving color in the base color of the target object. The color ratio is used to indicate the degree of color change of the base color of the target object from the light-receiving side to the backlight side.

[0059] Based on the color ratio and the second light-dark boundary line, the backlight color of the target object under the shadow is processed to further darken the dark part of the backlight color under the shadow, thus obtaining the processed backlight color.

[0060] The target base color of the target object is obtained by performing difference processing on the processed backlight color and the light-receiving color using the first light-dark boundary line.

[0061] In one possible implementation, the target object also receives illumination from other light sources, and the processing module is further configured to:

[0062] The base color is processed using the illumination parameters of the other light source to obtain other colors, and these other colors are mixed with the diffuse color to obtain the final diffuse color of the target object;

[0063] The rendering module is specifically used for:

[0064] The target object model is rendered based on the final diffuse color to obtain the diffuse rendering result of the target object.

[0065] This disclosure provides an electronic device, including a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the cartoon-style rendering method described in any of the above possible embodiments is executed.

[0066] This disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the cartoon-style rendering method described in any of the possible embodiments above.

[0067] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0068] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.

[0069] Figure 1 shows a flowchart of a cartoon-style rendering method provided by some embodiments of the present disclosure;

[0070] Figure 2 shows a flowchart of another cartoon-style rendering method provided by some embodiments of this disclosure;

[0071] Figure 3 shows a flowchart of a method for processing the color of a target object according to some embodiments of the present disclosure;

[0072] Figure 4 shows a schematic diagram of the part of the target object that is color-processed according to some embodiments of the present disclosure;

[0073] Figure 5 shows a schematic diagram of the structure of a cartoon-style rendering apparatus provided in some embodiments of the present disclosure;

[0074] Figure 6 shows a schematic diagram of an electronic device provided in some embodiments of the present disclosure. Detailed Implementation

[0075] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0076] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0077] In this document, the term "and / or" merely describes a relationship, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0078] Online games are popular due to their high degree of realism, visual appeal, and engaging gameplay. Different types of games have different game scene styles, and by using different stylistic rendering techniques to present rich game scenes, the user experience can be effectively enhanced. Examples include realistic rendering and cartoon-style rendering. Regardless of the rendering style, the rendering of lighting and shadows is a crucial factor affecting the visual effect.

[0079] Realistic lighting can be calculated based on the surface information of the model and the physical properties of light, usually resulting in rich details and smooth transitions. Cartoon style, on the other hand, has the opposite requirements for lighting. On the one hand, it requires that there not be too much detail, as that would destroy the cleanliness of the image. On the other hand, it requires that the transition between light and dark be sharp, with clear and neat outlines for shadows and highlights.

[0080] Research has revealed that current cartoon rendering typically employs physically based rendering combined with hand-drawn cartoon-style textures and stylized post-processing, LUT graph interpolation rendering where shadows are blended into lighting, or dual-texture interpolation rendering where shadows are blended into lighting to achieve a cartoon style. However, while these methods achieve a cartoon style, they have several drawbacks. For example, using physically based rendering combined with hand-drawn cartoon-style textures and stylized post-processing cannot customize the color representation of dark areas and results in multiple light-dark boundaries. Using LUT graph interpolation rendering where shadows are blended into lighting or dual-texture interpolation rendering where shadows are blended into lighting leads to a loss of lighting detail in shadows, does not adequately support multi-light source cartoon effects, and cannot handle the integration of indirect lighting effects in a cartoon style with the environment.

[0081] Based on the above research, this disclosure provides a cartoon-style rendering method. It determines a first light-dark boundary line based on the model information, direct light illumination parameters, and shadow information of the target object model. Then, based on the first light-dark boundary line and the indirect light illumination parameters, it processes the direct light illumination parameters to obtain the target direct light illumination parameters. Next, based on the target direct light illumination parameters and the indirect light illumination parameters, it processes the lighting information of the target object's base color to obtain the diffuse color of the target object. Finally, it renders the target object model based on the diffuse color to obtain the diffuse rendering result of the target object.

[0082] In this embodiment, since the first light-dark boundary line takes shadow information into account, the problem of multiple light-dark boundary lines caused by shadows can be reduced in subsequent rendering processes. Furthermore, by processing the direct light lighting parameters using the first light-dark boundary line and the indirect light lighting parameters, it is possible not only to distinguish whether the target object is in backlight or shadow, but also to integrate the direct lighting with the ambient lighting, thereby allowing the target object to blend into its surroundings and improving the cartoon-style rendering effect.

[0083] To facilitate understanding of this embodiment, the executing entity of the cartoon-style rendering method provided in this disclosure will first be described in detail. The executing entity of the cartoon-style rendering method provided in this disclosure is an electronic device. This electronic device can be a terminal device or a server. The terminal device can also be a mobile device, a user terminal, a terminal, a handheld device, a computing device, an in-vehicle device, a wearable device, etc. The server can be a standalone physical server, 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 storage, big data, and artificial intelligence platforms. In other embodiments, the cartoon-style rendering method can also be implemented by a processor calling computer-readable instructions stored in memory.

[0084] The cartoon-style rendering method provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings. Referring to Figure 1, a flowchart of a cartoon-style rendering method provided in an embodiment of this disclosure is shown. The cartoon-style rendering method includes the following steps S101 to S104:

[0085] S101, obtain the model information, lighting parameter information and shadow information of the target object model; the lighting information includes direct light lighting parameters and indirect light lighting parameters.

[0086] The target object can be a game character, game prop, game object, game building, etc., without limitation. The target object model refers to the model that constitutes the various target objects in the game scene. Specifically, the target object model can be a model designed and created to scale for game characters, game props, game objects, game buildings, etc. For example, according to the type of game model, the target object model can be a scene model, building model, animation model, character model, prop model, particle effect model, etc.; furthermore, according to the form of game model representation, the target object model can include 3D game models, 2D game models, etc.

[0087] For example, the model information of the target object model may include the surface normal information of the model, which is based on vertex information. In some possible embodiments, the model information of the target object model may also include the model's coordinate information, color information, vertex information, primitive information, fragment information, texture information, depth information, etc., without limitation.

[0088] For example, the shadow information can be obtained through a shadow map, which is a grayscale image that identifies the shadow reception at various locations in the target scene. The shadow map stores the shadow information received by each target object, including the shadow information generated by other models in the scene to be rendered on the target object model. That is, the shadow map can be understood as a 2D texture map that uses grayscale to identify the shadow reception of an object, where white represents outside the shadow, black represents inside the shadow, and intermediate grayscale represents the transition part of the shadow. In this embodiment, the shadow information is real-time shadow information, generated through depth comparison under the light's perspective.

[0089] Direct light illumination parameters refer to the illumination parameters of a direct light source. Direct light sources provide illumination information for lighting calculations. Direct light sources are further divided into parallel light sources and point light sources. Indirect light illumination parameters refer to the illumination parameters of an indirect light source, which is a light source formed by the diffuse reflection of light rays from a direct light source by objects in the environment.

[0090] It should be noted that parallel light sources are always present and provide both illumination and shadow information. Other multiple light sources, such as point light sources, only provide illumination information to form the distribution of light and shadow, and do not produce additional shadow information.

[0091] S102, based on the model information, the direct light illumination parameter information and the shadow information, determine the first light-dark boundary line, wherein the shadow information refers to the shadow information generated by other models in the scene to be rendered on the target object model.

[0092] In one possible implementation, the direct lighting parameters include the direct lighting direction; therefore, real-time shadow information generated on the target object model by at least one of the other models in the scene to be rendered can be calculated in real time based on the direct lighting parameters. Then, the first light-dark boundary line is determined based on a preset shading function, the model surface normal information, the direct lighting direction, and the real-time shadow information. The specific code is as follows:

[0093] Shading=f(Normal·Light Direction*Dynamic Shadow)

[0094] Wherein, Shading is the first light-dark boundary line, f(x) is the preset light-dark boundary line function for cartoon-style lighting, Normal is the model surface normal (also known as the object surface normal), Light Direction is the direct light direction, and Dynamic Shadow is the real-time shadow information.

[0095] It should be noted that Normal·Light Direction is the dot product of the lighting direction and the normal to the object's surface. f(Normal·Light Direction) is a further processing of the dot product. For example, Normal·Light Direction can be changed to 0.5*Normal·Light Direction+0.5 of the semi-Lambertian lighting, or a step(0.5, N·L) process can be performed to obtain the light and shadow boundary.

[0096] In this step, the lighting results are linearly interpolated to a relatively hard first light-dark boundary line. That is, the soft light-dark transition is limited to the hard first light-dark boundary line, which can ensure the hardness of the cartoon rendering style.

[0097] S103, based on the first light-dark boundary line and the indirect light illumination parameters, the direct light illumination parameters are processed to obtain the target direct light illumination parameters.

[0098] In one possible implementation, the direct light illumination parameters include direct light intensity and direct light color, and the indirect light illumination parameters include indirect light intensity; the step of processing the direct light illumination parameters based on the first light-dark boundary line and the indirect light illumination parameters to obtain the target direct light illumination parameters includes: processing the direct light intensity in the direct light illumination parameters based on the first light-dark boundary line and the indirect light illumination intensity to obtain the target direct light illumination parameters.

[0099] In this embodiment of the disclosure, by processing the direct light intensity in the direct light illumination parameters through indirect light intensity, the light intensity received by the target object can be affected by the ambient light. That is, the direct light intensity can be adjusted according to the brightness of the surrounding environment so that the direct light intensity blends into the surrounding environment, thereby ensuring that the rendering effect of the target object can blend into the surrounding environment.

[0100] For example, the indirect light intensity includes the R-channel indirect light intensity, the G-channel indirect light intensity, and the B-channel indirect light intensity; when processing the direct light intensity in the direct light parameters based on the first light-dark boundary line and the indirect light intensity to obtain the target direct light parameters, the following (1) to (2) may be included:

[0101] (1) Take the maximum light intensity among the indirect light intensity of the R channel, the indirect light intensity of the G channel, and the indirect light intensity of the B channel as the target indirect light intensity;

[0102] (2) Perform difference processing on the first light-dark boundary line and the indirect light intensity of the target to obtain the difference processing result, and process the direct light intensity in the direct light illumination parameters based on the difference processing result to obtain the direct light illumination parameters of the target.

[0103] Specifically, since the indirect light intensity includes three color channels (RGB channels), after obtaining the indirect light intensity, it is necessary to determine the maximum light intensity from the light intensities corresponding to each of the three color channels, and use the maximum light intensity among the three color channels as the target indirect light intensity. The specific implementation code is as follows:

[0104] Channel Max=max(Indirect Light.r,Indirect Light.g,Indirect Light.b)

[0105] Wherein, Channel Max is the target indirect light intensity, Indirect Light.r is the indirect light intensity of the R channel, Indirect Light.g is the indirect light intensity of the G channel, and Indirect Light.b is the indirect light intensity corresponding to the B channel.

[0106] After determining the target indirect light intensity, the direct light intensity parameters can be processed using the target indirect light intensity. Optionally, the difference between the first light-dark boundary line and the target indirect light intensity can be processed first, and then the direct light intensity can be processed based on the difference processing result. The specific code is as follows:

[0107] Light Color GI=lerp(Channel Max,1,Shading)*Light Color

[0108] Wherein, Light Color GI is the target direct light illumination parameter (including intensity and color), lerp is the interpolation function, Channel Max is the target indirect light illumination intensity, Shading is the first light-dark boundary line, and Light Color is the direct light illumination parameter (direct light illumination intensity and color).

[0109] In this embodiment, after processing, the light intensity received by the bright parts of the target object remains unchanged, while the light intensity received by the dark parts is the direct light intensity multiplied by the highest brightness of the surrounding environment. This causes the light intensity of the dark parts to be affected by the environment. That is, the first light-dark boundary line can be used to determine whether the target object is in shadow. If it is in shadow, the light intensity of the shadowed part (dark part) will be changed by the indirect light intensity (ambient light brightness), thus causing the dark parts of the target object to blend into its environment and improving the cartoon rendering effect.

[0110] S104, based on the target direct light illumination parameters and the indirect light illumination parameters, perform illumination information processing on the base color of the target object to obtain the diffuse color of the target object, and render the target object model based on the diffuse color to obtain the diffuse rendering result of the target object.

[0111] For example, after obtaining the direct light illumination parameters of the target, the base color of the target object can be processed based on the direct light illumination parameters and the indirect light illumination parameters to obtain the diffuse reflection color of the target object. Diffuse reflection is the result of mixing the object's base color with ambient light, representing the display effect of the object's base color on the illuminated and shaded sides.

[0112] The specific implementation code is as follows:

[0113] Color=Albedo Color*(Light Color GI+Indirect Light)

[0114] Where Albedo Color is the base color of the target object, Light Color GI is the direct light illumination parameter of the target, Indirect Light is the indirect light illumination parameter, and Color is the diffuse color.

[0115] After obtaining the diffuse color, the target object model can be rendered based on the diffuse color to obtain the diffuse rendering result of the target object. In this embodiment, since the first light-dark boundary line takes shadow information into account, the problem of multiple light-dark boundary lines caused by shadows can be reduced in subsequent rendering processes. In addition, by processing the direct light lighting parameters through the first light-dark boundary line and the indirect light lighting parameters, it is not only possible to distinguish whether the target object is in backlight or shadow, but also to integrate the direct lighting with the ambient lighting, thereby allowing the target object to blend into the surrounding environment and improving the cartoon-style rendering effect.

[0116] Referring to Figure 2, which is a flowchart of another cartoon-style rendering method provided in an embodiment of this disclosure, the method includes the following steps S201 to S206:

[0117] S201, Obtain model information, lighting parameter information, and shadow information of the target object model; the lighting information includes direct light lighting parameters and indirect light lighting parameters.

[0118] This step is similar to the aforementioned step S101, and will not be described again here.

[0119] S202, based on the model information, the direct light illumination parameter information, and the shadow information, determine the first light-dark boundary line; wherein, the shadow information refers to the shadow information generated by other models in the scene to be rendered on the target object model.

[0120] This step is similar to step S102 mentioned above, and will not be described again here.

[0121] S203, based on the first light-dark boundary line and the indirect light illumination parameters, the direct light illumination parameters are processed to obtain the target direct light illumination parameters.

[0122] This step is similar to step S103 mentioned above, and will not be described again here.

[0123] S204, Based on the model information and the direct light illumination parameter information, determine the second light-dark boundary line.

[0124] For example, similar to the method for determining the first light-dark boundary line, the second light-dark boundary line can be obtained based on a preset light-dark boundary line function, the model surface normal information, and the direct light illumination direction. Since shadow information is not involved in this process, the second light-dark boundary line is a light-dark boundary line that does not consider real-time shadows. The specific implementation code is as follows:

[0125] Shading NS=f(Normal·Light Direction)

[0126] Where Shading NS is the second light-dark boundary line, f(x) is the preset light-dark boundary line function for cartoon-style lighting, Normal is the surface normal of the model, and Light Direction is the direct light direction.

[0127] S205, based on the first light and dark dividing line and the second light and dark dividing line, perform light and dark processing on the base color of the target object to obtain the target base color of the target object.

[0128] For example, the base color of the target object can be processed based on the first light-dark boundary line and the second light-dark boundary line to obtain different colors of the target object in the light and dark parts.

[0129] Specifically, referring to Figure 3, for step S205, when performing light and dark processing on the base color of the target object based on the first light and dark boundary line and the second light and dark boundary line to obtain the target base color of the target object, the following steps S2051 to S2053 may be included:

[0130] S2051, determine the color ratio between the backlight color and the light-receiving color in the base color of the target object, wherein the color ratio is used to indicate the degree of color change of the base color of the target object from the light-receiving side to the backlight side.

[0131] Specifically, the color ratio of the backlight color and the light-receiving color can be determined first by using the backlight color map and the light-receiving color map of the target object. This color ratio is used to indicate the degree of color change of the base color of the target object from the light-receiving side to the backlight side. The specific code is as follows:

[0132] Tex Scale=Darkness Color / max(Brightness Color,0.01)

[0133] Wherein, Tex Scale is the color ratio of backlight color to light-receiving color, Darkness Color is the backlight color, and Brightness Color is the light-receiving color.

[0134] In this step, the difference between the illuminated surface texture and the backlit surface texture can be used to obtain the variation coefficient TexScale. In other words, this coefficient can be used to know the color change difference of the target object when it transitions from the illuminated surface to the backlit surface.

[0135] S2052, based on the color ratio and the second light-dark boundary line, the backlight color of the target object under the shadow is processed to further darken the dark part of the backlight color under the shadow, so as to obtain the processed backlight color.

[0136] For example, referring to Figure 4, the backlight color can be processed according to the second light-dark boundary line to further darken the dark color B1 in the backlight color. That is, in this process, the dark color A1 in the light-receiving direction under the shadow does not change, while the dark color B1 in the backlight direction under the shadow is further compressed. The specific implementation code is as follows:

[0137] Darkness Color=Darkness Color*lerp(Tex Scale,1,Shading NS)

[0138] Among them, Shading NS is the second light-dark boundary line, Tex Scale is the color ratio of backlight color and light-receiving color, and Darkness Color is the backlight color.

[0139] S2053, the first light-dark dividing line is used to perform difference processing on the processed backlight color and the light-receiving color to obtain the target base color of the target object.

[0140] For example, the target base color of the target object can be obtained by performing difference processing on the backlight color and the light-receiving color in the base color of the target object using a first light-dark boundary line. The specific code is as follows:

[0141] Albedo Color=lerp(Darkness Color,Brightness Color,Shading)

[0142] Among them, Albedo Color is the target base color, Darkness Color is the backlight color, Brightness Color is the light-receiving color, and Shading is the first light-dark boundary line.

[0143] It should be noted that, in different embodiments, Albedo Color can represent the unprocessed base color of the target object, or it can represent the processed base color of the target object.

[0144] In this embodiment, the dark colors under the shadow are further darkened by the color ratio and the second light-dark boundary line, which can ensure the difference between the light and dark colors of the base color. The light color and the processed backlight color are interpolated by the first light-dark boundary line, which can improve the light and dark effect of the base color.

[0145] S206, based on the target direct light illumination parameters and the indirect light illumination parameters, perform illumination information processing on the target basic color of the target object to obtain the diffuse reflection color of the target object.

[0146] This step is similar to step S104 mentioned above, and will not be described again here.

[0147] The rendering method in this embodiment differs from the rendering method in Figure 1 in that it also determines a second light-dark boundary line that does not consider shadows, and further uses the first light-dark boundary line and the second light-dark boundary line to perform light and dark processing on the base color of the target object, so that the dark color of the target object in the light-receiving direction under shadow does not change, while the dark color in the backlight direction in the shadow is further darkened, thereby obtaining the lighting details of the target object under shadow, and further improving the cartoon-style rendering effect.

[0148] In some possible implementations, the target object also receives illumination from other light sources; that is, in scenarios where multiple light sources exist in the target scene, the method further includes the following:

[0149] The base color is processed using the illumination parameters of the other light source to obtain other colors, and these other colors are mixed with the diffuse color to obtain the final diffuse color of the target object; then, the target object model is rendered based on the final diffuse color to obtain the diffuse rendering result of the target object.

[0150] In other words, in the presence of other light sources, diffuse color can be further processed, as shown in the following code:

[0151] Color+=Albedo Color Other Light;

[0152] Here, Albedo Color is the base color of the target object (or the target base color), Other Light is the lighting parameters of other light sources (including color and intensity), and Color is the diffuse color.

[0153] In this embodiment of the disclosure, when other light sources are present, the base color (or target base color) of the target object can be processed using the lighting parameters of the other light sources to obtain other colors. Then, the other colors are mixed with the diffuse colors originally obtained from direct and indirect light to obtain the final diffuse color. This makes the rendering effect of the target object present a multi-light source lighting effect, further improving the effect of cartoon-style rendering.

[0154] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0155] Based on the same technical concept, this disclosure also provides a cartoon-style rendering device corresponding to the cartoon-style rendering method. Since the principle of the device in this disclosure is similar to the cartoon-style rendering method described above, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0156] Referring to Figure 5, which is a schematic diagram of a cartoon-style rendering device 500 provided in an embodiment of this disclosure, the device includes:

[0157] The acquisition module 501 is used to acquire model information, lighting parameter information, and shadow information of the target object model; the lighting information includes direct light lighting parameters and indirect light lighting parameters.

[0158] The determining module 502 is used to determine a first light-dark boundary line based on the model information, the direct light illumination parameter information, and the shadow information; wherein, the shadow information refers to the shadow information generated by other models in the scene to be rendered on the target object model;

[0159] Processing module 503 is used to process the direct light illumination parameters based on the first light-dark boundary line and the indirect light illumination parameters to obtain the target direct light illumination parameters.

[0160] The rendering module 504 is used to process the lighting information of the base color of the target object based on the direct light illumination parameters and the indirect light illumination parameters of the target object, to obtain the diffuse color of the target object, and to render the target object model based on the diffuse color, so as to obtain the diffuse rendering result of the target object.

[0161] In one possible implementation, the model information includes the model surface normal information, and the direct lighting parameters include the direct lighting direction; the determining module 502 is specifically used for:

[0162] Based on the direct lighting parameters, the real-time shadow information generated on the target object model by at least one of the other models in the scene to be rendered is calculated in real time.

[0163] The first light-dark boundary line is determined based on the preset light-dark boundary line function, the model surface normal information, the direct light illumination direction, and the real-time shadow information.

[0164] In one possible implementation, the direct light illumination parameters include direct light intensity and direct light color, and the indirect light illumination parameters include indirect light intensity; the processing module 503 is specifically used for:

[0165] Based on the first light-dark boundary line and the indirect light intensity, the direct light intensity in the direct light illumination parameters is processed to obtain the target direct light illumination parameters.

[0166] In one possible implementation, the indirect light intensity includes the R-channel indirect light intensity, the G-channel indirect light intensity, and the B-channel indirect light intensity; the processing module 503 is specifically used for:

[0167] The maximum light intensity among the indirect light intensity of the R channel, the indirect light intensity of the G channel, and the indirect light intensity of the B channel is taken as the target indirect light intensity.

[0168] The first light-dark boundary line and the indirect light intensity of the target are subjected to difference processing to obtain the difference processing result. Based on the difference processing result, the direct light intensity in the direct light illumination parameters is processed to obtain the direct light illumination parameters of the target.

[0169] In one possible implementation, the determining module 502 is further configured to:

[0170] Based on the model information and the direct light illumination parameter information, the second light-dark boundary line is determined;

[0171] The processing module 503 is further configured to:

[0172] Based on the first light and dark boundary line and the second light and dark boundary line, the base color of the target object is processed to obtain the target base color of the target object.

[0173] The rendering module 504 is specifically used for:

[0174] Based on the target direct light illumination parameters and the indirect light illumination parameters, the target basic color of the target object is processed to obtain the diffuse color of the target object.

[0175] In one possible implementation, the processing module 503 is further specifically used for:

[0176] Determine the color ratio between the backlight color and the light-receiving color in the base color of the target object. The color ratio is used to indicate the degree of color change of the base color of the target object from the light-receiving side to the backlight side.

[0177] Based on the color ratio and the second light-dark boundary line, the backlight color of the target object under the shadow is processed to further darken the dark part of the backlight color under the shadow, thus obtaining the processed backlight color.

[0178] The target base color of the target object is obtained by performing difference processing on the processed backlight color and the light-receiving color using the first light-dark boundary line.

[0179] In one possible implementation, the target object also receives illumination from other light sources, and the processing module 503 is further configured to:

[0180] The base color is processed using the illumination parameters of the other light source to obtain other colors, and these other colors are mixed with the diffuse color to obtain the final diffuse color of the target object;

[0181] The rendering module 504 is specifically used for:

[0182] The target object model is rendered based on the final diffuse color to obtain the diffuse rendering result of the target object.

[0183] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.

[0184] Based on the same technical concept, this disclosure also provides an electronic device. Referring to FIG6, which is a schematic diagram of the structure of the electronic device 600 provided in this disclosure, it includes a processor 601, a memory 602, and a bus 603. The memory 602 is used to store execution instructions and includes a main memory 6021 and an external memory 6022. The main memory 6021, also called internal memory, is used to temporarily store computational data in the processor 601, as well as data exchanged with external memory 6022 such as a hard disk. The processor 601 exchanges data with the external memory 6022 through the main memory 6021.

[0185] In this embodiment, the memory 602 is specifically used to store application code that executes the solution of this application, and its execution is controlled by the processor 601. That is, when the electronic device 600 is running, the processor 601 communicates with the memory 602 through the bus 603, so that the processor 601 executes the application code stored in the memory 602, and then executes the method described in any of the foregoing embodiments.

[0186] The memory 602 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0187] Processor 601 may be an integrated circuit chip with signal processing capabilities. The aforementioned processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application-Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor.

[0188] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 600. In other embodiments of this application, the electronic device 600 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0189] This disclosure also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the cartoon-style rendering method described in the above-described method embodiments. The storage medium can be either volatile or non-volatile computer-readable storage.

[0190] This disclosure also provides a computer program product carrying program code. The program code includes instructions that can be used to execute the steps of the cartoon-style rendering method in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.

[0191] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.

[0192] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0193] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0194] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0195] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.

[0196] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A cartoon-style rendering method, characterized in that, include: Obtain model information, lighting parameters, and shadow information of the target object model; The illumination parameter information includes direct light illumination parameters and indirect light illumination parameters; Based on the model information, the direct light illumination parameters, and the shadow information, a first light-dark boundary line is determined; wherein, the shadow information refers to the shadow information generated by other models in the scene to be rendered on the target object model; based on the first light-dark boundary line and the indirect light illumination parameters, the direct light illumination parameters are processed to obtain the target direct light illumination parameters; Based on the direct light illumination parameters and the indirect light illumination parameters of the target object, the basic color of the target object is processed to obtain the diffuse color of the target object, and the target object model is rendered based on the diffuse color to obtain the diffuse rendering result of the target object.

2. The method according to claim 1, characterized in that, The model information includes the model surface normal information, and the direct light illumination parameters include the direct light illumination direction. Determining the first light-dark boundary line based on the model information, the direct light illumination parameters, and the shadow information includes: calculating real-time shadow information generated on the target object model by at least one of the other models in the scene to be rendered based on the direct light illumination parameters; and determining the first light-dark boundary line based on a preset light-dark boundary line function, the model surface normal information, the direct light illumination direction, and the real-time shadow information.

3. The method according to claim 1, characterized in that, The direct light illumination parameters include direct light intensity and direct light color, and the indirect light illumination parameters include indirect light intensity. The step of processing the direct light illumination parameters based on the first light-dark boundary line and the indirect light illumination parameters to obtain the target direct light illumination parameters includes: processing the direct light intensity in the direct light illumination parameters based on the first light-dark boundary line and the indirect light intensity to obtain the target direct light illumination parameters.

4. The method according to claim 3, characterized in that, The indirect light intensity includes the R-channel indirect light intensity, the G-channel indirect light intensity, and the B-channel indirect light intensity. The step of processing the direct light intensity in the direct light illumination parameters based on the first light-dark boundary and the indirect light intensity to obtain the target direct light illumination parameters includes: taking the maximum intensity among the R-channel indirect light intensity, the G-channel indirect light intensity, and the B-channel indirect light intensity as the target indirect light intensity; performing a difference processing on the first light-dark boundary and the target indirect light intensity to obtain a difference processing result; and processing the direct light intensity in the direct light illumination parameters based on the difference processing result to obtain the target direct light illumination parameters.

5. The method according to claim 1, characterized in that, Before processing the base color of the target object based on the target direct light illumination parameters and the indirect light illumination parameters to obtain the diffuse color of the target object, the method further includes: determining a second light-dark boundary line based on the model information and the direct light illumination parameters; processing the base color of the target object based on the first light-dark boundary line and the second light-dark boundary line to obtain the target base color of the target object; the process of processing the base color of the target object based on the target direct light illumination parameters and the indirect light illumination parameters to obtain the diffuse color of the target object includes: processing the target base color of the target object based on the target direct light illumination parameters and the indirect light illumination parameters to obtain the diffuse color of the target object.

6. The method according to claim 5, characterized in that, The step of processing the base color of the target object based on the first and second light-dark boundary lines to obtain the target base color of the target object includes: determining the color ratio between the backlight color and the illuminated color in the base color of the target object, wherein the color ratio is used to indicate the degree of color change of the base color of the target object from the illuminated side to the backlight side; processing the backlight color of the target object under shadow based on the color ratio and the second light-dark boundary line to further darken the dark part of the backlight color under shadow, thereby obtaining the processed backlight color; and performing difference processing on the processed backlight color and the illuminated color using the first light-dark boundary line to obtain the target base color of the target object.

7. The method according to claim 1, characterized in that, The target object also receives illumination from other light sources. The method further includes: processing the base color using the illumination parameters of the other light sources to obtain other colors, and mixing the other colors with the diffuse color to obtain the final diffuse color of the target object; rendering the target object model based on the diffuse color to obtain a diffuse rendering result includes: rendering the target object model based on the final diffuse color to obtain the diffuse rendering result of the target object.

8. A cartoon-style rendering device, characterized in that, include: The acquisition module is used to acquire model information, lighting parameters, and shadow information of the target object model; The illumination parameter information includes direct light illumination parameters and indirect light illumination parameters; A determination module is used to determine a first light-dark boundary line based on the model information, the direct light illumination parameters, and the shadow information; wherein, the shadow information refers to the shadow information generated by other models in the scene to be rendered on the target object model; a processing module is used to process the direct light illumination parameters based on the first light-dark boundary line and the indirect light illumination parameters to obtain the target direct light illumination parameters; a rendering module is used to process the lighting information of the base color of the target object based on the target direct light illumination parameters and the indirect light illumination parameters to obtain the diffuse color of the target object, and render the target object model based on the diffuse color to obtain the diffuse rendering result of the target object.

9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the cartoon-style rendering method as described in any one of claims 1-7 is performed.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the cartoon-style rendering method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Virtual vegetation making method and device, electronic equipment and storage medium

    CN110124318A

  • Rendering method and device, electronic equipment and storage medium

    CN113052947A