High-light rendering method, device and electronic equipment of model

By adjusting the initial specular parameters using shape gradient parameters in non-realistic rendering, the specular rendering effect conforms to the anisotropic law and has a painterly style, solving the problems of monotonous rendering effects and low efficiency in existing technologies.

CN114387372BActive Publication Date: 2026-02-27NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111639163.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-29
Publication Date
2026-02-27
Estimated Expiration
2041-12-29

AI Technical Summary

Technical Problem

In non-realistic rendering, existing technologies struggle to simultaneously achieve specular rendering effects that conform to anisotropy and painting style, and also suffer from low rendering efficiency.

Method used

The initial specular parameters are calculated using a preset lighting model, the shape gradient parameters of the target model are obtained, the initial specular parameters are adjusted based on the shape gradient parameters to generate specular parameters, and then the specular parameters are used for rendering.

Benefits of technology

While maintaining the anisotropic nature of specular rendering, we added painting styles and improved rendering efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114387372B_ABST
    Figure CN114387372B_ABST
Patent Text Reader

Abstract

The application provides a high-light rendering method and device of a model and electronic equipment, and the initial high-light parameter of a target model is calculated through a preset light model; a shape gradient parameter of the target model is acquired; the shape gradient parameter represents the relative positions between each vertex of the target model; the initial high-light parameter is adjusted based on the shape gradient parameter to obtain the high-light parameter of the target model; and the target model is rendered based on the high-light parameter. The rendering effect of the high light is ensured to be roughly consistent with the anisotropic rule, the rendering effect has a certain painting style, the effect requirement of the non-real rendering scene is met, and the rendering efficiency of the high light is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of model rendering, in particular to a model high-light rendering method and device and electronic equipment. BACKGROUND

[0002] In a virtual scene of non-photorealistic rendering, while a model shows a high-light effect, an artistic performance effect of drawing also needs to be simulated. In related technologies, when non-photorealistic rendering is performed, a light model such as an anisotropic high-light model can be used, or a hand-drawn high-light can be used to render a high-light of a model. However, in the process of rendering a high-light by using a light model, the irradiance of the high-light is usually calculated based on tangent data and normal data of a model to be rendered, the calculation result follows an anisotropic law, and then the high-light of the model is rendered according to the calculated irradiance. The stereoscopic effect of the model rendered by this method is more consistent with the physical high-light effect in a real scene, but the drawing effect is poor. If a hand-drawn high-light is used for rendering, the rendering efficiency is low. SUMMARY

[0003] Therefore, the present application aims to provide a model high-light rendering method, device and electronic equipment, which can ensure that the rendering effect of a high-light is roughly consistent with an anisotropic law, and at the same time, the rendering effect has a certain drawing style, and the rendering efficiency of the high-light is improved.

[0004] In a first aspect, an embodiment of the present application provides a model high-light rendering method, which includes: calculating an initial high-light parameter of a target model by using a preset light model; obtaining a shape gradient parameter of the target model; wherein the shape gradient parameter represents relative positions between vertices of the target model; adjusting the initial high-light parameter based on the shape gradient parameter to obtain a high-light parameter of the target model; and performing high-light rendering on the target model based on the high-light parameter.

[0005] The step of adjusting the initial high-light parameter based on the shape gradient parameter to obtain the high-light parameter of the target model includes: mapping the shape gradient parameter to a specified data range by using a target function to obtain a high-light coefficient of the target model; and adjusting the initial high-light parameter based on the high-light coefficient to obtain the high-light parameter of the target model.

[0006] The step of adjusting the initial high-light parameter based on the high-light coefficient to obtain the high-light parameter of the target model includes: determining a product of the high-light coefficient and the initial high-light parameter as the high-light parameter of the target model.

[0007] The step of adjusting the initial high-light parameter based on the shape gradient parameter to obtain the high-light parameter of the target model includes: mapping a product of the shape gradient parameter and the initial high-light parameter by using a target function to obtain the high-light parameter of the target model.

[0008] The step of obtaining the shape gradient parameter of the target model comprises: generating a directional distance field image corresponding to a texture map of the target model based on the texture map; the texture map comprises texture map coordinates of each vertex of the target model; performing sampling processing on a pixel point of the directional distance field image based on the texture map coordinates of the vertex to obtain the shape gradient parameter of the target model; the shape gradient parameter comprises a pixel value of each vertex in the directional distance field image.

