Virtual character hair rendering method, device, electronic device and storage medium

By obtaining pixels from the shadow map, calculating the occlusion shadow coefficient and lighting coefficient, and performing an addition operation based on the color and highlight sampling values, the problem of the light and shadow effect of the virtual character's hair not changing with the movement of the character is solved, and more natural and realistic hair is achieved. Rendering effect.

CN115082607BActive Publication Date: 2024-08-30NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210589067.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-26
Publication Date
2024-08-30
Estimated Expiration
2042-05-26

AI Technical Summary

Technical Problem

In the prior art, the light and shadow effects of the virtual character's hair do not change with the movement of the character, resulting in unnatural hair performance.

Method used

By obtaining the pixel points that meet the preset requirements from the shadow map, the occlusion shadow coefficient and the lighting coefficient are calculated, and combined with the color sampling value and the highlight sampling value, the sum operation is performed to render the hair of the virtual character, ensuring that the hair effect follows the movement of the character. Natural changes.

Benefits of technology

The hair rendering effect of virtual characters has been improved to make it appear more natural and realistic, increasing the realism of virtual characters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115082607B
    Figure CN115082607B
Patent Text Reader

Abstract

The present application discloses a method, device, electronic device and storage medium for rendering hair of a virtual character; including: obtaining pixel points that meet preset requirements from a shadow map; determining illumination influence parameters, and calculating the occlusion shadow coefficient according to the illumination influence parameters and the shadow sampling value; constructing a circumscribed sphere, obtaining the normal of the position where the surface of the circumscribed sphere contacts the vertex of the hair of the virtual character as the normal of the adjacent vertex; calculating the illumination coefficient of each shading point according to the occlusion shadow coefficient, the illumination direction vector and the normals corresponding to multiple vertices; obtaining the first operation result of each shading point according to the color sampling value, the highlight sampling value, and the illumination coefficient of each shading point; obtaining the stroke description information, and obtaining the second operation result; obtaining the sum of the first operation result and the second operation result, and rendering according to the sum corresponding to each shading point to obtain the rendering result. The present application can increase the realism of the hair of the virtual character.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a method, device, electronic device and storage medium for rendering hair of a virtual character. Background Art

[0002] In the prior art, when rendering the hair of a virtual character, the light and shadow problem of the hair is usually solved by fixing the shadow of the hair on a texture.

[0003] However, in the manner in which the shadow of the hair is fixedly drawn on the texture, the light and shadow effect of the virtual character's hair does not change with the movement of the virtual character, and the virtual character's hair is not expressed naturally. That is, there is a problem in the prior art that the virtual character's hair is not expressed naturally. Summary of the invention

[0004] The embodiments of the present application provide a method, device, electronic device and storage medium for rendering hair of a virtual character, which can improve the problem in the prior art that the hair of the virtual character is not rendered naturally enough.

[0005] The present application provides a method for rendering hair of a virtual character, the method comprising:

[0006] For each of the plurality of shading points, a pixel point that meets a preset requirement is obtained from the shadow map, wherein the plurality of shading points are shading points corresponding to a plurality of planes included in the three-dimensional model of the hair of the virtual character, and the pixel point that meets the preset requirement is recorded as a shadow sampling value;

[0007] Determine the lighting impact parameter, and calculate the occlusion shadow coefficient of each shading point according to the lighting impact parameter and the shadow sampling value of each shading point;

[0008] Constructing a circumscribed sphere for wrapping the hair of the virtual character, obtaining normals of positions corresponding to vertices of the hair of the virtual character on the surface of the circumscribed sphere, and using the normals as normals of corresponding adjacent vertices;

[0009] Calculate the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector, and the normals corresponding to multiple vertices of the hair of the virtual character;

[0010] Obtaining a color sampling value and a highlight sampling value of each shading point, and obtaining a first operation result corresponding to each shading point according to the color sampling value, the highlight sampling value of each shading point, and the illumination coefficient corresponding to each shading point;

[0011] Acquire stroke description information, and acquire a second operation result based on the stroke description information;

[0012] For each shading point corresponding to a first operation result, a sum of the first operation result and the second operation result is obtained, and the three-dimensional model of the virtual character's hair is rendered according to the sum corresponding to each shading point to obtain a rendering result.

[0013] The embodiment of the present application also provides a virtual character hair rendering device, the device comprising:

[0014] a pixel point acquisition unit, configured to acquire, for each of a plurality of shading points, a pixel point that meets preset requirements from a shadow map, wherein the plurality of shading points are shading points corresponding to a plurality of planes included in a three-dimensional model of the hair of the virtual character, and the pixel point that meets the preset requirements is recorded as a shadow sampling value;

[0015] An illumination parameter determination unit, used to determine illumination influence parameters, and calculate an occlusion shadow coefficient of each shading point according to the illumination influence parameters and the shadow sampling value of each shading point;

[0016] A normal acquisition unit, used for constructing a circumscribed sphere for wrapping the hair of the virtual character, acquiring normals of positions corresponding to vertices of the hair of the virtual character on the surface of the circumscribed sphere, and using the normals as normals of corresponding adjacent vertices;

[0017] An illumination coefficient calculation unit, used to calculate the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector, and the normals corresponding to the multiple vertices of the hair of the virtual character;

[0018] A first result acquisition unit, used to acquire a color sampling value and a highlight sampling value of each shading point, and acquire a first operation result corresponding to each shading point according to the color sampling value, the highlight sampling value of each shading point, and the illumination coefficient corresponding to each shading point;

[0019] A second result obtaining unit, used to obtain stroke description information, and obtain a second operation result based on the stroke description information;

[0020] The sum result acquisition unit is used to obtain the sum of the first operation result and the second operation result for each shading point, and render the three-dimensional model of the virtual character's hair according to the sum result corresponding to each shading point to obtain a rendering result.

[0021] In some embodiments, the pixel point acquisition unit is specifically used to: for each shading point, obtain the pixel point corresponding to the UV coordinate value of the shading point in the shadow map, wherein the pixel point is a pixel point that meets preset requirements.

[0022] In some embodiments, the illumination parameter determination unit includes:

[0023] Lighting vector subunit, used to obtain the lighting direction vector;

[0024] A projection vector subunit, used for projecting the illumination direction vector on a target projection plane to obtain an illumination projection vector, wherein the target projection plane is a projection plane formed by the virtual character's facing direction and a vertical upward direction vector;

[0025] The influence parameter calculation subunit is used to calculate the illumination influence parameter according to the illumination projection vector and the vertical upward direction vector.

[0026] In some embodiments, the normal acquisition unit includes:

[0027] A circumscribed sphere subunit, used for generating a circumscribed sphere corresponding to the hair of the virtual character, wherein the center of the circumscribed sphere coincides with the center of the head of the virtual character;

[0028] A corner point acquisition subunit, used to make a ray from the center of the circumscribed sphere to each of the multiple vertices of the hair of the virtual character, and obtain the intersection point of each ray with the surface of the circumscribed sphere;

[0029] The normal calculation subunit is used to calculate the normal of each intersection position for each intersection point among the multiple intersection points, and use the normal of each intersection position as the normal of each vertex adjacent to each intersection point.

[0030] In some embodiments, the illumination coefficient calculation unit includes:

[0031] A normal conversion subunit, used for converting normals corresponding to a plurality of vertices of the hair of the virtual character into a world space coordinate system, and performing normalization processing to obtain a normal vector corresponding to each shading point;

[0032] A point product result subunit, for calculating the point product of the normal vector corresponding to each shading point and the illumination direction vector, to obtain a point product result;

[0033] A preliminary parameter subunit, for performing a smooth step function process on the dot product result corresponding to each shading point to obtain a preliminary illumination coefficient;

[0034] The illumination coefficient determination subunit is used to obtain the smaller value of the preliminary illumination coefficient and the occlusion shadow coefficient for each shading point, where the smaller value is the illumination coefficient.

[0035] In some embodiments, the first result obtaining unit includes:

[0036] A color sampling subunit is used to obtain, for each shading point, a pixel point corresponding to the UV coordinate value of the shading point in the shadow map, wherein the pixel point is a pixel point that meets preset requirements;

[0037] The highlight sampling subunit is used to obtain, for each shading point, a pixel point corresponding to the UV coordinate value of the shading point in the highlight map, wherein the pixel point is the highlight sampling value.

[0038] In some embodiments, the first result obtaining unit includes:

[0039] For each shading point:

[0040] A first product subunit, used for calculating a product of a color parameter value, a color intensity value and the color sampling value to obtain a first product;

[0041] A second product subunit is used to calculate the product of the highlight color value, the highlight intensity value and the highlight sampling value to obtain a second product;

[0042] a sum result subunit, configured to calculate the sum of the first product and the second product to obtain a product sum result;

[0043] The first result subunit is used to multiply the product addition result with the corresponding illumination coefficient to obtain a corresponding first operation result.

[0044] In some embodiments, the second result obtaining unit includes:

[0045] A three-dimensional model subunit, used for obtaining a three-dimensional model of the hair of the virtual character that has completed the preset processing, wherein the edge area of ​​each strand of hair in the three-dimensional model of the hair of the virtual character that has completed the preset processing is a first color and the center area is a second color;

[0046] The stroke area subunit is used to perform an interpolation operation on the area to which the first color of each strand of hair belongs, for each pixel point of the area to which the first color of each strand of hair belongs, according to the distance between the pixel point and the central area of ​​the strand of hair to which it belongs, and the distance between the pixel point and the edge line of the strand of hair to which it belongs, so as to obtain the stroke description information.

[0047] In some embodiments, the second result obtaining unit includes:

[0048] A stroke operation subunit, used for performing a step function operation on the stroke description information and the stroke thickness parameter to obtain a stroke operation result;

[0049] The multiplication operation subunit is used to calculate the multiplication result of the stroke color value, the stroke strength value and the stroke operation result, and the multiplication result is the second operation result.

[0050] In some embodiments, the apparatus further comprises:

