Target object rendering method and device, storage medium and computer device
By improving the diffuse and specular lighting processing in the rendering pipeline and decoupling indirect lighting processing, the problem that the existing rendering pipeline cannot render stylized images has been solved, and real-time light and shadow interaction and stylized rendering effects have been achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2022-11-30
- Publication Date
- 2026-06-09
AI Technical Summary
Existing physically based rendering pipelines are unable to effectively render highly stylized images, resulting in non-real-time lighting and shadow interactions and unstable painting effects.
By improving the rendering equations for diffuse, specular, and indirect lighting in the physically based rendering pipeline, and by using a preset diffuse function and texture coordinates to control the specular highlight coefficient, stylized rendering is achieved by decoupling the diffuse and specular lighting processing of indirect lighting.
It achieves real-time light and shadow interaction and improves stylized rendering efficiency, softens the boundary between light and shadow, and enhances the stability and stylized expression of the painting effect.
Smart Images

Figure CN116363288B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, specifically to a method, apparatus, computer-readable storage medium, and computer device for rendering a target object. Background Technology
[0002] The PBR (Physically Based Rendering) pipeline approximates and fits laboratory measurement data using mathematical formulas, ultimately deriving a material representation method primarily based on Base Color, Metallic, and Roughness parameters, also known as the rendering equation. Based on this equation, computer graphics can create incredibly realistic effects. Because the PBR rendering pipeline's rendering equation was designed to achieve highly realistic results, it is not suitable for rendering highly stylized scenes, such as traditional Chinese landscape painting, cel animation, or Impressionist art styles.
[0003] Hand-painted texture mapping expresses information such as color, light and shadow, and reflection in a color map through hand-painting. Depending on the art style, the drawing effect of hand-painted texture mapping varies. Hand-painted texture mapping often better reflects the sense of painting. However, since all the details such as color, light and shadow, and reflection are recorded on a single color map, it is impossible to produce real-time light and shadow interaction. At the same time, after applying hand-painted texture mapping to a 3D model, it is impossible to guarantee that the observed object's appearance will always be within the correct range when viewed from different angles.
[0004] Therefore, a rendering method is needed to render highly stylized images. Summary of the Invention
[0005] This application provides a method, apparatus, computer-readable storage medium, and computer device for rendering a target object, which can generate real-time light and shadow interaction and improve the efficiency of stylized rendering.
[0006] This application provides a method for rendering a target object, including:
[0007] Acquire the model information and light source information of the target object, wherein the model information includes normal information;
[0008] Based on the normal information and the light source information, the diffuse reflection illumination coefficient of each pixel in the pixel to be rendered of the target object is determined using a preset diffuse reflection function. The preset diffuse reflection function is differentiable at the function value of zero and its reciprocal is zero.
[0009] Based on the diffuse reflection illumination coefficient and the light source information, determine the diffuse reflection illumination value of each pixel;
[0010] Based on the diffuse illumination value, the target object is stylized and rendered.
[0011] This application provides a method for rendering a target object, including:
[0012] Acquire the model information and light source information of the target object, wherein the model information includes normal information;
[0013] Obtain the texture coordinates, shadow coefficient, and specular color of each pixel in the target object to be rendered, and generate the specular intensity of each pixel in the target object to be rendered based on the texture coordinates of the target object;
[0014] The specular reflection illumination value of each pixel is determined based on the specular intensity, the specular color, the shadow coefficient or the corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel.
[0015] The target object is stylized and rendered based on the specular reflection illumination value.
[0016] This application provides a method for rendering a target object, including:
[0017] The model information and light source information of the target object are obtained, wherein the model information includes normal information and the light source information includes indirect light information;
[0018] The indirect light diffuse reflection processing and the indirect light specular reflection processing are decoupled by using the indirect light information and normal information to perform indirect light diffuse reflection processing on each pixel of the target object to be rendered, and / or by using roughness and normal information to perform indirect light specular reflection processing on each pixel of the target object to be rendered, so as to decouple the indirect light diffuse reflection processing and the indirect light specular reflection processing.
[0019] Based on the indirect light diffuse reflection illumination value and / or indirect light specular reflection illumination value, determine the indirect light illumination value of each pixel in the pixels to be rendered of the target object;
[0020] Based on the indirect light illumination value, the target object is stylized and rendered.
[0021] This application embodiment also provides a rendering apparatus for a target object, including:
[0022] The first acquisition module is used to acquire model information and light source information of the target object, wherein the model information includes normal information;
[0023] The first diffuse reflection module is used to determine the diffuse reflection illumination coefficient of each pixel in the target object to be rendered pixels according to the normal information and the light source information, using a preset diffuse reflection function; and to determine the diffuse reflection illumination value of each pixel according to the diffuse reflection illumination coefficient and the light source information; wherein, the preset diffuse reflection function is differentiable at the function value of zero and its reciprocal is zero;
[0024] The first rendering module is used to perform stylized rendering of the target object based on the diffuse illumination value.
[0025] This application embodiment also provides a rendering apparatus for a target object, including:
[0026] The second acquisition module is used to acquire the model information and light source information of the target object, wherein the model information includes normal information; and to acquire the texture coordinates, shadow coefficients and specular colors of each pixel in the pixels to be rendered of the target object;
[0027] The second specular reflection module is used to generate the specular intensity of each pixel in the pixel to be rendered based on the texture coordinates of the target object; and to determine the specular reflection illumination value of each pixel based on the specular intensity, the specular color, the shadow coefficient or the corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel.
[0028] The second rendering module is used to perform stylized rendering of the target object based on the specular reflection illumination value.
[0029] This application embodiment also provides a rendering apparatus for a target object, including:
[0030] The third acquisition module is used to acquire model information and light source information of the target object. The model information includes normal information, and the light source information includes indirect light information.
[0031] The third indirect lighting module is used to perform indirect diffuse reflection processing on each pixel of the target object to be rendered using the indirect lighting information and normal information to obtain indirect diffuse reflection lighting value, and / or perform indirect specular reflection processing on each pixel of the target object to be rendered using roughness and normal information to obtain indirect specular reflection lighting value, so as to decouple the indirect diffuse reflection processing and the indirect specular reflection processing; and determine the indirect lighting value of each pixel of the target object to be rendered based on the indirect diffuse reflection lighting value and / or the indirect specular reflection lighting value.
[0032] The third rendering module is used to perform stylized rendering of the target object based on the indirect light illumination value.
[0033] This application also provides a computer-readable storage medium storing a computer program adapted for loading by a processor to perform steps in the object rendering method as described in any of the above embodiments.
[0034] This application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the steps in the target rendering method as described in any of the above embodiments by calling the computer program stored in the memory.
[0035] The rendering method, apparatus, computer-readable storage medium, and computer device for target objects provided in this application improve the rendering equations and / or rendering flow of diffuse lighting, and / or specular lighting, and / or diffuse lighting and / or specular lighting of indirect lighting in a physically based rendering pipeline. For example, for diffuse lighting, the diffuse function in the physically based rendering pipeline is modified to obtain a preset diffuse function. Since the preset diffuse function is differentiable at its zero value and its reciprocal is zero, the harshness of the light-dark boundary line after rendering diffuse lighting in the original physically based rendering pipeline is changed, making the light-dark boundary line softer. For example, for specular lighting, the specular function in the physically based rendering pipeline... The surface reflection part is controlled based on the roughness of the target object. However, in this application, the specular reflection specular reflection highlight mask data is obtained based on the texture coordinates of the target object, which changes the original specular reflection rendering process. For example, for diffuse and specular reflection lighting of indirect light, the physically based rendering pipeline couples diffuse and specular reflection lighting of indirect light. In the embodiments of this application, diffuse and specular reflection lighting of indirect light are processed separately, realizing the decoupling between diffuse and specular reflection lighting of indirect light. This improvement can not only generate real-time light and shadow interaction, but also make the improved rendering pipeline suitable for stylized rendering, improve the efficiency of stylized rendering, and achieve stylized rendering effects. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a schematic diagram of the diffuse reflection function image in a standard PBR rendering pipeline.
[0038] Figure 2 This is a schematic diagram of the light and shadow boundary in a standard PBR rendering pipeline.
[0039] Figure 3 This is a flowchart illustrating the rendering method for the target object provided in an embodiment of this application.
[0040] Figure 4 This is a schematic diagram of the light and dark boundary line provided in the embodiments of this application.
[0041] Figure 5 This is a schematic diagram of a preset diffuse reflection function image provided in an embodiment of this application.
[0042] Figure 6 This is a schematic diagram of the preset diffuse reflection function image under different attenuation coefficients provided in the embodiments of this application.
[0043] Figure 7a This is a schematic diagram of the light-dark boundary line corresponding to the unadjusted attenuation coefficient of diffuse reflection provided in an embodiment of this application.
[0044] Figure 7b This is a schematic diagram of the light-dark boundary line after adjusting the attenuation coefficient, provided in an embodiment of this application.
[0045] Figure 7c This is a schematic diagram showing a self-shadowed display as provided in an embodiment of this application.
[0046] Figure 8 This is a schematic flowchart of a method for rendering a target object provided in an embodiment of this application.
[0047] Figure 9 This is a schematic diagram of the specular texture map corresponding to the virtual eyeball provided in the embodiments of this application.
[0048] Figure 10 A schematic diagram of the vertical and horizontal vectors corresponding to the virtual eyeball provided in the embodiments of this application.
[0049] Figure 11 This is a schematic diagram showing the normal directions of two virtual eyeballs provided in an embodiment of this application.
[0050] Figure 12 This is a schematic diagram illustrating projection based on the frontal view of a virtual camera of a virtual eyeball, as provided in an embodiment of this application.
[0051] Figure 13a and Figure 13b This is a schematic diagram illustrating the highlight effect of the virtual eyeball provided in an embodiment of this application.
[0052] Figure 14a This is a schematic diagram of the original texture coordinates of the virtual hair patch provided in the embodiments of this application.
[0053] Figure 14b This is a schematic diagram of the unfolded preset texture coordinates provided in the embodiments of this application.
[0054] Figure 15a This is a schematic diagram of multiple virtual hair patches and their unfolded preset texture coordinates provided in the embodiments of this application.
[0055] Figure 15b This is a schematic diagram of the roots and ends of a virtual hair provided in an embodiment of this application.
[0056] Figure 16a and Figure 16b This is a schematic diagram of the Gaussian function graphs corresponding to different c values provided in the embodiments of this application.
[0057] Figure 17a This is a schematic diagram of the highlight effect of a virtual hair patch under the highlight factor provided in an embodiment of this application.
[0058] Figure 17b A schematic diagram of the highlight effect of the entire virtual hair under the highlight factor provided in the embodiment of this application.
[0059] Figure 18a This is a schematic diagram of the H-shaped highlight shape of a virtual hair patch provided in an embodiment of this application.
[0060] Figure 18b A schematic diagram of the H-shaped highlight shape of the entire virtual hair provided in the embodiments of this application.
[0061] Figure 18c This is a schematic diagram of the interference effect obtained after noise processing of a virtual hair patch provided in an embodiment of this application.
[0062] Figure 19 This is a schematic diagram of the specular texture map of the third target object provided in the embodiments of this application.
[0063] Figure 20 This is a schematic diagram of the rendering result of an H-shaped highlight on a garment provided in an embodiment of this application.
[0064] Figure 21 This is another schematic diagram of the rendering method for the target object provided in the embodiments of this application.
[0065] Figure 22 A schematic diagram of the Fresnel effect provided in an embodiment of this application.
[0066] Figure 23 This is a schematic diagram of the indirect reflection color and the reflection color of the target object provided in the indirect light specular reflection processing according to the embodiments of this application.
[0067] Figure 24This is another schematic diagram of the rendering method for the target object provided in the embodiments of this application.
[0068] Figure 25 A simplified flowchart illustrating the rendering method for the target object provided in this application embodiment.
[0069] Figure 26 This is another simplified flowchart illustrating the rendering method for the target object provided in the embodiments of this application.
[0070] Figure 27 This is a schematic diagram of the structure of the rendering apparatus for the target object provided in the embodiments of this application.
[0071] Figure 28 This is a schematic diagram of the structure of the rendering apparatus for the target object provided in the embodiments of this application.
[0072] Figure 29 Another schematic diagram of the rendering apparatus for the target object provided in the embodiments of this application.
[0073] Figure 30 A schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0074] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0075] This application provides a method, apparatus, computer-readable storage medium, and computer device for rendering a target object. Specifically, the method for rendering the target object in this application can be executed by a computer device, which can be a terminal or a server. The terminal can be a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer (PC), intelligent robot, in-vehicle computer, or other terminal device. The server can be a standalone physical server, a server cluster consisting of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services and cloud databases.
[0076] Stylization, generally in contrast to realism, refers to the artist's use of methods that deviate from the original impression when describing and interpreting a thing or object. It involves imitation or originality to give the painting a special style. Most of these styles imitate various hand-painting techniques, such as pencil strokes, oil painting strokes, and watercolor strokes. They may also involve aging or damaging the overall style, or exaggerating, deforming, distorting, or childishizing the shapes.
[0077] Rendering includes forward rendering and backward rendering, also known as deferred rendering. Forward rendering refers to calculating the lighting effect for each light source vertex-by-vertex or pixel-by-pixel during the vertex shader or fragment shader stage. Backward rendering, on the other hand, stores the data needed for lighting calculations first, and then performs the lighting calculations in screen space at the end. The structure used to store the lighting data in backward rendering is called a Geometry Buffer, or simply G-Buffer, and it is usually composed of multiple materials (GPU Textures) in different formats.
[0078] This application relates to the backward rendering process in a physically based rendering (PBR) pipeline, including the rendering equations and rendering flow of backward rendering. Stylized rendering in this application refers to rendering a target object to obtain a stylized effect.
[0079] It should be noted that the scheme in this application embodiment is based on pixel calculation, which involves improvements to the pixel shader stage.
[0080] Because it involves changes to the rendering equations and rendering process of backward rendering, the data stored in the G-Buffer has been planned as follows.
[0081] G-Buffer1: The R, G, and B channels store the self-illumination parameters, while the A channel is reserved.
[0082] G-Buffer2: The R, G, and B channels store the base color, while the A channel is reserved.
[0083] G-Buffer3: The R channel stores roughness, and the A channel stores the ambient occlusion (AO) coefficient, which is the ratio of ambient occlusion intensity to indirect occlusion intensity. Specifically, if the R, G, and B channels use the same attenuation coefficient in diffuse lighting, this coefficient is stored in G-Buffer3. If the attenuation coefficients of the R, G, and B channels are changed in diffuse lighting, the modified attenuation coefficients are stored in G-Buffer5.
[0084] G-Buffe4: Used to store the normal information of the target object, such as the normal vector N. It should be noted that the normal information includes various normals such as vertex normals and / or texture normals.
[0085] G-Buffe5: Used to store custom material parameters, such as the attenuation coefficients of the R, G, and B channels after changes. If the specular reflection part has been modified, the specular reflection part's highlight color and the calculated highlight intensity also need to be stored.
[0086] The storage format of G-Buffer1, G-Buffer2, G-Buffer3, G-Buffer4, and G-Buffer5 can be determined according to the specific storage precision, and can be selected as RGBA8, RGBA32, or RGBA64, etc. G-Buffer1, G-Buffer2, and G-Buffer4 are consistent with those in the PBR rendering pipeline; this application mainly modifies G-Buffer3 and G-Buffer5.
[0087] Based on the data stored in the G-Buffer described above, the following will provide a detailed description of a target object rendering method, apparatus, computer-readable storage medium, and computer device provided in the embodiments of this application. It should be noted that the sequence numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0088] First, let's introduce the processing of diffuse lighting. For the diffuse lighting term in the standard PBR rendering pipeline (corresponding to the calculated diffuse light intensity / diffuse light coefficient), it is a function of the dot product (N·L) between the normal vector N of the target object and the lighting direction vector L, and satisfies the condition that the function value is 0 when N·L is less than 0. Its function graph is as follows. Figure 1 As shown. From Figure 1 As can be seen, when the function value is 0, the function is not differentiable. This is manifested in the very abrupt boundary between light and dark areas, such as... Figure 2As shown. However, in the stylized rendering of this application, a softer boundary between light and shadow is required. Therefore, the rendering equation for diffuse lighting in the standard PBR rendering pipeline cannot be used for stylized rendering.
[0089] Figure 3 This is a flowchart illustrating the rendering method for a target object provided in an embodiment of this application. The method mainly involves improving the rendering equation for diffuse lighting in the standard PBR rendering pipeline, and includes the following steps.
[0090] 101. Obtain the model information and light source information of the target object. The model information includes normal information.
[0091] The target object can be any virtual object and / or a person and / or animal, etc. The model information of the target object includes the normal information and material information of the model. The normal information includes the normal vector N and texture coordinates (UV coordinates) of each pixel. It should be noted that the UV coordinates are initially obtained from the vertices, but will be interpolated and mapped to each pixel. The material information includes at least one of the target object's intrinsic color, roughness, attenuation coefficient, reflection color, ambient light occlusion intensity, etc. The light source information includes at least one of the light source color, light source intensity, light source direction, light source transmission ratio, etc.
[0092] 102. Based on the normal information and the light source information, the diffuse reflection illumination coefficient of each pixel in the pixel to be rendered is determined using a preset diffuse reflection function. This preset diffuse reflection function is differentiable at the function value of zero and its reciprocal is zero.
[0093] This application uses function filtering. When the diffuse term is zero, the function is differentiable and its derivative is zero, which makes the boundary between light and dark softer, such as... Figure 4 As shown, it can be used with Figure 2 Let's compare and contrast them together. The filtering function is required to be defined in the domain x∈[-1,1], with a range of y∈[0,1], and at y=0, the derivative dy / dx should approach 0 as closely as possible. In this application, the filtering function is a quadratic function y=k 2 To perform the filtering calculation, let x = N·L, k = (x-1) / (λ*2)+1. Thus, the preset diffuse reflection function y = ((x-1) / (λ*2)+1) in this application is obtained. 2 Where x = N·L, and λ is the attenuation coefficient of the diffuse reflection term, ranging from [0, +∞]. Specifically, when λ = 0.5, the image of the preset diffuse reflection function is as follows: Figure 5 As shown.
[0094] After obtaining the preset diffuse function, the attenuation coefficients λ of the R, G, and B channels stored in G-Buffer3 are retrieved. Based on normal information such as the normal vector, and light source information such as the light source direction and attenuation coefficient, the diffuse term for each pixel is determined using the preset diffuse function, i.e., diffuse light intensity / diffuse light coefficient. This involves substituting the normal vector, light source direction, and attenuation coefficient into the preset diffuse function for calculation; the resulting value is the calculated diffuse light coefficient. The obtained diffuse light coefficient can be represented by DiffuseTerm. Since the R, G, and B channels share the same attenuation coefficient, the changes in DiffuseTerm for the final calculated diffuse light coefficients of the R, G, and B channels are consistent. Because the preset diffuse function is differentiable at its zero value and its reciprocal is zero, it results in a softer boundary between light and dark areas.
[0095] In one scenario, the step of determining the diffuse illumination coefficient of each pixel in the pixel to be rendered using a preset diffuse function based on normal information and light source information includes: obtaining different preset attenuation coefficients for each of the R, G, and B channels, such as obtaining different preset attenuation coefficients λ1, λ2, and λ3 from G-Buffer5; determining the channel diffuse illumination coefficient of each pixel in the pixel to be rendered in the R, G, and B channels respectively, based on normal information such as the normal vector, light source information such as the light source direction, and the set different attenuation coefficients, using the preset diffuse function. For example, substituting the normal vector, light source direction, and corresponding channel attenuation coefficient of each pixel into the preset diffuse function yields the channel full emission illumination coefficient of the corresponding channel; and determining the channel diffuse illumination coefficients of the R, G, and B channels as the diffuse illumination coefficient DiffuseTerm of each pixel in the pixel to be rendered. In this embodiment, different attenuation coefficients are set for each channel, and the attenuation rate is controlled for each channel.
[0096] Among them, if any one of λ1, λ2, or λ3 is different from the others, then they are considered different attenuation coefficients. The image of the preset diffuse reflection function under different attenuation coefficients is shown below. Figure 6 As shown, Figure 6 In the diagram, the attenuation coefficients of the three diffuse reflection curves from left to right are 0.8, 0.5, and 0.2, respectively. Different attenuation coefficients correspond to different diffuse reflection curves, and different diffuse reflection curves correspond to different attenuation rates.
[0097] It is important to note that in the standard PBR rendering pipeline, there is no channel-specific control over the attenuation of diffuse reflection. In this application, the attenuation of diffuse reflection is controlled channel-specifically. By modifying the attenuation coefficients of the R, G, and B channels, the R, G, and B channels are made to have different attenuation rates, thereby achieving hue separation while the brightness of diffuse reflection changes, thus increasing the richness of color variations.
[0098] In practical applications, the attenuation coefficients of different channels can be adjusted according to the characteristics of the target object. For example, to make the skin appear more rosy, the λ values of the R and G channels can be increased to temporarily slow down their attenuation. For instance, the attenuation coefficient of the R channel can be set to 0.62, the attenuation coefficient of the G channel to 0.48, and the attenuation coefficient of the B channel to 0.46, thus obtaining a more rosy skin.
[0099] In some cases, different attenuation requirements can be set based on different parts of the target object. For example, when the target object is a person, the facial bones are less transparent, while the thinner parts such as the ears are more transparent. Therefore, a texture can be used to finely control the attenuation, that is, to set different attenuation coefficients for different channels of each pixel.
[0100] Correspondingly, different attenuation coefficients can be set for the R, G, and B channels of each different pixel in the pixel to be rendered. These different attenuation coefficients can be stored in the G-Buffer through texture. The attenuation coefficients of different channels for each different pixel are obtained. Based on the normal information of each pixel (such as the normal vector), the light source information (such as the light source direction), and the different attenuation coefficients set for the corresponding pixel, a preset diffuse reflection function is used to determine the channel diffuse reflection illumination coefficients of each pixel in the R, G, and B channels of the pixel to be rendered. The channel diffuse reflection illumination coefficients of each pixel in the R, G, and B channels are used as the diffuse reflection illumination coefficients (DiffuseTerm) of each pixel in the pixel to be rendered. In this embodiment, different attenuation coefficients are set for each different channel of each pixel to determine the channel diffuse reflection illumination coefficients of each pixel.
[0101] Because this application controls brightness attenuation through different attenuation coefficients, light leakage may occur when the attenuation coefficient is set too high. Therefore, this application adds a transmission ratio parameter to the light source. The transmission ratio, also known as the "transmission coefficient," refers to the ratio of transmitted light flux to incident light flux. It should be noted that the standard PBR rendering pipeline does not have this parameter for light sources.
[0102] Therefore, in one scenario, the method further includes: when the light source's transmittance is zero, setting the attenuation coefficient of each of the R, G, and B channels of each pixel to a preset attenuation coefficient, which can also be used as a default attenuation coefficient, and can be 0.4; when the light source's transmittance is 1, setting the attenuation coefficient of each of the R, G, and B channels of each pixel to a pre-set attenuation coefficient, i.e., the attenuation coefficient stored in the G-Buffer; when the light source's transmittance is between 0 and 1, setting the attenuation coefficient of each of the R, G, and B channels to an interpolated attenuation coefficient, which is an attenuation coefficient obtained by interpolating the preset attenuation coefficient and the pre-set attenuation coefficient, wherein each channel is interpolated to obtain the corresponding channel's interpolated attenuation coefficient. In this embodiment, when the light source's transmittance is different, the R, G, and B channels are set to different attenuation coefficients. Thus, when the light source's transmittance is 1, it transmits completely; when the transmittance is 0, all attenuation coefficients are set to 0.4, making the attenuation result close to the N·L attenuation trend in the standard PBR rendering pipeline. This allows the transmittance of the light source to be determined according to the rendering requirements to avoid light leakage.
[0103] In one embodiment, the method further includes: when the light source transmittance is zero, setting the attenuation coefficient of different channels of different pixels to a preset attenuation coefficient, which can be 0.4; when the light source transmittance is 1, setting the attenuation coefficient of different channels of different pixels to a pre-set attenuation coefficient, i.e., the attenuation coefficient stored in the G-Buffer as a texture; when the light source transmittance is between 0 and 1, setting the attenuation coefficient of different channels of different pixels to an interpolated attenuation coefficient, which is an attenuation coefficient obtained by interpolating the preset attenuation coefficient and the pre-set attenuation coefficient, wherein interpolation is performed on the R channel, G channel, and B channel of different pixels to obtain the corresponding interpolated attenuation coefficient. In this embodiment, appropriate attenuation coefficients can be set for different channels of different pixels according to the light source transmittance to avoid light leakage.
[0104] Adjusting the attenuation factor for diffuse reflection will cause the terminator to shift backward, such as... Figure 7a and Figure 7b As shown. Among them, Figure 7a This is a schematic diagram of the light-dark boundary line corresponding to the attenuation coefficient of diffuse reflection without adjustment. Figure 7b This is a schematic diagram of the light-dark boundary line after adjusting the attenuation coefficient. Figure 7a and Figure 7b It can be seen from this that Figure 7b The terminator (line of demarcation between light and shadow) has clearly shifted backward. This shift causes shadows that were originally hidden in the darker areas to become visible, such as... Figure 7c As shown.
[0105] In one embodiment, after determining the diffuse illumination coefficient of each pixel in the pixel to be rendered, the method further includes: correcting the shadow coefficient of each pixel in the pixel to be rendered to obtain a corrected shadow coefficient, and determining the final diffuse illumination coefficient of each pixel based on the diffuse illumination coefficient of each pixel and the corrected shadow coefficient.
[0106] Specifically, the step of correcting the shadow coefficient of each pixel in the pixel to be rendered to obtain the corrected shadow coefficient includes: obtaining the original shadow coefficient of each pixel, and the first diffuse illumination coefficient and the maximum shadow coefficient corresponding to the normal vector being perpendicular to the lighting direction; using the first diffuse illumination coefficient and the maximum shadow coefficient, correcting the original shadow coefficient to obtain the corrected shadow coefficient. Here, the original shadow coefficient of each pixel refers to the shadow coefficient in the standard PBR rendering pipeline, and this original shadow coefficient is obtained.
[0107] The preset diffuse reflection function mentioned above is y = k 2 k = (x-1) / (λ*2)+1, x = N·L, and the final diffuse illumination coefficient is max(y, 0). When x = 0, that is, when the vertex normal is perpendicular to the illumination direction, the value of y is taken as the first diffuse illumination coefficient, and the first diffuse illumination coefficient is denoted as bound.
[0108] Assuming the original shadow coefficient of each pixel is Shadow, where Shadow = 0 when there is a shadow and Shadow = 1 when there is no shadow, then the maximum shadow coefficient is 1. The steps described above, which use the first diffuse illumination coefficient and the maximum shadow coefficient to correct the original shadow coefficient to obtain the corrected shadow coefficient, include: interpolating the original shadow coefficient based on the first diffuse illumination coefficient and the maximum shadow coefficient to obtain the corrected shadow coefficient. For example, interpolating between the first diffuse illumination coefficient and the maximum shadow coefficient based on the original shadow coefficient to obtain the corrected shadow coefficient. The corrected shadow coefficient is denoted by Shadow', and the process of obtaining the corrected shadow coefficient can be expressed by the formula Shadow' = Mix(Shadow, bound, 1), where Mix(t, a, b) represents linear interpolation between a and b based on t.
[0109] After obtaining the corrected shadow coefficients, the final diffuse illumination coefficient of each pixel is determined based on the diffuse illumination coefficient of each pixel and the corrected shadow coefficients. For example, the smaller of the diffuse illumination coefficient and the corrected shadow coefficient of each pixel is taken as the final diffuse illumination coefficient of the corresponding vertex. The final diffuse illumination coefficient is still represented by DiffuseTerm, and the process of obtaining the final diffuse illumination coefficient can be expressed by the formula: DiffuseTerm = min(Shadow', max(y, 0)).
[0110] It should be noted that the above modifications have been made to the diffuse function in the standard PBR rendering pipeline, and the rendering process for diffuse in the PBR rendering pipeline has also been modified, including: controlling the attenuation coefficient for each channel, taking into account the transmission ratio of the light source, and correcting the shadow coefficient, etc.
[0111] 103. Based on the diffuse reflection illumination coefficient and light source information, determine the diffuse reflection illumination value of each pixel.
[0112] If we don't consider the shift in the light-dark boundary line (i.e., we don't correct the original shadow coefficient), then the diffuse illumination value of each pixel is determined based on its diffuse illumination coefficient, light source information, and the original shadow coefficient. The light source information includes the light source color (LightColor) and light source intensity (LightStr). For example, the diffuse illumination coefficient, light source color, light source intensity, and the original shadow coefficient of each pixel are multiplied together to obtain the diffuse illumination value of each pixel. The diffuse illumination value of each pixel can be represented by LightValue1, and the process of obtaining the diffuse illumination value of each pixel can be expressed by the formula: LightValue1 = DiffuseTerm * LightColor * LightStr * Shadow.
[0113] If we consider the case where the light-dark boundary line shifts backward, the original shadow coefficient is corrected. Then, the diffuse illumination value of each pixel is determined based on its diffuse illumination coefficient, light source information, and the corrected shadow coefficient. For example, the diffuse illumination coefficient, light source color, light source intensity, and the corrected shadow coefficient of each pixel are multiplied together to obtain the diffuse illumination value of each pixel. This can be expressed by the formula: LightValue1 = DiffuseTerm * LightColor * LightStr * Shadow'.
[0114] 104. Stylize the target object based on the diffuse illumination value.
[0115] After obtaining the diffuse lighting value, the target object is rendered based on the diffuse lighting value to achieve stylized rendering. In this case, only the diffuse lighting of the target object is involved.
[0116] In one scenario, in addition to determining the diffuse lighting value LightValue1 of the target object, it is also necessary to determine the specular lighting value LightValue2 and / or the indirect diffuse lighting value LightValue3 and / or the indirect specular lighting value LightValue4 of the target object, and then perform stylized rendering on the target object based on the diffuse lighting value LightValue1, the specular lighting value LightValue2 and / or the indirect diffuse lighting value LightValue3 and / or the indirect specular lighting value LightValue4.
[0117] The specular reflection illumination value of the target object can be determined using any method for determining specular reflection illumination value, the indirect diffuse reflection illumination value of the target object can be determined using any method for determining indirect diffuse reflection illumination value, and the indirect specular reflection illumination value of the target object can be determined using any method for determining indirect specular reflection illumination value.
[0118] In one scenario, the specular illumination value (LightValue2) of the target object can be determined as follows: The specular illumination coefficient (SpecTerm) for each pixel is determined using a physically based rendering pipeline. Based on the specular illumination coefficient (SpecTerm), the corrected shadow coefficient (Shadow') for each pixel, and light source information such as light color (LightColor) and light intensity (LightStr), the specular illumination value (LightValue2) for each pixel is determined. The corrected shadow coefficient is obtained by modifying the original shadow coefficient of each pixel. For details on how to obtain the corrected shadow coefficient, please refer to the above text; it will not be repeated here. The process of obtaining the specular illumination value for each pixel can be expressed by the formula: LightValue2 = 0.04 * SpecTerm * LightColor * LightStr * Shadow'. In this embodiment, the corrected shadow coefficient is used to calculate the specular illumination value, resulting in a better specular highlight effect. The determination of the specular illumination coefficient for each pixel in the physically based rendering pipeline can be achieved using the GGX algorithm in the standard PBR rendering pipeline.
[0119] In one scenario, the model information includes the texture coordinates of each vertex of the target object. Mapping these coordinates to each pixel yields the texture coordinates of each pixel. The specular illumination value (LightValue2) of the target object can also be determined as follows: Based on the texture coordinates of each pixel in the target object to be rendered, the specular intensity of each pixel is generated. Then, based on the specular intensity, specular color, corrected shadow coefficient, and light source information, the specular illumination value of each pixel in the target object to be rendered is determined. It is important to note that in the standard PBR rendering pipeline, the specular spot size is controlled by roughness and satisfies the law of energy conservation. However, this application determines the specular intensity based on the texture coordinates of each pixel in the target object to be rendered, which differs from the roughness-based control principle in the standard PBR rendering pipeline. This part will be described in detail later; please refer to the corresponding section below.
[0120] In one case, indirect lighting processing is also included. Indirect light can also be called ambient light. Correspondingly, the light source information also includes indirect light information, i.e., ambient light information. The indirect diffuse reflection illumination value and / or indirect specular reflection illumination value of the target object can be determined as follows: Indirect diffuse reflection illumination value is obtained by performing indirect diffuse reflection processing on each pixel of the target object to be rendered using indirect light information and normal information, and / or indirect specular reflection illumination value is obtained by performing indirect specular reflection processing on each pixel of the target object to be rendered using roughness and normal information, thereby decoupling the indirect diffuse reflection processing and the indirect specular reflection processing; the indirect lighting value of each pixel is determined based on the indirect diffuse reflection illumination value and / or the indirect specular reflection illumination value. It is important to note that in the standard PBR rendering pipeline, the calculation of indirect diffuse and specular reflection lighting values is coupled. In this embodiment, the indirect diffuse and specular reflection lighting values will be calculated separately to decouple the indirect diffuse and specular reflection processing, thereby achieving diverse specular and diffuse reflection effects of indirect light. This will be described in detail later; please refer to the corresponding sections below.
[0121] The following section discusses specular lighting, starting with its processing. In the standard PBR rendering pipeline, the size of the specular highlight (or highlight point) is related to the roughness of the target object. Furthermore, specular lighting follows the law of conservation of energy, meaning the integral of the highlight is a fixed value. This results in a brighter appearance for more concentrated highlights and a darker appearance for more dispersed highlights; the size and brightness of the highlight are controlled together. However, in stylized rendering, it's not always necessary for larger highlights to be darker and smaller highlights to be brighter. Sometimes, both larger and brighter highlights are needed. Therefore, the standard PBR rendering pipeline's specular lighting processing doesn't always perform well in stylized rendering.
[0122] Figure 8 This is a schematic diagram of a rendering method for a target object provided in an embodiment of this application. The method mainly involves improving the rendering process and rendering equation for specular reflection processing of the standard PBR rendering pipeline. The method includes the following steps.
[0123] 201. Obtain the model information and light source information of the target object. The model information includes normal information.
[0124] For details regarding the model information and the light source information, please refer to the specific description in step 201; they will not be repeated here.
[0125] 202. Obtain the texture coordinates, shadow coefficient, and specular color of each pixel in the target object to be rendered, and generate the specular intensity of each pixel in the target object to be rendered based on the texture coordinates of each pixel in the target object to be rendered.
[0126] It is important to note that the standard PBR rendering pipeline calculates the specular reflection coefficient based on roughness, but does not calculate the specular intensity or the specular intensity based on texture coordinates.
[0127] In one scenario, the step of generating the specular intensity of each pixel in the target pixel to be rendered based on the texture coordinates of each pixel includes: determining the specular coefficient of each pixel in the target pixel to be rendered based on the texture coordinates; and generating the specular intensity of each pixel in the target pixel to be rendered based on the specular coefficient and a preset specular intensity value. The specular coefficient is a value between [0,1]. The preset specular intensity value is the standard specular intensity value. For example, the preset specular intensity value could be the specular intensity value when the light source color is white, the light source intensity is 1, and the reflected specular color is white. In different application scenarios, the standard specular intensity value can be the same or different. Based on the specular coefficient and the preset specular intensity value, the specular intensity corresponding to each pixel under that standard specular intensity value can be obtained.
[0128] In one scenario, the target object includes a first target object, which can be a virtual eyeball or similar object. Correspondingly, the step of determining the specular coefficient of each pixel in the pixel to be rendered based on texture coordinates includes: acquiring a specular texture map of the first target object; determining the sampled texture coordinates of each pixel in the pixel to be rendered based on the texture coordinates, the normal information in the model information of the first target object, and the positional relationship with the virtual camera; and sampling the specular texture map based on the sampled texture coordinates to generate the specular coefficient of each pixel. Here, the virtual camera refers to the virtual camera in the current virtual scene. In this embodiment, the offset data between the virtual camera and the first target object is determined based on the texture coordinates, normal information, and the positional relationship with the virtual camera. This offset data is used as the offset data of the texture coordinates to obtain the sampled texture coordinates, and the specular texture map is sampled based on the sampled texture coordinates to obtain the correct specular coefficient of each pixel.
[0129] Let's take a virtual eyeball as the first target object as an example. Correspondingly, the specular texture map of the first target object refers to the specular texture map corresponding to the virtual eyeball, such as... Figure 9 The image shown is a schematic diagram of the specular texture map corresponding to a virtual eyeball.
[0130] Correspondingly, the step of determining the sampled texture coordinates of each pixel in the pixel to be rendered based on the texture coordinates, the normal information in the model information of the first target object, and the positional relationship with the virtual camera includes: when the virtual camera is looking directly at the virtual eyeball, obtaining the vertical vector in the vertical direction and the horizontal vector in the horizontal direction on the plane where the virtual eyeball is located; determining the offset between the virtual camera and the virtual eyeball based on the vertical vector, the horizontal vector, and the orientation vector of the virtual camera; and determining the sampled texture coordinates of each pixel in the pixel to be rendered based on the texture coordinates, the offset, the movement speed of the highlight point with the line of sight, and the scaling data of the highlight point. In this embodiment, the position of the virtual camera relative to the virtual eyeball is determined based on the offset between the virtual camera and the virtual eyeball, thereby further determining the position of the highlight point on the virtual eyeball. The position of the highlight point on the virtual eyeball can be obtained based on the corresponding sampled texture coordinates and the highlight texture map.
[0131] When the virtual camera is looking directly at the virtual eyeball, the vertical vector in the vertical direction and the horizontal vector in the horizontal direction on the plane where the virtual eyeball is located can be as follows: Figure 10 As shown, the vertical vector in the vertical direction can be represented by UP, and the horizontal vector in the horizontal direction can be represented by Right. Determining these vertical and horizontal vectors is equivalent to determining a frame, so that subsequent calculations can be performed according to this frame, simplifying subsequent calculations. At the same time, it is also convenient to determine the relationship between the virtual eyeball and the line of sight (virtual camera), because the highlight of the virtual eyeball will move with the movement of the line of sight.
[0132] Two different methods can be used to determine the vertical and horizontal vectors: First, if the virtual eyeball is involved in rigging and animation, obtain the bone vectors of the bones rigging the virtual eyeball, and determine the vertical and horizontal vectors in the vertical direction and horizontal direction on the plane where the virtual eyeball is located based on these bone vectors. Second, if the virtual eyeball is not rigging or bone vectors cannot be obtained, use the second method: duplicate two identical eyeball models to obtain two virtual eyeball models, and set the normal vectors of the two virtual eyeball models to the vertical and horizontal vectors in the vertical direction and horizontal direction respectively on the plane where the virtual eyeball is located. Figure 11 As shown. For the second method, the values of the vertical and horizontal vectors in the tangent space of the target object's surface can be recorded on the texture by baking normal maps, and then restored to world space when calculating the specular position.
[0133] Let the orientation vector of the virtual camera be V, the vertical vector obtained above be UP, and the horizontal vector be Right. Correspondingly, the step of determining the offset between the virtual camera and the virtual eyeball based on the vertical vector, the horizontal vector, and the orientation vector of the virtual camera includes: taking the dot product of the vertical vector and the horizontal vector with the orientation vector of the virtual camera to obtain two offsets between the virtual camera and the virtual eyeball. The process of obtaining the two offsets can be expressed by the formulas Offset1 = V·Right, Offset2 = V·UP. When the line of sight (virtual camera) is directly facing the virtual eyeball, both offsets Offset1 and Offset2 are 0.
[0134] The steps described above, which determine the sampled texture coordinates of each pixel in the pixel to be rendered based on texture coordinates, offset, the speed at which the highlight moves with the viewpoint, and the scaling data of the highlight, include: offsetting the original texture coordinates of each pixel in the pixel to be rendered in the virtual eyeball to obtain the offset texture coordinates UV' = UV - 0.5; and determining the sampled texture coordinates of each pixel in the pixel to be rendered based on the offset, the offset texture coordinates, the speed at which the highlight moves with the viewpoint, and the scaling data of the highlight. It is important to note that the original texture coordinates of each pixel in the pixel to be rendered in the virtual eyeball need to be projected based on the virtual camera's viewpoint in front of the virtual eyeball. Figure 12 As shown, an offset is performed based on this. The scaling data of the highlight point is used to control its size, and can be represented by Scale. The speed at which the highlight point moves with the viewpoint can be represented by Speed. The sampling texture coordinates of each pixel are UVHighLight, which can be determined by the formula UVHighLight = (UV' - (Vec2(Offset1,Offset2)*Speed + Vec2(BaseOffset1,BaseOffset2)))*Scale), where BaseOffset1 and BaseOffset2 are the base offsets of the highlight.
[0135] It should be noted that in this embodiment, a separate parameter Scale is used to control the size and scaling of the highlight. The position offset of the highlight is controlled using Offset1, Offset2, BaseOffset1, BaseOffset2, and Speed. The size, scaling, and position offset of the highlight are controlled independently.
[0136] After obtaining the sampled texture coordinates of each pixel, the specular texture map corresponding to the virtual eyeball is sampled using these coordinates to obtain the specular coefficient of each pixel. The range of the sampled texture coordinates is [0,1], and the specular coefficient of each pixel is also a value in [0,1]. After obtaining the specular coefficient, the specular intensity of each pixel is generated based on the specular coefficient and a preset specular intensity value. For example, the specular coefficient and the preset specular intensity value are multiplied to obtain the specular intensity SpecStr of each pixel.
[0137] Therefore, for the first target object, such as a virtual eyeball, the size and intensity of the highlight points are represented by two different parameters, Scale and SpecStr. By controlling the highlight size and intensity separately during the specular reflection process, the highlight size and intensity do not need to satisfy the law of energy conservation as in a standard PBR rendering pipeline. This makes the scheme in this embodiment suitable for stylized rendering of virtual eyeballs. The final rendered highlight effect of the virtual eyeball can be as follows: Figure 13a and Figure 13b As shown.
[0138] In one case, the target object includes a second target object, which can be a virtual hair or similar object. Correspondingly, the step of determining the specular coefficient of each pixel in the pixel to be rendered based on texture coordinates includes: determining the preset texture coordinates of the second target object, which are obtained by unfolding the texture coordinates of the face corresponding to the second target object into texture coordinates arranged vertically along the V-axis coordinate direction; determining the specular coefficient of each pixel in the pixel to be rendered based on the preset texture coordinates, for example, obtaining a pre-constructed preset function, which includes a specular position offset coefficient and a specular thickness coefficient, wherein the maximum value of the preset function is controllable, the range of the independent variables is controllable, and the position of the maximum value of the preset function within the range of the independent variables is controllable; setting the specular position offset value corresponding to the specular position offset coefficient and the specular thickness value corresponding to the specular thickness coefficient; and generating the specular coefficient of each pixel in the pixel to be rendered based on the preset texture coordinates, the specular position offset value, and the specular thickness value using the preset function.
[0139] Taking virtual hair as the second target object as an example, in order to better control the position and size (thickness) of the highlights without affecting the original texture sampling, a separate set of preset texture coordinates is established. This preset texture coordinate system is established with the center of the texture coordinate (original texture coordinate) space as the origin. The texture coordinates of each virtual hair patch (also called a virtual hair interpolation patch) in the virtual hair are unfolded into UV blocks arranged vertically along the V-axis. After obtaining this other set of preset texture coordinates, it is mapped onto pixels to obtain the preset texture coordinates of each pixel. The preset texture coordinates of each pixel are used in the calculation of the specular coefficient.
[0140] like Figure 14a The image shown is a schematic diagram of the original texture coordinates of the virtual hair patch. Figure 14b The image shown is a schematic diagram of the preset texture coordinates after unfolding.
[0141] The preset texture coordinates require that even if the virtual hair patch is curved, the resulting UV blocks must be straight and arranged from smallest to largest along the V-axis, from the root to the tip. For example... Figure 15a As shown, the right side displays multiple virtual hair patches, which are curved, while the left side displays preset texture coordinates corresponding to the original texture coordinates. These preset texture coordinates are straight. Figure 15b As shown, in the virtual hair patch, the black part has a smaller V coordinate in the preset texture coordinate system, that is, the hair root part has a smaller V coordinate, and the white part has a larger V coordinate, that is, the hair tip part has a larger V coordinate.
[0142] Because each virtual hair patch has a different length, the UV blocks in the resulting preset texture coordinates also have varying lengths in the vertical direction. This can be understood from the opposite perspective: if all hair texture coordinates were set to 0 to 1, the result would be stretched highlights in longer virtual hair patches and compressed highlights in shorter ones. Therefore, the texture coordinates are adjusted to obtain the preset texture coordinates. In the preset texture coordinates, the UV blocks corresponding to shorter virtual hair patches are shorter, and the UV blocks corresponding to longer virtual hair patches are longer. Alternatively, because each virtual hair patch has a different length, there are certain requirements for the preset texture coordinates: First, the starting positions of the UV blocks (also called UV islands) of the virtual hair patches in the V-axis direction should be almost uniform. Second, based on the length of the virtual hair patch, scaling the UV islands in the V-axis direction ensures that when the parameters b and c of the preset function (explained later) are the same, the position and thickness of the highlights are ideal, without excessive offset or stretching.
[0143] A preset function is constructed using the value v along the V-axis in the adjusted preset texture coordinates as the independent variable. This preset function includes a specular position offset coefficient and a specular coarseness coefficient (controlling specular size, scaling, etc.). The maximum value of the preset function is controllable, the range of the independent variable is controllable, and the position of the maximum value within the range of the independent variable is controllable. In this embodiment, a Gaussian function is used as an example for illustration.
[0144] The constructed Gaussian function can be Where b is the specular position offset coefficient, c is the specular coarseness coefficient, v is the independent variable, and f(v) is the Gaussian function value, i.e., the specular coefficient SpecFactor. It can be seen that when processing the specular intensity of the second target object, the specular coarseness (spectral size scaling) is set as an independent parameter, and the specular position offset is also set as an independent parameter.
[0145] When b = 0 and c = 0.34, the graph of the Gaussian function is as follows: Figure 16a As shown, modifying the value of b shifts the shape of the function's graph horizontally, while modifying the value of c widens or narrows the graph. Figure 16b As shown, during the process of the function shape change, its maximum value is always 1, and the direction is controlled by the intensity of the highlight. This Gaussian function meets all the requirements of the above-mentioned preset function.
[0146] Set appropriate b and c values, that is, set the specular position offset value corresponding to the specular position offset coefficient and the specular thickness value corresponding to the specular thickness coefficient. Substitute the v value of the V-axis coordinate in the preset texture coordinate into the preset function to generate the specular coefficient of each pixel of the second target object. The specular coefficient can also be called the specular intensity mask. The value range of the specular coefficient is [0,1].
[0147] like Figure 17a The image shows a schematic diagram of the specular effect of a virtual hair patch with its specular coefficient (spectral intensity mask). It illustrates the fixed-width strip-shaped specular intensity mask obtained at this point. Figure 17b This is a schematic diagram of the highlight effect of the highlight coefficient in the entire virtual hair.
[0148] After obtaining the specular coefficient of each pixel, the specular intensity of each pixel is obtained based on the specular coefficient and the preset specular intensity value. For example, multiplying the specular coefficient by the preset specular intensity value will give the specular intensity of each pixel relative to the preset specular intensity value.
[0149] The process of obtaining the highlight intensity described above only uses the v value in the V-axis direction of the preset texture coordinates. In one case, the u value in the U-axis direction of the preset texture coordinates can also be used. Correspondingly, the step of setting the highlight coarseness coefficient includes: allowing the highlight coarseness coefficient to change with the u value in the U-axis direction of the preset texture coordinates to obtain the changing highlight coarseness value. Correspondingly, the step of generating the highlight coefficient of each pixel of the second target object using a preset function based on the preset texture coordinates, the highlight position offset value, and the highlight coarseness value includes: generating the highlight coefficient of each pixel of the second target object using a preset function based on the v value in the V-axis direction of the preset texture coordinates, the highlight position offset value, and the changing highlight coarseness value.
[0150] Specifically, the value of the Gaussian function c can be varied according to the value of u along the U-axis in the preset texture coordinate system, using a function c = g(u), to obtain varying specular thickness values, thereby increasing the shape detail of the specular highlights. For example, the minimum and maximum specular thickness values can be obtained, and based on these values, an interpolation function can be used to interpolate the specular thickness coefficients in the preset function to obtain varying specular thickness values.
[0151] For example, the following formula can be used to modify it: c = Mix((|(u-0.5)|*2)2,minC,maxC), where u is the value along the U-axis, minC is the minimum specular thickness, maxC is the maximum specular thickness, and Mix(t,min,max) represents interpolation between min and max based on t. It is important to note that when using this formula, the preset texture coordinates of the virtual hair patch should be as close to the center as possible along the U-axis and have sufficient width. Following this formula, an H-shaped specular style can be obtained, such as... Figure 18a The image shown is a schematic diagram of the H-shaped highlight shape of a virtual hair patch. Figure 18b This is a schematic diagram of the H-shaped highlight shape of the entire virtual hair.
[0152] In one embodiment, after obtaining the highlight position offset value, a first noise function can be used to further noise process the highlight position offset value to obtain the final highlight position offset value, and / or, after obtaining the varying highlight thickness value, a second noise function can be used to further noise process the varying highlight thickness value to obtain the final highlight thickness value. Specifically, noise processing of the highlight position offset value and the highlight thickness value simulates the interference effect of hair strands on the highlight. For example... Figure 18c The image shows a schematic diagram of the interference effect obtained after noise processing of a virtual hair patch. In this diagram, noise processing was applied to both the highlight position offset value and the highlight thickness value.
[0153] Finally, based on the v value in the V-axis direction of the preset texture coordinates, the highlight position offset value, and the varying highlight thickness value, a preset function is used to generate the highlight coefficient of each pixel of the second target object. Then, based on the highlight coefficient of each pixel and the preset highlight intensity value, the highlight intensity SpecStr of each pixel is generated.
[0154] It should be noted that when processing the specular intensity of the second target object, the specular thickness (scaling of specular size) and specular intensity of the second target object are represented by two different parameters c and SpecStr, respectively. The specular size and specular intensity in the specular reflection process are controlled separately. In this way, the specular size and specular intensity do not need to satisfy the law of conservation of energy as in the standard PBR rendering pipeline, making the scheme in this embodiment applicable to the stylized rendering of the second target object.
[0155] In one scenario, the target object includes a third target object, which is a complex target object whose UV coordinates cannot be unfolded as neatly as virtual hair, such as clothing. Correspondingly, the steps described above for determining the specular coefficient of each pixel based on texture coordinates include: obtaining a specular texture map of the third target object; sampling the specular texture map based on the texture coordinates of each pixel in the pixel to be rendered of the third target object to obtain new texture coordinates; obtaining a pre-constructed preset function, which includes a specular position offset coefficient and a specular coarseness coefficient, wherein the maximum value of the preset function is controllable, the range of the independent variables of the preset function is controllable, and the position of the maximum value within the range of the independent variables is controllable; setting the specular position offset value corresponding to the specular position offset coefficient and the specular coarseness value corresponding to the specular coarseness coefficient; and generating the specular coefficient of each pixel in the pixel to be rendered of the third target object using the preset function based on the new texture coordinates, specular position offset value, and specular coarseness value.
[0156] When the target object includes a third target object, the step of determining the specular coefficient of each pixel based on texture coordinates differs from the step when the target object is a second target object in that: the specular texture map of the third target object is obtained; and the specular texture map is sampled based on the texture coordinates of each pixel to obtain new texture coordinates. These two differing steps will be described below.
[0157] The steps for obtaining the specular texture map of a third target object include: obtaining the normal map of the third target object; importing the normal map into a preset tool such as Blender; marking the specular region and direction by adding and adjusting curves according to the normal structure; and then rendering it as the specular texture map of the third target object. This specular texture map describes the coordinate direction of the specular highlights. The specular texture map of a specific third target object can be as follows: Figure 19As shown, after obtaining the specular texture map of the third target object, the R and G channels of the specular texture map are sampled according to the texture coordinates of each pixel, resulting in two values. These two values are then used as the u and v values of the new texture coordinates, respectively.
[0158] After obtaining the new texture coordinates u and v values, they are substituted into a preset function for processing to obtain the specular coefficients. This part is consistent with the processing of the second target object above and will not be repeated here. Understandably, for the second target object, the preset texture coordinates are substituted into the preset function, while for the third target object, the new texture coordinates obtained from the specular texture map are substituted into the preset function.
[0159] like Figure 20 The image shown is a schematic diagram illustrating the rendering result of an H-shaped highlight on a piece of clothing.
[0160] 203. Based on the specular intensity, specular color, shadow coefficient or corrected shadow coefficient, and light source information, determine the specular reflection illumination value of each pixel. The corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel.
[0161] After obtaining the specular intensity SpecStr for each pixel, the specular color SpecColor stored in the G-Buffer, the shadow coefficient Shadow, the light intensity LightStr, and the light color LightColor for each pixel are used to determine the specular value LightValue2 for each pixel. For example, the specular intensity, specular color, light color, light intensity, and shadow coefficient of each pixel are multiplied together to obtain the specular illumination value for each pixel. The process of obtaining the specular value for each pixel can be expressed by the following formula: LightValue2 = SpecStr * SpecColor * LightColor * LightStr * Shadow.
[0162] In one scenario, instead of using the original shadow coefficient, a modified shadow coefficient is used. Correspondingly, the specular value LightValue2 for each pixel is determined based on the specular intensity SpecStr, specular color SpecColor, modified shadow coefficient Shadow', light intensity LightStr, and light color LightColor. For example, the specular illumination value of each pixel is obtained by multiplying its specular intensity, specular color, light color, light intensity, and modified shadow coefficient. The process of obtaining the specular value for each pixel can be expressed using the following formula: LightValue2 = SpecStr * SpecColor * LightColor * LightStr * Shadow'. The calculation method for the modified shadow coefficient can be found above and will not be repeated here.
[0163] 204. Stylize the target object based on the specular reflection illumination value.
[0164] After obtaining the specular reflection lighting value, the target object is rendered based on the specular reflection lighting value to achieve stylized rendering. In this case, only the specular reflection lighting of the target object is involved.
[0165] In one scenario, in addition to determining the specular reflection lighting value LightValue2 of the target object, it is also necessary to determine the diffuse reflection lighting value LightValue1 and / or the indirect diffuse reflection lighting value LightValue3 and / or the indirect specular reflection lighting value LightValue4 of the target object. Based on the diffuse reflection lighting value LightValue1, the specular reflection lighting value LightValue2 and / or the indirect diffuse reflection lighting value LightValue3 and / or the indirect specular reflection lighting value LightValue4, the target object is stylized and rendered.
[0166] The diffuse lighting value of the target object can be determined using the method for determining diffuse lighting values in the standard PBR rendering pipeline. If the standard PBR rendering pipeline method is used, the original shading coefficient is used to determine the specular lighting value of the target object. Alternatively, the diffuse lighting value of the target object can be determined using the method described in the above embodiment involving modifications to the standard PBR rendering pipeline; please refer to the relevant sections above for details, which will not be repeated here.
[0167] In one case, indirect lighting processing is also included. Indirect light can also be called ambient light, and correspondingly, the light source information also includes indirect light information, i.e., ambient light information. The indirect diffuse reflection illumination value and / or indirect specular reflection illumination value of the target object can be determined as follows: Indirect diffuse reflection illumination value is obtained by performing indirect diffuse reflection processing on each pixel of the target object to be rendered using indirect light information and normal information, and / or indirect specular reflection illumination value is obtained by performing indirect specular reflection processing on each pixel of the target object to be rendered using roughness and normal information, thus decoupling the indirect diffuse reflection processing and the indirect specular reflection processing; based on the indirect diffuse reflection illumination value and / or indirect specular reflection illumination value, the indirect lighting value of each pixel of the target object to be rendered is determined. This part will be described in detail later; please refer to the corresponding section below.
[0168] The following section will introduce indirect lighting, starting with the processing of indirect lighting, also known as ambient light. For the standard PBR rendering pipeline, the indirect lighting processing involves first capturing an image of the target object's surrounding environment to obtain ambient light information, i.e., indirect light information. Based on this information, the specular reflection value of the indirect light is determined. This specular reflection value is then processed to obtain a smoother value, which is used as the diffuse reflection value. Thus, the specular and diffuse reflection values of the indirect light are coupled. For example, if the specular reflection value is red, the diffuse reflection value will also be red. Alternatively, it can be understood that the diffuse reflection processing and specular reflection processing are coupled. However, for stylized rendering, the specular reflection portion of the indirect light needs to maintain rich detail and color variations, while the diffuse reflection portion needs to maintain low frequencies as much as possible, and the color needs to be controllable. Therefore, the standard PBR rendering pipeline's indirect lighting processing cannot meet these requirements.
[0169] Figure 21 This is another schematic diagram of the rendering method for the target object provided in the embodiments of this application. The method mainly involves improving the rendering process and rendering equation of the indirect light reflection processing of the standard PBR rendering pipeline. The method includes the following steps.
[0170] 301. Obtain the model information and light source information of the target object. The model information includes normal information, and the light source information includes indirect light information.
[0171] Please refer to the above text for model information. Indirect light information includes indirect light direction, indirect light color, and indirect light occlusion intensity.
[0172] 302. Indirect light diffuse reflection processing is performed on each pixel of the target object to be rendered using indirect light information and normal information to obtain indirect light diffuse reflection illumination value, and / or indirect light specular reflection processing is performed on each pixel of the target object to be rendered using roughness and normal information to obtain indirect light specular reflection illumination value, so as to decouple indirect light diffuse reflection processing and indirect light specular reflection processing.
[0173] In this embodiment, the indirect light diffuse reflection processing and the indirect light specular reflection processing are completely separated, and the indirect light diffuse reflection illumination value and the indirect light specular reflection illumination value are completely decoupled. In this way, there is no relationship between the obtained indirect light diffuse reflection illumination value and the indirect light specular reflection illumination value, so as to meet the stylized rendering requirements.
[0174] For the processing of indirect light diffuse reflection, the steps described above, which utilize indirect light information and normal information to perform indirect light diffuse reflection processing on each pixel in the target object's pixel to be rendered to obtain the indirect light diffuse reflection illumination value, include: setting a spatial axis and setting multiple indirect light colors and multiple indirect light intensities along the spatial axis; determining the indirect light diffuse reflection value of each pixel in the target object's pixel to be rendered based on the spatial axis, normal information, multiple indirect light colors, and multiple indirect light intensities; and determining the indirect light diffuse reflection illumination value of each pixel in the target object's pixel to be rendered based on the indirect light diffuse reflection value, the inherent color of each pixel, and the indirect light occlusion intensity. This embodiment achieves controllable indirect light diffuse reflection color, specifically by setting the spatial axis and multiple indirect light colors and multiple indirect light intensities along the spatial axis.
[0175] The spatial axis can be represented by a vector, which can be determined based on the indirect lighting information of the specific target object. Multiple indirect light colors and intensities are illustrated using three examples. For instance, suppose the scene to be rendered includes the sky, horizon, and ground. The sky is the brightest, the horizon is next, and the ground is the darkest. The light rays in the scene from top to bottom decrease in brightness. Correspondingly, the spatial axis can be an upward vector (from the ground to the sky). Three different indirect light colors and three different indirect light intensities can be set, corresponding to the ground, horizon, and sky, respectively. For example, in a photography studio, ambient light may have a clear direction, such as coming from the left. The ambient light weakens from left to right. Therefore, the spatial axis can be set as a horizontal vector pointing to the left, and the indirect light colors and intensities can be set to three along this spatial axis.
[0176] By setting a spatial axis, so that multiple different indirect light colors and indirect light intensities set thereon vary along the spatial axis. The spatial axis is a reference direction for the change of the indirect light color and intensity, or it can also be understood that the spatial axis is related to the indirect light direction.
[0177] Determine the relationship between the normal vector in the normal information and the set spatial axis. According to the relationship, perform interpolation processing on multiple indirect light colors and multiple indirect light intensities to obtain the indirect light diffuse reflection value of each pixel. Among them, the relationship between the vertex normal and the spatial axis refers to the dot product result between the vertex normal and the spatial axis.
[0178] Assume that the spatial axis is vector A, the normal vector of each pixel of the target object is N, the three indirect light colors are SkyLightUpColor, SkyLightMidColor and SkyLightDownColor respectively, and the three indirect light intensities are SkyLightUpStr, SkyLightMidStr and SkyLightDownStr respectively. Let Term = |(A·N)), Sign = step(0, A·N), the indirect light diffuse reflection color of each pixel = Mix(Sign, Mix(1 - Term, SkyLightDownColor, SkyLightMidColor), Mix(Term, SkyLightMidColor, SkyLightUpColor)), where step(a, b) means taking 0 when b = a, and Mix(t, a, b) means linearly interpolating between a and b according to t. According to a similar method, the indirect light diffuse reflection intensity of each pixel can be obtained. In this way, the indirect light diffuse reflection value of each pixel can be obtained according to the indirect light diffuse reflection intensity and the indirect light diffuse reflection color of each pixel. For example, multiply the indirect light diffuse reflection color and the indirect light diffuse reflection intensity of each pixel to obtain the indirect light diffuse reflection value SkyLightColor of each pixel. This indirect light diffuse reflection value SkyLightColor can be understood as the value of the indirect light for performing diffuse illumination processing.
[0179] After obtaining the indirect light diffuse reflection value of each pixel, multiply the indirect light diffuse reflection value of each pixel, the solid color of each pixel and the indirect light occlusion intensity to obtain the indirect light diffuse reflection illumination value of each pixel. The process of obtaining the indirect light diffuse reflection illumination value can be represented by a formula, LightValue3 = SkyLightColor * BaseColor * AO, where SkyLightColor is the indirect light diffuse reflection value of each pixel, BaseColor is the solid color of each pixel, and AO is the indirect light occlusion intensity of each pixel.
[0180] The above relates to the processing of indirect light diffuse reflection. This indirect light diffuse reflection processing modifies the standard PBR rendering pipeline's standard process of using indirect light specular reflection illumination values to obtain indirect light diffuse reflection illumination values. Instead, it directly customizes the indirect light direction (related to the spatial axis), customizes multiple different indirect light colors and intensities in the entire rendered image, and interpolates them to obtain indirect light diffuse reflection values. The indirect light diffuse reflection illumination values are then obtained based on the indirect light diffuse reflection values, the intrinsic color of each pixel, and the indirect light occlusion intensity.
[0181] For handling indirect specular reflection, in a standard PBR rendering pipeline, due to the Fresnel effect, the more parallel the viewing angle is to the surface of the target object, the stronger the reflection will be. For non-metallic objects, the target object will emit a layer of white light, such as... Figure 22 As shown, both surfaces containing the arrows within the line of sight appear to have a layer of white light, affecting the color stability of the target object. To maintain the color stability of the target object, two processing methods are proposed in the embodiments of this application.
[0182] The first method involves removing the Fresnel term. After removing the Fresnel term, the corresponding step of performing indirect specular reflection processing on each pixel of the target object to be rendered using roughness and normal information to obtain the indirect specular reflection illumination value includes: determining the indirect specular reflection value (IndirectSpecColor) of each pixel of the target object to be rendered based on normal information such as the normal vector and roughness; obtaining the reflection color of each pixel of the target object to be rendered; and determining the indirect specular reflection illumination value of each pixel based on the indirect specular reflection value, the reflection color of the target object, and the indirect light occlusion intensity. Simply put, this means determining the indirect specular reflection illumination value based on the indirect specular reflection value (IndirectSpecColor) and the reflection color (SpecColor) of each pixel of the target object. In one embodiment, the reflection color (SpecColor) of each pixel of the target object can be the specular color mentioned above, which is stored in the G-Buffer.
[0183] The second method is to improve the Fresnel term. Specifically, the Fresnel term is processed according to the roughness. Correspondingly, the above step of performing indirect specular reflection processing on each pixel in the target object's pixels to be rendered using roughness and normal information to obtain the indirect specular reflection illumination value includes: determining the indirect specular reflection value IndirectSpecColor of each pixel in the target object's pixels to be rendered according to normal information such as the normal vector and roughness; determining the reflection color of the target object according to the roughness and the solid color of each pixel; determining the indirect specular reflection illumination value of each pixel in the target object's pixels to be rendered according to the indirect specular reflection value, the reflection color of the target object, and the indirect occlusion intensity. Among them, the step of determining the reflection color of the target object according to the roughness and the solid color of each pixel includes: performing interpolation processing on the preset reflection color and the solid color according to the roughness to obtain the reflection color of each pixel of the target object. The process of obtaining the reflection color of each pixel of the target object can be represented by a formula, SpecColor = Mix(Clamp(Roughness * Coefficient, 0, 1), Preset Reflection Color, Solid Color), where the preset reflection color can be 0.04, and the coefficient can be set according to the required effect. Clamp(x, a, b) means taking a when x < a, taking b when x > b, and taking x otherwise. Mix(t, a, b) means linearly interpolating between a and b according to t.
[0184] Among them, the above determination of the indirect specular reflection value of each pixel according to the normal information and roughness can be understood as follows. For example, the reflection color of each point on a metal ball looks different, and the roughness of the target object also affects the indirect specular reflection value, and different roughnesses look different. The indirect specular reflection value IndirectSpecColor of each pixel can be understood as the ambient color obtained without considering the reflection of the target object's own color, or the ambient color reflected by a target object with a reference color such as white, as Figure 23 shown. IndirectSpecColor represents the ambient color reflected by a target object with a reference color of white, and can also be called the indirect reflection color.
[0185] Among them, the above step of determining the indirect specular reflection illumination value of each pixel in the target object's pixels to be rendered according to the indirect specular reflection value, the reflection color of the target object, and the indirect occlusion intensity includes: multiplying the indirect specular reflection value, the reflection color of the target object, and the ambient occlusion intensity to obtain the indirect specular reflection illumination value of each pixel. Among them, the process of obtaining the indirect specular reflection illumination value of each pixel can be represented by a formula, LightValue4 = IndirectSpecColor * SpecColor * AO.
[0186] The above describes the indirect light specular reflection processing, which removes the Fresnel term from the standard PBR rendering pipeline or modifies the Fresnel term using roughness. Finally, the indirect light specular reflection illumination value is obtained based on the indirect light specular reflection value, the reflection color of each pixel, and the indirect light occlusion intensity.
[0187] 303. Determine the indirect light illumination value of each pixel in the target object to be rendered based on the indirect light diffuse reflection illumination value and / or the indirect light specular reflection illumination value.
[0188] If only the diffuse indirect light illumination value for each pixel needs to be calculated, then that value is directly determined as the indirect illumination value. Similarly, if only the specular indirect light illumination value for each pixel needs to be calculated, then that value is directly determined as the indirect illumination value. If both diffuse and specular indirect light illumination values are calculated, they can be directly added together to obtain the indirect illumination value, or a weighted average can be applied to obtain the indirect illumination value.
[0189] 304. Stylize the target object based on the indirect light illumination value.
[0190] After obtaining the indirect lighting value for each pixel, the target object is rendered based on the indirect lighting value to achieve stylized rendering. In this case, only the indirect lighting of the target object is involved.
[0191] In one case, in addition to determining the indirect lighting value corresponding to the indirect lighting of the target object, it is also necessary to determine the diffuse lighting value and / or the specular lighting value of the target object, and to perform stylized rendering of the target object based on the indirect lighting value, and / or the diffuse lighting value, and / or the specular lighting value of the target object.
[0192] The diffuse reflection illumination value of the target object can be determined using any existing method, or it can be determined using the method for determining diffuse reflection illumination value mentioned in any of the embodiments mentioned above in this application, and will not be described in detail here. The specular reflection illumination value of the target object can be determined using any existing method, or it can be determined using the method for determining specular reflection illumination value mentioned in any of the embodiments mentioned above in this application.
[0193] In the above description of stylizing the target object based on its diffuse lighting value, and / or specular lighting value, and / or indirect diffuse lighting value, and / or indirect specular lighting value, if multiple lighting values are involved, the multiple lighting values can be added together to obtain the final lighting value for each pixel. Alternatively, the multiple lighting values can be weighted to obtain the final lighting value for each pixel, and then the rendering can be performed based on the final lighting value to achieve stylized rendering.
[0194] For example, when dealing with diffuse lighting values, specular lighting values, and indirect diffuse lighting values, you can add them together and use the result as the final lighting value for each pixel. Alternatively, you can weight the diffuse lighting values, specular lighting values, and indirect diffuse lighting values, add them together, and use the result as the final lighting value for each pixel. Then, you can render according to the final lighting value.
[0195] Figure 24 This is another flowchart illustrating the rendering method for a target object provided in this application embodiment. The method involves diffuse reflection, specular reflection, diffuse reflection of indirect light, specular reflection of indirect light, etc., and includes the following steps.
[0196] 401. Obtain the model information and light source information of the target object. The model information includes normal information, and the light source information includes first light source information and indirect light information.
[0197] The first light source information is used to determine the diffuse reflection illumination value and the specular reflection illumination value. The light source information used to determine the diffuse reflection illumination value and the specular reflection illumination value in the above embodiment is the first light source information, and will not be repeated here. The indirect light information is used to determine the indirect light specular reflection illumination value and the indirect light diffuse reflection illumination value.
[0198] 402. Based on the normal information and the first light source information, the diffuse reflection illumination coefficient of each pixel in the target object to be rendered is determined using a preset diffuse reflection function. Based on the diffuse reflection illumination coefficient and the first light source information, the diffuse reflection illumination value of each pixel is determined. The preset diffuse reflection function is differentiable at the function value of zero and its reciprocal is zero.
[0199] 403. Obtain the texture coordinates, specular color, and shadow coefficient of each pixel in the target object to be rendered. Generate the specular intensity of each pixel based on the texture coordinates. Determine the specular reflection illumination value of each pixel based on the specular intensity, specular color, shadow coefficient or the corrected shadow coefficient, and the first light source information. The corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel.
[0200] 404. Indirect light diffuse reflection processing is performed on each pixel of the target object to be rendered using indirect light information and normal information to obtain indirect light diffuse reflection illumination value. Indirect light specular reflection processing is performed on each pixel of the target object to be rendered using roughness and normal information to obtain indirect light specular reflection illumination value.
[0201] Please refer to the descriptions in the corresponding embodiments above for steps 402 to 404, which will not be repeated here.
[0202] 405. Stylize the target object based on diffuse reflection illumination value, specular reflection illumination value, indirect diffuse reflection illumination value, and indirect specular reflection illumination value.
[0203] This involves adding diffuse lighting values, specular lighting values, indirect diffuse lighting values, and indirect specular lighting values together to obtain the final lighting value for each pixel. The target object is then rendered based on the final lighting value to achieve stylized rendering.
[0204] In this process, the diffuse lighting value, specular lighting value, indirect diffuse lighting value, and indirect specular lighting value can be weighted to obtain the final lighting value for each pixel. The target object is then rendered based on the final lighting value to achieve stylized rendering.
[0205] Figure 25 and Figure 26 This is a simplified flowchart illustrating the rendering method for the target object provided in this application embodiment, wherein, Figure 25 In the diffuse reflection processing section, different attenuation coefficients are set for different channels. However, in the specular reflection processing section, the specular reflection processing workflow in the standard PBR rendering pipeline is used. The improved processing method in this application is adopted in the indirect light diffuse reflection processing and indirect light specular reflection processing. Figure 26 In the diffuse reflection processing section, a uniform attenuation coefficient is set. However, in the specular reflection processing section, the specular reflection processing in the standard PBR rendering pipeline has been improved. The improved processing method in this application is adopted in the indirect light diffuse reflection processing and indirect light specular reflection processing. Please refer to the description in the previous text for details.
[0206] The above method embodiments have improved the diffuse lighting, specular lighting, indirect diffuse lighting, and indirect specular lighting in the PBR rendering pipeline to make them suitable for stylized rendering. This not only enables light and shadow interaction but also improves the efficiency of stylized rendering.
[0207] All of the above technical solutions can be combined in any way to form optional embodiments of this application, and will not be described in detail here.
[0208] To facilitate better implementation of the target object rendering method of this application embodiment, this application embodiment also provides a target object rendering apparatus. Please refer to... Figure 27 , Figure 27 This is a schematic diagram of the structure of a rendering apparatus for a target object provided in an embodiment of this application. The rendering apparatus 500 for the target object may include a first acquisition module 501, a first diffuse reflection module 502, and a first rendering module 503.
[0209] The first acquisition module 501 is used to acquire the model information and light source information of the target object, wherein the model information includes normal information.
[0210] The first diffuse reflection module 502 is used to determine the diffuse reflection illumination coefficient of each pixel in the target object to be rendered pixels according to the normal information and the light source information, using a preset diffuse reflection function, wherein the preset diffuse reflection function is differentiable at the function value of zero and its reciprocal is zero; and to determine the diffuse reflection illumination value of each pixel according to the diffuse reflection illumination coefficient and the light source information.
[0211] The first diffuse reflection module 502 includes a diffuse reflection coefficient determination module and a diffuse reflection illumination value determination module. The diffuse reflection coefficient determination module is used to determine the diffuse reflection illumination coefficient of each pixel in the target object to be rendered, based on the normal information and the light source information, using a preset diffuse reflection function. The preset diffuse reflection function is differentiable at its zero value and its reciprocal is zero. The diffuse reflection illumination value determination module is used to determine the diffuse reflection illumination value of each pixel based on the diffuse reflection illumination coefficient and the light source information.
[0212] In one embodiment, the diffuse reflection coefficient determination module is used to obtain different preset attenuation coefficients for each of the R, G, and B channels; based on the normal information, the light source information, and the different preset attenuation coefficients, and using the preset diffuse reflection function, determine the channel diffuse reflection illumination coefficients of each pixel in the pixel to be rendered in the R, G, and B channels respectively; and determine the channel diffuse reflection illumination coefficients of the R, G, and B channels as the diffuse reflection illumination coefficients of each pixel in the pixel to be rendered.
[0213] In one embodiment, the light source information includes the light source transmission ratio and a diffuse reflection coefficient determination module. The module is further configured to: when the transmission ratio is zero, set the attenuation coefficient of each of the R, G, and B channels of each pixel to a default attenuation coefficient; when the transmission ratio is 1, set the attenuation coefficient of each of the R, G, and B channels of each pixel to a preset attenuation coefficient; and when the transmission ratio is between 0 and 1, set the attenuation coefficient of each of the R, G, and B channels to an interpolated attenuation coefficient, wherein the interpolated attenuation coefficient is an attenuation coefficient obtained by interpolating the default attenuation coefficient and the preset attenuation coefficient.
[0214] In one embodiment, after determining the diffuse illumination coefficient of each pixel in the pixel to be rendered, the diffuse illumination coefficient determination module is further configured to correct the shadow coefficient of each pixel in the pixel to be rendered to obtain a corrected shadow coefficient; and determine the final diffuse illumination coefficient of each pixel based on the diffuse illumination coefficient of each pixel and the corrected shadow coefficient.
[0215] The first rendering module 503 performs stylized rendering on the target object based on the diffuse illumination value.
[0216] In one embodiment, such as Figure 27 As shown, the rendering apparatus 500 for the target object may further include a first specular reflection module 504. The first specular reflection module 504 is used to determine the specular reflection illumination coefficient of each pixel in the pixels to be rendered using a method in a physically-based rendering pipeline; determine the specular reflection illumination value of each pixel based on the specular reflection illumination coefficient, shadow coefficient or a corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel; or, generate the highlight intensity of each pixel in the pixels to be rendered based on the texture coordinates of each pixel in the target object; determine the specular reflection illumination value of each pixel based on the highlight intensity, highlight color, corrected shadow coefficient, and the light source information. Correspondingly, the first rendering module 503 is used to perform stylized rendering of the target object based on the diffuse illumination value and the specular reflection illumination value.
[0217] In one embodiment, such as Figure 27As shown, the rendering apparatus 500 for the target object further includes a first indirect light module 505. The first indirect light module 505 is used to perform indirect diffuse reflection processing on each pixel of the target object to be rendered using the indirect light information and normal information to obtain an indirect diffuse reflection illumination value, and / or to perform indirect specular reflection processing on each pixel of the target object to be rendered using roughness and normal information to obtain an indirect specular reflection illumination value, thereby decoupling the indirect diffuse reflection processing and the indirect specular reflection processing; and to determine the indirect light illumination value in the target object to be rendered pixels based on the indirect diffuse reflection illumination value and / or the indirect specular reflection illumination value. Correspondingly, the first rendering module 503 is used to perform stylized rendering of the target object based on the diffuse reflection illumination value and the indirect light illumination value; or, to perform stylized rendering of the target object based on the diffuse reflection illumination value, the specular reflection illumination value, and the indirect diffuse reflection illumination value and / or the indirect specular reflection illumination value.
[0218] In one embodiment, such as Figure 28 The diagram shown is a structural schematic of a target object rendering apparatus provided in an embodiment of this application. The target object rendering apparatus 600 may include a second acquisition module 601, a second specular reflection module 602, and a second rendering module 603.
[0219] The second acquisition module 601 is used to acquire the model information and light source information of the target object, wherein the model information includes normal information; and to acquire the texture coordinates, shadow coefficients and specular colors of each pixel in the pixel to be rendered of the target object.
[0220] The second specular reflection module 602 is used to generate the specular intensity of each pixel in the pixel to be rendered based on the texture coordinates of the target object; and to determine the specular reflection illumination value of each pixel based on the specular intensity, the specular color, the shadow coefficient or the corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel.
[0221] In one embodiment, the second specular reflection module 602 includes a specular reflection intensity determination module and a specular reflection illumination value determination module. The specular reflection intensity determination module is used to generate the specular reflection intensity of each pixel in the pixel to be rendered based on the texture coordinates of the target object. The specular reflection illumination value determination module is used to determine the specular reflection illumination value of each pixel based on the specular reflection intensity, the specular reflection color, the shadow coefficient or the corrected shadow coefficient, and the light source information. The corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel.
[0222] In one embodiment, the highlight intensity determination module is specifically used to determine the highlight coefficient of each pixel in the pixel to be rendered based on the texture coordinates; and to generate the highlight intensity of each pixel in the pixel to be rendered based on the highlight coefficient and a preset highlight intensity value.
[0223] In one embodiment, the target object includes a first target object. The specular intensity determination module, when performing the step of determining the specular coefficient of each pixel in the pixel to be rendered based on the texture coordinates, specifically performs the following: acquiring a specular texture map of the first target object; determining the sampled texture coordinates of each pixel in the pixel to be rendered based on the texture coordinates, the normal information in the model information of the first target object, and the positional relationship with the virtual camera; and sampling the specular texture map based on the sampled texture coordinates to generate the specular coefficient of each pixel in the pixel to be rendered.
[0224] In one embodiment, the target object includes a second target object. The specular intensity determination module, when performing the step of determining the specular coefficient of each pixel in the pixel to be rendered based on the texture coordinates, specifically performs the following: determining the preset texture coordinates of the second target object, where the preset texture coordinates are obtained by unfolding the texture coordinates of the facet corresponding to the second target object into a vertical arrangement along the V-axis coordinate direction; obtaining a pre-constructed preset function, where the preset function includes a specular position offset coefficient and a specular coarseness coefficient, the maximum value of the preset function is controllable, the range of the independent variables of the preset function is controllable, and the position of the maximum value within the range of the independent variables is controllable; setting the specular position offset value corresponding to the specular position offset coefficient and the specular coarseness value corresponding to the specular coarseness coefficient; and generating the specular coefficient of each pixel in the pixel to be rendered of the second target object using the preset function based on the preset texture coordinates, the specular position offset value, and the specular coarseness value.
[0225] In one embodiment, the target object further includes a third target object. The specular intensity determination module, when performing the step of determining the specular coefficient of each pixel in the pixel to be rendered based on the texture coordinates, specifically performs the following: obtaining a specular texture map of the third target object; sampling the specular texture map based on the texture coordinates of each pixel in the pixel to be rendered of the third target object to obtain new texture coordinates; obtaining a pre-constructed preset function, the preset function including a specular position offset coefficient and a specular coarseness coefficient, the maximum value of the preset function being controllable, the range of the independent variables of the preset function being controllable, and the position of the maximum value within the range of the independent variables being controllable; setting a specular position offset value corresponding to the specular position offset coefficient and a specular coarseness value corresponding to the specular coarseness coefficient; and generating the specular coefficient of each pixel in the pixel to be rendered of the third target object using the preset function based on the new texture coordinates, the specular position offset value, and the specular coarseness value.
[0226] The second rendering module 603 is used to perform stylized rendering of the target object based on the specular reflection illumination value.
[0227] In one embodiment, the rendering apparatus 600 for the target object may further include a second indirect light module 604 (same as the first indirect light module). The second indirect light module is used to perform indirect diffuse reflection processing on each pixel of the target object to be rendered using the indirect light information and normal information to obtain an indirect diffuse reflection illumination value, and / or to perform indirect specular reflection processing on each pixel of the target object to be rendered using roughness and normal information to obtain an indirect specular reflection illumination value, thereby decoupling the indirect diffuse reflection processing and the indirect specular reflection processing; and to determine the indirect illumination value of each pixel of the target object to be rendered based on the indirect diffuse reflection illumination value and / or the indirect specular reflection illumination value. Correspondingly, the second rendering module 603 is further used to perform stylized rendering of the target object based on the specular reflection illumination value and the indirect illumination value.
[0228] In one embodiment, the rendering apparatus 600 for the target object may further include a second diffuse reflection module (same as the first diffuse reflection module). The second diffuse reflection module is used to determine the diffuse reflection illumination coefficient of each pixel in the target object to be rendered in the normal information using a preset diffuse reflection function based on the normal information and the light source information. The preset diffuse reflection function is differentiable at a function value of zero and its reciprocal is zero. The diffuse reflection illumination value of each pixel is determined based on the diffuse reflection illumination coefficient and the light source information.
[0229] In one embodiment, such as Figure 29The diagram shown is a structural schematic of a target object rendering apparatus provided in an embodiment of this application. The target object rendering apparatus 700 may include a third acquisition module 701, a third indirect light module 702, and a third rendering module 703.
[0230] The third acquisition module 701 is used to acquire model information and light source information of the target object. The model information includes normal information, and the light source information includes indirect light information.
[0231] The third indirect lighting module 702 is used to perform indirect diffuse reflection processing on each pixel of the target object to be rendered using the indirect lighting information and normal information to obtain an indirect diffuse reflection illumination value, and / or perform indirect specular reflection processing on each pixel of the target object to be rendered using roughness and normal information to obtain an indirect specular reflection illumination value, thereby decoupling the indirect diffuse reflection processing and the indirect specular reflection processing; and to determine the indirect lighting value of each pixel of the target object to be rendered based on the indirect diffuse reflection illumination value and / or the indirect specular reflection illumination value. This third indirect lighting module 702 is the same as the first indirect lighting module.
[0232] In one embodiment, the third indirect lighting module 702 includes: an indirect light diffuse reflection module, an indirect light specular reflection module, and an indirect light illumination value determination module. The indirect light diffuse reflection module is used to perform indirect light diffuse reflection processing on each pixel of the target object to be rendered using the indirect light information and normal information to obtain an indirect light diffuse reflection illumination value. The indirect light specular reflection module is used to perform indirect light specular reflection processing on each pixel of the target object to be rendered using roughness and normal information to obtain an indirect light specular reflection illumination value. The indirect light illumination value determination module is used to determine the indirect light illumination value of each pixel of the target object to be rendered based on the indirect light diffuse reflection illumination value and / or the indirect light specular reflection illumination value.
[0233] In one embodiment, the indirect light information includes indirect light color and indirect light intensity. The indirect light diffuse reflection module is specifically used to set a spatial axis and set multiple indirect light colors and multiple indirect light intensities along the spatial axis; determine the indirect light diffuse reflection value of each pixel in the target object to be rendered pixels based on the spatial axis, the normal information, the multiple indirect light colors, and the multiple indirect light intensities; and determine the indirect light diffuse reflection illumination value of each pixel based on the indirect light diffuse reflection value, the inherent color of each pixel, and the indirect light occlusion intensity.
[0234] In one embodiment, the indirect light specular reflection module is specifically used to determine the indirect light specular reflection value of each pixel in the target object to be rendered based on normal information and roughness; obtain the reflection color of each pixel of the target object; and determine the indirect light specular reflection illumination value of each pixel based on the indirect light specular reflection value, the reflection color of the target object, and the indirect light occlusion intensity.
[0235] The third rendering module 703 is used to perform stylized rendering of the target object based on the indirect light illumination value of each pixel.
[0236] In one embodiment, the rendering apparatus 700 for the target object may further include a third diffuse reflection module, which is the same as the first diffuse reflection module, and will not be described in detail here.
[0237] In one embodiment, the rendering device 700 for the target object may further include a third specular reflection module, which is the same as the first specular reflection module and will not be described in detail here.
[0238] All of the above technical solutions can be combined in any way to form optional embodiments of this application, and will not be described in detail here.
[0239] Accordingly, embodiments of this application also provide a computer device, which can be a terminal or a server. For example... Figure 30 As shown, Figure 30 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. The computer device 800 includes a processor 801 with one or more processing cores, a memory 802 with one or more computer-readable storage media, and a computer program stored in the memory 802 and executable on the processor. The processor 801 is electrically connected to the memory 802.
[0240] The processor 801 is the control center of the computer device 800. It connects various parts of the computer device 800 through various interfaces and lines. By running or loading software programs (computer programs) and / or modules stored in the memory 802, and calling data stored in the memory 802, it performs various functions of the computer device 800 and processes data, thereby monitoring the computer device 800 as a whole.
[0241] In this embodiment, the processor 801 in the computer device 800 loads the instructions corresponding to the processes of one or more application programs / computer programs into the memory 802 according to the following steps, and the processor 801 runs the application programs / computer programs stored in the memory 802 to realize various functions, such as as shown below:
[0242] The process involves acquiring model information and light source information for the target object, where the model information includes normal information; determining the diffuse illumination coefficient of each pixel in the target object to be rendered using a preset diffuse reflection function based on the normal information and the light source information, where the preset diffuse reflection function is differentiable at zero and its reciprocal is zero; determining the diffuse illumination value of each pixel based on the diffuse illumination coefficient and the light source information; and performing stylized rendering on the target object based on the diffuse illumination value.
[0243] or,
[0244] The process involves: acquiring model information and light source information of the target object, whereby the model information includes normal information; acquiring the texture coordinates, shadow coefficient, and specular color of each pixel in the target object to be rendered, and generating the specular intensity of each pixel based on the texture coordinates of the target object; determining the specular reflection illumination value of each pixel based on the specular intensity, the specular color, the shadow coefficient or a corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel; and performing stylized rendering on the target object based on the specular reflection illumination value.
[0245] or,
[0246] The process involves acquiring model information and light source information for the target object, whereby the model information includes normal information and the light source information includes indirect lighting information. The process then uses the indirect lighting information and normal information to perform indirect diffuse reflection processing on each pixel of the target object to be rendered, obtaining an indirect diffuse lighting value. Alternatively, it uses roughness and normal information to perform indirect specular reflection processing on each pixel of the target object to be rendered, obtaining an indirect specular lighting value, thereby decoupling the indirect diffuse reflection processing and the indirect specular reflection processing. Based on the indirect diffuse lighting value and / or the indirect specular lighting value, the process determines the indirect lighting value for each pixel of the target object to be rendered. Finally, the process performs stylized rendering on the target object based on the indirect lighting value.
[0247] The processor can execute the steps / operations in any of the above method embodiments. Please refer to the description in the method embodiments above for details, which will not be repeated here. The specific implementation of each of the above operations and the beneficial effects that can be achieved can be referred to the previous embodiments, which will not be repeated here.
[0248] Optional, such as Figure 30As shown, the computer device 800 also includes: a touch screen display 803, a radio frequency circuit 804, an audio circuit 805, an input unit 806, and a power supply 807. The processor 801 is electrically connected to the touch screen display 803, the radio frequency circuit 804, the audio circuit 805, the input unit 806, and the power supply 807. Those skilled in the art will understand that... Figure 30 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0249] The touch display screen 803 can be used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. The touch display screen 803 may include a display panel and a touch panel. The display panel can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the computer device. These graphical user interfaces can be composed of graphics, text, icons, video, and any combination thereof. Optionally, the display panel can be configured using a liquid crystal display (LCD), organic light-emitting diode (OLED), or other similar devices. The touch panel can be used to collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel), generate corresponding operation commands, and execute the corresponding program. The touch panel may cover the display panel. When the touch panel detects a touch operation on or near it, it transmits the data to the processor 801 to determine the type of touch event. Subsequently, the processor 801 provides corresponding visual output on the display panel based on the type of touch event. In this embodiment, the touch panel and display panel can be integrated into the touch display screen 803 to achieve input and output functions. However, in some embodiments, the touch panel and the touch display screen 803 can be implemented as two independent components to achieve input and output functions. That is, the touch display screen 803 can also be used as part of the input unit 806 to achieve input functions.
[0250] In this embodiment, the touch display screen 803 is used to present a graphical user interface and receive operation commands generated by the user interacting with the graphical user interface.
[0251] The radio frequency circuit 804 can be used to transmit and receive radio frequency signals to establish wireless communication with network devices or other computer devices, and to transmit and receive signals with network devices or other computer devices.
[0252] Audio circuitry 805 can be used to provide an audio interface between a user and a computer device via a speaker and a microphone. Audio circuitry 805 converts received audio data into electrical signals, transmits them to the speaker, and the speaker converts them into sound signals for output. Conversely, the microphone converts collected sound signals into electrical signals, which are then received by audio circuitry 805, converted back into audio data, and output to processor 801 for processing. The audio data is then transmitted via radio frequency circuitry 804 to, for example, another computer device, or output to memory 802 for further processing. Audio circuitry 805 may also include an earphone jack to facilitate communication between peripheral headphones and computer devices.
[0253] The input unit 806 can be used to receive input numbers, characters, or user characteristic information (such as fingerprints, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control.
[0254] Power supply 807 is used to supply power to various components of computer device 800. Optionally, power supply 807 can be logically connected to processor 801 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. Power supply 807 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0255] although Figure 30 As not shown in the diagram, the computer device 800 may also include a camera, sensors, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0256] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0257] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0258] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of computer programs / instructions. These computer programs can be loaded by a processor to execute steps in the target object rendering method provided in any of the embodiments of this application. For example, the computer program can execute the following steps:
[0259] The process involves acquiring model information and light source information for the target object, where the model information includes normal information; determining the diffuse illumination coefficient of each pixel in the target object to be rendered using a preset diffuse reflection function based on the normal information and the light source information, where the preset diffuse reflection function is differentiable at zero and its reciprocal is zero; determining the diffuse illumination value of each pixel based on the diffuse illumination coefficient and the light source information; and performing stylized rendering on the target object based on the diffuse illumination value.
[0260] or,
[0261] The process involves: acquiring model information and light source information of the target object, whereby the model information includes normal information; acquiring the texture coordinates, shadow coefficient, and specular color of each pixel in the target object to be rendered, and generating the specular intensity of each pixel based on the texture coordinates of the target object; determining the specular reflection illumination value of each pixel based on the specular intensity, the specular color, the shadow coefficient or a corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel; and performing stylized rendering on the target object based on the specular reflection illumination value.
[0262] or,
[0263] The process involves acquiring model information and light source information for the target object, whereby the model information includes normal information and the light source information includes indirect lighting information. The process then uses the indirect lighting information and normal information to perform indirect diffuse reflection processing on each pixel of the target object to be rendered, obtaining an indirect diffuse lighting value. Alternatively, it uses roughness and normal information to perform indirect specular reflection processing on each pixel of the target object to be rendered, obtaining an indirect specular lighting value, thereby decoupling the indirect diffuse reflection processing and the indirect specular reflection processing. Based on the indirect diffuse lighting value and / or the indirect specular lighting value, the process determines the indirect lighting value for each pixel of the target object to be rendered. Finally, the process performs stylized rendering on the target object based on the indirect lighting value.
[0264] The specific implementation of each of the above operations and the beneficial effects they can achieve can be found in the previous embodiments, and will not be repeated here.
[0265] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0266] Since the computer program stored in the storage medium can execute the steps in any of the target object rendering methods provided in the embodiments of this application, the beneficial effects that any of the target object rendering methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0267] The above provides a detailed description of a method, apparatus, storage medium, and computer device for rendering a target object according to embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for rendering a target object, characterized in that, include: Acquire the model information and light source information of the target object, wherein the model information includes normal information; Based on the normal information and the light source information, the diffuse reflection illumination coefficient of each pixel in the pixel to be rendered of the target object is determined using a preset diffuse reflection function. The preset diffuse reflection function is differentiable at the function value of zero and its reciprocal is zero. Based on the diffuse reflection illumination coefficient and the light source information, determine the diffuse reflection illumination value of each pixel; Based on the diffuse illumination value, the target object is stylized and rendered.
2. The method according to claim 1, characterized in that, The preset diffuse reflection function includes a diffuse reflection attenuation coefficient. Each pixel includes an R channel, a G channel, and a B channel. The step of determining the diffuse reflection illumination coefficient of each pixel in the target object to be rendered using the preset diffuse reflection function based on the normal information and the light source information includes: For each of the R, G, and B channels, obtain the pre-set different attenuation coefficients; Based on the normal information, the light source information, and the different attenuation coefficients set, the channel diffuse illumination coefficients of each pixel in the pixel to be rendered in the R channel, G channel, and B channel are determined using the preset diffuse reflection function. The diffuse illumination coefficients of the R, G, and B channels are determined as the diffuse illumination coefficients of each pixel in the pixel to be rendered.
3. The method according to claim 2, characterized in that, The step of obtaining different preset attenuation coefficients for each of the R, G, and B channels includes: obtaining different preset attenuation coefficients for different channels of different pixels.
4. The method according to claim 2, characterized in that, The light source information includes the transmittance ratio of the light source, and the method further includes: When the transmission ratio is zero, the attenuation coefficient of each of the R, G, and B channels of each pixel is set to the default attenuation coefficient. When the transmission ratio is 1, the attenuation coefficient of each of the R, G and B channels of each pixel is set to a preset attenuation coefficient; When the transmission ratio is between 0 and 1, the attenuation coefficient of each of the R, G and B channels is set as the interpolated attenuation coefficient, which is the attenuation coefficient obtained by interpolating the default attenuation coefficient and the preset attenuation coefficient.
5. The method according to claim 2, characterized in that, After determining the diffuse illumination coefficients of each pixel in the pixel to be rendered, the process also includes: The shadow coefficient of each pixel in the pixel to be rendered is corrected to obtain the corrected shadow coefficient; The final diffuse illumination coefficient of each pixel is determined based on the diffuse illumination coefficient of each pixel and the corrected shadow coefficient.
6. The method according to claim 5, characterized in that, The light source information includes the illumination direction, and the step of correcting the shadow coefficient of each pixel in the pixel to be rendered to obtain the corrected shadow coefficient includes: Obtain the shadow coefficient of each pixel, as well as the first diffuse illumination coefficient and the maximum shadow coefficient corresponding to the normal information being perpendicular to the illumination direction; The shadow coefficient is corrected using the first diffuse illumination coefficient and the maximum shadow coefficient to obtain the corrected shadow coefficient.
7. The method according to claim 5 or 6, characterized in that, Before the step of stylizing the target object based on the diffuse illumination value, the method further includes: The specular reflection illumination coefficient of each pixel in the pixel to be rendered is determined using a method in the physically based rendering pipeline. The specular reflection illumination value of each pixel is determined based on the specular reflection illumination coefficient, the shadow coefficient or the corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel. or, Based on the texture coordinates of each pixel in the target object to be rendered, generate the highlight intensity of each pixel in the target object to be rendered; Based on the specular intensity, specular color, corrected shadow coefficient, and light source information, determine the specular reflection illumination value of each pixel; The step of stylizing the target object based on the diffuse illumination value includes: The target object is stylized and rendered based on the diffuse and specular illumination values.
8. The method according to claim 1 or 7, characterized in that, The light source information also includes indirect light information, and before the step of stylizing the target object based on the diffuse illumination value, the method further includes: The indirect light diffuse reflection processing and the indirect light specular reflection processing are decoupled by using the indirect light information and normal information to perform indirect light diffuse reflection processing on each pixel of the target object to be rendered, and / or by using roughness and normal information to perform indirect light specular reflection processing on each pixel of the target object to be rendered, so as to decouple the indirect light diffuse reflection processing and the indirect light specular reflection processing. Based on the indirect light diffuse reflection illumination value and / or the indirect light specular reflection illumination value, determine the indirect light illumination value of each pixel in the target object to be rendered.
9. A method for rendering a target object, characterized in that, include: Acquire the model information and light source information of the target object, wherein the model information includes normal information; Obtain the texture coordinates, shadow coefficient, and specular color of each pixel in the target object to be rendered, and generate the specular intensity of each pixel in the target object to be rendered based on the texture coordinates of the target object; The specular reflection illumination value of each pixel is determined based on the specular intensity, the specular color, the shadow coefficient or the corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel. The target object is stylized and rendered based on the specular reflection illumination value.
10. The method according to claim 9, characterized in that, The step of generating the specular intensity of each pixel in the pixels to be rendered based on the texture coordinates of the target object includes: Based on the texture coordinates, determine the specular coefficient of each pixel in the pixel to be rendered; Based on the specular coefficient and the preset specular intensity value, the specular intensity of each pixel in the pixel to be rendered is generated.
11. The method according to claim 10, characterized in that, The target object includes a first target object, and the step of determining the specular coefficient of each pixel in the pixel to be rendered based on the texture coordinates includes: Obtain the specular texture map of the first target object; Based on the texture coordinates, the normal information in the model information of the first target object, and the positional relationship with the virtual camera, the sampled texture coordinates of each pixel in the pixel to be rendered are determined; The specular texture map is sampled based on the sampled texture coordinates to generate the specular coefficients for each pixel in the pixel to be rendered.
12. The method according to claim 11, characterized in that, The first target object is a virtual eyeball. The step of determining the sampled texture coordinates of each pixel in the pixel to be rendered based on the texture coordinates, the normal information in the model information of the first target object, and the positional relationship with the virtual camera includes: When the virtual camera is looking directly at the virtual eyeball, obtain the vertical vector in the vertical direction and the horizontal vector in the horizontal direction on the plane where the virtual eyeball is located; The offset between the virtual camera and the virtual eyeball is determined based on the vertical vector, the horizontal vector, and the orientation vector of the virtual camera. Based on the texture coordinates, the offset, the movement speed of the highlight point with the viewpoint, and the scaling data of the highlight point, the sampled texture coordinates of each pixel in the first target object to be rendered are determined.
13. The method according to claim 12, characterized in that, The step of obtaining the vertical vector in the vertical direction and the horizontal vector in the horizontal direction on the plane where the virtual eyeball is located includes: Obtain the skeletal vectors of the bones bound to the virtual eyeball; The vertical vector in the vertical direction and the horizontal vector in the horizontal direction on the plane where the virtual eyeball is located are determined based on the skeletal vector.
14. The method according to claim 12, characterized in that, The step of obtaining the vertical vector in the vertical direction and the horizontal vector in the horizontal direction on the plane where the virtual eyeball is located includes: The model information of the virtual eyeball is copied to obtain two virtual eyeball models; The normal vectors of the two virtual eyeball models are set as a vertical vector in the vertical direction and a horizontal vector in the horizontal direction on the plane where the virtual eyeballs are located.
15. The method according to claim 10, characterized in that, The target object includes a second target object, and the step of determining the specular coefficient of each pixel in the pixel to be rendered based on the texture coordinates includes: Determine the preset texture coordinates of the second target object. The preset texture coordinates are obtained by unfolding the texture coordinates of the facet corresponding to the second target object into texture coordinates arranged vertically along the V-axis coordinate direction. Obtain a pre-constructed preset function, which includes a highlight position offset coefficient and a highlight thickness coefficient. The maximum value of the preset function is controllable, the range of the independent variables of the preset function is controllable, and the position of the maximum value within the range of the independent variables is controllable. Set the highlight position offset value corresponding to the highlight position offset coefficient, and the highlight thickness value corresponding to the highlight thickness coefficient; Based on the preset texture coordinates, the specular position offset value, and the specular thickness value, the specular coefficient of each pixel in the second target object to be rendered is generated using the preset function.
16. The method according to claim 15, characterized in that, Set the highlight grit value corresponding to the highlight grit factor, including: The specular coarseness coefficient in the preset function is changed as the u value in the U-axis direction of the preset texture coordinates changes, so as to obtain the changing specular coarseness value; The step of generating the specular coefficient of each pixel in the second target object's pixel to be rendered using the preset function based on the preset texture coordinates, the specular position offset value, and the specular thickness value includes: generating the specular coefficient of each pixel in the second target object's pixel to be rendered using the preset function based on the v value in the V-axis direction of the preset texture coordinates, the specular position offset value, and the varying specular thickness value.
17. The method according to claim 16, characterized in that, After the step of setting the highlight position offset value corresponding to the highlight position offset coefficient, the method further includes: performing noise processing on the highlight position offset value using a first noise function to obtain the final highlight position offset value. and / or After obtaining the varying highlight thickness values, the method further includes: applying a second noise function to the varying highlight thickness values to obtain the final highlight thickness values.
18. The method according to claim 10, characterized in that, The target object also includes a third target object, and the step of determining the specular coefficient of each pixel in the pixel to be rendered based on the texture coordinates includes: Obtain the specular texture map of the third target object; The specular texture map is sampled based on the texture coordinates of each pixel in the third target object to be rendered to obtain new texture coordinates; Obtain a pre-constructed preset function, which includes a highlight position offset coefficient and a highlight thickness coefficient. The maximum value of the preset function is controllable, the range of the independent variables of the preset function is controllable, and the position of the maximum value within the range of the independent variables is controllable. Set the highlight position offset value corresponding to the highlight position offset coefficient, and the highlight thickness value corresponding to the highlight thickness coefficient; Based on the new texture coordinates, the specular position offset value, and the specular thickness value, the specular coefficient of each pixel in the third target object to be rendered is generated using the preset function.
19. The method according to claim 9, characterized in that, The light source information also includes indirect light information, and before the step of stylizing the target object based on the specular reflection illumination value, the method further includes: The indirect light diffuse reflection processing and the indirect light specular reflection processing are decoupled by using the indirect light information and normal information to perform indirect light diffuse reflection processing on each pixel of the target object to be rendered, and / or by using roughness and normal information to perform indirect light specular reflection processing on each pixel of the target object to be rendered, so as to decouple the indirect light diffuse reflection processing and the indirect light specular reflection processing. Based on the indirect light diffuse reflection illumination value and / or the indirect light specular reflection illumination value, determine the indirect light illumination value of each pixel in the target object to be rendered. The step of stylizing the target object based on the specular reflection illumination value includes: stylizing the target object based on the specular reflection illumination value and the indirect light illumination value.
20. A method for rendering a target object, characterized in that, include: The model information and light source information of the target object are obtained, wherein the model information includes normal information and the light source information includes indirect light information; The indirect light diffuse reflection processing and the indirect light specular reflection processing are decoupled by using the indirect light information and normal information to perform indirect light diffuse reflection processing on each pixel of the target object to be rendered, and / or by using roughness and normal information to perform indirect light specular reflection processing on each pixel of the target object to be rendered, so as to decouple the indirect light diffuse reflection processing and the indirect light specular reflection processing. Based on the indirect light diffuse reflection illumination value and / or indirect light specular reflection illumination value, determine the indirect light illumination value of each pixel in the pixels to be rendered of the target object; Based on the indirect light illumination value, the target object is stylized and rendered.
21. The method according to claim 20, characterized in that, The indirect light information includes indirect light color and indirect light intensity. The step of using the indirect light information and normal information to perform indirect light diffuse reflection processing on each pixel of the target object to be rendered to obtain the indirect light diffuse reflection illumination value includes: Set a spatial axis, and set multiple indirect light colors and multiple indirect light intensities along the spatial axis; Based on the spatial axis, the normal information, multiple indirect light colors, and multiple indirect light intensities, determine the indirect light diffuse reflection value of each pixel in the target object to be rendered. The indirect light diffuse reflection value of each pixel is determined based on the indirect light diffuse reflection value, the inherent color of each pixel of the target object, and the indirect light occlusion intensity.
22. The method according to claim 21, characterized in that, The step of determining the indirect diffuse reflection value of each pixel in the target object to be rendered pixels based on the spatial axis, the normal information, multiple indirect light colors, and multiple indirect light intensities includes: Determine the relationship between the normal information and the spatial axis; Based on the aforementioned relationship, multiple indirect light colors and multiple indirect light intensities are interpolated to obtain the indirect light diffuse reflection value of each pixel in the target object to be rendered.
23. The method according to claim 20, characterized in that, The step of performing indirect specular reflection processing on each pixel of the target object to be rendered using roughness and normal information to obtain indirect specular reflection illumination values includes: The indirect light specular reflection value of each pixel in the target object to be rendered is determined based on the normal information and roughness. Obtain the reflected color of each pixel of the target object; Based on the indirect light specular reflection value, the reflected color of the target object, and the indirect light occlusion intensity, the indirect light specular reflection illumination value of each pixel in the target object to be rendered is determined.
24. The method according to claim 23, characterized in that, The step of obtaining the reflected color of each pixel of the target object includes: The reflected color of each pixel of the target object is determined based on the roughness and the inherent color of each pixel in the target object to be rendered.
25. A rendering apparatus for a target object, characterized in that, include: The first acquisition module is used to acquire model information and light source information of the target object, wherein the model information includes normal information; The first diffuse reflection module is used to determine the diffuse reflection illumination coefficient of each pixel in the target object to be rendered pixels according to the normal information and the light source information, using a preset diffuse reflection function; and to determine the diffuse reflection illumination value of each pixel according to the diffuse reflection illumination coefficient and the light source information; wherein, the preset diffuse reflection function is differentiable at the function value of zero and its reciprocal is zero; The first rendering module is used to perform stylized rendering of the target object based on the diffuse illumination value.
26. A rendering apparatus for a target object, characterized in that, include: The second acquisition module is used to acquire the model information and light source information of the target object, wherein the model information includes normal information; And obtain the texture coordinates, shadow coefficients, and specular color of each pixel in the target object to be rendered; The second specular reflection module is used to generate the highlight intensity of each pixel in the pixel to be rendered based on the texture coordinates of the target object. The specular reflection illumination value of each pixel is determined based on the specular intensity, the specular color, the shadow coefficient or the corrected shadow coefficient, and the light source information, wherein the corrected shadow coefficient is obtained by correcting the shadow coefficient of each pixel. The second rendering module is used to perform stylized rendering of the target object based on the specular reflection illumination value.
27. A rendering apparatus for a target object, characterized in that, include: The third acquisition module is used to acquire model information and light source information of the target object. The model information includes normal information, and the light source information includes indirect light information. The third indirect light module is used to perform indirect light diffuse reflection processing on each pixel of the target object to be rendered using the indirect light information and normal information to obtain indirect light diffuse reflection illumination value, and / or perform indirect light specular reflection processing on each pixel of the target object to be rendered using roughness and normal information to obtain indirect light specular reflection illumination value, so as to decouple the indirect light diffuse reflection processing and the indirect light specular reflection processing. Based on the indirect light diffuse reflection illumination value and / or indirect light specular reflection illumination value, determine the indirect light illumination value of each pixel in the pixels to be rendered of the target object; The third rendering module is used to perform stylized rendering of the target object based on the indirect light illumination value.
28. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted for loading by a processor to perform the steps of the object rendering method as described in any one of claims 1-24.
29. A computer device, characterized in that, The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the steps of the target rendering method as described in any one of claims 1-24 by calling the computer program stored in the memory.