A skin rendering method and device
By calculating the index value set of light direction and normal direction, and using light and dark intensity maps and color superposition and fusion, the problem of lack of realism in the rendering of the game model's skin is solved, simulating the subsurface scattering effect of the skin, and improving the light and illumination of the skin Three-dimensional sense.
Patent Information
- Application Number
- CN202110290984.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-18
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2041-03-18
AI Technical Summary
In the prior art, the skin rendering of the game model lacks realism, is too smooth, lacks light and vitality, making it difficult to simulate the subsurface scattering and internal scattering effects of the skin.
By obtaining the light direction of the scene in which the model is located and the normal direction of each pixel point in the skin part, calculate the index value set, and use the mapping relationship between the map containing the gradient of light and dark intensity and the preset index value to obtain the light and dark intensity value set, It superimposes and blends with the color to simulate the subsurface scattering effect of light shining on the skin.
It achieves a more realistic lighting effect on the skin, simulates the reflection and scattering of light on the surface and inside of the skin, and enhances the three-dimensionality and authenticity of the skin.
Smart Images

Figure CN112991215B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a skin rendering method and device. Background Art
[0002] In recent years, due to the limitations of technology and picture style, the model skins in most mobile games are aestheticized with weakened light and shadow contrast. Such skins look too smooth and lack light and vitality, which makes the model skin appear very unreal. Therefore, how to improve the realism of the skin is currently a major problem in skin rendering. Summary of the invention
[0003] In view of this, an embodiment of the present invention provides a skin rendering method, which solves the problem that the skin in the prior art lacks realism.
[0004] An embodiment of the present invention discloses a skin rendering method, comprising:
[0005] Get the light direction of the scene where the model is located and the normal direction of each pixel point on the skin of the model;
[0006] Acquire multiple first index value sets according to the light direction and the normal direction of each pixel point;
[0007] Obtaining a mapping relationship between a first map corresponding to each first index value set and a preset index value; the first map is a map containing a gradual change in light intensity;
[0008] Obtain the light and dark intensity value of each index value in each first index value set on the corresponding first map through the mapping relationship between the first map and the preset index value, and obtain the light and dark intensity value set corresponding to each first index value set;
[0009] Superimpose each light and dark intensity value set with its corresponding color to obtain multiple light value sets;
[0010] A plurality of illumination value sets are fused, and the fused result is applied to the skin of the model.
[0011] Optionally, obtaining a plurality of first index value sets through the light direction and the normal direction of each pixel point includes:
[0012] Calculate the dot product of the light direction and the normal direction of each pixel point to obtain a second index value set;
[0013] In response to the offset instruction, the second index value set is offset processed using multiple offsets to obtain multiple first index value sets.
[0014] Optionally, the colors corresponding to each brightness value set include:
[0015] A first preset color, wherein the RGB range of the first preset color is a preset first range;
[0016] A second preset color, wherein the RGB range of the second preset color is a preset second range;
[0017] a third preset color, wherein the RGB range of the third preset color is a preset third range;
[0018] The RGB value of the third preset color is greater than the RGB value of the second preset color, and the RGB value of the second color is greater than the RGB value of the first preset color.
[0019] Optionally, when the mapping relationship between the first map and the index value corresponding to each first index value set is the same, it is characterized in that:
[0020] The first preset color corresponds to a set of light and dark intensity values calculated by the maximum offset;
[0021] The second preset color corresponds to a set of light and dark intensity values calculated by the intermediate offset;
[0022] The third preset color corresponds to a set of light and dark intensity values calculated by the minimum offset.
[0023] Optionally, also include:
[0024] After the model is rendered with opaque objects, determine the skin position of the model;
[0025] A preset convolution kernel is used to perform at least one horizontal sampling of the skin position of the model;
[0026] Multiplying the result of each horizontal sampling by the convolution kernel to obtain at least one first convolution result, and performing weighted averaging on multiple first convolution results to obtain a horizontal convolution result;
[0027] Using a preset convolution kernel to perform at least one longitudinal sampling on the transverse sampling result;
[0028] The result of each longitudinal sampling is multiplied by a preset convolution kernel to obtain at least one second convolution result, and all the second convolution results are weighted averaged to obtain a longitudinal convolution result.
[0029] Optionally, also include:
[0030] Retrieve parameters of the shadow camera; the parameters include at least: shadow range, color, and direction; the shadow range is obtained by statistically analyzing shadow ranges of different models;
[0031] If no parameter adjustment instruction is detected, the preset parameters of the shadow camera are applied to the model.
[0032] Optionally, also include:
[0033] If a parameter adjustment instruction is detected, the shadow range, target color and direction selected by the user are obtained; the target color is one of a plurality of preset colors, and the RGB value of the preset color is between the RGB value of black and the RGB value of white;
[0034] Performing interpolation processing between black and the target color to obtain an adjusted color;
[0035] The adjusted shadow camera parameters are applied to the model.
[0036] Optionally, also include:
[0037] Get the thickness values of different skin parts of the model;
[0038] The light intensity of the skin is adjusted by adjusting the thickness values of different skin parts.
[0039] Optionally, adjusting the light intensity of the skin according to the thickness values of different skin parts includes:
[0040] Get the light direction of the scene where the model is located and the normal direction of each pixel point on the skin of the model;
[0041] Calculate the initial illumination intensity by using the light direction and the normal direction of each pixel point of the model skin part, and the initial illumination intensity is a value in the range of 0 to 1;
[0042] According to the relationship between the light intensity and the skin thickness value, the initial light intensity in the range of 0 to 1 is adjusted to a light intensity greater than zero;
[0043] The adjusted light intensity is applied to the skin of the model.
[0044] Optionally, also include:
[0045] Acquire a skin part whose skin thickness is less than a preset thickness threshold as a target skin part;
[0046] If the target skin area includes a shadow, the intensity of the shadow is adjusted based on the thickness of the target skin area.
[0047] Optionally, also include:
[0048] Obtaining the light direction of the current scene in which the model is located, and performing a negation operation on the light direction to obtain a reverse light direction;
[0049] Perform a dot product of the reverse light direction and the sight direction, and perform a power operation on the dot product of the reverse light direction and the sight direction;
[0050] Multiply the result of the power operation by the thickness of the skin to obtain the light intensity of the skin;
[0051] The light intensity of the skin is applied to the model.
[0052] Optionally, also include:
[0053] In response to the detail setting instruction, a detail normal blending map is obtained; the detail normal blending map is used to represent the weights of each detail normal map and the skin part where the detail is to be set;
[0054] According to the weight of the detail normal map, the preset detail normal maps are weighted averaged to obtain the target detail normal map;
[0055] Based on the resolution of the model and the resolution of the target detail normal map, the target detail normal is tiled onto the skin part where the detail is to be set; the resolution of each detail normal map is smaller than the resolution of the model.
[0056] Optionally, also include:
[0057] Receiving a first roughness and a second roughness of a Beckmann model set by a user; simulating the reflection performance of light on the skin through the first roughness and the Beckman distribution function model;
[0058] The reflection performance of light on the skin is simulated through the second operating degree and Beckman distribution function model.
[0059] The embodiment of the present invention further discloses a skin rendering device, comprising:
[0060] A light parameter acquisition unit, used to acquire the light direction of the scene where the model is located and the normal direction of each pixel point on the skin part of the model;
[0061] An index value set acquisition unit, used to acquire a plurality of first index value sets according to the light direction and the normal direction of each pixel point;
[0062] A mapping relationship acquisition unit, used to acquire a mapping relationship between a first map corresponding to each first index value set and a preset index value; the first map is a map containing a gradual change in light intensity;
[0063] a light and dark intensity value acquisition unit, configured to acquire the light and dark intensity value of each index value in each first index value set on the corresponding first map through a mapping relationship between the first map and a preset index value, and obtain a light and dark intensity value set corresponding to each first index value set;
[0064] A color superposition unit, used to superimpose each light and dark intensity value set with its corresponding color to obtain multiple illumination value sets;
[0065] The fusion unit is used to fuse multiple illumination value sets and apply the fused result to the skin of the model.
[0066] The embodiment of the present invention provides a skin rendering method and device, the method comprising: obtaining multiple first index value sets through the light direction and the normal direction of each pixel point of the model skin part, determining the light and dark intensity corresponding to each index value in the first index value set according to the mapping relationship between the first map containing the light and dark intensity gradient and the preset index value, and obtaining multiple light and dark intensity value sets, superimposing each light and dark intensity value set with its corresponding color to obtain multiple illumination value sets, fusing the multiple illumination value sets, and applying the fused result to the skin of the model. Thus, the subsurface scattering of the skin is simulated by the above method, and the illumination result that after the light reaches the skin, in addition to the light reflected and absorbed on the surface, a part of the light enters the skin and is scattered and then emitted from the skin is simulated, so that the skin is close to the real illumination performance. And by superimposing colors on the illumination, the skin presents different colors, such as a slightly reddish color, so that the skin color is more realistic. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0068] Figure 1 A schematic flow chart of a skin rendering method provided by an embodiment of the present invention is shown;
[0069] Figure 2 A schematic diagram including a gradient of light and dark intensity;
[0070] Figure 3 Another schematic diagram including a gradient of light and dark intensity;
[0071] Figure 4 This is the first effect comparison before and after skin rendering;
[0072] Figure 5 Another schematic diagram of a process of a skin rendering method provided by an embodiment of the present invention is shown;
[0073] Figure 6 This is a comparison of the second effect before and after skin rendering;
[0074] Figure 7 Another schematic diagram of a process of a skin rendering method provided by an embodiment of the present invention is shown;
[0075] Figure 8 A third effect comparison diagram before and after skin rendering is shown;
[0076] Fig. 9 Another schematic diagram of a process of skin rendering is shown;
[0077] Fig.10 Another schematic diagram of a process of skin rendering is shown;
[0078] Fig.11 Another schematic diagram of a process of a skin rendering method provided by an embodiment of the present invention is shown;
[0079] Fig.12 A schematic structural diagram of a skin rendering device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0080] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0081] refer to Figure 1 , shows a schematic flow chart of a skin rendering method provided by an embodiment of the present invention. In this embodiment, the method includes:
[0082] S101: Obtaining the light direction of the scene where the model is located and the normal direction of each pixel point on the skin part of the model;
[0083] S102: Acquire multiple first index value sets according to the light direction and the normal direction of each pixel point;
[0084] In this embodiment, the first index value set includes multiple index values, where the main parameters for calculating the index value are the light direction and the normal direction of the pixel point. Without considering the offset, the index value can be the product of the light direction and the normal direction; or if the index value having a mapping relationship with the first map is in the range of [0,1], then the product of the light direction and the normal direction can be adjusted to be in the range of [0.1].
[0085] Furthermore, the result of simulating subsurface scattering is simulated. In this embodiment, multi-layer reflection is simulated so that each layer of reflection has different light and dark effects.
[0086] In order to achieve the above result, in this embodiment, multiple offsets may be used to offset the product of the light direction and the normal direction to obtain multiple first index value sets. Specifically, S102 includes:
[0087] Calculate the dot product of the light direction and the normal direction of each pixel point to obtain a second index value set;
[0088] In response to the offset instruction, the second index value set is offset processed using multiple offsets to obtain multiple first index value sets.
[0089] Furthermore, if the index value having a mapping relationship with the first map is a value in the range of [0, 1], then the first index value set can be adjusted to an index value in the range of [0, 1].
[0090] S103: respectively obtaining a mapping relationship between a first map corresponding to each first index value set and a preset index value; the first map is a map containing a gradual change in light intensity;
[0091] In this embodiment, a mapping relationship between the first map and the preset index value is preset, that is, different index values may correspond to different brightness intensities of light on the first map.
[0092] For example: Figure 2 As shown in FIG. 1 , a map can reflect the gradual change of light brightness. In this map, from bottom to top, different degrees of light brightness gradient are reflected. In this embodiment, for example, the Figure 2 A light and dark intensity gradient map in is used as the first map (such as Figure 3 shown).
[0093] In order to meet the needs of users, in this embodiment, the mapping relationship between the index value and the first map can be adjusted. For example, the first map can be replaced with a map that can reflect different degrees of light and dark gradients.
[0094] S104: according to the mapping relationship between the first map and the preset index value, obtaining the light and dark intensity value of each index value in each first index value set on the corresponding first map, and obtaining the light and dark intensity value set corresponding to each first index value set;
[0095] In this embodiment, the first index value set includes multiple index values, and each index value can find the corresponding light intensity value on the first map. For each first index value set, the obtained light intensity value can constitute a light intensity set;
[0096] Among them, it can be known from the above introduction that the corresponding relationship between the index value and the first map can be adjusted according to the actual needs of the user, for example, the first map corresponding to the index value can be replaced.
[0097] Therefore, the first maps corresponding to each first index value set may be the same or different.
[0098] S105: superimposing each light and dark intensity value set with its corresponding color to obtain multiple illumination value sets;
[0099] In this embodiment, in order to express different colors, colors can be superimposed on the light.
[0100] The color of the superimposed light may be user-defined, or in order to show a slightly reddish effect, the superimposed colors may include: a first preset color, a second preset color, and a third preset color. The RGB range of the first preset color is a preset first range, the RGB range of the second preset color is a preset second range, and the RGB range of the third preset color is a preset third range, wherein the RGB value of the third preset color is greater than the RGB value of the second preset color, and the RGB value of the third color is greater than the RGB value of the first preset color.
[0101] Among them, RGB is the so-called three primary optical colors, R stands for Red, G stands for Green, and B stands for Blue.
[0102] The first preset color may be any whitish color, and the range of R, G, and B may be, for example, (0,0,0)-(99,35,35);
[0103] The second preset color may be any reddish color, and the range of R, G, and B may be, for example, (99, 35, 35)-(243, 185, 185);
[0104] The third preset color may be any blackish color, wherein the colors of R, G, and B may be (243, 185, 185)-(255, 255, 255).
[0105] Among them, in each index value set corresponding to the first post Figure 1 When the mapping relationship between the first map and the index value corresponding to each first index value is the same, the corresponding relationship between the color and the brightness and darkness intensity set is:
[0106] The white color corresponds to a set of light and dark intensity values calculated by the maximum offset;
[0107] The red color corresponds to a set of light and dark intensity values calculated by the intermediate offset;
[0108] The black color corresponds to the set of light and dark intensity values calculated by the minimum offset.
[0109] S106: Fusing the multiple illumination value sets, and applying the fused result of the multiple illumination value sets to the skin of the model.
[0110] In this embodiment, the adjusted lighting result is applied to the skin of the model, so that the skin presents a more realistic lighting effect.
[0111] The embodiment of the present invention provides a skin rendering method and device, the method comprising: calculating a first index value set through the light direction and the normal direction of each pixel point of the model skin part, and offsetting the first index value set through multiple offsets, determining the light and dark intensity corresponding to each index value in the second index value set according to the mapping relationship between the first map reflecting the light and dark gradient and the preset index value, and obtaining multiple light and dark intensity value sets, superimposing each light and dark intensity value set with its corresponding color to obtain multiple illumination value sets, fusing the multiple illumination value sets, and applying the fused result to the skin of the model. Thus, the subsurface scattering of the skin is simulated by the above method, and the illumination result that after the light reaches the skin, in addition to the light reflected and absorbed on the surface, a part of the light enters the skin and is scattered and then emitted from the skin is simulated. And by superimposing colors on the illumination, the skin presents different colors, such as a slightly reddish color, so that the skin tends to be more realistic.
[0112] Furthermore, in order to reflect the true color of the skin, the result of the fusion of the illumination value set may be multiplied by the preset skin color.
[0113] In this embodiment, in order to obtain a display effect of slightly reddening the skin, the following operations may be performed:
[0114] Get the light direction of the scene where the model is located and the normal direction of each pixel point on the skin of the model;
[0115] Calculate the dot product of the light direction and the normal direction of each pixel point to obtain a second index value set;
[0116] Performing three offset processing on the second index value set by three offsets to obtain three first index value sets;
[0117] According to a preset mapping relationship between the first map and the index value, obtain the light and dark intensity value of each index value in each first index value set on the first map to obtain three light and dark intensity value sets;
[0118] Superimposing the light and dark intensity set obtained by the minimum offset with white to obtain a first illumination value set;
[0119] The light and dark intensity set obtained by the intermediate offset is superimposed with the red color to obtain a second illumination value set;
[0120] The light and dark intensity set obtained by the maximum offset is superimposed with black to obtain a third illumination value set;
[0121] The first illumination value set, the second illumination value set and the third illumination value set are fused, and the fused result is applied to the skin of the model.
[0122] In this embodiment, it can be considered that the final lighting effect of the skin is the result of three layers of lighting, and different colors are superimposed on each layer of lighting. The first layer is superimposed with a whitish color, the second layer is superimposed with a reddish color, and the third layer is superimposed with a blackish color. This allows the skin to show a slightly reddish effect, making the model's skin closer to the real effect.
[0123] For example: Figure 4 As shown, the right picture shows the effect before the above operation is performed, and the left picture shows the effect after the above operation is performed.
[0124] The applicant has found that the skin itself requires details, such as pores and skin texture, but the details will cause the skin to be dry as a whole, with a plastic or waxy texture. In order to improve this effect, a method is needed to maintain the skin details while making the overall skin texture softer and more moisturized.
[0125] refer to Figure 5 , shows another flow chart of a skin rendering method provided by an embodiment of the present invention, including:
[0126] S501: After the model is rendered as an opaque object, the skin position of the model is determined;
[0127] In this embodiment, the skin position can be determined by the pre-marking result. If the camera turns on HDR, an additional rendering process needs to be provided to generate the skin mark.
[0128] S502: Using a preset convolution kernel to perform at least one horizontal sampling on the skin position of the model;
[0129] In this embodiment, the number of horizontal sampling is related to the size of the convolution kernel.
[0130] S503: multiplying the result of each horizontal sampling by the convolution kernel to obtain multiple first convolution results, and performing weighted average on all the first convolution results to obtain a horizontal convolution result;
[0131] In this embodiment, after the horizontal convolution result is obtained, the horizontal convolution result is output to a RenderTexture, so that the horizontal convolution result is used as the input of the vertical convolution.
[0132] S504: Using a preset convolution kernel to perform at least one longitudinal sampling on the transverse sampling result;
[0133] In this embodiment, the number of vertical sampling is related to the size of the convolution kernel.
[0134] S505: multiply the result of each longitudinal sampling by a preset convolution kernel to obtain at least one second convolution result, and perform weighted averaging on all the second convolution results to obtain a longitudinal convolution result.
[0135] In this embodiment, in order to reduce the amount of calculation, the two-dimensional convolution kernel is split into two one-dimensional convolution kernels, and the original m*n sampling is reduced to m+n through two separate single convolution operations in the horizontal and vertical directions. The two-dimensional convolution kernel can be split into two one-dimensional convolution kernels through the separable subsurface scattering model Separable Subsurface Scattering.
[0136] In this embodiment, through two samplings in the horizontal and vertical directions, the color divergence on a pixel affects the surrounding pixels, simulating the physical phenomenon of scattering of real light after entering the skin, so that the skin looks smoother and more moisturized overall.
[0137] refer to Figure 6 , shows a comparison chart of moisturizing effects, where the left picture is before adding the moisturizing effect, and the right picture is after adding the moisturizing effect. It can be seen that the skin in the left picture appears very dry and lacks glossiness, while the skin in the right picture appears more hydrated.
[0138] The applicant has found that there are usually some shadow effects in game models or game scenes. For models, if there is no shadow, the model as a whole will appear to lack three-dimensionality, making the picture flat. Shadows can make the light and shadow contrast of the model stronger and enhance the three-dimensional effect of the model. However, in the prior art, the design of shadows usually needs to take into account the scope of the scene, which makes the model have a strong sense of jaggedness and makes the model skin look unreal. In order to enhance the realistic effect of shadows, reference Figure 7 , shows another flow chart of a skin rendering method provided by an embodiment of the present invention. In this embodiment, the method includes:
[0139] S701: Retrieve parameters of a shadow camera; the parameters at least include: shadow range, color, and direction; the shadow range is obtained by statistically analyzing shadow ranges of different models;
[0140] S702: If no parameter adjustment instruction is detected, the preset shadow camera parameters are applied to the model.
[0141] In this embodiment, the parameters of the shadow camera are pre-set. The parameters are obtained by analyzing and counting the shadow ranges of different models. That is, the parameters of the shadow camera only include the shadow range of the model and no longer include the shadow range of the scene. This reduces the shadow range of the model and enhances the self-shadow effect of the model, so that the skin of the model can present a more realistic effect.
[0142] Furthermore, in order to meet different needs of users, the parameters of the shadow camera can also be adjusted, such as the shadow range, color or direction. Specifically, it also includes:
[0143] If a parameter adjustment instruction is detected, the shadow range selected by the user, the target color and direction selected by the user are obtained; the target color is one of a plurality of preset colors;
[0144] Performing interpolation processing between black and the target color to obtain an adjusted color;
[0145] The adjusted shadow camera parameters are applied to the model.
[0146] In order to obtain a more realistic effect, the color of the shadow is diluted, and the RGB value range of the selected preset color is smaller than the RGB value range of black. Preferably, the preset color can be a red color.
[0147] An interpolation process is performed between black and the target color to obtain a gradient color between black and the target color.
[0148] refer to Figure 8 , showing a schematic diagram of a shadow effect, where the left Figure 1 The first picture is a picture without adding shadow effect, the middle picture is the effect after adding shadow in the prior art, and the right picture is the shadow effect achieved by the method of this embodiment.
[0149] The applicant also found that due to the different thickness of the skin, when the skin is under light conditions, different thicknesses of skin will show different effects. For example, in the thinner part of the skin, even in darker light, there will be light transmission. However, the existing technology cannot reflect this phenomenon. Therefore, in order to further enhance the realism of the skin, reference Fig. 9 Another schematic diagram of a skin rendering method is shown:
[0150] S901: Obtain thickness values of different skin parts of the model;
[0151] S902: adjusting the light intensity of the skin by adjusting the thickness values of different skin parts.
[0152] Among them, the method of adjusting the skin according to the skin thickness may include the following three methods:
[0153] Method 1:
[0154] Get the light direction of the scene where the model is located and the normal direction of each pixel point on the skin of the model;
[0155] Calculate the initial illumination intensity by using the light direction and the normal direction of each pixel point of the model skin part, and the initial illumination intensity is a value in the range of 0 to 1;
[0156] According to the relationship between light intensity and skin thickness, the initial light intensity in the range of 0 to 1 is adjusted to a light intensity greater than zero;
[0157] The adjusted light intensity is applied to the skin of the model.
[0158] In this embodiment, the initial illumination intensity in the range of 0 to 1 is adjusted to an illumination intensity greater than zero by taking into account the relationship between illumination intensity and skin thickness. Thus, even if the object is backlit, it will have a certain color instead of pure black.
[0159] For example, the adjustment of skin thickness to light intensity can be expressed by the following formula 1):
[0160] NdotL′=(NdotL+w) / ((1.0+w)*(1.0+w));
[0161] Wherein, NdotL' represents the light intensity after adjustment, and NdotL represents the light intensity before adjustment.
[0162] Method 2:
[0163] Acquire a skin part whose skin thickness is less than a preset thickness threshold as a target skin part;
[0164] If the target skin area includes a shadow, the intensity of the shadow is adjusted based on the thickness of the target skin area.
[0165] In the present embodiment, the skin portion whose skin thickness is less than the preset thickness threshold can be considered as a relatively thin skin portion. If a shadow effect exists in this skin portion, the intensity of the shadow will be relatively weak due to the higher degree of skin transparency in the relatively thin portion. Therefore, in the present embodiment, the intensity of the shadow is adjusted by the skin thickness to weaken the intensity of the shadow.
[0166] From this we can see that the smaller the skin thickness value, or the thinner the skin, the weaker the shadow intensity will be adjusted.
[0167] Method 3:
[0168] Obtaining the light direction of the current scene in which the model is located, and performing a negation operation on the light direction to obtain a reverse light direction;
[0169] Perform a dot product of the reverse light direction and the sight direction, and perform a power operation on the dot product of the reverse light direction and the sight direction;
[0170] Multiply the result of the power operation by the thickness of the skin to obtain the light intensity of the skin;
[0171] The light intensity of the skin is applied to the model.
[0172] In this embodiment, there are multiple methods for reversing the light direction, which will not be described in detail in this embodiment. For example, a modulatable offset may be added to the light direction to achieve the reversal of the light direction.
[0173] In this embodiment, in order to further enhance the sense of transparency, the light direction may be reversed, and after performing a dot product with the viewing direction, the result may be exponentiated. This makes the light at the edge of the skin stronger, thereby enhancing the projection performance at the edge of the skin.
[0174] In this embodiment, the result after the power operation is multiplied by the thickness of the skin, so that the transparent performance is only displayed at the position where the skin is relatively thin.
[0175] The applicant found that different parts of the skin will have different details. Skin lacking details may look perfect and smooth, but it is not real. In order to reflect the real skin details, it is necessary to use detail normals to set the skin details. However, if you want to show the real skin details, you need higher-precision detail normals, such as 4096 or even higher-precision normals. Moreover, a single detail normal is difficult to meet the setting of details of different parts of the skin.
[0176] In order to solve the above problems, in this embodiment, reference Fig.10 , shows another flow chart of a skin rendering method, including:
[0177] S1001: In response to a detail setting instruction, a detail normal mixed map is obtained; the detail normal mixed map is used to represent the weights of each detail normal map and the skin part where the detail is to be set;
[0178] S1002: performing weighted averaging on preset detail normal maps according to the weights of the detail normal maps to obtain a target detail normal map;
[0179] S1003: Based on the resolution of the model and the resolution of the target detail normal map, tiling the target detail normal onto the skin part where the detail is to be set; the resolution of each detail normal map is smaller than the resolution of the model.
[0180] Among them, through the detail normal selected by the user and the selected skin position, a detail normal map can be obtained. The detail normal mixed map is used to represent the weight of each detail normal map. For example, each detail normal corresponds to a channel of the mixed map, detail 1 corresponds to the R channel of the mixed map, detail 2 corresponds to the G channel of the mixed map, and detail 3 corresponds to the B channel of the mixed map. Among them, in actual applications, when it is detected that the user triggers an instruction to set details at a certain skin position, the channel corresponding to the currently selected detail map will be filled, and the remaining channels will be cleared.
[0181] When performing the "weighted average of each detail normal map according to the detail normal mixed map" operation, since the detail normal map is mutually exclusive when drawing, it can be ensured that different details are shown at the corresponding positions according to the RGB channels of the detail mixed map.
[0182] In this embodiment, a low-resolution detail normal map is applied to a high-resolution model. The low-resolution detail normal can be tiled on the high-resolution model. For example, the low-resolution detail normal map can be sampled multiple times and the results of the multiple samplings can be mixed to achieve a high-resolution detail effect.
[0183] In this embodiment, the pre-set low-resolution normal map is sampled multiple times to achieve the detail effect of the high-resolution map. In this way, the display effect of high-resolution details is achieved while occupying less memory. The applicant found that the structure of the skin is divided into a lipid layer, an epidermis layer, and a true skin layer. The lipid layer has more reflections under light, but because the lipid layer is thin, reflections of the inner layer will appear. Therefore, in order to present a more realistic skin performance, the reflections of different skin layers can be simulated to show a more realistic highlight performance. For details, refer to Fig.11 , shows another flow chart of a skin rendering method provided by an embodiment of the present invention. In this embodiment, the method includes:
[0184] S1101: receiving a first roughness and a second roughness of a Beckman distribution function model set by a user;
[0185] S1102: simulating the reflection performance of light on the skin through the first roughness and Beckman distribution function model;
[0186] S1103: Simulate the reflection performance of light on the skin through the second operation degree and the Beckman distribution function model. Among them, the first roughness and the second roughness are one with a larger roughness and the other with a smaller roughness, wherein the smaller roughness simulates the outer layer reflection, and the larger roughness simulates the inner layer reflection, but the execution order of the inner layer reflection and the outer layer reflection is not limited in this embodiment. Among them, the outer layer reflection can be considered to simulate the reflection of the oil layer, and the inner layer reflection can be considered to simulate the reflection of the epidermis and dermis.
[0187] In this embodiment, the Beckman distribution function model is a model for simulating light reflection, wherein the model can be expressed by the following formula 1):
[0188] 1)
[0189] Among them, m=N dot H, wherein N represents the normal, H represents the half-angle vector between the light direction and the viewing direction, wherein H=L+V, wherein L represents the light direction, V represents the viewing direction, and α represents the roughness.
[0190] refer to Fig.12 , shows a schematic diagram of the structure of a skin rendering device provided by an embodiment of the present invention. In this embodiment, the method includes:
[0191] A light parameter acquisition unit 1201 is used to acquire the light direction of the scene where the model is located and the normal direction of each pixel point of the skin part of the model;
[0192] An index value set acquisition unit 1202, configured to acquire a plurality of first index value sets according to the light direction and the normal direction of each pixel point;
[0193] A mapping relationship acquisition unit 1203 is used to acquire a mapping relationship between a first map corresponding to each first index value set and a preset index value; the first map is a map containing a gradual change in light intensity;
[0194] The light and dark intensity value acquisition unit 1204 is used to acquire the light and dark intensity value of each index value in each first index value set on the corresponding first map through the mapping relationship between the first map and the preset index value, and obtain the light and dark intensity value set corresponding to each first index value set;
[0195] A color superposition unit 1205 is used to superimpose each light and dark intensity value set with its corresponding color to obtain multiple illumination value sets;
[0196] The fusion unit 1206 is used to fuse multiple illumination value sets and apply the fused result to the skin of the model.
[0197] Optionally, the index value set acquisition unit includes:
[0198] a calculation unit, configured to calculate a dot product of the light direction and a normal direction of each pixel point to obtain a second index value set;
[0199] The offset unit is used to respond to the offset instruction and use multiple offsets to perform offset processing on the second index value set respectively to obtain multiple first index value sets.
[0200] Optionally, the colors corresponding to each brightness value set include:
[0201] A first preset color, wherein the RGB range of the first preset color is a preset first range;
[0202] A second preset color, wherein the RGB range of the second preset color is a preset second range;
[0203] a third preset color, wherein the RGB range of the third preset color is a preset third range;
[0204] The RGB value of the third preset color is greater than the RGB value of the second preset color, and the RGB value of the second color is greater than the RGB value of the first preset color.
[0205] Optionally, when the mapping relationship between the first map corresponding to each first index value set and the index value is the same, the first preset color corresponds to the light and dark intensity value set calculated by the maximum offset; the second preset color corresponds to the light and dark intensity value set calculated by the intermediate offset; the third preset color corresponds to the light and dark intensity value set calculated by the minimum offset.
[0206] Optional, smoothing effect rendering unit, used to:
[0207] After the model is rendered with opaque objects, determine the skin position of the model;
[0208] A preset convolution kernel is used to perform at least one horizontal sampling of the skin position of the model;
[0209] Multiplying the result of each horizontal sampling by the convolution kernel to obtain at least one first convolution result, and performing weighted averaging on multiple first convolution results to obtain a horizontal convolution result;
[0210] Using a preset convolution kernel to perform at least one longitudinal sampling on the transverse sampling result;
[0211] The result of each longitudinal sampling is multiplied by a preset convolution kernel to obtain at least one second convolution result, and all the second convolution results are weighted averaged to obtain a longitudinal convolution result.
[0212] Optionally, it further includes: a first shadow rendering unit, for
[0213] Retrieve parameters of the shadow camera; the parameters include at least: shadow range, color, and direction; the shadow range is obtained by statistically analyzing shadow ranges of different models;
[0214] If no parameter adjustment instruction is detected, the preset parameters of the shadow camera are applied to the model.
[0215] Optionally, it also includes: a second shadow rendering unit, for
[0216] If a parameter adjustment instruction is detected, the shadow range, target color and direction selected by the user are obtained; the target color is one of a plurality of preset colors, and the RGB value of the preset color is between the RGB value of black and the RGB value of white;
[0217] Performing interpolation processing between black and the target color to obtain an adjusted color;
[0218] The adjusted shadow camera parameters are applied to the model.
[0219] Optionally, it also includes: a transparent effect rendering unit, including:
[0220] Get the thickness values of different skin parts of the model;
[0221] The light intensity of the skin is adjusted by adjusting the thickness values of different skin parts.
[0222] Optionally, the transparency effect rendering subunit includes: a first transparency effect rendering subunit, configured to:
[0223] Get the light direction of the scene where the model is located and the normal direction of each pixel point on the skin of the model;
[0224] Calculate the initial illumination intensity by using the light direction and the normal direction of each pixel point of the model skin part, and the initial illumination intensity is a value in the range of 0 to 1;
[0225] According to the relationship between the light intensity and the skin thickness value, the initial light intensity in the range of 0 to 1 is adjusted to a light intensity greater than zero;
[0226] The adjusted light intensity is applied to the skin of the model.
[0227] Optionally, the transparency effect rendering subunit includes: a second transparency effect rendering subunit, configured to:
[0228] Acquire a skin part whose skin thickness is less than a preset thickness threshold as a target skin part;
[0229] If the target skin area includes a shadow, the intensity of the shadow is adjusted based on the thickness of the target skin area.
[0230] Optionally, the transparency effect rendering subunit includes: a third transparency effect rendering subunit, configured to:
[0231] Obtaining the light direction of the current scene in which the model is located, and performing a negation operation on the light direction to obtain a reverse light direction;
[0232] Perform a dot product of the reverse light direction and the sight direction, and perform a power operation on the dot product of the reverse light direction and the sight direction;
[0233] Multiply the result of the power operation by the thickness of the skin to obtain the light intensity of the skin;
[0234] The light intensity of the skin is applied to the model.
[0235] Optionally, it further includes: a detail setting unit, used to:
[0236] In response to the detail setting instruction, a detail normal blending map is obtained; the detail normal blending map is used to represent the weights of each detail normal map and the skin part where the detail is to be set;
[0237] According to the weight of the detail normal map, the preset detail normal maps are weighted averaged to obtain the target detail normal map;
[0238] Based on the resolution of the model and the resolution of the target detail normal map, the target detail normal is tiled onto the skin part where the detail is to be set; the resolution of each detail normal map is smaller than the resolution of the model.
[0239] Optionally, it further includes: a highlight setting unit, used for:
[0240] Receiving a first roughness and a second roughness of a Beckmann model set by a user; simulating the reflection performance of light on the skin through the first roughness and the Beckman distribution function model;
[0241] The reflection performance of light on the skin is simulated through the second operating degree and Beckman distribution function model.
[0242] The device of this embodiment obtains multiple first index value sets through the light direction and the normal direction of each pixel point in the model skin part, determines the light and dark intensity corresponding to each index value in the first index value set according to the mapping relationship between the first map containing the light and dark intensity gradient and the preset index value, and obtains multiple light and dark intensity value sets, superimposes each light and dark intensity value set with its corresponding color to obtain multiple illumination value sets, fuses the multiple illumination value sets, and applies the fused result to the skin of the model. Thus, the subsurface scattering of the skin is simulated by the above method, and the illumination result that after the light reaches the skin, in addition to the light reflected and absorbed on the surface, a part of the light enters the skin and is scattered and then emitted from the skin is simulated. And by superimposing colors on the illumination, the skin presents different colors, such as a slightly reddish color, making the skin more realistic.
[0243] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0244] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A skin rendering method, characterized in that: include: Get the light direction of the scene where the model is located and the normal direction of each pixel point on the skin of the model; Acquire multiple first index value sets according to the light direction and the normal direction of each pixel point; Obtaining a mapping relationship between a first map corresponding to each first index value set and a preset index value; the first map is a map containing a gradual change in light intensity; Obtain the light and dark intensity value of each index value in each first index value set on the corresponding first map through the mapping relationship between the first map and the preset index value, and obtain the light and dark intensity value set corresponding to each first index value set; Superimpose each light and dark intensity value set with its corresponding color to obtain multiple light value sets; Fusing multiple sets of illumination values, and applying the fused result to the skin of the model; The obtaining of a plurality of first index value sets according to the light direction and the normal direction of each pixel point includes: Calculate the dot product of the light direction and the normal direction of each pixel point to obtain a second index value set; In response to the offset instruction, use multiple offsets to perform offset processing on the second index value set respectively to obtain multiple first index value sets; The colors corresponding to each set of light and dark intensity values are: A first preset color, wherein the RGB range of the first preset color is a preset first range; A second preset color, wherein the RGB range of the second preset color is a preset second range; a third preset color, wherein the RGB range of the third preset color is a preset third range; The RGB value of the third preset color is greater than the RGB value of the second preset color, and the RGB value of the second preset color is greater than the RGB value of the first preset color.
2. The method according to claim 1, characterized in that When the mapping relationship between the first map and the index value corresponding to each first index value set is the same, it is characterized in that: The first preset color corresponds to a set of light and dark intensity values calculated by the maximum offset; The second preset color corresponds to a set of light and dark intensity values calculated by the intermediate offset; The third preset color corresponds to a set of light and dark intensity values calculated by the minimum offset.
3. The method according to claim 1, characterized in that: Also includes: After the model is rendered with opaque objects, determine the skin position of the model; A preset convolution kernel is used to perform at least one horizontal sampling of the skin position of the model; Multiplying the result of each horizontal sampling by the convolution kernel to obtain at least one first convolution result, and performing weighted averaging on multiple first convolution results to obtain a horizontal convolution result; Using a preset convolution kernel to perform at least one longitudinal sampling on the transverse sampling result; The result of each longitudinal sampling is multiplied by a preset convolution kernel to obtain at least one second convolution result, and all the second convolution results are weighted averaged to obtain a longitudinal convolution result.
4. The method according to claim 1, characterized in that Also includes: Retrieve parameters of the shadow camera; the parameters include at least: shadow range, color, and direction; the shadow range is obtained by statistically analyzing shadow ranges of different models; If no parameter adjustment instruction is detected, the preset parameters of the shadow camera are applied to the model.
5. The method according to claim 4, characterized in that Also includes: If a parameter adjustment instruction is detected, the shadow range selected by the user, the target color and direction selected by the user are obtained; The target color is one of a plurality of preset colors, and the RGB value of the preset color is between the RGB value of black and the RGB value of white; Performing interpolation processing between black and the target color to obtain an adjusted color; The adjusted shadow camera parameters are applied to the model.
6. The method according to claim 1, characterized in that Also includes: Get the thickness values of different skin parts of the model; The light intensity of the skin is adjusted by adjusting the thickness values of different skin parts.
7. The method according to claim 6, characterized in that The method of adjusting the light intensity of the skin by the thickness values of different skin parts includes: Get the light direction of the scene where the model is located and the normal direction of each pixel point on the skin of the model; Calculate the initial illumination intensity by using the light direction and the normal direction of each pixel point of the model skin part, and the initial illumination intensity is a value in the range of 0 to 1; According to the relationship between the light intensity and the skin thickness value, the initial light intensity in the range of 0 to 1 is adjusted to a light intensity greater than zero; The adjusted light intensity is applied to the skin of the model.
8. The method according to claim 6, characterized in that Also includes: Acquire a skin part whose skin thickness is less than a preset thickness threshold as a target skin part; If the target skin area includes a shadow, the intensity of the shadow is adjusted based on the thickness of the target skin area.
9. The method according to claim 8, characterized in that Also includes: Obtaining the light direction of the current scene in which the model is located, and performing a negation operation on the light direction to obtain a reverse light direction; Perform a dot product of the reverse light direction and the sight direction, and perform a power operation on the dot product of the reverse light direction and the sight direction; Multiply the result of the power operation by the thickness of the skin to obtain the light intensity of the skin; The light intensity of the skin is applied to the model.
10. The method according to claim 1, characterized in that Also includes: In response to the detail setting instruction, a detail normal blending map is obtained; the detail normal blending map is used to represent the weights of each detail normal map and the skin part where the detail is to be set; According to the weight of the detail normal map, the preset detail normal maps are weighted averaged to obtain the target detail normal map; Based on the resolution of the model and the resolution of the target detail normal map, the target detail normal is tiled onto the skin part where the detail is to be set; the resolution of each detail normal map is smaller than the resolution of the model.
11. The method according to claim 1, characterized in that: Also includes: Receiving a first roughness and a second roughness of a Beckmann model set by a user; simulating the reflection performance of light on the skin through the first roughness and the Beckman distribution function model; The reflection performance of light on the skin is simulated through the second operating degree and Beckman distribution function model.
12. A skin rendering device, characterized in that: include: A light parameter acquisition unit, used to acquire the light direction of the scene where the model is located and the normal direction of each pixel point on the skin part of the model; An index value set acquisition unit, used to acquire a plurality of first index value sets according to the light direction and the normal direction of each pixel point; A mapping relationship acquisition unit, used to acquire a mapping relationship between a first map corresponding to each first index value set and a preset index value; the first map is a map containing a gradual change in light intensity; a light and dark intensity value acquisition unit, configured to acquire the light and dark intensity value of each index value in each first index value set on the corresponding first map through a mapping relationship between the first map and a preset index value, and obtain a light and dark intensity value set corresponding to each first index value set; A color superposition unit, used to superimpose each light and dark intensity value set with its corresponding color to obtain multiple illumination value sets; A fusion unit, used for fusing a plurality of illumination value sets and applying the fused result to the skin of the model; Index value set acquisition unit, including: a calculation unit, configured to calculate a dot product of the light direction and a normal direction of each pixel point to obtain a second index value set; an offset unit, configured to, in response to an offset instruction, respectively perform offset processing on the second index value set using a plurality of offsets to obtain a plurality of first index value sets; The colors corresponding to each set of light and dark intensity values are: A first preset color, wherein the RGB range of the first preset color is a preset first range; A second preset color, wherein the RGB range of the second preset color is a preset second range; a third preset color, wherein the RGB range of the third preset color is a preset third range; The RGB value of the third preset color is greater than the RGB value of the second preset color, and the RGB value of the second preset color is greater than the RGB value of the first preset color.