[0051] A large and small shadow acquisition unit, used to acquire a maximum shadow map and a minimum shadow map corresponding to the hair of the virtual character, wherein the maximum shadow map is a map corresponding to the maximum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; the minimum shadow map is a map corresponding to the minimum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting;

[0052] an intermediate shadow calculation unit, configured to calculate an intermediate shadow area according to the maximum shadow map and the minimum shadow map;

[0053] an interpolation shadow unit, configured to perform an interpolation operation on each pixel point in the middle shadow area according to a distance between the pixel point and a first boundary of the middle shadow area and a distance between the pixel point and a second boundary of the middle shadow area, so as to obtain an interpolation shadow area; wherein the first boundary is a boundary adjacent to the minimum shadow, and the second boundary is a boundary away from the minimum shadow;

[0054] A shadow combining unit is used to combine the interpolation shadow area with the minimum shadow map to obtain the shadow map.

[0055] An embodiment of the present application also provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in any one of the virtual character hair rendering methods provided in the embodiments of the present application.

[0056] In the virtual character hair rendering method provided in the embodiment of the present application, a shadow sampling value that meets the preset requirements can be obtained from the shadow map; then the lighting influence parameters are determined, and the occlusion shadow coefficient is calculated based on the lighting influence parameters and the shadow sampling value. The embodiment of the present application can also calculate the normals corresponding to multiple vertices of the virtual character's hair, and calculate the lighting coefficient corresponding to each shading point based on the normals, lighting direction vectors and occlusion shadow coefficients corresponding to the above multiple vertices, and then combine the color sampling value and the highlight sampling value to obtain the first operation result corresponding to each shading point. The embodiment of the present application can also obtain the second operation result based on the stroke description information, and add the second operation result to the first operation result corresponding to each shading point to obtain the summed result corresponding to each shading point, and render the three-dimensional model of the virtual character's hair according to the above summed result.

[0057] In the present application, when calculating the illumination coefficient corresponding to each shading point, the occlusion shadow coefficient, the illumination direction vector, and the normals corresponding to the multiple vertices of the virtual character's hair are used. After calculating the illumination coefficient corresponding to each shading point, the color sampling value, the highlight sampling value, and the stroke description information are combined to finally calculate the sum of the corresponding results of each shading point. After introducing the coefficients of the above multiple aspects, the rendering of the virtual character's hair can form a natural displacement as the virtual character moves, thereby increasing the realism of the virtual character's hair. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0059] Figure 1a It is a scene schematic diagram of a virtual character hair rendering method provided in an embodiment of the present application;

[0060] Figure 1b It is a flowchart of a method for rendering hair of a virtual character provided in an embodiment of the present application;

[0061] Figure 1c A schematic diagram showing a shadow map of several tufts of hair of an avatar;

[0062] Figure 1d A three-dimensional model of the hair of the virtual character without the preset processing is shown;

[0063] Figure 1e A three-dimensional model of the hair of a virtual character that has been subjected to a preset process is shown;

[0064] Figure 2 is a flowchart of a method for rendering hair of a virtual character provided by another embodiment of the present application;

[0065] Figure 3 This is a structural schematic diagram of a virtual character hair rendering device provided in one embodiment of the present application;

[0066] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0067] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0068] Embodiments of the present application provide a method, device, mobile terminal and storage medium for rendering virtual character hair.

[0069] The virtual character hair rendering method can be integrated into an electronic device, which can be a terminal, a server, etc. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, or a personal computer (PC); the server can be a single server or a server cluster composed of multiple servers.

[0070] In some embodiments, the virtual character hair rendering method can also be integrated into multiple electronic devices. For example, the virtual character hair rendering method can be integrated into multiple servers, and the virtual character hair rendering method of the present application can be implemented by multiple servers.

[0071] In some embodiments, the server may also be implemented in the form of a terminal.

[0072] For example, see Figure 1aIn some embodiments, the electronic device may be a mobile terminal. The embodiment may obtain, for each of a plurality of shading points, a pixel point that meets a preset requirement from a shadow map, wherein the plurality of shading points are shading points corresponding to a plurality of planes included in a three-dimensional model of the hair of the virtual character, and the pixel point that meets the preset requirement is recorded as a shadow sampling value; determine an illumination influence parameter, and calculate an occlusion shadow coefficient of each shading point according to the illumination influence parameter and the shadow sampling value of each shading point; construct an external sphere for wrapping the hair of the virtual character, obtain a normal of a position corresponding to a vertex of the hair of the virtual character on the surface of the external sphere, and use the normal as a normal of a corresponding adjacent vertex; and calculate an occlusion shadow coefficient according to the occlusion shadow coefficient of each shading point. The illumination coefficient corresponding to each shading point is calculated according to the shadow coefficient, the illumination direction vector and the normals corresponding to multiple vertices of the hair of the virtual character; the color sampling value and the highlight sampling value of each shading point are obtained, and the first operation result corresponding to each shading point is obtained according to the color sampling value, the highlight sampling value and the illumination coefficient corresponding to each shading point; the stroke description information is obtained, and the second operation result is obtained based on the stroke description information; for the first operation result corresponding to each shading point, the sum of the first operation result and the second operation result is obtained, and the three-dimensional model of the hair of the virtual character is rendered according to the sum result corresponding to each shading point to obtain a rendering result.

[0073] In one embodiment of the present disclosure, a virtual character hair rendering method can be run on a terminal device or a server. The terminal device can be a local terminal device. When the virtual character hair rendering method is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.

[0074] In an optional embodiment, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operation subject of the game program and the game screen presentation subject are separated. The storage and operation of the virtual character hair rendering method are completed on the cloud game server. The role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a terminal, a TV, a computer, a handheld computer, etc.; but the terminal device for rendering the virtual character hair is a cloud game server in the cloud. When playing the game, the user operates the client device to send an operation instruction to the cloud game server, such as a touch operation instruction. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.

[0075] In an optional embodiment, the terminal device may be a local terminal device. Taking a game as an example, the local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the user through a graphical user interface, that is, the game program is downloaded and installed by an electronic device and run conventionally. The local terminal device may provide the graphical user interface to the user in a variety of ways, for example, it may be rendered and displayed on a display screen of the terminal, or provided to the user through a holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present a graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, and control the display of the graphical user interface on the display screen.

[0076] The game scene (or virtual scene) is a virtual scene displayed (or provided) when the application is running on a terminal or server. Optionally, the virtual scene is a simulation environment of the real world, or a semi-simulation and semi-fictitious virtual environment, or a purely fictitious virtual environment. The virtual scene is any one of a two-dimensional virtual scene and a three-dimensional virtual scene. The virtual environment can be the sky, land, ocean, etc., wherein the land includes environmental elements such as deserts and cities. Among them, the virtual scene is a scene with complete game logic of virtual objects such as user control. For example, in a sandbox 3D shooting game, the virtual scene is a 3D game world for users to control virtual objects for battle. Exemplary virtual scenes may include: at least one element of mountains, plains, rivers, lakes, oceans, deserts, skies, plants, buildings, and vehicles.

[0077] The game interface refers to the interface corresponding to the application provided or displayed through the graphical user interface, which includes the graphical user interface for users to interact with and the game screen, which is the screen of the game scene.

[0078] In an optional embodiment, the UI interface may include game controls (such as skill controls, behavior controls, function controls, etc.), indicators (such as direction indicators, character indicators, etc.), information display areas (such as number of kills, match time, etc.), or game setting controls (such as system settings, stores, gold coins, etc.).

[0079] In an optional implementation, the game screen is a display screen corresponding to the terminal device displaying a virtual scene. The game screen may include virtual objects such as game objects that execute game logic in the virtual scene, non-virtual characters (NPC), artificial intelligence (AI) characters, etc.

[0080] For example, in some embodiments, the content displayed in the graphical user interface at least partially includes a game scene, wherein the game scene includes at least one game object.

[0081] In some embodiments, the game objects in the game scene include virtual objects controlled by the player user, namely user objects.

[0082] Game objects refer to virtual objects in a virtual scene, including game characters. Game characters are dynamic objects that can be controlled, i.e., dynamic virtual objects. Optionally, the dynamic object can be a virtual person, a virtual animal, a cartoon character, etc. The virtual object is a character controlled by a user through an input device, or an AI set in a virtual environment through training, or an NPC set in a virtual scene.

[0083] Optionally, the virtual object is a virtual character competing in a virtual scene. Optionally, the number of virtual objects in the virtual scene battle is preset, or dynamically determined according to the number of clients joining the battle, which is not limited in the embodiment of the present application.

[0084] In one possible implementation, the user can control the virtual object to perform game behaviors in the virtual scene. Game behaviors may include movement, casting skills, using props, and conversations. For example, the user can control the virtual object to run, jump, crawl, etc., and can also control the virtual object to use the skills and virtual props provided by the application to fight with other virtual objects.

[0085] The virtual camera is a necessary component for presenting the game scene. One game scene corresponds to at least one virtual camera. Depending on actual needs, there can be two or more virtual cameras, which serve as game rendering windows to capture and present the game world's screen content to users. By setting the parameters of the virtual camera, the user's perspective of viewing the game world can be adjusted, such as the first-person perspective and the third-person perspective.

[0086] In an optional implementation, an embodiment of the present invention provides a method for rendering hair of a virtual character, providing a graphical user interface through a terminal device, wherein the terminal device can be the local terminal device mentioned above, or can be a client device in the cloud interaction system mentioned above.

[0087] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.

[0088] In this embodiment, a method for rendering hair of a virtual character is provided. Figure 1b As shown, the specific process of the method may include the following steps 110 to 170:

[0089] 110. For each of the multiple shading points, obtain a pixel point that meets preset requirements from the shadow map, wherein the multiple shading points are shading points corresponding to multiple planes included in the three-dimensional model of the virtual character's hair, and the pixel point that meets the preset requirements is recorded as a shadow sampling value.