[0009] The step of generating the directional distance field image corresponding to the texture map based on the texture map corresponding to the target model comprises: generating a mask image comprising the texture map corresponding to the target model; in the mask image, a pixel value of a pixel point corresponding to the texture map is a first pixel value, and a pixel value of a pixel point corresponding to an image other than the texture map is a second pixel value; calculating a directional distance of each pixel point in the mask image from a set region; the set region comprises an image region composed of the first pixel value or an image region composed of the second pixel value; mapping the directional distance of each pixel point to a distance field pixel value corresponding to the pixel point based on a resolution of the mask image; generating a directional distance field image corresponding to the mask image based on a position of each pixel point in the mask image and the corresponding distance field pixel value.

[0010] After the step of obtaining the shape gradient parameter of the target model based on the sampling processing of the pixel point of the directional distance field image based on the texture map coordinates of the vertex, the method further comprises: for each vertex, performing normalization processing on a pixel value of the vertex in the directional distance field image through a target threshold; determining the pixel value of each vertex after the normalization processing as the shape gradient parameter of the target model.

[0011] In a second aspect, an embodiment of the present application provides a high light rendering device of a model, the device comprising: an initial parameter acquisition module configured to calculate an initial high light parameter of a target model through a preset light model; a shape gradient parameter acquisition module configured to obtain a shape gradient parameter of the target model; wherein the shape gradient parameter represents relative positions between each vertex of the target model; a parameter adjustment module configured to adjust the initial high light parameter based on the shape gradient parameter to obtain a high light parameter of the target model; and a high light rendering module configured to perform high light rendering on the target model based on the high light parameter.

[0012] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, the memory storing machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the high light rendering method of the model.

[0013] In a fourth aspect, an embodiment of the present application provides a machine readable storage medium storing machine executable instructions, which when invoked and executed by a processor, cause the processor to implement the high-light rendering method of the model as described above.

[0014] The embodiments of the present application bring the following beneficial effects:

[0015] The above provides a high-light rendering method of a model, device and electronic equipment, the initial high-light parameter of the target model is calculated through the preset light model; the shape gradient parameter of the target model is obtained; wherein, the shape gradient parameter represents the relative position between each vertex of the target model; the initial high-light parameter is adjusted based on the shape gradient parameter, and the high-light parameter of the target model is obtained; the target model is high-light rendered based on the high-light parameter. This way ensures that the rendering effect of the high-light generally conforms to the anisotropic rule, while making the rendering effect have a certain painting style, meeting the effect requirements of the non-real rendering scene, and improving the rendering efficiency of the high-light.

[0016] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent to those skilled in the art from the description, or can be learned by practice of the present application. The objects and other advantages of the present application will be realized and achieved by the structure particularly pointed out in the description, claims and drawings.

[0017] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the following preferred embodiments are specifically described below, and the accompanying drawings are described in detail as follows. BRIEF DESCRIPTION OF DRAWINGS

[0018] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0019] Figure 1 A flow chart of a high-light rendering method of a model provided by an embodiment of the present application is shown in the figure;

[0020] Figure 2 A schematic diagram of a mask image of a plurality of UV shells provided by an embodiment of the present application is shown in the figure;

[0021] Figure 3 A schematic diagram of a directed distance field image provided by an embodiment of the present application is shown in the figure;

[0022] Figure 4The high light effect drawing provided by the embodiment of the present application is rendered by using the high light calculated by the Cook-Torrance BRDF algorithm;

[0023] Figure 5 The schematic diagram of the preprocessed distance field provided by the embodiment of the present application is shown in the figure;

[0024] Figure 6 The high light effect drawing provided by the embodiment of the present application is rendered by using the adjusted high light parameter;

[0025] Figure 7 The high light effect drawing provided by the embodiment of the present application is rendered by using the adjusted high light parameter;

[0026] Figure 8 The structural schematic diagram of the high light rendering device of the model provided by the embodiment of the present application is shown in the figure;

[0027] Figure 9 The structural schematic diagram of the electronic device provided by the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical scheme and advantages of the embodiment of the present application clearer, the technical scheme of the present application will be described clearly and completely below in combination with the drawings. Obviously, the described embodiment is a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by the person skilled in the art without creative labor are within the protection scope of the present application.

[0029] In the real-time non-photography rendering (NPR) scene, a complete rendering result generally contains direct light and indirect light, and the direct light contains diffuse reflection and specular reflection, wherein the specular reflection of the direct light is also called high light, which has a great influence on the light and shadow effect of the model. In the virtual scene of the non-photography rendering, the artistic performance effect of the drawing needs to be simulated while the high light effect of the model is performed.

