Stylized rendering method and device, computer program product and electronic equipment
By using multi-channel input and lighting calculation of preset color information in stylized rendering, the problem of lack of personalization and inapplicability of stylized rendering in the prior art is solved, and high personalization and dynamic adaptation rendering is achieved Effect.
Patent Information
- Application Number
- CN202411876081.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-02-18
AI Technical Summary
Existing stylized rendering techniques lack personalization and are not suitable for dynamic environments.
By inputting the preset bright surface color information into the first color channel of the buffer and the preset dark surface color information into the second color channel, lighting calculation is performed to obtain the light and shadow rendering result of the target object model.
It realizes the simple color level light and dark distinction between specific objects in the scene, improves the personalization of stylized rendering, supports dynamic lighting changes, and is suitable for dynamic environments.
Smart Images

Figure CN119478193A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a stylized rendering method, a stylized rendering device, a computer program product, and an electronic device. Background Art
[0002] Stylized rendering is a rendering style that is different from realistic rendering. It achieves unique visual effects by simplifying details and enhancing artistic effects.
[0003] In related technologies, the following two methods are usually used to achieve stylized rendering: the first is to use post-processing materials to segment the scene's lighting to achieve a simplified light and dark contrast effect. Since post-processing is usually applied to the entire scene, all objects will be subjected to the same cartoon processing and lack personalization; the second is to use the normal and light source direction to calculate the light intensity in the Unlit material, and then divide it into two or more discrete color levels, corresponding to different colors or brightness. Since the Unlit material does not support dynamic lighting and shadows, it cannot respond to changes in the light source in the scene, which limits its use in dynamic environments.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] The present disclosure provides a stylized rendering method, a stylized rendering device, a computer program product and an electronic device, so as to at least to some extent solve the problems in the related art such as lack of personalization and unsuitability for dynamic environments.
[0006] According to a first aspect of the present disclosure, a stylized rendering method is provided, the method comprising: inputting preset bright surface color information into a first color channel of a buffer to control the bright surface color of a target object model through the first color channel; inputting preset dark surface color information into a second color channel of the buffer to control the backlight surface color and the projection area color of the target object model through the second color channel; performing illumination calculation based on the preset bright surface color information input into the first color channel and the preset dark surface color information input into the second color channel to obtain a light and shadow rendering result of the target object model.
[0007] According to a second aspect of the present disclosure, a stylized rendering device is provided, comprising: a first color channel input module, used to input preset bright surface color information into a first color channel of a buffer zone, so as to control the bright surface color of a target object model through the first color channel; a second color channel input module, used to input preset dark surface color information into a second color channel of the buffer zone, so as to control the backlight surface color and the projection area color of the target object model through the second color channel; and an illumination calculation module, used to perform illumination calculation based on the preset bright surface color information input into the first color channel and the preset dark surface color information input into the second color channel, so as to obtain a light and shadow rendering result of the target object model.
[0008] According to a third aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the stylized rendering method of the first aspect and possible implementation manners thereof are implemented.
[0009] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the stylized rendering method of the first aspect and its possible implementation methods by executing the executable instructions.
[0010] The technical solution disclosed in this disclosure has the following beneficial effects:
[0011] In the above-mentioned stylized rendering process, the preset bright surface color information is input into the first color channel of the buffer to control the bright surface color of the target object model through the first color channel; the preset dark surface color information is input into the second color channel of the buffer to control the backlight surface color and the projection area color of the target object model through the second color channel; based on the preset bright surface color information input into the first color channel and the preset dark surface color information input into the second color channel, lighting calculation is performed to obtain the light and shadow rendering result of the target object model. The present invention inputs preset bright surface color information into the first color channel of the buffer, controls the bright surface color of the target object model through the first color channel, inputs preset dark surface color information into the second color channel of the buffer, controls the backlight surface color and the projection area color of the target object model through the second color channel, can achieve simple color level distinction between light and dark for specific objects in the scene, thereby enhancing the personalization of stylized rendering, and can achieve free control of dark results, ensuring that the backlight surface and the projection area appear more unified and coordinated in the rendering, thereby meeting the visual effects of a specific artistic style; by performing lighting calculations through the preset bright surface color information and the preset dark surface color information stored in the first color channel and the second color channel, the model can support changes in light sources in the scene and is suitable for dynamic environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 A flowchart of a stylized rendering method in this exemplary embodiment is shown;
[0013] Figure 2 A flowchart of illumination calculation in this exemplary embodiment is shown;
[0014] Figure 3 A flow chart for calculating a first diffuse reflection value in this exemplary embodiment is shown;
[0015] Figure 4 A light and shadow rendering flow chart integrating a backlight surface and a projection surface in this exemplary embodiment is shown;
[0016] Figure 5A A schematic diagram of model rendering in which a backlight surface color and a projection color of a fused model are shown in this exemplary embodiment;
[0017] Figure 5B Another schematic diagram of model rendering that fuses the backlight surface color and projection color of the model in this exemplary embodiment is shown;
[0018] Figure 5C A schematic diagram showing a method of setting a dark surface portion of a model as a map in this exemplary embodiment is shown;
[0019] Figure 6 A structural block diagram of a stylized rendering device in this exemplary embodiment is shown;
[0020] Figure 7 An electronic device for implementing the above-mentioned stylized rendering method in this exemplary embodiment is shown. DETAILED DESCRIPTION
[0021] Exemplary embodiments of the present disclosure will be described more fully hereinafter with reference to the accompanying drawings.
[0022] The accompanying drawings are schematic diagrams of the present disclosure and are not necessarily drawn to scale. Some of the block diagrams shown in the accompanying drawings may be functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in hardware modules or integrated circuits, or in networks, processors or microcontrollers. The embodiments can be implemented in various forms and should not be construed as being limited to the examples set forth herein. The features, structures or characteristics described in the present disclosure may be combined in one or more embodiments in any suitable manner. In the description below, many specific details are provided to provide a full description of the embodiments of the present disclosure. However, those skilled in the art should appreciate that one or more specific details may be omitted when implementing the technical solution of the present disclosure, or one or more specific details may be replaced by other methods, components, devices, steps, etc.
[0023] In the related art, post-processing materials are used to segment the scene's lighting to achieve a simplified chiaroscuro effect. Since post-processing is usually applied to the entire scene, all objects will be subjected to the same cartoon-like processing, lacking in individuality; since post-processing may increase the complexity of the rendering pipeline, especially in high-resolution or complex scenes, it may lead to performance degradation; since post-processing is performed after rendering is completed, some details (such as texture details) may be over-simplified or lost; since transparency is usually difficult to control accurately in the post-processing stage, post-processing may produce inconsistent or unexpected effects when processing transparent objects.
[0024] In the related technology, in the Unlit material, the light intensity is calculated using the normal and the light source direction, and then divided into two or more discrete color levels, corresponding to different colors or brightness. Since the Unlit material does not support dynamic lighting and shadows, it cannot respond to changes in light sources in the scene, which limits its use in dynamic environments; it is necessary to manually implement lighting calculations in the material, which may increase development complexity; and may result in a lack of layers and depth in the rendering results.
[0025] In view of one or more of the above problems, exemplary embodiments of the present disclosure provide a stylized rendering method, a stylized rendering apparatus, a computer program product, and an electronic device.
[0026] In an optional embodiment, reference Figure 1 As shown, a flowchart of a stylized rendering method is provided, which specifically includes the following steps S110 to S130:
[0027] Step S110, inputting preset bright surface color information into the first color channel of the buffer, so as to control the bright surface color of the target object model through the first color channel;
[0028] Step S120, inputting the preset dark surface color information into the second color channel of the buffer, so as to control the backlight surface color and the projection area color of the target object model through the second color channel;
[0029] Step S130, performing illumination calculation based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel, to obtain a light and shadow rendering result of the target object model.
[0030] Figure 1 In the method shown, preset bright surface color information is input into the first color channel of the buffer, and the bright surface color of the target object model is controlled through the first color channel. Preset dark surface color information is input into the second color channel of the buffer, and the backlight surface color and the projection area color of the target object model are controlled through the second color channel. Simple color gradations of light and dark distinction can be achieved for specific objects in the scene, thereby enhancing the personalization of stylized rendering, and free control of dark results can be achieved, ensuring that the backlight surface and the projection area appear more unified and coordinated in the rendering, thereby meeting the visual effects of a specific artistic style; lighting calculation is performed through the preset bright surface color information and the preset dark surface color information stored in the first color channel and the second color channel, so that the model can support changes in light sources in the scene and is suitable for dynamic environments.
[0031] Below Figure 1 Provide detailed instructions for each step.
[0032] In step S110, preset bright surface color information is input into a first color channel of a buffer, so as to control the bright surface color of the target object model through the first color channel.
[0033] The target object model may be any model object in the scene, such as a building model, a character model, a prop model, etc., which is not specifically limited in the present disclosure. It should be noted that the target object model may be a transparent model or a non-transparent model, which is not specifically limited in the present disclosure.
[0034] Among them, the buffer (such as Gbuffer) can be a buffer used to store scene geometry information in deferred rendering, which may include but is not limited to a base color channel, a normal channel, a roughness channel, a subsurface color channel, etc.
[0035] The first color channel is a color channel in the buffer, and may be a channel storing basic color information of the target object model, that is, a basic color channel. The preset bright surface color information may be passed into the first color channel, and the bright surface shading information of the target object model may be controlled through the first color channel, thereby controlling the color effect of the bright surface of the target object model.
[0036] The preset bright surface color information may be a pre-set parameter for controlling the bright surface color, which provides parameter support for the custom configuration of the bright surface color of the target object model.
[0037] In step S120, the preset dark surface color information is input into the second color channel of the buffer, so as to control the backlight surface color and the projection area color of the target object model through the second color channel.
[0038] The preset dark surface color information may be a pre-set parameter for controlling the backlight surface color and the projection area color, which provides parameter support for the customized configuration of the backlight surface color and the projection area color of the target object model.
[0039] Optionally, preset dark side color information can be configured through material parameters in the engine, and the preset dark side color information can be input into the second color channel to control the backlight surface color and the projection area color of the target object model through the second color channel, thereby controlling the color effect of the backlight surface of the target object model and the color effect of the projection area.
[0040] Exemplarily, the color of the projection area of the target object model can be controlled by using the second color channel through the shader code of the running engine.
[0041] The backlit surface and the projection area of the target object model share the preset dark surface color information, so that the user can flexibly control the display effect of the dark area of the model.
[0042] The second color channel is a color channel in the buffer, and may be a channel storing subsurface color information of the target object model, that is, a subsurface color channel.
[0043] After the geometry processing stage of deferred rendering is completed, step S130 may be executed to perform the illumination processing stage to perform illumination calculations on each pixel on the screen to avoid repeated calculations of geometric bodies that are not rendered on the screen. The geometry processing stage renders the geometric information in the scene (such as vertex information, normals, texture coordinates, etc. of the target object model) into a buffer to collect the geometric information of the scene and prepare for subsequent illumination calculations.
[0044] In step S130, based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel, illumination calculation is performed to obtain a light and shadow rendering result of the target object model.
[0045] Specifically, the lighting calculation can be performed based on the color channels stored in the buffer to obtain the light and shadow rendering result of the target object model.
[0046] In an optional implementation, the above-mentioned illumination calculation is performed based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel to obtain the light and shadow rendering result of the target object model, such as Figure 2 As shown, this can be achieved by following the steps below:
[0047] Step S210, performing diffuse reflection illumination calculation based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the illumination parameter information of the target light source to obtain a first diffuse reflection value under the target light source;
[0048] Step S220, for the projection area of the target object model, based on the preset dark surface color information input in the second color channel, diffuse reflection illumination calculation is performed to obtain a second diffuse reflection value of the projection area;
[0049] Step S230, rendering the target object model based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area to obtain a light and shadow rendering result of the target object model.
[0050] Figure 2 In the steps shown, the backlight surface and the projection area of the target object model share the preset dark surface color information, which can achieve light and dark distinction with simple color levels.
[0051] The target light source illumination parameter information may include but is not limited to the illumination direction, illumination attenuation parameters, light source color, etc. of the target light source, which is not specifically limited in the present disclosure. The target light source refers to the light source in the scene, which may include but is not limited to light sources of various forms, such as non-rectangular light sources.
[0052] The first diffuse reflection value is the diffuse reflection result of the target object model under the influence of light, and the second diffuse reflection value is the diffuse reflection result of the projection area of the target object model under the condition of considering projection.
[0053] Exemplarily, the lighting accumulation result of the target object model can be obtained by accumulating the first diffuse reflection value, the second diffuse reflection value and / or other lighting effects of the target object model, so that the target object model can be rendered based on the lighting accumulation result of the target object model to obtain the light and shadow rendering result of the target object model.
[0054] Optionally, the first color channel may be a channel for basic color information of the target object model; the second color channel may be a channel for subsurface color information of the target object model, so as to perform lighting calculation based on the basic color information and subsurface color information of the target object model, thereby being applicable to various lighting calculation scenarios.
[0055] In an optional embodiment, the above-mentioned diffuse reflection illumination calculation is performed based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the illumination parameter information of the target light source to obtain the first diffuse reflection value under the target light source, which can be achieved by the following steps: based on the first color channel, color information is extracted to obtain basic color information of the target object model; the basic color information includes the preset bright surface color information input in the first color channel; based on the second color channel, color information is extracted to obtain sub-surface color information of the target object model; the sub-surface color information includes the preset dark surface color information input in the second color channel; based on the model surface normal of the target object model and the illumination direction of the target light source, a shadow factor is determined; the shadow factor is used to characterize the bright surface and the backlight surface of the target object model; based on the shadow factor, the sub-surface color information of the target object model, and the basic color information of the target object model, a diffuse reflection illumination calculation is performed to determine the first diffuse reflection value of the target object model under the target light source.
[0056] The basic color information of the target object model is used to describe the basic color information of the target object model material itself.
[0057] The subsurface color information of the target object model is used to describe information about light scattering inside the target object model.
[0058] The shadow factor is an important parameter that affects whether a point is illuminated. For example, if the shadow factor of the point is greater than a preset threshold, the point can be considered to be located on the bright side; if the shadow factor of the point is less than or equal to the preset threshold, the point can be considered to be located on the backlit side.
[0059] Exemplarily, basic color information of the target object model, namely preset bright surface color information, may be extracted based on the first color channel; and sub-surface color information of the target object model, namely preset dark surface color information, may be extracted based on the second color channel.
[0060] In actual application, the data output to the first color channel of a single material (which may include preset bright surface color information) can be written into the diffuse color buffer (i.e., GBuffer.DiffuseColor) to obtain the basic color information of the target object model through the diffuse color buffer. Among them, GBuffer.DiffuseColor can write the data of the basic color channel of all objects on the screen.
[0061] In actual application, the subsurface color information of the target object model in the buffer can be extracted by calling the ExtractSubsurfaceColor() function, that is, the preset dark surface color information input in the second color channel, so as to simulate the effect of light scattering inside the target object model.
[0062] Exemplarily, the shadow factor can be determined based on the dot product of each normal vector on the target object model and the light vector. The shadow factor is used to control the bright surface and the backlight surface of the target object model, and the illumination intensity can be divided into two color levels, so that the target object model presents a light and dark contrast effect that conforms to the cartoon style. Specifically, the dot product of each normal vector on the target object model and the light vector can be input into the smoothstep() smooth interpolation function to determine the shadow factor.
[0063] The shadow factor is used to control the bright side and backlight side of the target object model. Based on the basic color information of the target object model (i.e., the preset bright side color information) and the sub-surface color information of the target object model (i.e., the preset dark side color information), the shadow factor can control the bright side color and backlight side color of the target object model through the diffuse reflection illumination model.
[0064] In an optional implementation, the diffuse reflection illumination calculation based on the shadow factor, the sub-surface color information of the target object model, and the basic color information of the target object model to determine the first diffuse reflection value of the target object model under the target light source can be achieved by the following steps: determining the interpolation factor according to the surface shadow parameter of the target object model and the shadow factor; performing linear interpolation calculation on the sub-surface color information of the target object model and the basic color information of the target object model based on the interpolation factor to obtain an interpolation result; performing diffuse reflection illumination calculation according to the interpolation result and the illumination parameter information of the target light source to determine the first diffuse reflection value of the target object model under the influence of the surface shadow.
[0065] Among them, the surface shadow parameters of the target object model define the surface properties of the shadow and can be used to control the surface effect of the model shadow.
[0066] Exemplarily, the interpolation factor may be determined according to the surface shadow intensity and shadow factor of the target object model; and the sub-surface color information and basic color information of the target object model may be linearly interpolated based on the interpolation factor using the lerp() function to obtain an interpolation result.
[0067] Exemplarily, when performing diffuse reflection illumination calculation based on the interpolation result and illumination parameter information of the target light source to determine the first diffuse reflection value of the target object model under the influence of surface shadow, the Lambert illumination model can be used to calculate the first diffuse reflection value of the target object model under the influence of surface shadow.
[0068] In actual application, the following code can be configured in the shadingmodels.ush file to determine the first diffuse reflection value of the target object model under the influence of surface shadows. Among them: the shadingmodels.ush file can be used to process the light and shadow changes of the model itself, that is, the surface shadows.
[0069] float shadow=smoothstep(0.0,0.05,NoL)*Shadow.SurfaceShadow;
[0070] float3 DarkColor=ExtractSubsurfaceColor(GBuffer);
[0071] Lighting.Diffuse=Diffuse_Lambert(lerp(DarkColor,GBuffer.DiffuseColor,shadow)*Falloff*AreaLight.FalloffColor).
[0072] Among them, Shadow.SurfaceShadow represents the surface shadow parameters of the target object model, NoL represents the dot product of the normal and the light direction, the smoothstep() function is used to smoothly interpolate NoL to obtain the shadow factor, shadow represents the interpolation factor, GBuffer represents the buffer zone, the ExtractSubsurfaceColor() function is used to extract the subsurface color, DarkColor represents the subsurface color extracted from GBuffer, that is, the preset dark surface color information, GBuffer.DiffuseColor represents the buffer zone of the diffuse reflection color; the lerp() function is used to implement linear interpolation, Falloff represents light attenuation, AreaLight.FalloffColor represents the light source color, the Diffuse_Lambert() function is the Lambert lighting model used for diffuse reflection calculation, and Lighting.Diffuse represents the diffuse reflection value of the target object model under the influence of surface shadow.
[0073] The lerp() interpolation function simplifies lighting calculations, improves rendering efficiency, and reduces computational complexity while maintaining the artistic style.
[0074] For example, Figure 3 As shown, a flow chart for calculating the first diffuse reflection value is provided, which may specifically include the following steps:
[0075] Step S301, determining a shadow factor based on a model surface normal of a target object model and an illumination direction of a target light source;
[0076] Step S302, determining an interpolation factor based on the surface shadow parameter and shadow factor of the target object model;
[0077] Step S303, based on the interpolation factor, performing linear interpolation calculation on the sub-surface color information of the target object model and the basic color information of the target object model to obtain an interpolation result;
[0078] Step S304: perform diffuse reflection illumination calculation according to the interpolation result and illumination parameter information of the target light source to determine a first diffuse reflection value of the target object model under the influence of the surface shadow.
[0079] In an optional embodiment, the above-mentioned diffuse reflection illumination calculation is performed for the projection area of the target object model based on the preset dark surface color information input in the second color channel to obtain the second diffuse reflection value of the projection area, which can be achieved by the following steps: color information is extracted based on the second color channel to obtain sub-surface color information of the target object model; the sub-surface color information includes the preset dark surface color information input in the second color channel; the projection area of the target object model is determined, and for the projection area of the target object model, diffuse reflection illumination calculation is performed based on the sub-surface color information of the target object model to obtain the second diffuse reflection value.
[0080] The projection area of the target object model refers to the range of shadows cast by other objects received by the target object model, which can be determined by the light angle and the model position in the scene, and the present disclosure does not make any specific limitations on this.
[0081] Specifically, sub-surface color extraction can be performed based on the second color channel to obtain sub-surface color information, that is, preset dark side color information; for the projection area of the target object model, diffuse reflection lighting calculation can be performed based on the sub-surface color information of the target object model to obtain the second diffuse reflection value of the target object model in the projection area, so as to achieve flexible control of the shading information of the projection area of the target object model.
[0082] Exemplarily, in the lighting calculation stage, the subsurface color information of the target object model in the buffer, that is, the preset dark surface color information, can be extracted by calling the ExtractSubsurfaceColor() function.
[0083] Optionally, for the projection area of the target object model, based on the sub-surface color information of the target object model, a Lambert illumination model may be used to perform diffuse reflection illumination to calculate the second diffuse reflection value of the target object model.
[0084] Exemplarily, the following code may be configured in the DeferredLightingCommon.ush file to determine the second diffuse reflection value of the target object model for the projection area.
[0085] float3 DarkColor=ExtractSubsurfaceColor(GBuffer);
[0086] Lighting.Diffuse=Diffuse_Lambert(DarkColor).
[0087] Among them, GBuffer represents the buffer zone, the ExtractSubsurfaceColor() function is used to extract the subsurface color, DarkColor represents the subsurface color extracted from GBuffer, that is, the preset dark surface color information, the Diffuse_Lambert() function is the Lambert model used for diffuse reflection calculation, and Lighting.Diffuse is the second diffuse reflection value of the target object model for the projection area.
[0088] In an optional embodiment, the above-mentioned rendering of the target object model based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area to obtain the light and shadow rendering result of the target object model can be achieved through the following steps: rendering the target object model based on the first diffuse reflection value under the target light source to obtain the first light and shadow rendering result of the target object model; rendering the target object model based on the second diffuse reflection value of the projection area on the basis of the first light and shadow rendering result of the target object model to obtain the second light and shadow rendering result of the target object model.
[0089] The first light and shadow rendering result is the rendering effect of the bright surface and the backlight surface under the target light source, and the second light and shadow rendering result is the effect of rendering the projection area based on the first light and shadow rendering result.
[0090] After rendering the target object model based on the first diffuse reflection value under the target light source, the target object model is rendered again based on the second diffuse reflection value of the projection area, so as to achieve fusion of the backlight surface color and the projection area color.
[0091] For example, Figure 4 As shown, a light and shadow rendering flow chart integrating the backlight surface and the projection surface is provided, which specifically includes the following steps:
[0092] Step S401, inputting preset bright surface color information into the first color channel of the buffer;
[0093] Step S402, inputting the preset dark surface color information into the second color channel of the buffer;
[0094] Step S403, performing diffuse reflection illumination calculation based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the illumination parameter information of the target light source to obtain a first diffuse reflection value under the target light source;
[0095] Step S404, for the projection area of the target object model, based on the preset dark surface color information input in the second color channel, diffuse reflection illumination calculation is performed to obtain a second diffuse reflection value of the projection area;
[0096] Step S405 , rendering the target object model based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area to obtain a light and shadow rendering result of the target object model.
[0097] Figure 4 In the steps shown, lighting calculation is performed during the model rendering process, which can ensure that the model details are not over-simplified, support dynamic lighting and projection, and enhance the level and depth of the rendering results.
[0098] The present disclosure can be implemented based on the existing UE engine by modifying its shader code and material blueprint. Exemplarily, the subsurface mode can be modified by modifying the ShadingModels.ush file and the DeferredLightingCommon.ush file in the shader code. Among them, the shadingmodels.ush file can be used to process the light and shadow changes of the object itself, that is, self-shadowing; the DeferredLightingCommon.ush file can be used to process projections. In the UE engine, the corresponding material ball can be set on the target object model, and the shading model of the material can be set to the subsurface mode, so that the color information of the subsurface color channel can be used as the color information of the backlight surface and the projection area. Among them, the material blueprint is a visual tool for creating and editing materials in UE (UnrealEngine), which allows developers to define the appearance and behavior of materials through node graphs. In the present disclosure, the lighting effect can be customized through the material blueprint.
[0099] For example, Figure 5A As shown, a schematic diagram of model rendering that integrates the model backlight surface color and projection color is provided, wherein the projection color displayed in the square mark is the same as the model backlight surface color displayed in the circle mark.
[0100] Optionally, the projection color and the backlight color can be changed by customizing the preset dark side color information to meet the needs of different artistic styles, such as Figure 5BAs shown, another schematic diagram of model rendering is provided for fusing the backlight surface color and projection color of the model.
[0101] Optional, such as Figure 5C As shown, a schematic diagram of setting the dark surface part of a model as a map is provided, so as to add self-shadowing and / or projection on the target object model through the map of the dark surface part of the model.
[0102] The exemplary embodiment of the present disclosure also provides a stylized rendering device, referring to Figure 6 As shown, the stylized rendering device 600 may include the following program modules:
[0103] A first color channel input module 610, used for the first color channel input module, is used to input preset bright surface color information into the first color channel of the buffer to control the bright surface color of the target object model through the first color channel;
[0104] A second color channel input module 620, used to input preset dark surface color information into a second color channel of the buffer, so as to control the backlight surface color and the projection area color of the target object model through the second color channel;
[0105] The illumination calculation module 630 is used to perform illumination calculation based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel to obtain the light and shadow rendering result of the target object model.
[0106] In an optional embodiment, based on the above-mentioned scheme, the lighting calculation module 630 includes: a first diffuse reflection determination module, which is used to perform diffuse reflection lighting calculation based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the lighting parameter information of the target light source, and obtain a first diffuse reflection value under the target light source; a second diffuse reflection determination module, which is used to perform diffuse reflection lighting calculation for the projection area of the target object model based on the preset dark surface color information input in the second color channel, and obtain a second diffuse reflection value of the projection area; and a fusion rendering module, which is used to render the target object model based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area, and obtain a light and shadow rendering result of the target object model.
[0107] In an optional implementation, based on the above solution, the first color channel is a channel for basic color information of the target object model; and the second color channel is a channel for sub-surface color information of the target object model.
[0108] In an optional embodiment, based on the above scheme, the first diffuse reflection determination module includes: a first information extraction module, which is used to extract color information based on the first color channel to obtain basic color information of the target object model; the basic color information includes preset bright surface color information input by the first color channel; a second information extraction module, which is used to extract color information based on the second color channel to obtain sub-surface color information of the target object model; the sub-surface color information includes preset dark surface color information input by the second color channel; a shadow factor determination module, which is used to determine the shadow factor based on the model surface normal of the target object model and the illumination direction of the target light source; the shadow factor is used to characterize the bright surface and backlight surface of the target object model; a diffuse reflection calculation module, which is used to perform diffuse reflection lighting calculation based on the shadow factor, the sub-surface color information of the target object model, and the basic color information of the target object model, and determine the first diffuse reflection value of the target object model under the target light source.
[0109] In an optional embodiment, based on the aforementioned scheme, the diffuse reflection calculation module includes: determining an interpolation factor according to the surface shadow parameters and the shadow factor of the target object model; performing linear interpolation calculation on the sub-surface color information of the target object model and the basic color information of the target object model based on the interpolation factor to obtain an interpolation result; performing diffuse reflection illumination calculation according to the interpolation result and the illumination parameter information of the target light source to determine the first diffuse reflection value of the target object model under the influence of the surface shadow.
[0110] In an optional embodiment, based on the aforementioned scheme, the second diffuse reflection determination module can be configured to: extract color information based on the second color channel to obtain sub-surface color information of the target object model; the sub-surface color information includes preset dark side color information input by the second color channel; determine the projection area of the target object model, and perform diffuse reflection lighting calculation for the projection area of the target object model based on the sub-surface color information of the target object model to obtain a second diffuse reflection value.
[0111] In an optional embodiment, based on the aforementioned scheme, the fusion rendering module can be configured to: render the target object model based on the first diffuse reflection value under the target light source to obtain a first light and shadow rendering result of the target object model; based on the first light and shadow rendering result of the target object model, render the target object model based on the second diffuse reflection value of the projection area to obtain a second light and shadow rendering result of the target object model.
[0112] The specific details of each part of the above-mentioned device have been described in detail in the implementation method of the method part. The undisclosed details can be found in the implementation method of the method part, so they will not be repeated here.
[0113] The exemplary embodiments of the present disclosure also provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, the stylized rendering method is implemented.
[0114] In one embodiment, the computer program product may be a tangible product containing a computer program, such as a computer-readable storage medium storing a computer program. The readable storage medium may be a storage medium based on electrical, magnetic, optical, electromagnetic, infrared, or other signals, including but not limited to: random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory (Flash), mechanical hard disk (HDD), solid-state drive (SSD), and the like. Exemplarily, the computer program product may be implemented as a non-volatile storage medium storing a computer program, such as a read-only memory, a NAND flash memory, and the like.
[0115] In one embodiment, the computer program product may be an intangible product including a computer program. Exemplarily, the computer program product may be implemented as a virtual digital product, such as a digital file storing an executable file, an installation package, etc. of the computer program.
[0116] The code of the computer program can be written in one or more programming languages. Programming languages such as C language, Java, C++, etc. The program code can be executed entirely on the user computing device, or partially on the user computing device, or as a separate software package, or partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, such as a local area network (LAN), a wide area network (WAN), etc., or can be connected to an external computing device (e.g., an Internet connection provided by an operator).
[0117] The computer program may be carried or transmitted via electrical, magnetic, optical, electromagnetic, infrared, or other signals. The electronic device may convert the signal carrying the computer program into a digital signal, thereby running the computer program. When the computer program is run on an electronic device, its code is used to enable the electronic device to execute (more specifically, the processor of the electronic device may execute) the method steps of various exemplary embodiments of the present disclosure. Exemplarily, the following steps may be included:
[0118] Inputting preset bright surface color information into a first color channel of the buffer to control the bright surface color of the target object model through the first color channel;
[0119] Inputting the preset dark surface color information into the second color channel of the buffer, so as to control the backlight surface color and the projection area color of the target object model through the second color channel;
[0120] Based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel, illumination calculation is performed to obtain a light and shadow rendering result of the target object model.
[0121] In an optional embodiment, based on the aforementioned scheme, the above-mentioned lighting calculation is performed based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel to obtain the light and shadow rendering result of the target object model, which can be achieved through the following steps: based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the lighting parameter information of the target light source, diffuse reflection lighting calculation is performed to obtain a first diffuse reflection value under the target light source; for the projection area of the target object model, based on the preset dark surface color information input in the second color channel, diffuse reflection lighting calculation is performed to obtain a second diffuse reflection value of the projection area; based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area, the target object model is rendered to obtain the light and shadow rendering result of the target object model.
[0122] In an optional implementation, based on the above solution, the first color channel is a channel for basic color information of the target object model; and the second color channel is a channel for sub-surface color information of the target object model.
[0123] In an optional embodiment, based on the aforementioned scheme, the above-mentioned diffuse reflection illumination calculation is performed based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the illumination parameter information of the target light source to obtain the first diffuse reflection value under the target light source, which can be achieved by the following steps: based on the first color channel, color information is extracted to obtain basic color information of the target object model; the basic color information includes the preset bright surface color information input in the first color channel; based on the second color channel, color information is extracted to obtain sub-surface color information of the target object model; the sub-surface color information includes the preset dark surface color information input in the second color channel; based on the model surface normal of the target object model and the illumination direction of the target light source, a shadow factor is determined; the shadow factor is used to characterize the bright surface and the backlight surface of the target object model; based on the shadow factor, the sub-surface color information of the target object model, and the basic color information of the target object model, a diffuse reflection illumination calculation is performed to determine the first diffuse reflection value of the target object model under the target light source.
[0124] In an optional embodiment, based on the aforementioned scheme, the diffuse reflection lighting calculation is performed based on the shadow factor, the sub-surface color information of the target object model, and the basic color information of the target object model to determine the first diffuse reflection value of the target object model under the target light source. This can be achieved by the following steps: determining the interpolation factor according to the surface shadow parameters of the target object model and the shadow factor; performing linear interpolation calculation on the sub-surface color information of the target object model and the basic color information of the target object model based on the interpolation factor to obtain an interpolation result; performing diffuse reflection lighting calculation according to the interpolation result and the lighting parameter information of the target light source to determine the first diffuse reflection value of the target object model under the influence of the surface shadow.
[0125] In an optional embodiment, based on the aforementioned scheme, the above-mentioned diffuse reflection illumination calculation is performed for the projection area of the target object model based on the preset dark surface color information input in the second color channel to obtain the second diffuse reflection value of the projection area, which can be achieved by the following steps: based on the second color channel, color information is extracted to obtain sub-surface color information of the target object model; the sub-surface color information includes the preset dark surface color information input in the second color channel; the projection area of the target object model is determined, and for the projection area of the target object model, a diffuse reflection illumination calculation is performed based on the sub-surface color information of the target object model to obtain the second diffuse reflection value.
[0126] In an optional embodiment, based on the aforementioned scheme, the target object model is rendered based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area to obtain the light and shadow rendering result of the target object model. This can be achieved by the following steps: based on the first diffuse reflection value under the target light source, the target object model is rendered to obtain the first light and shadow rendering result of the target object model; based on the first light and shadow rendering result of the target object model, the target object model is rendered based on the second diffuse reflection value of the projection area to obtain the second light and shadow rendering result of the target object model.
[0127] In the above steps, the preset bright surface color information is input into the first color channel of the buffer, and the bright surface color of the target object model is controlled through the first color channel. The preset dark surface color information is input into the second color channel of the buffer, and the backlight surface color and the projection area color of the target object model are controlled through the second color channel. This can achieve simple color gradation distinction between light and dark for specific objects in the scene, thereby enhancing the personalization of stylized rendering, and achieving free control of dark results, ensuring that the backlight surface and the projection area appear more unified and coordinated in the rendering, thereby meeting the visual effects of a specific artistic style; by performing lighting calculations using the preset bright surface color information and the preset dark surface color information stored in the first color channel and the second color channel, the model can support changes in light sources in the scene and is suitable for dynamic environments.
[0128] The exemplary embodiment of the present disclosure also provides an electronic device capable of implementing the above-mentioned stylized rendering method. The electronic device may include a processor and a memory. The memory stores executable instructions of the processor, such as program code. The processor executes the method in the exemplary embodiment by executing the executable instructions. In addition, the electronic device may also include a display for displaying a graphical user interface.
[0129] Reference below Figure 7 , the electronic device is exemplarily described in the form of a general-purpose computing device. It should be understood that Figure 7 The electronic device 700 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0130] like Figure 7 As shown, the electronic device 700 may include: a processor 710 , a memory 720 , a bus 730 , an I / O (input / output) interface 740 , a network adapter 750 , and a display 760 .
[0131] The memory 720 may include a volatile memory, such as a RAM 721, a cache unit 722, and may also include a non-volatile memory, such as a ROM 723. The memory 720 may also include one or more program modules 724, such program modules 724 include but are not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or a combination thereof may include the implementation of a network environment. For example, the program module 724 may include each module in the above-mentioned device.
[0132] The processor 710 may include one or more processing units. For example, the processor 710 may include an AP (Application Processor), a modem processor, a GPU (Graphics Processing Unit), an ISP (Image Signal Processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor), a baseband processor and / or an NPU (Neural-Network Processing Unit), etc.
[0133] The processor 710 may be configured to execute executable instructions stored in the memory 720 , such as executing any one or more method steps in the exemplary embodiment.
[0134] Exemplarily, the processor 710 may perform the following steps:
[0135] Inputting preset bright surface color information into a first color channel of the buffer to control the bright surface color of the target object model through the first color channel;
[0136] Inputting the preset dark surface color information into the second color channel of the buffer, so as to control the backlight surface color and the projection area color of the target object model through the second color channel;
[0137] Based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel, illumination calculation is performed to obtain a light and shadow rendering result of the target object model.
[0138] In an optional embodiment, based on the aforementioned scheme, the above-mentioned lighting calculation is performed based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel to obtain the light and shadow rendering result of the target object model, which can be achieved through the following steps: based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the lighting parameter information of the target light source, diffuse reflection lighting calculation is performed to obtain a first diffuse reflection value under the target light source; for the projection area of the target object model, based on the preset dark surface color information input in the second color channel, diffuse reflection lighting calculation is performed to obtain a second diffuse reflection value of the projection area; based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area, the target object model is rendered to obtain the light and shadow rendering result of the target object model.
[0139] In an optional implementation, based on the above solution, the first color channel is a channel for basic color information of the target object model; and the second color channel is a channel for sub-surface color information of the target object model.
[0140] In an optional embodiment, based on the aforementioned scheme, the above-mentioned diffuse reflection illumination calculation is performed based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the illumination parameter information of the target light source to obtain the first diffuse reflection value under the target light source, which can be achieved by the following steps: based on the first color channel, color information is extracted to obtain basic color information of the target object model; the basic color information includes the preset bright surface color information input in the first color channel; based on the second color channel, color information is extracted to obtain sub-surface color information of the target object model; the sub-surface color information includes the preset dark surface color information input in the second color channel; based on the model surface normal of the target object model and the illumination direction of the target light source, a shadow factor is determined; the shadow factor is used to characterize the bright surface and the backlight surface of the target object model; based on the shadow factor, the sub-surface color information of the target object model, and the basic color information of the target object model, a diffuse reflection illumination calculation is performed to determine the first diffuse reflection value of the target object model under the target light source.
[0141] In an optional embodiment, based on the aforementioned scheme, the diffuse reflection lighting calculation is performed based on the shadow factor, the sub-surface color information of the target object model, and the basic color information of the target object model to determine the first diffuse reflection value of the target object model under the target light source. This can be achieved by the following steps: determining the interpolation factor according to the surface shadow parameters of the target object model and the shadow factor; performing linear interpolation calculation on the sub-surface color information of the target object model and the basic color information of the target object model based on the interpolation factor to obtain an interpolation result; performing diffuse reflection lighting calculation according to the interpolation result and the lighting parameter information of the target light source to determine the first diffuse reflection value of the target object model under the influence of the surface shadow.
[0142] In an optional embodiment, based on the aforementioned scheme, the above-mentioned diffuse reflection illumination calculation is performed for the projection area of the target object model based on the preset dark surface color information input in the second color channel to obtain the second diffuse reflection value of the projection area, which can be achieved by the following steps: based on the second color channel, color information is extracted to obtain sub-surface color information of the target object model; the sub-surface color information includes the preset dark surface color information input in the second color channel; the projection area of the target object model is determined, and for the projection area of the target object model, a diffuse reflection illumination calculation is performed based on the sub-surface color information of the target object model to obtain the second diffuse reflection value.
[0143] In an optional embodiment, based on the aforementioned scheme, the target object model is rendered based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area to obtain the light and shadow rendering result of the target object model. This can be achieved by the following steps: based on the first diffuse reflection value under the target light source, the target object model is rendered to obtain the first light and shadow rendering result of the target object model; based on the first light and shadow rendering result of the target object model, the target object model is rendered based on the second diffuse reflection value of the projection area to obtain the second light and shadow rendering result of the target object model.
[0144] The bus 730 is used to realize the connection between different components of the electronic device 700, and may include a data bus, an address bus, and a control bus.
[0145] The electronic device 700 can communicate with one or more external devices 800 (eg, a keyboard, a mouse, an external controller, etc.) through the I / O interface 740 .
[0146] The electronic device 700 can communicate with one or more networks through the network adapter 750. For example, the network adapter 750 can provide mobile communication solutions such as 3G / 4G / 5G, or wireless communication solutions such as wireless LAN, Bluetooth, near field communication, etc. The network adapter 750 can communicate with other modules of the electronic device 700 through the bus 730.
[0147] The electronic device 700 may display a graphical user interface and the like through the display 760 .
[0148] although Figure 7 Not shown, other hardware and / or software modules may also be provided in the electronic device 700, including but not limited to: a display, a microcode, a device driver, a redundant processor, an external disk drive array, a RAID (Redundant Arrays of Independent Disks) system, a tape drive, and a data backup storage system.
[0149] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the exemplary embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0150] It will be appreciated by those skilled in the art that various aspects of the present disclosure may be implemented as a system, method or program product. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software aspects, which may be collectively referred to herein as a "circuit", "module" or "system". Those skilled in the art will readily think of other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses or adaptive changes of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and implementation are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0151] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A stylized rendering method, characterized in that: The method comprises: Inputting preset bright surface color information into a first color channel of the buffer to control the bright surface color of the target object model through the first color channel; Inputting the preset dark surface color information into the second color channel of the buffer, so as to control the backlight surface color and the projection area color of the target object model through the second color channel; Based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel, illumination calculation is performed to obtain a light and shadow rendering result of the target object model.
2. The method according to claim 1, characterized in that The step of performing illumination calculation based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel to obtain the light and shadow rendering result of the target object model includes: Based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the illumination parameter information of the target light source, diffuse reflection illumination calculation is performed to obtain a first diffuse reflection value under the target light source; For the projection area of the target object model, based on the preset dark surface color information input in the second color channel, diffuse reflection illumination calculation is performed to obtain a second diffuse reflection value of the projection area; The target object model is rendered based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area to obtain a light and shadow rendering result of the target object model.
3. The method according to claim 2, characterized in that The first color channel is a channel for basic color information of the target object model; and the second color channel is a channel for sub-surface color information of the target object model.
4. The method according to claim 3, characterized in that The step of performing diffuse reflection illumination calculation based on the preset bright surface color information input in the first color channel, the preset dark surface color information input in the second color channel, and the illumination parameter information of the target light source to obtain a first diffuse reflection value under the target light source includes: Based on the first color channel, color information is extracted to obtain basic color information of the target object model; the basic color information includes the preset bright surface color information input by the first color channel; Based on the second color channel, color information is extracted to obtain sub-surface color information of the target object model; the sub-surface color information includes the preset dark surface color information input by the second color channel; Determine a shadow factor based on a model surface normal of the target object model and an illumination direction of the target light source; the shadow factor is used to characterize a bright surface and a backlit surface of the target object model; Based on the shadow factor, the subsurface color information of the target object model, and the basic color information of the target object model, diffuse reflection lighting calculation is performed to determine a first diffuse reflection value of the target object model under the target light source.
5. The method according to claim 4, characterized in that The performing diffuse reflection illumination calculation based on the shadow factor, the subsurface color information of the target object model, and the basic color information of the target object model to determine a first diffuse reflection value of the target object model under the target light source includes: Determining an interpolation factor according to the surface shadow parameter of the target object model and the shadow factor; Based on the interpolation factor, linear interpolation calculation is performed on the sub-surface color information of the target object model and the basic color information of the target object model to obtain an interpolation result; Diffuse reflection illumination calculation is performed according to the interpolation result and illumination parameter information of the target light source to determine a first diffuse reflection value of the target object model under the influence of surface shadow.
6. The method according to claim 3, characterized in that: The step of performing diffuse reflection illumination calculation on the projection area of the target object model based on the preset dark surface color information input in the second color channel to obtain a second diffuse reflection value of the projection area includes: Based on the second color channel, color information is extracted to obtain sub-surface color information of the target object model; the sub-surface color information includes the preset dark surface color information input by the second color channel; The projection area of the target object model is determined, and diffuse reflection illumination calculation is performed on the projection area of the target object model based on sub-surface color information of the target object model to obtain a second diffuse reflection value.
7. The method according to claim 2, characterized in that: The step of rendering the target object model based on the first diffuse reflection value under the target light source and the second diffuse reflection value of the projection area to obtain a light and shadow rendering result of the target object model includes: Rendering the target object model based on the first diffuse reflection value under the target light source to obtain a first light and shadow rendering result of the target object model; On the basis of the first light and shadow rendering result of the target object model, the target object model is rendered based on the second diffuse reflection value of the projection area to obtain a second light and shadow rendering result of the target object model.
8. A stylized rendering device, characterized in that: The device comprises: A first color channel input module, used for inputting preset bright surface color information into a first color channel of a buffer, so as to control the bright surface color of a target object model through the first color channel; A second color channel input module, used for inputting preset dark surface color information into a second color channel of a buffer, so as to control the backlight surface color and the projection area color of the target object model through the second color channel; The lighting calculation module is used to perform lighting calculation based on the preset bright surface color information input in the first color channel and the preset dark surface color information input in the second color channel to obtain the light and shadow rendering result of the target object model.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 7 by executing the executable instructions.