[0090] The shadow map is a map that reflects the shadow formed by the virtual character's hair being blocked by the virtual character's head decoration. The head decoration is an object located on the head of the virtual character that has a decorative effect, such as a hat, hairpin, etc. The method for obtaining the shadow map will be described in detail below.

[0091] The preset requirement is a pre-set requirement. Optionally, in a specific implementation, step 110 may specifically include: for each shading point, obtaining the UV coordinate value of the shading point corresponding to the pixel point in the shadow map, wherein the pixel point is a pixel point that meets the preset requirement. For the convenience of description, it is assumed that any shading point is a target shading point, and the target shading point has its own corresponding target UV coordinate value. The target shading point belongs to a target shading surface, and the target shading surface is any plane among the multiple planes included in the three-dimensional model of the virtual character's hair.

[0092] The target shading point is any shading point located on the target shading surface. The target shading surface includes three vertex shading points located at the vertex positions of the target shading surface and a plurality of non-vertex shading points located at the non-vertex positions of the target shading point. Among them, the UV coordinate value of any non-vertex shading point among the plurality of non-vertex shading points can be obtained by interpolating the UV coordinate values ​​of the three vertex shading points. The target shading point can be a vertex shading point or a non-vertex shading point.

[0093] In the above implementation, the shadow sampling value may be obtained by obtaining the target UV coordinate value and determining the pixel point corresponding to the target UV coordinate value in the shadow map. The shadow sampling value may be recorded as S0.

[0094] Optionally, in a specific implementation, the method for obtaining the shadow map may specifically include the following steps A1 to A4:

[0095] A1. Obtain a maximum shadow map and a minimum shadow map corresponding to the hair of the virtual character, wherein the maximum shadow map is a map corresponding to the maximum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; and the minimum shadow map is a map corresponding to the minimum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting.

[0096] The size of the shadow formed by the head ornaments of the virtual character on the hair of the virtual character changes with the angle of the virtual lighting. Generally, the smaller the angle between the virtual lighting and the ground plane of the virtual scene, the larger the shadow formed by the head ornaments on the hair; the larger the angle between the virtual lighting and the ground plane of the virtual scene, the smaller the shadow formed by the head ornaments on the hair.

[0097] The above steps can obtain the texture corresponding to the maximum shadow formed by the virtual character's head ornament on the virtual character's hair, and the texture corresponding to the minimum shadow formed by the virtual character's head ornament on the virtual character's hair.

[0098] A2. Calculate an intermediate shadow area according to the maximum shadow map and the minimum shadow map.

[0099] Optionally, the maximum shadow in the maximum shadow map and the minimum shadow in the minimum shadow map may be subtracted to obtain an intermediate shadow area. The intermediate shadow area varies between no display at all and full display as the angle of the virtual lighting changes.

[0100] A3. For each pixel point in the middle shadow area, an interpolation operation is performed on the middle shadow area according to the distance between the pixel point and the first boundary of the middle shadow area, and the distance between the pixel point and the second boundary of the middle shadow area to obtain an interpolated shadow area; wherein the first boundary is a boundary adjacent to the minimum shadow, and the second boundary is a boundary away from the minimum shadow.

[0101] For more information, please see Figure 1c , Figure 1c A schematic diagram showing a shadow map of several tufts of hair of an avatar, Figure 1c The B area in the figure is the minimum shadow area, the A area is the middle shadow area, and the combination of the A area and the B area is the maximum shadow area. The middle area includes a first boundary close to the minimum shadow (i.e., the B area) and a second boundary away from the minimum shadow (i.e., the B area).

[0102] Optionally, according to the distance between each pixel point in the middle shadow area and the first boundary, and the distance between each pixel point in the middle shadow area and the second boundary, an interpolation operation is performed on the middle shadow area to obtain an interpolation operation shadow area. The operation process may be specifically as follows:

[0103] For each pixel in the middle shadow area, obtain the distance R1 between the pixel and the first boundary and the distance R2 between the pixel and the second boundary, and then use the formula Calculate the gray value I. The larger the I value, the lighter the color; the smaller the I value, the darker the color. For each pixel in the middle shadow area, use the obtained gray value to fill the corresponding pixel with gray value, and you can get the interpolation shadow area.

[0104] It should be understood that the gray value can be calculated by the above formula or by other calculation formulas. For example, Calculate the gray value I. The specific calculation method of the gray value should not be understood as a limitation to the present application.

[0105] A4. Combining the interpolation shadow area with the minimum shadow map to obtain the shadow map.

[0106] After the interpolated shadow area is calculated and obtained through step A3, the interpolated shadow area is combined with the minimum shadow map to obtain a shadow map.

[0107] In the above implementation, the maximum shadow area and the minimum shadow area can be subtracted to obtain the middle shadow area; then the middle shadow area is interpolated to change the middle shadow area into the interpolated shadow area; then the interpolated shadow area is combined with the minimum shadow area to obtain the shadow map. The shadow map obtained by this implementation has a small amount of calculation and can also obtain a good display effect. Therefore, the use of the shadow map to continue to perform subsequent hair rendering processing can greatly reduce the consumption of computing power, thereby reducing the computing power requirements of the terminal device running the game.

[0108] 120. Determine the lighting impact parameter, and calculate the occlusion shadow coefficient of each shading point according to the lighting impact parameter and the shadow sampling value of each shading point.

[0109] The lighting impact parameter is a parameter that reflects the impact of virtual lighting on the hair of the virtual character. Optionally, in a specific implementation, the step of "determining the lighting impact parameter" includes the following steps 121 to 123:

[0110] 121. Get the lighting direction vector.

[0111] The light direction vector is a vector whose direction is consistent with the light direction in world space coordinates and whose modulus is 1.

[0112] 122. Project the illumination direction vector on a target projection plane to obtain an illumination projection vector, wherein the target projection plane is a projection plane formed by the facing direction of the virtual character and a vertical upward direction vector.

[0113] The vertical upward direction vector is a vector whose direction is the vertical upward direction in world space coordinates.

[0114] The target projection plane formed by the facing direction of the virtual character and the vertical upward direction vector may be first obtained, and then the illumination direction vector may be projected onto the target projection plane to obtain the illumination projection vector.

[0115] 123. Calculate the lighting impact parameter according to the lighting projection vector and the vertical upward direction vector.

[0116] The illumination projection vector and the vertical upward direction vector can be normalized, that is, the direction of the illumination projection vector is kept unchanged, its modulus is changed to 1, and the illumination projection normalized vector is obtained; and the direction of the vertical upward direction vector is kept unchanged, its modulus is changed to 1, and the vertical upward normalized vector is obtained.

[0117] Then, the normalized vector of the illumination projection is multiplied by the vertical normalized vector. The result of the dot product is the illumination influence parameter, which may be recorded as FdotL.

[0118] In the above implementation, during the calculation of the lighting influence parameters, the lighting influence parameters may be affected by the lighting direction and the direction the virtual character is facing, so that during the rendering process, the influence of the lighting influence parameters on the virtual character's hair may be more natural.

[0119] Optionally, in a specific implementation, the step of “determining the illumination impact parameter, and calculating the occlusion shadow coefficient of each shading point according to the illumination impact parameter and the shadow sampling value of each shading point” includes the following steps:

[0120] The occlusion shadow coefficient S can be calculated according to the formula S=step(FdotL,S0), where FdotL is the lighting impact parameter and S0 is the shadow sampling value.

[0121] 130. Construct a circumscribed sphere for wrapping the hair of the virtual character, obtain normals of the surface of the circumscribed sphere at positions corresponding to vertices of the hair of the virtual character, and use the normals as normals of corresponding adjacent vertices.

[0122] Optionally, in a specific implementation, step 130 includes the following steps 131 to 133:

[0123] 131. Generate a circumscribed sphere corresponding to the hair of the virtual character, wherein the center of the circumscribed sphere coincides with the center of the head of the virtual character.

[0124] The center of the generated circumscribed sphere may coincide with the center of the head of the virtual character.

[0125] It should be understood that, since the virtual character's hair may be of different lengths, and the radius of the circumscribed sphere is the same, some of the multiple vertices of the virtual character's hair may be in contact with the surface of the circumscribed sphere, or all of the vertices of the virtual character's hair may not be in contact with the surface of the circumscribed sphere, or all of the vertices of the virtual character's hair may be in contact with the surface of the circumscribed sphere. Whether the vertices of the virtual character's hair are in contact with the surface of the circumscribed sphere should not be understood as limiting the present application.

[0126] 132. Draw a ray from the center of the circumscribed sphere to each of the multiple vertices of the hair of the virtual character, and obtain the intersection point of each ray with the surface of the circumscribed sphere.

[0127] 133. For each intersection point among the multiple intersection points, calculate the normal line of each intersection point, and use the normal line of each intersection point as the normal line of each vertex adjacent to each intersection point.

[0128] In the above implementation, a ray can be drawn from the center of the circumscribed sphere to each of the multiple vertices of the virtual character's hair to obtain the intersection point of each ray with the surface of the circumscribed sphere. By drawing rays, a one-to-one correspondence between the multiple vertices and the multiple intersection points of the surface of the circumscribed sphere is established. Subsequently, for each of the multiple intersection points, the normal of each intersection point can be calculated respectively, and the calculated normal of the intersection point is used as the normal of the vertex corresponding to the intersection point.

[0129] In the above implementation, a circumscribed sphere with the same center as the head of the virtual character can be set first, and multiple vertices of the hair of the virtual character can be obtained, and then the normal of each vertex position can be obtained by ray drawing, and the normal is used as the normal of the corresponding vertex. By setting a circumscribed sphere to re-determine the normal of each vertex of the multiple vertices of the hair of the virtual character, the calculation of the normal can be made more accurate.

[0130] 140. Calculate the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector, and the normals corresponding to multiple vertices of the hair of the virtual character.

[0131] Each shading point is each shading point among the multiple shading points corresponding to the multiple planes included in the three-dimensional model of the virtual character's hair. The illumination coefficient is a coefficient reflecting the influence of the virtual illumination on the corresponding shading point. Optionally, in a specific implementation, step 140 may specifically include the following steps 141 to 144:

[0132] 141. Convert normals corresponding to multiple vertices of the virtual character's hair into a world space coordinate system, and perform normalization processing to obtain normal vectors corresponding to each shading point.

[0133] 142. For the normal vector corresponding to each shading point, calculate the dot product of the normal vector and the illumination direction vector to obtain a dot product result.

[0134] The normal vector corresponding to each shading point is a vector with a direction that is the normal direction of the corresponding shading point and a modulus of 1. For each shading point, the dot product of the normal vector and the illumination direction vector is calculated to obtain the dot product result corresponding to each shading point, which can be represented by NdotL.

[0135] 143. For the dot product result corresponding to each shading point, perform smooth step function processing on the dot product result to obtain a preliminary lighting coefficient.

[0136] Optionally, the preliminary illumination coefficient LI may be calculated according to the formula LI=smoothstep(ms,m+s,NdotL), wherein m and s are both preset coefficients.

[0137] 144. For the preliminary illumination coefficient corresponding to each shading point, obtain the smaller value of the preliminary illumination coefficient and the occlusion shadow coefficient, where the smaller value is the illumination coefficient.

[0138] For each shading point, the preliminary illumination coefficient LI of the shading point can be compared with the occlusion shadow coefficient S, and the smaller of the two can be used as the illumination coefficient I of the shading point. For example, the illumination coefficient I of the shading point can be calculated according to the formula I=min(LI,S).

[0139] The above steps are performed for each shading point, so that the illumination coefficient corresponding to each shading point can be obtained.

[0140] In the above embodiment, when calculating the illumination coefficient corresponding to each shading point, the influence of the illumination direction, the occlusion shadow coefficient and the normal direction of the shading point can be introduced, so that during the rendering process, the illumination coefficient corresponding to each shading point can have a more natural effect on the virtual character's hair.

[0141] 150. Obtain a color sampling value and a highlight sampling value of each shading point, and obtain a first operation result corresponding to each shading point according to the color sampling value, the highlight sampling value, and the illumination coefficient corresponding to each shading point.

[0142] The color sampling value is the pixel point corresponding to the target UV coordinate value in the color map, and the highlight sampling value is the pixel point corresponding to the target UV coordinate value in the highlight map. By obtaining the pixel points corresponding to the target UV coordinate value in maps of different properties, the sampling values ​​of the corresponding properties can be obtained. Optionally, in a specific implementation, the step of "obtaining the color sampling value and highlight sampling value of each shading point" can specifically include the following steps 151 to 152:

[0143] 151. For each shading point, obtain a pixel point corresponding to the UV coordinate value of the shading point in the color map, wherein the pixel point is the color sampling value.

[0144] 152. For each shading point, obtain a pixel point corresponding to the UV coordinate value of the shading point in the highlight map, wherein the pixel point is the highlight sampling value.

[0145] Optionally, in a specific implementation, the step of “obtaining the first operation result corresponding to each shading point according to the color sampling value, the highlight sampling value of each shading point, and the illumination coefficient corresponding to each shading point” may specifically include the following steps 153 to 156:

[0146] 153. Calculate a multiplication result of the color parameter value, the color intensity value, and the color sampling value to obtain a first product.

[0147] The color parameter value and the color intensity value can be set manually by the artist. The first product can be obtained by calculating the multiplication result of the color parameter value, the color intensity value and the color sampling value.

[0148] 154. Calculate the product of the highlight color value, the highlight intensity value and the highlight sampling value to obtain a second product.

[0149] The highlight color value and the highlight intensity value can be set manually by the artist. The second product can be obtained by calculating the multiplication result of the highlight color value, the highlight intensity value and the highlight sampling value.

[0150] 155. Calculate the sum of the first product and the second product to obtain a product sum result.

[0151] 156. Multiply the product addition result by the corresponding illumination coefficient to obtain a corresponding first operation result.

[0152] Among them, the above steps 153 to 156 can be performed for each shading point. After obtaining the first product and the second product respectively, the sum of the two can be obtained to obtain the product sum result. For each shading point, the illumination coefficient corresponding to the shading point can be multiplied by the above product sum result, so as to obtain the first operation result corresponding to the shading point, and then the first operation result corresponding to each shading point can be obtained.

[0153] In the above-mentioned embodiment, for each shading point, when calculating the first operation result, the influence of the color parameter value, color intensity value, color sampling value, highlight color value, highlight intensity value, highlight sampling value, and the illumination coefficient corresponding to each shading point are respectively introduced, so that during the rendering process, the first operation result corresponding to each shading point can have a more natural effect on the virtual character's hair.

[0154] 160. Obtain stroke description information, and obtain a second operation result based on the stroke description information.

[0155] The stroke description information is information reflecting the influence of the stroke of the virtual character's hair by the artist. Optionally, in a specific implementation, the step of "obtaining the stroke description information" may specifically include the following steps 161 to 162:

[0156] 161. Obtain a three-dimensional model of the hair of the virtual character that has completed the preset processing, wherein the edge area of ​​each strand of hair in the three-dimensional model of the hair of the virtual character that has completed the preset processing is a first color, and the center area is a second color.

[0157] The preset processing is a process of coloring each strand of hair in the three-dimensional model of the virtual character's hair in different regions. Specifically, the center region of each strand of hair in the three-dimensional model of the virtual character's hair may be colored with the second color, and the edge region of each strand of hair may be colored with the first color. The coloring process may be performed manually by an artist, or may be performed by a preset coloring program.

[0158] Let's assume the second color is black and the first color is white. Figure 1d and Figure 1e , Figure 1d The three-dimensional model of the hair of the virtual character without the preset processing is shown. Figure 1e A three-dimensional model of the virtual character's hair that has been subjected to preset processing is shown.

[0159] 162. For each pixel point in the area belonging to the first color of each strand of hair, perform an interpolation operation on the area belonging to the first color of the strand of hair according to the distance between the pixel point and the central area of ​​the strand of hair to which it belongs and the distance between the pixel point and the edge line of the strand of hair to which it belongs, so as to obtain the stroke description information.

[0160] For each pixel point in the area of ​​the first color of each hair strand, an interpolation operation may be performed based on the distance between the pixel point and the center area of ​​the hair strand to which it belongs, and the distance between the pixel point and the edge line of the hair strand to which it belongs. Optionally, the interpolation operation process may be as follows:

[0161] According to the formula Calculate the gray value J. The larger the J value, the lighter the color; the smaller the J value, the darker the color. R3 is the distance between the pixel and the center area of ​​the hair strand to which it belongs, and R4 is the distance between the pixel and the edge of the hair strand to which it belongs. For each pixel in the area to which the first color belongs, fill the corresponding pixel with the gray value using the obtained gray value, and then obtain the stroke description information MdotL.

[0162] It should be understood that the gray value can be calculated by the above formula or by other calculation formulas. For example, Calculate the gray value J. The specific calculation method of the gray value should not be understood as a limitation to the present application.

[0163] Optionally, in a specific implementation, the step of “obtaining a second operation result based on the stroke description information” may specifically include the following steps 163 to 164:

[0164] 163. Perform a step function operation on the stroke description information and the stroke thickness parameter to obtain a stroke operation result.

[0165] The stroke thickness parameter is a parameter set manually by the artist, and the stroke thickness parameter may be recorded as Ol. Then the stroke operation result Os is calculated according to the formula Os=Step(MdotL,Ol). Among them, MdotL is the stroke description information, and Ol is the stroke thickness parameter.

[0166] 164. Calculate a multiplication result of the stroke color value, the stroke strength value, and the stroke operation result, where the multiplication result is the second operation result.

[0167] The stroke color value and the stroke strength value can be set manually by the artist. The second operation result can be obtained by calculating the multiplication result of the stroke color value, the stroke strength value and the stroke operation result.

[0168] In the above implementation, when calculating the second calculation result, the influence of the stroke description information, the stroke thickness parameter, the stroke color value and the stroke strength value is introduced. The calculation process of the stroke description information has low requirements on the computing power of the terminal device, so the calculation process of the second calculation result consumes better computing resources, thereby reducing the requirements on the computing power of the terminal device running the game.

[0169] 170. For each shading point corresponding to a first operation result, a sum of the first operation result and the second operation result is obtained, and the three-dimensional model of the virtual character's hair is rendered according to the sum corresponding to each shading point to obtain a rendering result.

[0170] For each of the multiple shading points corresponding to the multiple planes included in the three-dimensional model of the virtual character's hair, the above-mentioned operation process of steps 110 to 170 can be performed, so as to obtain multiple first operation results corresponding to the multiple planes included in the three-dimensional model of the virtual character's hair, and add the multiple first operation results to the second operation results respectively, so as to obtain multiple sum results corresponding to the multiple planes included in the three-dimensional model of the virtual character's hair, thereby realizing the rendering process of the three-dimensional model of the virtual character's hair.

[0171] In the virtual character hair rendering method provided in the embodiment of the present application, for each of the multiple shading points, a shadow sampling value that meets the preset requirements can be obtained from the shadow map; then the lighting influence parameter is determined, and the occlusion shadow coefficient of each shading point is calculated based on the lighting influence parameter and the shadow sampling value of each shading point. The embodiment of the present application can also calculate the normals corresponding to the multiple vertices of the virtual character's hair, and calculate the lighting coefficient corresponding to each shading point based on the normals corresponding to the above multiple vertices, the lighting direction vector and the occlusion shadow coefficient of each shading point, and then combine the color sampling value and the highlight sampling value of each shading point to obtain the first operation result corresponding to each shading point. The embodiment of the present application can also obtain the second operation result based on the stroke description information, and add the second operation result to the first operation result corresponding to each shading point to obtain the summed result corresponding to each shading point, and render the three-dimensional model of the virtual character's hair according to the above summed result. In the present application, when calculating the illumination coefficient corresponding to each shading point, the occlusion shadow coefficient of the corresponding shading point, the illumination direction vector and the normals corresponding to the multiple vertices of the virtual character's hair are used. After calculating the illumination coefficient corresponding to each shading point, the color sampling value, highlight sampling value and stroke description information of each shading point are combined to finally calculate the summation result corresponding to each shading point. After introducing the coefficients of the above multiple aspects, the rendering of the virtual character's hair can form a natural displacement as the virtual character moves.