[0030] Taking a hair model as an example, in the related art, in a real-time rendering process, a Kajiya-Kay light model, an anisotropic highlight light model, or a multi-layer anisotropic highlight light model can be used to render highlights of the hair. Taking anisotropic highlights as an example below, a common calculation method of PBR (Physically Based Shading) highlights is usually a Bidirectional Reflectance Distribution Function (BRDF) based on specular reflection or a Cook-Torrance BRDF (including a diffuse reflection and a specular reflection part, and the specular reflection part is usually used for highlight rendering, hereinafter referred to as BRDF). To reduce the amount of calculation, the irradiance representing the highlight parameter can be calculated by a formula obtained by simplifying and fitting the BRDF as follows:

[0031] f = L·N*D*F*V / 4

[0032] In the above formula, L is a light direction, N is a normal direction, D is a normal distribution term, F is a Fresnel term, and V is a visibility term fitted by Unity PBS. Among them, the D term can be calculated based on Anisotropic GGX (i.e., Trowbridge-Reitz distribution), and the specific method is as follows:

[0033] First, a parallel main light source is defined, and the vectors defined below are all unit vectors. The direction vector of the light source is defined as L, the color of the light source is defined as LightColor, the surface normal direction vector corresponding to each polygon of the target model is defined as N, the tangent direction vector is defined as T, the bitangent direction is defined as B, the view direction vector is defined as V, the half-angle vector is defined as H = normalize(L+V), the anisotropy value is defined as Aniso, the roughness is defined as Roughness, and π is represented by PI. Based on the above definitions, the D term calculation process of the highlight anisotropy is as follows:

[0034] Aspect = sqrt(1.0–0.9*Aniso)

[0035] ax = Aniso*Aniso / aspect

[0036] ay = roughness*roughness / aspect

[0037] XoH = dot(T, H)

[0038] YoH = dot(B, H)

[0039] NoH = dot(N, H)

[0040] d = XoH * XoH / (ax * ax) + YoH * YoH / (ay * ay) + NoH * NoH D = 1 / (PI * ax * ay * d * d)

[0041] The final calculation result specular is the D term result of the BRDF specular reflection. Based on the calculated D term, the highlight parameter of the target model can be calculated, and the target model is further rendered by the calculated highlight parameter.

[0042] Based on the above discussion process, it can be known that the highlight parameter is calculated based on the tangent data and the normal data of the model, and the calculation result follows the anisotropic law. The highlight effect rendered based on the highlight parameter conforms to the physical law in the actual scene, but in the non-realistic rendering scene, it is often necessary to have a less physical result to express the hand-drawing feeling. If the hand-drawing highlight is used for highlight rendering, the hand-drawing highlight effect needs to be obtained, and the efficiency is low. Based on this, the model highlight rendering method, device and electronic equipment provided by the embodiment of the application can be applied to the highlight rendering of the game model or other virtual models in the virtual scene.

[0043] In order to facilitate the understanding of the embodiment, first, a model highlight rendering method disclosed by the embodiment of the application is introduced in detail, as shown in the following formula (1) : Figure 1 The method includes the following steps:

[0044] In step S102, the initial highlight parameter of the target model is calculated by a preset light model.

[0045] The light model is usually a computer model that simulates the physical process of light illumination in nature according to the relevant laws of optics, and can use Kajiya-Kay light model, anisotropic highlight light model or multi-layer anisotropic highlight light model, etc. The light model usually includes a diffuse reflection part and a specular reflection part. Since the highlight represents the part of the object directly reflecting the light source, it is often seen in objects with relatively smooth texture, so the specular reflection part of the light model can be used to calculate the initial highlight parameter of the target model. The intensity of the highlight and the angle between the reflection R formed after the light L enters the point P on the surface of the object and the connecting vector E between the observation point and the point P are related. The closer E is to R, the more information P point receives, and the brighter P point is in the field of view, that is, the angle between the reflection R and E will determine the intensity of the highlight. In related technologies, the normal distribution term is often used to represent the angle between the reflection R and E.

[0046] The target model refers to a three-dimensional model in a game scene or other virtual scene, which can be a virtual model corresponding to an object in a real scene with a strong light and shadow effect due to a relatively smooth surface, such as a watermelon, a stainless steel sphere, a vase, a human head, and the like. The surface of the target model is composed of graphics primitives. The graphics primitives can be in the form of simple polygons, such as triangles, quadrilaterals, and the like. In the process of calculating the initial highlight parameter of the target model by using the above light models, the normal and tangent data of the surface formed by the graphics primitives and the illumination direction of the light source are usually required to simulate the physical law of light illumination on the model surface. The initial highlight parameter obtained by using the above method follows the anisotropic law of light illumination on the object surface, and direct rendering of the target model by using the initial highlight parameter can make the highlight effect of the rendered target model consistent with the real scene, but the highlight effect almost does not have a painting style.

