A method, system, storage medium and device for rendering skin on a three-dimensional model surface
By obtaining 3D model parameters on mobile devices and creating shading use cases in shader programs, combined with the adjustment of PBR parameters and lighting parameters, the problem of poor rendering of the surface skin of 3D models on mobile devices is solved, achieving efficient and realistic rendering effects.
Patent Information
- Application Number
- CN202411110215.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-08-14
AI Technical Summary
The prior art is difficult to efficiently render the surface skin of three-dimensional model on mobile devices, resulting in poor rendering and poor user experience.
By obtaining the model parameters of the three-dimensional model, create shading use cases in the preset shader program, set appearance parameters and reflection parameters, and render by fusing PBR parameters. Adjust lighting parameters according to scene parameters and optimize rendering effects.
It realizes efficient rendering of three-dimensional model surface skin on mobile devices, improving rendering efficiency and quality, enhancing skin effects, and improving user experience.
Smart Images

Figure CN118674853B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of model rendering, and in particular to a method, system, storage medium and device for rendering the surface skin of a three-dimensional model. Background Art
[0002] Unity is a real-time rendering engine that can generate images in real time during runtime. Real-time rendering means that when each frame is updated, the lighting, shadows, materials and other information in the scene are calculated and rendered to the screen, allowing users to see the interactive effects instantly.
[0003] A shader is a program that defines the appearance and rendering of an object's surface. In Unity, shaders are usually written in the ShaderLab language, which includes vertex shaders and fragment shaders, which are used to control the vertex position and pixel color of an object. For skin rendering, shaders can control the surface reflection, scattering, and transparency of the skin.
[0004] At present, surface skin rendering of three-dimensional models is usually performed on computer terminal devices. This is because the computing power of mobile devices is limited, and complex shadow rendering calculations and skin rendering cannot be performed efficiently, making it difficult to obtain good rendering effects, resulting in a poor user experience. Summary of the invention
[0005] In view of the deficiencies in the prior art, the purpose of the present invention is to provide a method, system, storage medium and device for rendering the surface skin of a three-dimensional model, aiming to provide a solution that can perform three-dimensional model surface skin rendering on a mobile device, and to optimize the rendering method so that good rendering effects can also be obtained through mobile devices, thereby solving the problems existing in the prior art.
[0006] A first aspect of the present invention is to provide a method for rendering skin on a three-dimensional model surface, the method comprising:
[0007] Acquire a three-dimensional model for model skin rendering, and extract model parameters of the three-dimensional model;
[0008] According to the model parameters, creating a shading case in a preset shader program, and setting the appearance parameters and reflection parameters of the three-dimensional model in the shading case;
[0009] In the shader program, a first rendering parameter is set according to the shading use case, and the three-dimensional model is rendered according to the first rendering parameter;
[0010] According to the scene parameters of the three-dimensional model, the illumination parameters in the shading use case are adjusted to obtain second rendering parameters, and the three-dimensional model is rendered according to the second rendering parameters to obtain a target three-dimensional model.
[0011] According to one aspect of the above technical solution, in the shader program, setting a first rendering parameter according to the shading use case, and rendering the three-dimensional model according to the first rendering parameter specifically includes:
[0012] In the shader program, a skin main structure of the three-dimensional model is determined according to the shading use case, and a first PBR parameter is calculated according to the skin main structure;
[0013] Perform skin smoothness offset on the skin main structure and calculate a second PBR parameter;
[0014] The first PBR parameter and the second PBR parameter are fused to obtain first rendering parameters, and the three-dimensional model is rendered according to the first rendering parameters.
[0015] According to one aspect of the above technical solution, the first PBR parameter and the second PBR parameter are fused to obtain a first rendering parameter, and the step of rendering the three-dimensional model according to the first rendering parameter specifically includes:
[0016] Obtaining a distribution function value of a preset roughness and an angle between a normal line and a half vector;
[0017] Get the occlusion value of the occlusion item of the viewing angle between the preset roughness and normal and the viewing direction;
[0018] And obtain the preset light incident angle and the specular reflection value of the material;
[0019] The roughness, the specular color, the normal, the light direction and the observation camera direction are used as input values of the bidirectional reflectance distribution function, and the output value of the bidirectional reflectance distribution function is calculated using the GGX distribution function, the Smith occlusion term and the Schlick approximation to obtain a first rendering parameter, where the first rendering parameter is used to describe the highlight condition;
[0020] The three-dimensional model is rendered according to the first rendering parameters.
[0021] According to one aspect of the above technical solution, according to the scene parameters of the three-dimensional model, the illumination parameters in the shading use case are adjusted to obtain second rendering parameters, and the step of rendering the three-dimensional model according to the second rendering parameters to obtain a target three-dimensional model specifically includes:
[0022] Obtaining scene parameters of the three-dimensional model when rendered by a shader program;
[0023] According to the scene parameters, adjusting the lighting parameters in the shading use case, at least including adjusting the ambient occlusion color and the indirect diffuse lighting, to obtain diffuse color parameters, so as to obtain second rendering parameters including the diffuse color parameters;
[0024] The three-dimensional model is rendered according to the second rendering parameters to obtain a target three-dimensional model.
[0025] According to one aspect of the above technical solution, the method further includes:
[0026] Calculates subsurface scattering color parameters of the model's skin under camera light.
[0027] According to one aspect of the above technical solution, the step of calculating the subsurface scattering color parameters of the model skin under the illumination of camera light specifically includes:
[0028] Calculate the perspective offset vector, and combine the perspective offset vector with the set skin camera light angle parameter;
[0029] Create a new perspective offset vector, which contains the X and Z components of the original perspective offset vector and the newly calculated Y component;
[0030] Calculate the angle parameter between the offset perspective offset vector and the surface normal using a dot multiplication operation, and limit the angle parameter to a preset range using a saturation function to describe the surface projection intensity of the light on the surface;
[0031] The surface projection intensity is converted into UV coordinate parameters, and sampled in the pre-integrated map to obtain a pre-integrated value;
[0032] The ambient occlusion color parameter, the skin camera light color parameter and the pre-integrated value are merged to obtain the subsurface scattering color parameter of the model skin under the illumination of the camera light;
[0033] Multiplying the logarithm of the surface projection intensity by a preset power parameter and performing exponential calculation to adjust the scattering intensity and scattering shape of the light scattering to obtain a scattering intensity parameter and a scattering shape parameter;
[0034] The scattering intensity parameter is multiplied by the scattering shape parameter to obtain a final subsurface scattering color parameter of the model skin under the illumination of camera light.
[0035] A second aspect of the present invention is to provide a three-dimensional model surface skin rendering system, which is applied to the method described in the above technical solution, and the system comprises:
[0036] A parameter extraction module, used to obtain a three-dimensional model to be subjected to model skin rendering, and extract model parameters of the three-dimensional model;
[0037] A shading case creation module, used to create a shading case in a preset shader program according to the model parameters, and to set the appearance parameters and reflection parameters of the three-dimensional model in the shading case;
[0038] A first rendering module, configured to set a first rendering parameter in the shader program according to the shading use case, and render the three-dimensional model according to the first rendering parameter;
[0039] The second rendering module is used to adjust the lighting parameters in the shading use case according to the scene parameters of the three-dimensional model to obtain second rendering parameters, and render the three-dimensional model according to the second rendering parameters to obtain a target three-dimensional model.
[0040] According to one aspect of the above technical solution, the first rendering module is specifically used for:
[0041] In the shader program, a skin main structure of the three-dimensional model is determined according to the shading use case, and a first PBR parameter is calculated according to the skin main structure;
[0042] Perform skin smoothness offset on the skin main structure and calculate a second PBR parameter;
[0043] The first PBR parameter and the second PBR parameter are fused to obtain first rendering parameters, and the three-dimensional model is rendered according to the first rendering parameters.
[0044] A third aspect of the present invention is to provide a readable storage medium having a computer program stored thereon, which implements the method described in the above technical solution when executed by a processor.
[0045] The fourth aspect of the present invention is to provide an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the method described in the above technical solution when executing the computer program.
[0046] Compared with the prior art, the method, system, storage medium and device for rendering the surface skin of a three-dimensional model shown in the present invention have the following beneficial effects:
[0047] When performing skin rendering on the surface of a three-dimensional model, the three-dimensional model to be rendered with the model skin is obtained, the model parameters of the three-dimensional model are extracted, and then a shading case is created in a preset shader program according to the model parameters, the appearance parameters and reflection parameters of the three-dimensional model are set in the shading case, and in the shader program, a first rendering parameter is set according to the shading case, and the three-dimensional model is rendered according to the first rendering parameter, and finally, according to the scene parameters of the three-dimensional model, the illumination parameters in the shading case are adjusted to obtain the second rendering parameter, and the three-dimensional model is rendered according to the second rendering parameter to obtain the target three-dimensional model. The method shown in this embodiment is adopted, by providing a simple PCF shadow rendering technology suitable for mobile devices, as well as a pre-integrated SSS skin rendering technology for AO correction and a subsurface scattering effect based on screen space, which can improve the rendering efficiency and quality on mobile devices, achieve a more realistic skin effect, and thus enhance the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0049] Figure 1 It is a schematic flow chart of a method for rendering the surface skin of a three-dimensional model shown in one embodiment of the present invention;
[0050] Figure 2 It is a structural block diagram of a three-dimensional model surface skin rendering system shown in one embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings. Several embodiments of the present invention are shown in the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0053] Embodiment 1
[0054] See also Figure 1 The first embodiment of the present invention provides a method for rendering the surface skin of a three-dimensional model, the method comprising steps S10 to S40:
[0055] Step S10, obtaining a three-dimensional model to be subjected to model skin rendering, and extracting model parameters of the three-dimensional model.
[0056] In this embodiment, the three-dimensional model to be rendered on the surface skin is a virtual character model, such as a virtual head model. After rendering, its surface can have surface features similar to those of a real person, so that it can be applied to game characters in terminal games.
[0057] After acquiring the three-dimensional model, in order to facilitate surface skin rendering of the three-dimensional model, the present embodiment also needs to extract model parameters in the three-dimensional model, which are similar to drawing parameters of the three-dimensional model, so as to clarify the feature details of each feature of the three-dimensional model.
[0058] Step S20, creating a shading case in a preset shader program according to the model parameters, and setting the appearance parameters and reflection parameters of the three-dimensional model in the shading case.
[0059] In this embodiment, after acquiring the three-dimensional model and extracting the model parameters of the three-dimensional model, a shading case corresponding to the three-dimensional model will be created in a preset shader program based on the above model parameters. The shading case is used for program execution of a computer device, so that the surface skin rendering of the three-dimensional model can be performed step by step through the actual shading case.
[0060] When creating a shading case in a shader program, it is necessary to set the appearance parameters and reflection parameters of the three-dimensional model in the shading case accordingly, so as to facilitate subsequent surface skin rendering.
[0061] Specifically, when rendering the surface skin of a 3D model, you need to create a shader program Shader. By creating a new shader program Shader, the appearance and reflection method of the skin surface can be defined. The Standard Shader provided by Unity can be used as a basis, and then modified according to actual needs.
[0062] Step S30: In the shader program, first rendering parameters are set according to the shading use case, and the three-dimensional model is rendered according to the first rendering parameters.
[0063] In this embodiment, in the shader program, setting a first rendering parameter according to the shading use case, and rendering the three-dimensional model according to the first rendering parameter specifically includes:
[0064] In the shader program, a skin main structure of the three-dimensional model is determined according to the shading use case, and a first PBR parameter is calculated according to the skin main structure;
[0065] Perform skin smoothness offset on the skin main structure and calculate a second PBR parameter;
[0066] The first PBR parameter and the second PBR parameter are fused to obtain first rendering parameters, and the three-dimensional model is rendered according to the first rendering parameters.
[0067] The step of fusing the first PBR parameter with the second PBR parameter to obtain a first rendering parameter, and rendering the three-dimensional model according to the first rendering parameter specifically includes:
[0068] Obtaining a distribution function value of a preset roughness and an angle between a normal line and a half vector;
[0069] Get the occlusion value of the occlusion item of the viewing angle between the preset roughness and normal and the viewing direction;
[0070] And obtain the preset light incident angle and the specular reflection value of the material;
[0071] The roughness, the specular color, the normal, the light direction and the observation camera direction are used as input values of the bidirectional reflectance distribution function, and the output value of the bidirectional reflectance distribution function is calculated using the GGX distribution function, the Smith occlusion term and the Schlick approximation to obtain a first rendering parameter, where the first rendering parameter is used to describe the highlight condition;
[0072] The three-dimensional model is rendered according to the first rendering parameters.
[0073] Specifically, in the process of rendering the surface skin of the three-dimensional model according to the first rendering parameter, the basic BRDF highlight calculation formula is added, and the Cook-Torrance model is used. The BRDF (Bidirectional Reflectance Distribution Function) calculation based on the microplane model is implemented, in which the GGX (also known as Trowbridge-Reitz) microplane model, as well as the Smith occlusion term and Schlick approximation are used to calculate the highlight part. The functions used are as follows:
[0074] GGX microfacet distribution function (D_GGX): It is a function used to describe the distribution of microsurface normals, describing the relationship between the microsurface normal and the line of sight. This function returns the value of the GGX distribution function for a given roughness parameter and the angle between the normal and the half-vector.
[0075] Smith Occlusion Term (Vis_Smith): The Smith geometry occlusion term is a factor used to estimate microfacet occlusion. It takes into account the occlusion between the view from the light source and the viewer, as well as the occlusion between the normal and the light. This function returns the value of the Smith occlusion term for a given roughness parameter, the view between the normal and the view direction.
[0076] Schlick's approximation of reflectance (F_Schlick): Schlick's approximation of reflectance is a simplified formula for calculating specular reflection of non-metallic surfaces. The reflectance is calculated by using an approximation of the Fresnel equations. This function returns the value of the specular reflectance for a given light incident angle and material.
[0077] DirectBRDFSpecularSmith function: This function combines the above three parts and calculates the highlight part of the BRDF based on the microfacet model. It accepts roughness, specular color, normal, light direction and viewing direction as input, and then uses the GGX distribution function, Smith occlusion term and Schlick approximation to calculate the highlight part of the BRDF, and finally returns the result.
[0078] The above functions are all physically based rendering models, which are used to simulate lighting and reflection in computer graphics to achieve more realistic image effects.
[0079] Specifically, the first layer of skin main structure calculates the PBR effect once, the second layer of skin smoothness offsets, and the PBR effect is calculated again. The two layers are superimposed to simulate the detailed highlights of the skin.
[0080] Step S40: adjusting the illumination parameters in the shading use case according to the scene parameters of the three-dimensional model to obtain second rendering parameters, and rendering the three-dimensional model according to the second rendering parameters to obtain a target three-dimensional model.
[0081] In this embodiment, according to the scene parameters of the three-dimensional model, the illumination parameters in the shading use case are adjusted to obtain second rendering parameters, and the step of rendering the three-dimensional model according to the second rendering parameters to obtain the target three-dimensional model specifically includes:
[0082] Obtaining scene parameters of the three-dimensional model when rendered by a shader program;
[0083] According to the scene parameters, adjusting the lighting parameters in the shading use case, at least including adjusting the ambient occlusion color and the indirect diffuse lighting, to obtain diffuse color parameters, so as to obtain second rendering parameters including the diffuse color parameters;
[0084] The three-dimensional model is rendered according to the second rendering parameters to obtain a target three-dimensional model.
[0085] Specifically, the lighting parameters in the shading use case are adjusted to obtain the second rendering parameters, including the calculation of indirect light, by calculating indirect diffuse lighting, in which custom spherical harmonic coefficients (SH) are used to approximate diffuse lighting, and modified ambient occlusion (AO) is used to adjust the diffuse color.
[0086] Including the calculation of AO color, specifically:
[0087] lerp(_SkinAOColor,1,ao): Use the AO (ambient occlusion) value to interpolate between the specified _SkinAOColor and 1 to get the AO color. This color is used to adjust the intensity of indirect diffuse reflections.
[0088] saturate(lerp(1,aoColor,_SSSSpecParam4)) : Interpolate the AO color again, but use another parameter _SSSSpecParam4. Finally, the saturate function ensures that the color component is between 0 and 1.
[0089] It also includes the calculation of indirect diffuse lighting, including:
[0090] ShadeSH9_New(half4(normalWorld1,1)): This function calculates the indirect diffuse lighting based on the spherical harmonics. It accepts a normal as input and returns a half3 color representing the indirect diffuse lighting.
[0091] indirectDiffuse = indirectDiffuse * aoColor: Multiply the calculated indirect diffuse lighting by the AO color to adjust the diffuse color. This process actually applies the AO effect to the diffuse lighting.
[0092] It also includes pre-integrated SSS skin, which pre-calculates and stores the integral value to speed up the simulation of subsurface scattering effects of translucent materials such as skin in graphics rendering.
[0093] 1. Calculate the angle between the light and the normal: Use the dot function to calculate the angle between the main light source direction and the surface normal, and use the saturate function to ensure that the angle is between 0 and 1.
[0094] 2. Calculate the pre-integrated texture coordinates: Calculate the UV coordinates of the pre-integrated texture through some parameters. These parameters include linear combinations of NoL and some adjustments to paramTex.
[0095] 3. Sample the pre-integrated map: Use the calculated UV coordinates to sample from the pre-integrated map to obtain the pre-integrated value.
[0096] 4. Smooth normals: Smooth the surface normals to generate two smooth normals with different degrees of smoothness.
[0097] 5. Calculate the angle between the normal and the light: Calculate the angle between the two smooth normals and the light separately, and use the saturate function to ensure that it is between 0 and 1.
[0098] 6. Sample curvature map: Use some parameters to calculate the UV coordinates of the curvature map and sample the curvature value from the curvature map.
[0099] 7. Calculate the temporary curvature value: perform some processing on the sampled curvature value to obtain the temporary curvature value.
[0100] 8. Calculate the main SSS color: Through some mixing operations, combined with the pre-integrated value, angle value and temporary curvature value, the main SSS color is calculated.
[0101] The subsurface scattering (SSS) effect of skin under camera lighting is calculated through screen space, producing an effect similar to side lighting.
[0102] First, the original view vector is combined with the specified skin camera light angle by calculating the view offset (viewYOffset).
[0103] Then, create a new view offset vector (viewOffset) that contains the X and Z components of the original view vector and the newly calculated Y component.
[0104] Next, the dot operation (dot) is used to calculate the angle between the offset view vector and the surface normal, and the result is limited to between 0 and 1 (NoOffsetV) through the saturation function (saturate), which represents the projection intensity of the light on the surface.
[0105] Next, the pre-integrated value (preintegratedValueInCameraLight) is obtained by converting the surface projection intensity into UV coordinates and sampling the pre-integrated map. The pre-integrated map contains information about the subsurface scattering intensity at a given incident angle.
[0106] Then, the ambient occlusion (AO), skin camera light color and pre-integrated value are combined to get the subsurface scattering color (skinCameraSSSColor) of the skin under camera light.
[0107] Finally, the scattering effect's scattering strength and scattering shape (NoOffsetVPow) are adjusted by multiplying the logarithm of the surface projection intensity by a specified power parameter (_SkinCameraLightingPow) and then exponentially again.
[0108] Finally, the skin subsurface scattering color is multiplied by NoOffsetVPow to get the final subsurface scattering color of the skin under camera light.
[0109] It also includes the calculation of soft shadows, using different shadow sampling methods under different platforms and scene settings, including:
[0110] 1. Two constants are defined:
[0111] _ShadowMapTexelOffset: Used to calculate the Texel offset in the shadow map. The value here is 1 divided by the resolution of the shadow map, assuming the shadow map resolution is 2048.
[0112] _ShadowKernelOffset: Used to control the kernel offset of soft shadow sampling, affecting the blurriness of soft shadows.
[0113] 2. CalculateShadowMap function: This function is used to calculate the shadow value.
[0114] 3. First determine whether screen space shadows are enabled (SHADOWS_SCREEN) and whether Unity's screen space shadows are disabled (UNITY_NO_SCREENSPACE_SHADOWS).
[0115] 4. For the case where screen space shadows are enabled and Unity's screen space shadows are disabled, a custom soft shadow sampling method is used:
[0116] Iterates through a range of sample points defined by _ShadowKernelOffset.
[0117] For each sampling point, calculate its coordinates in the shadow map and perform a Texel offset.
[0118] The shadow value of each sampling point is sampled and accumulated into totalAtten.
[0119] Finally, the accumulated shadow value is divided by the number of sampling points to get the average shadow value, which is then mapped to between 0 and 1 using the smoothstep function.
[0120] 5. Return the calculated average shadow value.
[0121] Also included is the setup for the second light, including:
[0122] Fixed pipeline, refer to URP's multi-light implementation, the character skin Shader is special and can light this light separately. Dynamically pass in the _SecondLightColorSkin color in the C# code.
[0123] If the second light is enabled (i.e. secondLightEnable is true), then the following steps are performed:
[0124] Compute the specular terms for the first and second light sources for the surface (specularTerm2nd1 and specularTerm2nd2).
[0125] These terms are calculated by calling the DirectBRDFSpecularSmith function, which is usually used to calculate the specular reflection terms based on the Smith geometry function.
[0126] Afterwards, these terms are multiplied by paramTex2.z and the result is clamped between 0 and 1 by the saturate function.
[0127] Calculate the dot product between the light direction and the surface normal, multiply it by the second light's color (_SecondLightColorSkin), and add the result to extraColor.
[0128] Finally, the specular terms of the two light sources are added together, multiplied by the minimum value of the second light source's color (the .xyz component, since it is a color value), and added to directSpecular.
[0129] By calculating and superimposing the specular reflection items of multiple light sources, special lighting processing of the character skin shader in the fixed pipeline is achieved.
[0130] It also includes SSSSS calculations, based on the subsurface scattering effect in screen space, including:
[0131] First, the skin areas are marked on the screen using a stencil test. Stencil testing is a technique used during rendering to control whether pixels are drawn. It is used to determine which pixels belong to the skin area. With the stencil test, a marker can be applied to specific pixel locations so that subsequent rendering is only performed at these locations.
[0132] Convolution is performed on the skin area. In Unity, the properties of the shader program can be accessed in C# code through the Shader.PropertyToID method. Several constants are defined in this code to access the properties in the shader. These properties include _5STempBuffer (used to store the intermediate results of convolution), _5SCameraParams (camera parameters), _5SKernelParams (convolution kernel parameters), and _5SKernel (convolution kernel array). These properties are passed to the shader in the form of uniform variables in the C# code, and can be declared and accessed in the shader through the uniform keyword.
[0133] Convolution kernel and parameters:
[0134] In the C# code, some fixed convolution kernels and parameter values are defined, which are used in the convolution process. The convolution kernel is a list of multiple Vector4s, each Vector4 represents a row of the convolution kernel. The parameters _5SCameraParams and _5SKernelParams are also fixed and passed to the shader during the convolution process.
[0135] ExecutePass method:
[0136] This method is used to perform the convolution process. It accepts a series of parameters, including the command buffer, material, width and height of the render target, etc.
[0137] In the method, first, start and end sampling through cmd.BeginSample and cmd.EndSample to display the execution time in the Unity Profiler. Then, create a temporary RenderTexture through cmd.GetTemporaryRT to store the intermediate results of the convolution process. Then set the uniform variables in the shader through cmd.SetGlobalVector and cmd.SetGlobalVectorArray. Use the cmd.BlitFullscreenTriangle method to pass the source RenderTexture to the shader and perform the convolution process. Finally, pass the convolution result back to the source RenderTexture.
[0138] In this embodiment, it is easy to understand that the method includes:
[0139] 1. Two-layer base PBR:
[0140] Implementation method: By using two PBR material layers in the rendering pipeline, the basic material properties of the object surface (such as roughness, metalness, etc.) are described separately, and they are synthesized into the final surface color and reflection properties.
[0141] Technical effect: A double-layer basic PBR (Physically Based Rendering) is implemented, that is, two PBR material layers are used to simulate the complexity and reality of the object surface.
[0142] 2. Indirect light, AO correction:
[0143] Implementation: By adjusting the lighting model and ambient occlusion algorithm to more accurately reflect the indirect reflection of light and the occlusion effect in the scene, the lighting quality and visual details of the scene are improved.
[0144] Technical Effects: Improved indirect lighting and ambient occlusion (AO) to enhance the realism and visual quality of your scenes.
[0145] 3. Pre-integrated SSS skin, normal + camera space:
[0146] Implementation: Using a pre-computed scattering model, the scattering effect of light inside the skin is calculated based on the material properties of the skin and the camera's viewing angle, and applied to the surface color and reflection, thereby enhancing the realism and fidelity of the skin.
[0147] Technical Effect: Pre-integration based skin subsurface scattering (SSS) is implemented, and the influence of surface normal and camera perspective on the scattering effect is taken into account.
[0148] 4. Soft shadows on the skin:
[0149] Implementation method: When SSSM (Screen Space Subsurface Scattering Maps) is not turned on on the mobile terminal, a simple PCF (Percentage Closer Filtering) shadow algorithm based on ShadowMap is used to produce a softened shadow effect on the skin surface.
[0150] Technical Effect: Produces soft shadow effects on skin surfaces to enhance the visual quality and realism of renderings.
[0151] 5. SSSSS calculation, based on subsurface scattering effect in screen space:
[0152] Implementation: Utilize screen space information and algorithms to calculate the multiple scattering effects of light inside the skin and apply them to the rendering process to enhance the lighting effect and visual quality of the skin surface.
[0153] Technical Effect: Through screen-space-based calculations, the subsurface scattering (SSSSS) effect is achieved, further enhancing the realism and authenticity of the skin.
[0154] The above technical effects shown in this embodiment are achieved through a carefully designed rendering pipeline and algorithm, and corresponding implementation and optimization are performed in the shader code and rendering engine to achieve higher rendering quality and visual fidelity.
[0155] Compared with the prior art, the three-dimensional model surface skin rendering method shown in this embodiment has the following beneficial effects:
[0156] When performing skin rendering on the surface of a three-dimensional model, the three-dimensional model to be rendered with the model skin is obtained, the model parameters of the three-dimensional model are extracted, and then a shading case is created in a preset shader program according to the model parameters, the appearance parameters and reflection parameters of the three-dimensional model are set in the shading case, and in the shader program, a first rendering parameter is set according to the shading case, and the three-dimensional model is rendered according to the first rendering parameter, and finally, according to the scene parameters of the three-dimensional model, the illumination parameters in the shading case are adjusted to obtain the second rendering parameter, and the three-dimensional model is rendered according to the second rendering parameter to obtain the target three-dimensional model. The method shown in this embodiment is adopted, by providing a simple PCF shadow rendering technology suitable for mobile devices, as well as a pre-integrated SSS skin rendering technology for AO correction and a subsurface scattering effect based on screen space, which can improve the rendering efficiency and quality on mobile devices, achieve a more realistic skin effect, and thus enhance the user experience.
[0157] Embodiment 2
[0158] See also Figure 2 The second embodiment of the present invention provides a three-dimensional model surface skin rendering system, which is applied to the method described in the above embodiment. The system includes: a parameter extraction module 10, a shading case creation module 20, a first rendering module 30 and a second rendering module 40.
[0159] A parameter extraction module 10 is used to obtain a three-dimensional model to be rendered with model skin and extract model parameters of the three-dimensional model;
[0160] A shading case creation module 20, for creating a shading case in a preset shader program according to the model parameters, and setting the appearance parameters and reflection parameters of the three-dimensional model in the shading case;
[0161] A first rendering module 30, configured to set a first rendering parameter according to the shading use case in the shader program, and render the three-dimensional model according to the first rendering parameter;
[0162] The second rendering module 40 is used to adjust the lighting parameters in the shading use case according to the scene parameters of the three-dimensional model to obtain second rendering parameters, and render the three-dimensional model according to the second rendering parameters to obtain a target three-dimensional model.
[0163] Wherein, the first rendering module 30 is specifically used for:
[0164] In the shader program, a skin main structure of the three-dimensional model is determined according to the shading use case, and a first PBR parameter is calculated according to the skin main structure;
[0165] Perform skin smoothness offset on the skin main structure and calculate a second PBR parameter;
[0166] The first PBR parameter and the second PBR parameter are fused to obtain first rendering parameters, and the three-dimensional model is rendered according to the first rendering parameters.
[0167] Compared with the prior art, the three-dimensional model surface skin rendering system shown in this embodiment has the following beneficial effects:
[0168] When performing skin rendering on the surface of a three-dimensional model, the three-dimensional model to be rendered with the model skin is obtained, the model parameters of the three-dimensional model are extracted, and then a shading case is created in a preset shader program according to the model parameters, the appearance parameters and reflection parameters of the three-dimensional model are set in the shading case, and in the shader program, a first rendering parameter is set according to the shading case, and the three-dimensional model is rendered according to the first rendering parameter, and finally, according to the scene parameters of the three-dimensional model, the illumination parameters in the shading case are adjusted to obtain the second rendering parameter, and the three-dimensional model is rendered according to the second rendering parameter to obtain the target three-dimensional model. The system shown in this embodiment is adopted, by providing a simple PCF shadow rendering technology suitable for mobile devices, as well as a pre-integrated SSS skin rendering technology for AO correction and a subsurface scattering effect based on screen space, which can improve the rendering efficiency and quality on mobile devices, achieve a more realistic skin effect, and thus enhance the user experience.
[0169] Embodiment 3
[0170] A third embodiment of the present invention provides a readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described in the above embodiment is implemented.
[0171] Embodiment 4
[0172] A fourth embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the method described in the above embodiments when executing the computer program.
[0173] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0174] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for those of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A method for rendering skin on a three-dimensional model surface, characterized in that: The method comprises: Acquire a three-dimensional model for model skin rendering, and extract model parameters of the three-dimensional model; According to the model parameters, creating a shading case in a preset shader program, and setting the appearance parameters and reflection parameters of the three-dimensional model in the shading case; In the shader program, a first rendering parameter is set according to the shading use case, and the three-dimensional model is rendered according to the first rendering parameter; According to the scene parameters of the three-dimensional model, adjusting the illumination parameters in the shading use case to obtain second rendering parameters, and rendering the three-dimensional model according to the second rendering parameters to obtain a target three-dimensional model; In the shader program, setting a first rendering parameter according to the shading use case, and rendering the three-dimensional model according to the first rendering parameter specifically includes: In the shader program, a skin main structure of the three-dimensional model is determined according to the shading use case, and a first PBR parameter is calculated according to the skin main structure; Perform skin smoothness offset on the skin main structure and calculate a second PBR parameter; The first PBR parameter and the second PBR parameter are fused to obtain a first rendering parameter, and the three-dimensional model is rendered according to the first rendering parameter; The step of fusing the first PBR parameter with the second PBR parameter to obtain a first rendering parameter, and rendering the three-dimensional model according to the first rendering parameter specifically includes: Obtaining a distribution function value of a preset roughness and an angle between a normal line and a half vector; Get the occlusion value of the occlusion item of the viewing angle between the preset roughness and normal and the viewing direction; And obtain the preset light incident angle and the specular reflection value of the material; The roughness, the specular color, the normal, the light direction and the observation camera direction are used as input values of the bidirectional reflectance distribution function, and the output value of the bidirectional reflectance distribution function is calculated using the GGX distribution function, the Smith occlusion term and the Schlick approximation to obtain a first rendering parameter, where the first rendering parameter is used to describe the highlight condition; The three-dimensional model is rendered according to the first rendering parameters.
2. The method for rendering the surface skin of a three-dimensional model according to claim 1, characterized in that: The step of adjusting the illumination parameters in the shading use case according to the scene parameters of the three-dimensional model to obtain second rendering parameters, and rendering the three-dimensional model according to the second rendering parameters to obtain a target three-dimensional model specifically includes: Obtaining scene parameters of the three-dimensional model when rendered by a shader program; According to the scene parameters, adjusting the lighting parameters in the shading use case, at least including adjusting the ambient occlusion color and the indirect diffuse lighting, to obtain diffuse color parameters, so as to obtain second rendering parameters including the diffuse color parameters; The three-dimensional model is rendered according to the second rendering parameters to obtain a target three-dimensional model.
3. The method for rendering the surface skin of a three-dimensional model according to any one of claims 1 to 2, characterized in that: The method further comprises: Calculates subsurface scattering color parameters of the model's skin under camera light.
4. The method for rendering the surface skin of a three-dimensional model according to claim 3, characterized in that: The steps for calculating the subsurface scattering color parameters of the model skin under the illumination of camera light include: Calculate the perspective offset vector, and combine the perspective offset vector with the set skin camera light angle parameter; Create a new perspective offset vector, which contains the X and Z components of the original perspective offset vector and the newly calculated Y component; Calculate the angle parameter between the offset perspective offset vector and the surface normal using a dot multiplication operation, and limit the angle parameter to a preset range using a saturation function to describe the surface projection intensity of the light on the surface; The surface projection intensity is converted into UV coordinate parameters, and sampled in the pre-integrated map to obtain a pre-integrated value; The ambient occlusion color parameter, the skin camera light color parameter and the pre-integrated value are merged to obtain the subsurface scattering color parameter of the model skin under the illumination of the camera light; Multiplying the logarithm of the surface projection intensity by a preset power parameter and performing exponential calculation to adjust the scattering intensity and scattering shape of the light scattering to obtain a scattering intensity parameter and a scattering shape parameter; The scattering intensity parameter is multiplied by the scattering shape parameter to obtain a final subsurface scattering color parameter of the model skin under the illumination of camera light.
5. A three-dimensional model surface skin rendering system, characterized in that: The method applied to any one of claims 1 to 4, wherein the system comprises: A parameter extraction module, used to obtain a three-dimensional model to be rendered with model skin, and extract model parameters of the three-dimensional model; A shading case creation module, used to create a shading case in a preset shader program according to the model parameters, and to set the appearance parameters and reflection parameters of the three-dimensional model in the shading case; A first rendering module, configured to set a first rendering parameter in the shader program according to the shading use case, and render the three-dimensional model according to the first rendering parameter; A second rendering module, configured to adjust the illumination parameters in the shading use case according to the scene parameters of the three-dimensional model to obtain second rendering parameters, and render the three-dimensional model according to the second rendering parameters to obtain a target three-dimensional model; The first rendering module is specifically used for: In the shader program, a skin main structure of the three-dimensional model is determined according to the shading use case, and a first PBR parameter is calculated according to the skin main structure; Perform skin smoothness offset on the skin main structure and calculate a second PBR parameter; The first PBR parameter and the second PBR parameter are fused to obtain first rendering parameters, and the three-dimensional model is rendered according to the first rendering parameters.
6. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of being executed on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Virtual model rendering method and device, electronic equipment and storage medium
CN116958395A