[0172] In this application, the realism of the virtual character's hair can be increased.

[0173] The method described in the above embodiment will be further described in detail below.

[0174] In this embodiment, the method of the embodiment of the present application is described in detail by taking the shadow sampling value S0, the illumination projection vector L', the vertical upward direction vector F, the illumination influence parameter FdotL, the occlusion shadow coefficient S, the dot product result NdotL, the preliminary illumination coefficient LI, and the illumination coefficient I as an example.

[0175] like Figure 2 As shown, the specific process of a virtual character hair rendering method is as follows:

[0176] 201. Obtain a maximum shadow map and a minimum shadow map corresponding to the hair of the virtual character.

[0177] Among them, the maximum shadow map is the map corresponding to the maximum shadow formed by the head decoration of the virtual character on the hair of the virtual character under the influence of virtual lighting; the minimum shadow map is the map corresponding to the minimum shadow formed by the head decoration of the virtual character on the hair of the virtual character under the influence of virtual lighting.

[0178] 202. Calculate an intermediate shadow area according to the maximum shadow map and the minimum shadow map.

[0179] 203. For each pixel point in the middle shadow area, perform an interpolation operation on the middle shadow area according to a distance between the pixel point and a first boundary of the middle shadow area and a distance between the pixel point and a second boundary of the middle shadow area to obtain an interpolated shadow area.

[0180] The first boundary is a boundary close to the minimum shadow, and the second boundary is a boundary far from the minimum shadow.

[0181] 204. Combine the interpolation shadow area with the minimum shadow map to obtain the shadow map.

[0182] 205. Obtain a pixel point corresponding to a target UV coordinate value in the shadow map, wherein the pixel point is a shadow sampling value S0.

[0183] For ease of description, let any shading point be a target shading point, and the target shading point has its own corresponding target UV coordinate value. The target UV coordinate value is the coordinate value corresponding to the target shading point, and the target shading point belongs to a target shading surface, which is any plane among the multiple planes included in the three-dimensional model of the virtual character's hair.

[0184] 206. Obtain a lighting direction vector, and project the lighting direction vector onto a target projection surface to obtain a lighting projection vector L'.

[0185] The target projection plane is a projection plane formed by the facing direction of the virtual character and the vertical upward direction vector F.

[0186] 207. Calculate the illumination influence parameter FdotL according to the illumination projection vector L′ and the vertical upward direction vector F.

[0187] 208. Calculate the occlusion shadow coefficient S according to the formula S=step(FdotL,S0), where FdotL is the illumination impact parameter and S0 is the shadow sampling value.

[0188] 209. Generate a circumscribed sphere corresponding to the hair of the virtual character.

[0189] The center of the circumscribed sphere coincides with the center of the head of the virtual character.

[0190] 210. Draw a ray from the center of the circumscribed sphere to each of the multiple vertices of the hair of the virtual character, and obtain the intersection point of each ray with the surface of the circumscribed sphere.

[0191] 211. For each intersection point among the multiple intersection points, calculate the normal line of each intersection point, and use the normal line of each intersection point as the normal line of each vertex adjacent to each intersection point.

[0192] 212. Convert normals corresponding to multiple vertices of the virtual character's hair into a world space coordinate system, and perform normalization processing to obtain normal vectors corresponding to each shading point.

[0193] 213. For the normal vector corresponding to each shading point, calculate the dot product of the normal vector and the illumination direction vector to obtain a dot product result NdotL.

[0194] 214. Calculate the preliminary illumination coefficient LI according to the formula LI = smoothstep(ms,m+s,NdotL), where m and s are both pre-set coefficients.

[0195] 215. Calculate the illumination coefficient I of each shading point according to the formula I=min(LI,S), where S is the occlusion shadow coefficient and LI is the primary illumination coefficient.

[0196] 216. Obtain the pixel point corresponding to the target UV coordinate value in the color map, where the pixel point is the color sampling value; obtain the pixel point corresponding to the target UV coordinate value in the highlight map, where the pixel point is the highlight sampling value.

[0197] 217. For each shading point, calculate the multiplication result of the color parameter value, the color intensity value and the color sampling value to obtain a first product; calculate the multiplication result of the highlight color value, the highlight intensity value and the highlight sampling value to obtain a second product; calculate the sum of the first product and the second product to obtain a product sum result; multiply the product sum result by the corresponding illumination coefficient to obtain a corresponding first operation result.

[0198] 218. Obtain stroke description information, and obtain a second operation result based on the stroke description information.

[0199] In a specific implementation, step 218 may specifically include the following steps:

[0200] Acquire a three-dimensional model of the hair of the virtual character that has completed the preset processing, wherein the edge area of ​​each strand of hair in the three-dimensional model of the hair of the virtual character that has completed the preset processing is a first color and the center area is a second color;

[0201] For each pixel point in the area to which the first color of each hair strand belongs, an interpolation operation is performed on the area to which the first color of the hair strand belongs according to a distance between the pixel point and a central area of ​​the hair strand to which it belongs and a distance between the pixel point and a borderline of the hair strand to which it belongs, so as to obtain the stroke description information;

[0202] Performing a step function operation on the stroke description information and the stroke thickness parameter to obtain a stroke operation result;

[0203] A multiplication result of the stroke color value, the stroke strength value and the stroke operation result is calculated, and the multiplication result is the second operation result.

[0204] 219. For each shading point corresponding to a first operation result, obtain a sum of the first operation result and the second operation result, and render the three-dimensional model of the virtual character's hair according to the sum corresponding to each shading point to obtain a rendering result.

[0205] As can be seen from the above, the embodiment of the present application can obtain shadow sampling values ​​that meet preset requirements from the shadow map; then determine the lighting impact parameters, and calculate the occlusion shadow coefficient based on the lighting impact parameters and the shadow sampling values. The embodiment of the present application can also calculate the normals corresponding to multiple vertices of the virtual character's hair, and calculate the lighting coefficient corresponding to each shading point based on the normals, lighting direction vectors and occlusion shadow coefficients corresponding to the above multiple vertices, and then combine the color sampling values ​​and highlight sampling values ​​to obtain the first operation result corresponding to each shading point. The embodiment of the present application can also obtain the second operation result based on the stroke description information, and add the second operation result to the first operation result corresponding to each shading point to obtain the summed result corresponding to each shading point, and render the three-dimensional model of the virtual character's hair according to the above summed result. In this application, when calculating the illumination coefficient corresponding to each shading point, the occlusion shadow coefficient, the illumination direction vector, and the normals corresponding to multiple vertices of the virtual character's hair are used. After calculating the illumination coefficient corresponding to each shading point, the color sampling value, the highlight sampling value, and the stroke description information are combined to finally calculate the sum of the corresponding results of each shading point. After introducing the coefficients of the above multiple aspects, the rendering of the virtual character's hair can form a natural displacement as the virtual character moves.

[0206] In this application, the realism of the virtual character's hair can be increased.

[0207] In order to better implement the above method, the embodiment of the present application also provides a virtual character hair rendering device, which can be integrated into an electronic device, and the electronic device can be a terminal. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer, and other devices.

[0208] For example, in this embodiment, the device of the embodiment of the present application is described in detail by taking the virtual character hair rendering device specifically integrated in the terminal as an example.

[0209] For example, Figure 3 As shown, the virtual character hair rendering device may include:

[0210] A pixel point acquisition unit 301 is used to acquire a pixel point that meets preset requirements from a shadow map for each of a plurality of shading points, wherein the plurality of shading points are shading points corresponding to a plurality of planes included in a three-dimensional model of the hair of the virtual character, and the pixel point that meets the preset requirements is recorded as a shadow sampling value;

[0211] An illumination parameter determination unit 302 is used to determine an illumination influence parameter, and calculate an occlusion shadow coefficient of each shading point according to the illumination influence parameter and a shadow sampling value of each shading point;

[0212] The normal acquisition unit 303 is used to construct a circumscribed sphere for wrapping the hair of the virtual character, obtain the normal of the surface of the circumscribed sphere at the position corresponding to the vertex of the hair of the virtual character, and use the normal as the normal of the corresponding adjacent vertex;

[0213] An illumination coefficient calculation unit 304 is used to calculate the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector, and the normals corresponding to the multiple vertices of the hair of the virtual character;

[0214] A first result acquisition unit 305 is used to acquire a color sampling value and a highlight sampling value of each shading point, and acquire a first operation result corresponding to each shading point according to the color sampling value, the highlight sampling value of each shading point, and the illumination coefficient corresponding to each shading point;

[0215] A second result obtaining unit 306, configured to obtain stroke description information, and obtain a second operation result based on the stroke description information;

[0216] The sum result acquisition unit 307 is used to obtain the sum of the first operation result and the second operation result for each shading point, and render the three-dimensional model of the virtual character's hair according to the sum result corresponding to each shading point to obtain a rendering result.

[0217] In some embodiments, the pixel acquisition unit 301 is specifically used to: for each shading point, obtain the pixel point corresponding to the UV coordinate value of the shading point in the shadow map, wherein the pixel point is a pixel point that meets preset requirements.

[0218] In some embodiments, the illumination parameter determination unit 302 includes:

[0219] Lighting vector subunit, used to obtain the lighting direction vector;

[0220] A projection vector subunit, used for projecting the illumination direction vector on a target projection plane to obtain an illumination projection vector, wherein the target projection plane is a projection plane formed by the virtual character's facing direction and a vertical upward direction vector;

[0221] The influence parameter calculation subunit is used to calculate the illumination influence parameter according to the illumination projection vector and the vertical upward direction vector.

[0222] In some embodiments, the normal acquisition unit 303 includes:

[0223] A circumscribed sphere subunit, used for generating a circumscribed sphere corresponding to the hair of the virtual character, wherein the center of the circumscribed sphere coincides with the center of the head of the virtual character;

[0224] A corner point acquisition subunit, used to make a ray from the center of the circumscribed sphere to each of the multiple vertices of the hair of the virtual character, and obtain the intersection point of each ray with the surface of the circumscribed sphere;

[0225] The normal calculation subunit is used to calculate the normal of each intersection position for each intersection point among the multiple intersection points, and use the normal of each intersection position as the normal of each vertex adjacent to each intersection point.

[0226] In some embodiments, the illumination coefficient calculation unit 304 includes:

[0227] A normal conversion subunit, used for converting normals corresponding to a plurality of vertices of the hair of the virtual character into a world space coordinate system, and performing normalization processing to obtain a normal vector corresponding to each shading point;

[0228] A point product result subunit, for calculating the point product of the normal vector corresponding to each shading point and the illumination direction vector, to obtain a point product result;

[0229] A preliminary parameter subunit, for performing a smooth step function process on the dot product result corresponding to each shading point to obtain a preliminary illumination coefficient;

[0230] The illumination coefficient determination subunit is used to obtain the smaller value of the preliminary illumination coefficient and the occlusion shadow coefficient for each shading point, where the smaller value is the illumination coefficient.

[0231] In some embodiments, the first result obtaining unit 305 includes:

[0232] A color sampling subunit is used to obtain, for each shading point, a pixel point corresponding to the UV coordinate value of the shading point in the color map, wherein the pixel point is the color sampling value;

[0233] The highlight sampling subunit is used to obtain, for each shading point, a pixel point corresponding to the UV coordinate value of the shading point in the highlight map, wherein the pixel point is the highlight sampling value.

[0234] In some embodiments, the first result obtaining unit 305 further includes:

[0235] A first product subunit, used for calculating a product of a color parameter value, a color intensity value and the color sampling value to obtain a first product;

[0236] A second product subunit, used for calculating a product of the highlight color value, the highlight intensity value and the highlight sampling value to obtain a second product;

[0237] a sum result subunit, configured to calculate the sum of the first product and the second product to obtain a product sum result;

[0238] The first result subunit is used to multiply the product addition result with the corresponding illumination coefficient to obtain a corresponding first operation result.

[0239] In some embodiments, the second result obtaining unit 306 includes:

[0240] A three-dimensional model subunit, used for obtaining a three-dimensional model of the hair of the virtual character that has completed the preset processing, wherein the edge area of ​​each strand of hair in the three-dimensional model of the hair of the virtual character that has completed the preset processing is a first color and the center area is a second color;

[0241] The stroke area subunit is used to perform an interpolation operation on the area to which the first color of each strand of hair belongs, for each pixel point of the area to which the first color of each strand of hair belongs, according to the distance between the pixel point and the central area of ​​the strand of hair to which it belongs, and the distance between the pixel point and the edge line of the strand of hair to which it belongs, so as to obtain the stroke description information.

[0242] In some embodiments, the second result obtaining unit 306 further includes:

[0243] A stroke operation subunit, used for performing a step function operation on the stroke description information and the stroke thickness parameter to obtain a stroke operation result;

[0244] The multiplication operation subunit is used to calculate the multiplication result of the stroke color value, the stroke strength value and the stroke operation result, and the multiplication result is the second operation result.

[0245] In some embodiments, the apparatus further comprises:

[0246] A large and small shadow acquisition unit, used to acquire a maximum shadow map and a minimum shadow map corresponding to the hair of the virtual character, wherein the maximum shadow map is a map corresponding to the maximum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; the minimum shadow map is a map corresponding to the minimum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting;

[0247] an intermediate shadow calculation unit, configured to calculate an intermediate shadow area according to the maximum shadow map and the minimum shadow map;

[0248] an interpolation shadow unit, configured to perform an interpolation operation on each pixel point in the middle shadow area according to a distance between the pixel point and a first boundary of the middle shadow area and a distance between the pixel point and a second boundary of the middle shadow area, so as to obtain an interpolation shadow area; wherein the first boundary is a boundary adjacent to the minimum shadow, and the second boundary is a boundary away from the minimum shadow;

[0249] A shadow combining unit is used to combine the interpolation shadow area with the minimum shadow map to obtain the shadow map.

[0250] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0251] As can be seen from the above, in this application, when calculating the illumination coefficient corresponding to each shading point, the occlusion shadow coefficient, the illumination direction vector, and the normals corresponding to multiple vertices of the virtual character's hair are used, and after calculating the illumination coefficient corresponding to each shading point, the color sampling value, the highlight sampling value, and the stroke description information are combined to finally calculate the summation result corresponding to each shading point. After introducing the coefficients of the above multiple aspects, the rendering of the virtual character's hair can form a natural displacement as the virtual character moves.

[0252] The embodiments of the present application can increase the realism of the virtual character's hair.

[0253] The embodiment of the present application also provides an electronic device, which can be a terminal, a server, etc. The terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc. The server can be a single server or a server cluster composed of multiple servers, etc.

[0254] In some embodiments, the virtual character hair rendering device can also be integrated into multiple electronic devices. For example, the virtual character hair rendering device can be integrated into multiple servers, and the virtual character hair rendering method of the present application is implemented by multiple servers.

[0255] In this embodiment, the electronic device of this embodiment is an electronic device as an example for detailed description, for example, Figure 4 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:

[0256] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, an input module 404, and a communication module 405. Those skilled in the art will appreciate that Figure 4 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0257] The processor 401 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402 and calling data stored in the memory 402, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. In some embodiments, the processor 401 may include one or more processing cores; in some embodiments, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.

[0258] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0259] The electronic device also includes a power supply 403 for supplying power to various components. In some embodiments, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 403 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0260] The electronic device may further include an input module 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0261] The electronic device may further include a communication module 405. In some embodiments, the communication module 405 may include a wireless module. The electronic device may perform short-range wireless transmission through the wireless module of the communication module 405, thereby providing the user with wireless broadband Internet access. For example, the communication module 405 may be used to help the user send and receive emails, browse web pages, and access streaming media.

[0262] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:

[0263] For each of the multiple shading points, a pixel point that meets the preset requirements is obtained from the shadow map, wherein the multiple shading points are shading points corresponding to multiple planes included in the three-dimensional model of the virtual character's hair, and the pixel point that meets the preset requirements is recorded as a shadow sampling value; determining the lighting influence parameter, and calculating the occlusion shadow coefficient of each shading point according to the lighting influence parameter and the shadow sampling value of each shading point; constructing a circumscribed sphere for wrapping the virtual character's hair, obtaining the normal of the position corresponding to the vertex of the circumscribed sphere surface and the hair of the virtual character, and using the normal as the normal of the corresponding adjacent vertex; according to the occlusion shadow coefficient of each shading point, the lighting direction vector and the The normals corresponding to multiple vertices of the virtual character's hair are used to calculate the illumination coefficient corresponding to each shading point; the color sampling value and the highlight sampling value of each shading point are obtained, and the first operation result corresponding to each shading point is obtained according to the color sampling value, the highlight sampling value, and the illumination coefficient corresponding to each shading point; the stroke description information is obtained, and the second operation result is obtained based on the stroke description information; for the first operation result corresponding to each shading point, the sum of the first operation result and the second operation result is obtained, and the three-dimensional model of the virtual character's hair is rendered according to the sum result corresponding to each shading point to obtain a rendering result.

[0264] Optionally, for each of the multiple shading points, obtaining a pixel point that meets preset requirements from the shadow map includes: for each shading point, obtaining a pixel point whose UV coordinate value of the shading point corresponds to the pixel point in the shadow map, wherein the pixel point is a pixel point that meets the preset requirements.

[0265] In the above implementation, the shadow sampling value may be obtained by obtaining the target UV coordinate value and determining the pixel point corresponding to the target UV coordinate value in the shadow map. The shadow sampling value may be recorded as S0.

[0266] Optionally, determining the lighting impact parameters includes: obtaining a lighting direction vector; projecting the lighting direction vector onto a target projection plane to obtain a lighting projection vector, wherein the target projection plane is a projection plane formed by the facing direction of the virtual character and a vertical upward direction vector; and calculating the lighting impact parameters based on the lighting projection vector and the vertical upward direction vector.

[0267] In the above implementation, during the calculation of the lighting influence parameters, the lighting influence parameters may be affected by the lighting direction and the direction the virtual character is facing, so that during the rendering process, the influence of the lighting influence parameters on the virtual character's hair may be more natural.

[0268] Optionally, constructing a circumscribed sphere for wrapping the virtual character's hair, obtaining normals of positions of the circumscribed sphere surface corresponding to vertices of the virtual character's hair, and using the normals as normals of corresponding adjacent vertices, includes: generating a circumscribed sphere corresponding to the virtual character's hair, wherein the center of the circumscribed sphere coincides with the center of the virtual character's head; drawing a ray from the center of the circumscribed sphere to each of multiple vertices of the virtual character's hair, and obtaining the intersection of each ray with the surface of the circumscribed sphere; for each of the multiple intersections, calculating the normal of each intersection position, and using the normal of each intersection position as the normal of each vertex adjacent to each intersection.

[0269] In the above implementation, a circumscribed sphere that is concentric with the head of the virtual character can be set first, and the positions where the surface of the circumscribed sphere contacts the multiple vertices of the hair of the virtual character can be obtained, and then the normal of each of the contact positions can be obtained by raycasting, and the normal can be used as the normal of the corresponding vertex. By re-determining the normal of each of the multiple vertices of the hair of the virtual character by setting a circumscribed sphere, the calculation of the normal can be made more accurate.