[0047] In step S104, a shape gradient parameter of the target model is obtained; wherein the shape gradient parameter represents the relative positions between the vertices of the target model.

[0048] The graphics primitives of the target model are usually polygons, and the polygons include a plurality of vertices. The graphics primitives with curved radii are connected to each other by the vertices to form the surface of the target model, thereby constituting a relatively continuous and smooth three-dimensional shape of the target model in a macroscopic view. When light is illuminated on the surface of the target model, different angles between the surface of the target model and the light rays at different positions will produce different intensities of highlights due to different shapes of the model surface. Since the surface of the target model is relatively smooth, the relative positions between the vertices of the graphics primitives, or the positions of the vertices of the graphics primitives on the surface of the entire target model can reflect the shape gradient of the target model to a certain extent.

[0049] In the specific implementation process, the shape gradient parameter of the target model can be determined by calculating the distance field parameters of the vertices of the target model. The distance field is a field function. The field function is a function defined in the entire space, and in the method, the entire space can be a three-dimensional space constituted by the target model. The distance field parameter of each vertex can be the distance of each vertex from the three-dimensional space constituted by the target model. The Euclidean distance calculation can be used for calculation, and sometimes other distance calculation functions are used for calculation.

[0050] In order to simplify the calculation process, the vertices of the target model can be first mapped to a two-dimensional image, which is usually referred to as a texture map. The pixels in the texture map correspond to the vertices of the target model, and the coordinates of the pixels in the texture map correspond to the three-dimensional coordinates of the vertices. Then, the distance field parameters of each pixel in the texture map are calculated based on the coordinates of the pixels, and then the distance field image corresponding to the entire texture map is obtained, and the distance field parameters of each vertex are determined based on the correspondence between the vertices and the pixels. The correspondence between the position parameters of each vertex and the distance field parameters can be directly determined as the shape gradient parameters of the target model, or the distance field parameters can be processed, such as smoothing filtering, and the correspondence between the position parameters of each vertex and the processed distance field parameters can be determined as the shape gradient parameters of the target model.

[0051] In step S106, the initial highlight parameters are adjusted based on the shape gradient parameters to obtain the highlight parameters of the target model.

[0052] In the non-realistic rendering scene, the painting effect needs to be generated, and the highlight distribution in the painting effect is roughly the same as the physical law, but the change gradient of the highlight with the shape of the model is generally relatively flat. However, the initial highlight parameters are consistent with the physical law of the highlight distribution generated by the light shining on the surface of the target model, and therefore the initial highlight parameters need to be adjusted by the shape gradient parameters of the target model.

[0053] In the specific implementation process, the target function can be first used to pre-process the shape gradient parameters to obtain the target adjustment effect. In the process of determining the target function, the preset function can be applied to the shape gradient parameters, and the preset function can be adjusted according to the generated adjustment effect, and when the target adjustment effect is obtained, the adjusted preset function (i.e. the target function) is used to map the shape gradient parameters to obtain the pre-processed shape gradient parameters. Since the highlight distribution in the painting effect is roughly the same as the physical law, the shape gradient parameters usually only have a fine-tuning effect on the initial highlight parameters, and therefore the numerical range of the pre-processed shape gradient parameters needs to be limited within a preset numerical range, which is usually [0, 1].

[0054] In the specific implementation process, the initial highlight parameters can also be directly adjusted by the shape gradient parameters, such as multiplying the shape gradient parameters by the initial highlight parameters, or subtracting the shape gradient parameters from the initial highlight parameters to obtain the processed highlight parameters. Then, the target function is used to map the processed initial highlight parameters to obtain the final highlight parameters of the target model according to the target adjustment effect. The above process also usually needs to limit the value range of the shape gradient parameters, and the value range can be limited by normalizing the shape gradient parameters by using a preset normalization parameter.

[0055] Step S108, perform high light rendering on the target model based on the high light parameter.

[0056] When performing high light rendering, the high light rendering mode of the preset light model can be adopted, but the initial high light parameter in the light model needs to be replaced by the high light parameter that has been adjusted through the shape gradient parameter. As the above-mentioned high light parameter has been adjusted through the shape gradient parameter of the target model, the high light effect obtained by using this high light parameter to perform high light rendering on the target model can meet the physical high light distribution rule to a certain extent, and at the same time has a certain painting style.