[0270] Optionally, the method of calculating the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector and the normals corresponding to multiple vertices of the virtual character's hair includes: converting the normals corresponding to multiple vertices of the virtual character's hair to the world space coordinate system, and normalizing them to obtain the normal vector corresponding to each shading point; for the normal vector corresponding to each shading point, calculating the dot product of the normal vector and the illumination direction vector to obtain a dot product result; for the dot product result corresponding to each shading point, performing smooth step function processing on the dot product result to obtain a preliminary illumination coefficient; for the preliminary illumination coefficient corresponding to each shading point, obtaining the smaller value of the preliminary illumination coefficient and the occlusion shadow coefficient, wherein the smaller value is the illumination coefficient.

[0271] In the above embodiment, when calculating the illumination coefficient corresponding to each shading point, the influence of the illumination direction, the occlusion shadow coefficient and the normal direction of the shading point can be introduced, so that during the rendering process, the illumination coefficient corresponding to each shading point can have a more natural effect on the virtual character's hair.

[0272] Optionally, the first operation result corresponding to each shading point is obtained according to the color sampling value, the highlight sampling value, and the illumination coefficient corresponding to each shading point, including: for each shading point: calculating the multiplication result of the color parameter value, the color intensity value and the color sampling value to obtain a first product; calculating the multiplication result of the highlight color value, the highlight intensity value and the highlight sampling value to obtain a second product; calculating the sum of the first product and the second product to obtain a product sum result; multiplying the product sum result by the corresponding illumination coefficient to obtain the corresponding first operation result.

[0273] In the above-mentioned embodiment, for each shading point, when calculating the first operation result, the influence of the color parameter value, color intensity value, color sampling value, highlight color value, highlight intensity value, highlight sampling value, and the illumination coefficient corresponding to each shading point are respectively introduced, so that during the rendering process, the first operation result corresponding to each shading point can have a more natural effect on the virtual character's hair.

[0274] Optionally, obtaining the second operation result based on the stroke description information includes: performing a step function operation on the stroke description information and a stroke thickness parameter to obtain a stroke operation result; calculating a multiplication result of a stroke color value, a stroke strength value and the stroke operation result, and the multiplication result is the second operation result.

[0275] In the above implementation, when calculating the second calculation result, the influence of the stroke description information, the stroke thickness parameter, the stroke color value and the stroke strength value is introduced. The calculation process of the stroke description information has low requirements on the computing power of the terminal device, so the calculation process of the second calculation result consumes better computing resources, thereby reducing the requirements on the computing power of the terminal device running the game.

[0276] Optionally, before obtaining the pixel points that meet the preset requirements from the shadow map for each of the multiple shading points, the method further includes: obtaining a maximum shadow map and a minimum shadow map corresponding to the hair of the virtual character, wherein the maximum shadow map is a map corresponding to the maximum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; the minimum shadow map is a map corresponding to the minimum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; according to the maximum shadow map and the minimum shadow map, calculating the middle shadow area; for each pixel point in the middle shadow area, performing an interpolation operation on the middle shadow area according to the distance between the pixel point and a first boundary of the middle shadow area and the distance between the pixel point and a second boundary of the middle shadow area to obtain an interpolated shadow area; wherein the first boundary is a boundary adjacent to the minimum shadow, and the second boundary is a boundary away from the minimum shadow; combining the interpolated shadow area with the minimum shadow map to obtain the shadow map.

[0277] In the above implementation, the maximum shadow area and the minimum shadow area can be subtracted to obtain the middle shadow area; then the middle shadow area is interpolated to change the middle shadow area into the interpolated shadow area; then the interpolated shadow area is combined with the minimum shadow area to obtain the shadow map. The shadow map obtained by this implementation has a small amount of calculation and can also obtain a good display effect. Therefore, the use of the shadow map to continue to perform subsequent hair rendering processing can greatly reduce the consumption of computing power, thereby reducing the computing power requirements of the terminal device running the game.

[0278] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0279] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0280] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any of the virtual character hair rendering methods provided in the embodiments of the present application. For example, the instructions can execute the following steps:

[0281] For each of the multiple shading points, a pixel point that meets the preset requirements is obtained from the shadow map, wherein the multiple shading points are shading points corresponding to multiple planes included in the three-dimensional model of the virtual character's hair, and the pixel point that meets the preset requirements is recorded as a shadow sampling value; determining the lighting influence parameter, and calculating the occlusion shadow coefficient of each shading point according to the lighting influence parameter and the shadow sampling value of each shading point; constructing a circumscribed sphere for wrapping the virtual character's hair, obtaining the normal of the position corresponding to the vertex of the circumscribed sphere surface and the hair of the virtual character, and using the normal as the normal of the corresponding adjacent vertex; according to the occlusion shadow coefficient of each shading point, the lighting direction vector and the The normals corresponding to multiple vertices of the virtual character's hair are used to calculate the illumination coefficient corresponding to each shading point; the color sampling value and the highlight sampling value of each shading point are obtained, and the first operation result corresponding to each shading point is obtained according to the color sampling value, the highlight sampling value, and the illumination coefficient corresponding to each shading point; the stroke description information is obtained, and the second operation result is obtained based on the stroke description information; for the first operation result corresponding to each shading point, the sum of the first operation result and the second operation result is obtained, and the three-dimensional model of the virtual character's hair is rendered according to the sum result corresponding to each shading point to obtain a rendering result.

[0282] Optionally, for each of the multiple shading points, obtaining a pixel point that meets preset requirements from the shadow map includes: for each shading point, obtaining a pixel point whose UV coordinate value of the shading point corresponds to the pixel point in the shadow map, wherein the pixel point is a pixel point that meets the preset requirements.

[0283] In the above implementation, the shadow sampling value may be obtained by obtaining the target UV coordinate value and determining the pixel point corresponding to the target UV coordinate value in the shadow map. The shadow sampling value may be recorded as S0.

[0284] Optionally, determining the lighting impact parameters includes: obtaining a lighting direction vector; projecting the lighting direction vector onto a target projection plane to obtain a lighting projection vector, wherein the target projection plane is a projection plane formed by the facing direction of the virtual character and a vertical upward direction vector; and calculating the lighting impact parameters based on the lighting projection vector and the vertical upward direction vector.

[0285] In the above implementation, during the calculation of the lighting influence parameters, the lighting influence parameters may be affected by the lighting direction and the direction the virtual character is facing, so that during the rendering process, the influence of the lighting influence parameters on the virtual character's hair may be more natural.

[0286] Optionally, constructing a circumscribed sphere for wrapping the virtual character's hair, obtaining normals of positions of the circumscribed sphere surface corresponding to vertices of the virtual character's hair, and using the normals as normals of corresponding adjacent vertices, includes: generating a circumscribed sphere corresponding to the virtual character's hair, wherein the center of the circumscribed sphere coincides with the center of the virtual character's head; drawing a ray from the center of the circumscribed sphere to each of multiple vertices of the virtual character's hair, and obtaining the intersection of each ray with the surface of the circumscribed sphere; for each of the multiple intersections, calculating the normal of each intersection position, and using the normal of each intersection position as the normal of each vertex adjacent to each intersection.

[0287] In the above implementation, a circumscribed sphere that is concentric with the head of the virtual character can be set first, and the positions where the surface of the circumscribed sphere contacts the multiple vertices of the hair of the virtual character can be obtained, and then the normal of each of the contact positions can be obtained by raycasting, and the normal can be used as the normal of the corresponding vertex. By re-determining the normal of each of the multiple vertices of the hair of the virtual character by setting a circumscribed sphere, the calculation of the normal can be made more accurate.

[0288] Optionally, the method of calculating the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector and the normals corresponding to multiple vertices of the virtual character's hair includes: converting the normals corresponding to multiple vertices of the virtual character's hair to the world space coordinate system, and normalizing them to obtain the normal vector corresponding to each shading point; for the normal vector corresponding to each shading point, calculating the dot product of the normal vector and the illumination direction vector to obtain a dot product result; for the dot product result corresponding to each shading point, performing smooth step function processing on the dot product result to obtain a preliminary illumination coefficient; for the preliminary illumination coefficient corresponding to each shading point, obtaining the smaller value of the preliminary illumination coefficient and the occlusion shadow coefficient, wherein the smaller value is the illumination coefficient.

[0289] In the above embodiment, when calculating the illumination coefficient corresponding to each shading point, the influence of the illumination direction, the occlusion shadow coefficient and the normal direction of the shading point can be introduced, so that during the rendering process, the illumination coefficient corresponding to each shading point can have a more natural effect on the virtual character's hair.

[0290] Optionally, the first operation result corresponding to each shading point is obtained according to the color sampling value, the highlight sampling value, and the illumination coefficient corresponding to each shading point, including: for each shading point: calculating the multiplication result of the color parameter value, the color intensity value and the color sampling value to obtain a first product; calculating the multiplication result of the highlight color value, the highlight intensity value and the highlight sampling value to obtain a second product; calculating the sum of the first product and the second product to obtain a product sum result; multiplying the product sum result by the corresponding illumination coefficient to obtain the corresponding first operation result.

[0291] In the above-mentioned embodiment, for each shading point, when calculating the first operation result, the influence of the color parameter value, color intensity value, color sampling value, highlight color value, highlight intensity value, highlight sampling value, and the illumination coefficient corresponding to each shading point are respectively introduced, so that during the rendering process, the first operation result corresponding to each shading point can have a more natural effect on the virtual character's hair.

[0292] Optionally, obtaining the second operation result based on the stroke description information includes: performing a step function operation on the stroke description information and a stroke thickness parameter to obtain a stroke operation result; calculating a multiplication result of a stroke color value, a stroke strength value and the stroke operation result, and the multiplication result is the second operation result.

[0293] In the above implementation, when calculating the second calculation result, the influence of the stroke description information, the stroke thickness parameter, the stroke color value and the stroke strength value is introduced. The calculation process of the stroke description information has low requirements on the computing power of the terminal device, so the calculation process of the second calculation result consumes better computing resources, thereby reducing the requirements on the computing power of the terminal device running the game.

[0294] Optionally, before obtaining the pixel points that meet the preset requirements from the shadow map for each of the multiple shading points, the method further includes: obtaining a maximum shadow map and a minimum shadow map corresponding to the hair of the virtual character, wherein the maximum shadow map is a map corresponding to the maximum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; the minimum shadow map is a map corresponding to the minimum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; according to the maximum shadow map and the minimum shadow map, calculating the middle shadow area; for each pixel point in the middle shadow area, performing an interpolation operation on the middle shadow area according to the distance between the pixel point and a first boundary of the middle shadow area and the distance between the pixel point and a second boundary of the middle shadow area to obtain an interpolated shadow area; wherein the first boundary is a boundary adjacent to the minimum shadow, and the second boundary is a boundary away from the minimum shadow; combining the interpolated shadow area with the minimum shadow map to obtain the shadow map.

[0295] In the above implementation, the maximum shadow area and the minimum shadow area can be subtracted to obtain the middle shadow area; then the middle shadow area is interpolated to change the middle shadow area into the interpolated shadow area; then the interpolated shadow area is combined with the minimum shadow area to obtain the shadow map. The shadow map obtained by this implementation has a small amount of calculation and can also obtain a good display effect. Therefore, the use of the shadow map to continue to perform subsequent hair rendering processing can greatly reduce the consumption of computing power, thereby reducing the computing power requirements of the terminal device running the game.

[0296] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0297] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the various optional implementations provided in the above embodiments.

[0298] Since the instructions stored in the storage medium can execute the steps in any virtual character hair rendering method provided in the embodiments of the present application, the beneficial effects that can be achieved by any virtual character hair rendering method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0299] The above is a detailed introduction to a virtual character hair rendering method, device, electronic device and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for rendering virtual character hair, characterized in that: The method comprises: For each of the plurality of shading points, a pixel point that meets a preset requirement is obtained from the shadow map, wherein the plurality of shading points are shading points corresponding to a plurality of planes included in the three-dimensional model of the hair of the virtual character, and the pixel point that meets the preset requirement is recorded as a shadow sampling value; Determine the lighting impact parameter, and calculate the occlusion shadow coefficient of each shading point according to the lighting impact parameter and the shadow sampling value of each shading point; Constructing a circumscribed sphere for wrapping the hair of the virtual character, obtaining normals of positions corresponding to vertices of the hair of the virtual character on the surface of the circumscribed sphere, and using the normals as normals of corresponding adjacent vertices; Calculate the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector, and the normals corresponding to multiple vertices of the hair of the virtual character; Obtaining a color sampling value and a highlight sampling value of each shading point, and obtaining a first operation result corresponding to each shading point according to the color sampling value, the highlight sampling value of each shading point, and the illumination coefficient corresponding to each shading point; Acquire stroke description information of the three-dimensional model of the virtual character's hair, and perform a step function operation on the stroke description information and a stroke thickness parameter to obtain a stroke operation result, wherein the stroke description information is information about the influence of stroking the virtual character's hair on the virtual character's hair; Calculate a multiplication result of the stroke color value, the stroke strength value and the stroke operation result, where the multiplication result is a second operation result; For each shading point corresponding to a first operation result, a sum of the first operation result and the second operation result is obtained, and the three-dimensional model of the virtual character's hair is rendered according to the sum corresponding to each shading point to obtain a rendering result.

2. The method according to claim 1, characterized in that For each of the plurality of shading points, obtaining a pixel point that meets a preset requirement from the shadow map includes: For each shading point, obtain the pixel point corresponding to the UV coordinate value of the shading point in the shadow map, wherein the pixel point is a pixel point that meets preset requirements.

3. The method according to claim 1, characterized in that The determining of the illumination impact parameter comprises: Get the light direction vector; Projecting the illumination direction vector on a target projection plane to obtain an illumination projection vector, wherein the target projection plane is a projection plane formed by the virtual character's facing direction and a vertical upward direction vector; The illumination impact parameter is calculated according to the illumination projection vector and the vertical upward direction vector.

4. The method according to claim 1, characterized in that The step of constructing a circumscribed sphere for wrapping the hair of the virtual character, obtaining normals of positions corresponding to vertices of the hair of the virtual character on the surface of the circumscribed sphere, and using the normals as normals of corresponding adjacent vertices includes: Generating a circumscribed sphere corresponding to the hair of the virtual character, wherein the center of the circumscribed sphere coincides with the center of the head of the virtual character; Draw a ray from the center of the circumscribed sphere to each of the multiple vertices of the hair of the virtual character, and obtain the intersection point of each ray with the surface of the circumscribed sphere; For each of the multiple intersection points, a normal line at the position of each intersection point is calculated, and the normal line at the position of each intersection point is used as the normal line of each vertex adjacent to each intersection point.

5. The method according to claim 1, characterized in that The step of calculating the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector, and the normals corresponding to the multiple vertices of the hair of the virtual character comprises: The normals corresponding to the multiple vertices of the hair of the virtual character are converted to the world space coordinate system, and normalized to obtain the normal vectors corresponding to each shading point; For the normal vector corresponding to each shading point, calculate the dot product of the normal vector and the illumination direction vector to obtain a dot product result; For each shading point corresponding to the dot product result, the dot product result is processed by a smooth step function to obtain a preliminary lighting coefficient; For the preliminary illumination coefficient corresponding to each shading point, a smaller value between the preliminary illumination coefficient and the occlusion shadow coefficient is obtained, and the smaller value is the illumination coefficient.

6. The method according to claim 1, characterized in that The method of obtaining the color sampling value and the highlight sampling value of each shading point includes: For each shading point, obtain the pixel point corresponding to the UV coordinate value of the shading point in the color map, wherein the pixel point is the color sampling value; For each shading point, obtain the pixel point corresponding to the UV coordinate value of the shading point in the highlight map, wherein the pixel point is the highlight sampling value.

7. The method according to claim 1, characterized in that The obtaining, according to the color sampling value, the highlight sampling value of each shading point, and the illumination coefficient corresponding to each shading point, a first operation result corresponding to each shading point includes: For each shading point: Calculate the multiplication result of the color parameter value, the color intensity value and the color sampling value to obtain a first product; Calculate the product of the highlight color value, the highlight intensity value and the highlight sampling value to obtain a second product; Calculating a sum of the first product and the second product to obtain a product sum result; The product addition result is multiplied by the corresponding illumination coefficient to obtain a corresponding first operation result.

8. The method according to claim 1, characterized in that The step of obtaining the stroke description information of the three-dimensional model of the virtual character's hair includes: Acquire a three-dimensional model of the hair of the virtual character that has completed the preset processing, wherein the edge area of ​​each strand of hair in the three-dimensional model of the hair of the virtual character that has completed the preset processing is a first color and the center area is a second color; For each pixel point in the area to which the first color of each strand of hair belongs, an interpolation operation is performed on the area to which the first color of the strand of hair belongs according to a distance between the pixel point and a central area of ​​the strand of hair to which it belongs, and a distance between the pixel point and a borderline of the strand of hair to which it belongs, so as to obtain the stroke description information.

9. The method according to claim 1, characterized in that Before acquiring a pixel point that meets a preset requirement from a shadow map for each of the plurality of shading points, the method further comprises: Obtaining a maximum shadow map and a minimum shadow map corresponding to the hair of the virtual character, wherein the maximum shadow map is a map corresponding to the maximum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; the minimum shadow map is a map corresponding to the minimum shadow formed by the head ornaments of the virtual character on the hair of the virtual character under the influence of virtual lighting; Calculating an intermediate shadow area according to the maximum shadow map and the minimum shadow map; For each pixel point in the middle shadow area, an interpolation operation is performed on the middle shadow area according to a distance between the pixel point and a first boundary of the middle shadow area and a distance between the pixel point and a second boundary of the middle shadow area to obtain an interpolation operation shadow area; wherein the first boundary is a boundary adjacent to the minimum shadow, and the second boundary is a boundary away from the minimum shadow; The interpolated shadow area is combined with the minimum shadow map to obtain the shadow map.

10. A virtual character hair rendering device, characterized in that: The device comprises: a pixel point acquisition unit, configured to acquire, for each of a plurality of shading points, a pixel point that meets preset requirements from a shadow map, wherein the plurality of shading points are shading points corresponding to a plurality of planes included in a three-dimensional model of the hair of the virtual character, and the pixel point that meets the preset requirements is recorded as a shadow sampling value; An illumination parameter determination unit, used to determine illumination influence parameters, and calculate an occlusion shadow coefficient of each shading point according to the illumination influence parameters and the shadow sampling value of each shading point; A normal acquisition unit, used for constructing a circumscribed sphere for wrapping the hair of the virtual character, acquiring normals of positions corresponding to vertices of the hair of the virtual character on the surface of the circumscribed sphere, and using the normals as normals of corresponding adjacent vertices; An illumination coefficient calculation unit, used to calculate the illumination coefficient corresponding to each shading point according to the occlusion shadow coefficient of each shading point, the illumination direction vector, and the normals corresponding to the multiple vertices of the hair of the virtual character; A first result acquisition unit, used to acquire a color sampling value and a highlight sampling value of each shading point, and acquire a first operation result corresponding to each shading point according to the color sampling value, the highlight sampling value of each shading point, and the illumination coefficient corresponding to each shading point; a second result acquisition unit, configured to acquire stroke description information of the three-dimensional model of the virtual character's hair, and perform a step function operation on the stroke description information and a stroke thickness parameter to obtain a stroke operation result, wherein the stroke description information is information reflecting the influence of stroking the virtual character's hair on the virtual character's hair, and calculate a multiplication result of a stroke color value, a stroke strength value and the stroke operation result, wherein the multiplication result is a second operation result; The sum result acquisition unit is used to obtain the sum of the first operation result and the second operation result for each shading point, and render the three-dimensional model of the virtual character's hair according to the sum result corresponding to each shading point to obtain a rendering result.

11. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the virtual character hair rendering method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the virtual character hair rendering method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Illumination rendering method and device, storage medium and computer equipment

    CN112755535A

  • Model rendering method and device, storage medium and computing equipment

    CN113223131A