[0057] The above provides a high light rendering method of a model, calculates an initial high light parameter of a target model through a preset light model; obtains a shape gradient parameter of the target model; wherein the shape gradient parameter represents the relative positions between each vertex of the target model; adjusts the initial high light parameter based on the shape gradient parameter to obtain a high light parameter of the target model; and performs high light rendering on the target model based on the high light parameter. This way ensures that the rendering effect of the high light is roughly consistent with the anisotropic rule, while making the rendering effect have a certain painting style, meeting the effect requirement of the non-real rendering scene, and at the same time improving the rendering efficiency of the high light.

[0058] The following embodiments provide an implementation manner of obtaining a shape gradient parameter of a target model.

[0059] In the process of obtaining the shape gradient parameter of the target model, a directed distance field image corresponding to the texture map of the target model (also referred to as UV shell) can be generated based on the target model first; wherein the texture map includes the texture map coordinates (also referred to as UV coordinates) of each vertex of the target model; then the pixel points of the directed distance field image are sampled and processed based on the texture map coordinates of the vertex to obtain the shape gradient parameter of the target model; wherein the shape gradient parameter includes the pixel values of each vertex corresponding to the directed distance field image.

[0060] Taking a hair model as an example, a directed distance field image (which can be referred to as a "distance field" for short) is first generated using a UV shell of the hair model (also referred to as a "hair tile" or a "hair cluster model"). In the process of making a hair model, UV shell unfolding is a necessary step. The coordinates of a hair sampling map in the UV shell are a mapping of three-dimensional vertex coordinates on a two-dimensional plane. A closed interval formed by three or more vertices in the UV coordinates is usually referred to as a UV shell. The model shape of a hair cluster or a hair tile is usually a long strip shape or a column shape. By calculating a gradient from left to right or directly calculating a distance field for the UV shell, and then sampling pixel points in the directed distance field image based on the UV coordinates of each vertex, a sampling distance field can be obtained, which represents the relative distance of each pixel in the UV shell (corresponding to the pixel value of the pixel point obtained by sampling), that is, the shape gradient parameter described above. In this way, the shape gradient parameter can be used to further control the highlight intensity of each surface of the target image, and then control the highlight shape. For each vertex, the pixel value of each vertex after normalization processing by a target threshold is usually determined as the shape gradient parameter of the target model.

[0061] Specifically, in the process of generating a directed distance field image corresponding to a texture map, a mask image corresponding to the texture map of the target model is first generated. Taking a hair model as an example, Figure 2 The mask image of the UV shell of the plurality of hair tiles is shown. In the generated mask image, the pixel value of the pixel point corresponding to the texture map is a first pixel value, Figure 2 The black pixels are shown in the middle. The pixel value of the pixel point corresponding to the image other than the texture map is a second pixel value, Figure 2 The white pixels are shown in the middle. Then, the directed distance of each pixel point in the mask image from a set region is calculated. The set region includes an image region composed of the first pixel value or an image region composed of the second pixel value. Selecting which set region can affect the calculation result mainly in the positive and negative directions of the distance. Finally, the directed distance of each pixel point is mapped to the distance field pixel value corresponding to the pixel point based on the resolution of the mask image. Based on the position of each pixel point in the mask image and the corresponding distance field pixel value, a directed distance field image corresponding to the mask image is generated. The generated directed distance field image is shown in Figure 3 The image reflects the distance of each pixel point on the UV shell from the hair model to a certain extent.

[0062] The following embodiments provide an implementation manner of obtaining a highlight parameter of a target model.

[0063] In the process of adjusting the initial highlight parameter based on the shape gradient parameter, the shape gradient parameter can be mapped to a specified data range by a target function to obtain a highlight coefficient of the target model, and then the initial highlight parameter is adjusted based on the highlight coefficient to obtain the highlight parameter of the target model.

[0064] Mapping, in mathematics, refers to the relationship between two elements of the set corresponding to each other; here, it refers to the corresponding relationship between the shape gradient parameter and the value in the specified data range through the target function. The value corresponding to the shape gradient parameter obtained by mapping is used as the highlight coefficient, so that the highlight effect of the target model can be controlled through the target function.

[0065] The process of generating the highlight coefficient is also called preprocessing the distance field. If the distance field parameters of each vertex are normalized, the distance field parameter is a value in the range of 0-1 for each pixel on the UV coordinate, and finally it will be multiplied by the result of the highlight calculation in the real-time rendering stage. For artistic effects, generally the edge highlight of the film will be weak, so the sin function can be used as the target function to preprocess the distance field which increases linearly from left to right. The specific implementation is as follows:

[0066] RemapDF=sin(DF*pi)

[0067] Where RemapDF is the obtained highlight coefficient, DF (Distance Field) is the distance field parameter of each vertex sampled, and pi represents π. Through the above processing method, a result in the range of 0-1 can be obtained, with 0 at both ends and 1 in the middle. This result can be saved as a map using UV coordinates and provided to the real-time rendering stage for sampling. In the real-time rendering stage, the distance field map is sampled, and the D term of BRDF is calculated using the method described in 2.1. The D term is calculated as follows:

[0068] SpecularD=D*RemapDF

[0069] That is, the product of the highlight coefficient (RemapDF) and the initial highlight parameter (D) is determined as the highlight parameter (SpecularD) of the target model, and the final BRDF calculation result is:

[0070] f=L·N*SpecularD*F*V / 4

[0071] In addition, the shape gradient parameter can also be directly mapped in the real-time rendering stage by a target function to obtain the product of the shape gradient parameter and the initial highlight parameter, and then the highlight parameter of the target model is obtained.

[0072] Based on the above method embodiment, the embodiment provides another specific model high light rendering method, which takes a hair model as an example, and specifically introduces the process of realizing the painting style of the hair high light based on the PBR light model. The method mainly includes the following steps:

[0073] Step one, using the fitted Cook-Torrance BRDF algorithm to calculate the high light. Directly using the high light for high light rendering of the hair model, the effect diagram is as shown in Figure 4

[0074] Step two, generate a distance field through UV Shell.

[0075] Step three, preprocess the distance field, and the schematic diagram of the preprocessed distance field is as shown in Figure 5

[0076] Step four, define the material optical properties, Metallic is the metal degree, Roughness is the roughness, Aniso is the anisotropy degree, and BaseColor is the diffuse color.

[0077] Step five, calculate the direct light diffuse reflection, the calculation is as follows: DirectLightRadiance=saturate(dot(N,L))*LightColor;Wherein, LightColor is the light color.

[0078] Step six: calculate the direct light reflection color, that is, the initial high light parameter, the calculation is as follows:

[0079] Aspect=sqrt(1.0–0.9*Aniso

[0080] ax=Aniso*Aniso / aspect

[0081] ay=roughness*roughness / aspect

[0082] XoH=dot(T,H)

[0083] YoH=dot(B,H)

[0084] NoH=dot(N,H)

[0085] d=XoH*XoH / (ax*ax)+YoH*YoH / (ay*ay)+NoH*NoH D=1 / (PI*ax*ay*d*d)

[0086] V*F=1.0 / (LoH^2*(Roughness+0.5));

[0087] ​​SpecularColor = Lerp(0.04, BaseColor, Metallic);

[0088] BRDFspec = saturate(dot(N, L)) * (D * V * F) / 4;

[0089] wherein SpecularColor is the direct lighting specular color.

[0090] Step seven, define the current pixel distance field obtained by sampling as DFvalue, and calculate the highlight:

[0091] BRDFspec = smoothstep(0.45, 0.55, BRDFspec * DFvalue); this step is an assignment process, and the formula represents a process of mapping the product of the shape gradient parameter and the initial highlight parameter.

[0092] Step eight: calculate the final lighting result, as follows:

[0093] DirectColor = BRDFspec * SpecularColor + BaseColor;

[0094] DirectResult = DirectColor * DirectLightRadiance;

[0095] The rendering result of the hair model by superimposing the highlight after the distance field is shown in Figure 6 and Figure 7 , wherein Figure 6 and Figure 7 different mapping methods are used when adjusting the initial highlight parameter.

[0096] The above highlight rendering method of the model not only ensures that the highlight lighting feedback generally follows the anisotropic physical law, but also shows a hand-drawn style in the highlight shape.

[0097] For the above method embodiment, referring to a highlight rendering device of a model shown in Figure 8 , the device comprises:

[0098] An initial parameter acquisition module 802 is configured to calculate an initial highlight parameter of a target model by using a preset lighting model;

[0099] A shape gradient parameter acquisition module 804 is configured to acquire a shape gradient parameter of the target model; wherein the shape gradient parameter represents the relative positions between the vertices of the target model.

[0100] The parameter adjustment module 806 is configured to adjust the initial highlight parameter based on the shape gradient parameter to obtain a highlight parameter of the target model.

[0101] The highlight rendering module 808 is configured to perform highlight rendering on the target model based on the highlight parameter.

[0102] The above provides a highlight rendering device of a model. The initial highlight parameter of the target model is calculated based on a preset light model. The shape gradient parameter of the target model is obtained. The shape gradient parameter represents the relative positions between the vertices of the target model. The initial highlight parameter is adjusted based on the shape gradient parameter to obtain the highlight parameter of the target model. The target model is rendered based on the highlight parameter. The rendering effect of the highlight is ensured to be roughly consistent with the anisotropic rule, and the rendering effect has a certain painting style, which meets the effect requirement of the non-real rendering scene and improves the rendering efficiency of the highlight.

[0103] The parameter adjustment module includes a highlight coefficient obtaining unit configured to map the shape gradient parameter to a specified data range by a target function to obtain a highlight coefficient of the target model, and an adjustment unit configured to adjust the initial highlight parameter based on the highlight coefficient to obtain the highlight parameter of the target model.

[0104] The adjustment unit is further configured to determine the product of the highlight coefficient and the initial highlight parameter as the highlight parameter of the target model.

[0105] The parameter adjustment module is further configured to map the product of the shape gradient parameter and the initial highlight parameter by the target function to obtain the highlight parameter of the target model.

[0106] The shape gradient parameter obtaining module includes a directed distance field generating unit configured to generate a directed distance field image corresponding to a texture map of the target model based on the texture map, and a sampling unit configured to sample pixels of the directed distance field image based on the texture map coordinates of the vertices to obtain the shape gradient parameter of the target model. The shape gradient parameter includes pixel values of the vertices in the directed distance field image.

[0107] The directional distance field generation unit is further configured to generate a mask image corresponding to a texture map corresponding to the target model, wherein a pixel value of a pixel corresponding to the texture map in the mask image is a first pixel value, and a pixel value of a pixel corresponding to an image other than the texture map is a second pixel value; calculate directional distances between each pixel in the mask image and a set region; the set region includes an image region composed of the first pixel value or an image region composed of the second pixel value; map the directional distance of each pixel to a distance field pixel value corresponding to the pixel based on a resolution of the mask image; and generate a directional distance field image corresponding to the mask image based on a position of each pixel in the mask image and the corresponding distance field pixel value.

[0108] The device further includes a normalization module configured to normalize, for each vertex, a pixel value of the vertex in the directional distance field image by a target threshold; and a shape gradient parameter determination module configured to determine the normalized pixel value of each vertex as a shape gradient parameter of the target model.

[0109] The embodiment also provides an electronic device including a processor and a memory, the memory storing machine executable instructions executable by the processor, and the processor executes the machine executable instructions to implement the model high-light rendering method.

[0110] Referring to Figure 9 The electronic device includes a processor 100 and a memory 101, the memory 101 storing machine executable instructions executable by the processor 100, and the processor 100 executes the machine executable instructions to implement the model high-light rendering method.

[0111] Further, Figure 9 The electronic device also includes a bus 102 and a communication interface 103, and the processor 100, the communication interface 103 and the memory 101 are connected through the bus 102.

[0112] The memory 101 can include a high-speed random access memory (RAM) and can also include a non-volatile memory such as at least one disk memory. The communication between the system network element and at least one other network element is realized through at least one communication interface 103 (which can be wired or wireless), and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used. The bus 102 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 9 Only one bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0113] The processor 100 can be an integrated circuit chip with processing capability. In implementation process, each step of the above method can be completed by integrated logic circuit of hardware in the processor 100 or instruction in the form of software. The processor 100 described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component. Each method, step and logic block diagram disclosed in the embodiment of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiment of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium in the art. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101, and combines the hardware to complete the steps of the method of the above embodiment.

[0114] The embodiment also provides a machine readable storage medium, the machine readable storage medium stores machine executable instructions, when the machine executable instructions are called and executed by the processor, the machine executable instructions cause the processor to implement the high light rendering method of the model.

[0115] The model high light rendering method and device and electronic equipment provided by the embodiment of the present application include a computer readable storage medium storing program codes, the instructions included in the program codes can be used to execute the method described in the foregoing method embodiment, and the specific implementation can be referred to the method embodiment, and will not be described here.

[0116] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the foregoing method embodiment, and will not be described here.

[0117] In addition, in the description of the embodiments of the present application, unless otherwise explicitly specified and limited, the terms "mounting", "connection", "connecting" should be understood in a broad sense, for example, can be fixedly connected, can be detachably connected, or integrally connected; can be mechanically connected, can be electrically connected; can be directly connected, can be indirectly connected through an intermediate medium, or can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.

[0118] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application or the part of the prior art that essentially contributes to the present application or the part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiments of the present application. The foregoing storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0119] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first", "second", "third" are only for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0120] Finally, it should be noted that: the above embodiments are only specific embodiments of the present application, which are used to illustrate the technical solutions of the present application, and are not limited thereto, the protection scope of the present application is not limited thereto, although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art within the technical range disclosed by the present application can modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part of the technical features; and these modifications, changes or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for rendering specular highlights in a model, characterized in that, The method includes: The initial specular parameters of the target model are calculated using a preset lighting model. Obtain the shape gradient parameters of the target model; wherein the shape gradient parameters represent the relative positions between the vertices of the target model; The initial specular parameters are adjusted based on the shape gradient parameters to obtain the specular parameters of the target model; Specular rendering is performed on the target model based on the specular parameters; The steps for obtaining the shape gradient parameters of the target model include: Based on the texture map corresponding to the target model, a directed distance field image corresponding to the texture map is generated; the texture map includes the texture map coordinates of each vertex of the target model; Based on the texture map coordinates of the vertices, the pixels of the directed distance field image are sampled to obtain the shape gradient parameters of the target model; the shape gradient parameters include the pixel values ​​of each vertex in the directed distance field image.

2. The method according to claim 1, characterized in that, The step of adjusting the initial specular parameters based on the shape gradient parameters to obtain the specular parameters of the target model includes: The shape gradient parameters are mapped to a specified data range using an objective function to obtain the specular coefficients of the target model. The initial specular parameters are adjusted based on the specular coefficients to obtain the specular parameters of the target model.

3. The method according to claim 2, characterized in that, The step of adjusting the initial specular parameters based on the specular coefficient to obtain the specular parameters of the target model includes: The product of the specular coefficient and the initial specular parameter is determined as the specular parameter of the target model.

4. The method according to claim 1, characterized in that, The step of adjusting the initial specular parameters based on the shape gradient parameters to obtain the specular parameters of the target model includes: The product of the shape gradient parameters and the initial specular parameters is mapped by the objective function to obtain the specular parameters of the target model.

5. The method according to claim 1, characterized in that, The step of generating a directed range field image corresponding to the texture map based on the texture map corresponding to the target model includes: Generate a mask image including the texture map corresponding to the target model; in the mask image, the pixel value of the pixel corresponding to the texture map is a first pixel value, and the pixel value of the pixel corresponding to the image other than the texture map is a second pixel value; Calculate the directed distance between each pixel in the mask image and a set region; the set region includes the image region composed of the first pixel values ​​or the image region composed of the second pixel values. Based on the resolution of the mask image, the directed distance of each pixel is mapped to the distance field pixel value corresponding to the pixel. Based on the position of each pixel in the mask image and the corresponding distance field pixel value, a directional distance field image corresponding to the mask image is generated.

6. The method according to claim 1, characterized in that, After sampling the pixels of the directed distance field image based on the texture map coordinates of the vertices to obtain the shape gradient parameters of the target model, the method further includes: For each vertex, the pixel value of the vertex corresponding to the directed distance field image is normalized by a target threshold. The pixel values ​​of each vertex after normalization are determined as the shape gradient parameters of the target model.

7. A specular rendering device for a model, characterized in that, The device includes: The initial parameter acquisition module is used to calculate the initial specular parameters of the target model using a preset lighting model; A shape gradient parameter acquisition module is used to acquire the shape gradient parameters of the target model; wherein, the shape gradient parameters represent the relative positions between the vertices of the target model; The parameter adjustment module is used to adjust the initial specular parameters based on the shape gradient parameters to obtain the specular parameters of the target model; A specular rendering module is used to perform specular rendering on the target model based on the specular parameters; The shape gradient parameter acquisition module further includes: A directed distance field generation unit is used to generate a directed distance field image corresponding to the texture map based on the texture map corresponding to the target model; the texture map includes the texture map coordinates of each vertex of the target model; A sampling unit is used to sample the pixels of the directed distance field image based on the texture map coordinates of the vertices to obtain the shape gradient parameters of the target model; the shape gradient parameters include the pixel values ​​of each vertex in the directed distance field image.

8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the specular rendering method of the model according to any one of claims 1-6.

9. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the specular rendering method of the model according to any one of claims 1-6.

Citation Information

Patent Citations

  • Microstructure surface global illumination real-time rendering method based on height map

    CN101882323A

  • Hair highlight rendering method, device and equipment and storage medium

    CN113763525A