Virtual character clothing rendering method, device, electronic device and storage medium
By calculating the target highlight component and diffuse reflection component of the virtual character's clothing, the realism of the game rendering result is enhanced, the problem of low game immersion in the existing technology is solved, and the game computing requirements are reduced.
Patent Information
- Application Number
- CN202210589460.7
- 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
Existing technology cannot increase gamers' sense of immersion while lowering the entry threshold for games. Physics-based rendering styles require high computing power, while anime-style rendering styles have low authenticity.
By obtaining the normal direction vector and roughness of the coloring point of the virtual character's clothing, the target highlight component is calculated, and combined with the color parameters in the logo map, the diffuse reflection component is calculated to realize the rendering of the three-dimensional model of the virtual character's clothing and enhance the rendering results. sense of reality.
On the basis of the animation style, the realism of the rendering results is increased, while the requirements for the computing power of the terminal device are reduced, achieving the effect of lowering the entry threshold for the game while improving the sense of substitution.
Smart Images

Figure CN115082608B
Abstract
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 virtual character clothing. Background Art
[0002] In the prior art, when rendering a game character, the game character is usually rendered in one of the following two styles: 1) a rendering style based on physical rendering (Physical-Based Rendering, referred to as PBR); 2) anime-style rendering style.
[0003] However, in order to achieve a sense of realism, the rendering style based on the PBR method usually requires a large amount of calculations, which requires a high computing power of the terminal device; the rendering style of the anime style is less realistic and easily reduces the player's sense of immersion. Existing technologies usually cannot increase the sense of immersion of game players while lowering the entry threshold of the game. Summary of the invention
[0004] The embodiments of the present application provide a method, device, electronic device and storage medium for rendering virtual character clothing, which can improve the problem in the prior art that it is impossible to increase the sense of immersion of game players while lowering the game entry threshold.
[0005] The present application provides a method for rendering virtual character clothing, the method comprising:
[0006] For each of the plurality of shading points, a normal direction vector and a roughness of the shading point are obtained, wherein the plurality of shading points belong to the same target shading surface, and the target shading surface is any one of the plurality of planes included in the three-dimensional model of the clothing of the virtual character;
[0007] Calculate a target highlight component corresponding to each shading point according to a light direction vector, a normal direction vector of each shading point, and a roughness of each shading point;
[0008] Acquire a logo map related to the clothing of the virtual character, wherein the logo map carries multiple logos, the multiple logos are respectively marked at multiple different positions of the logo map, and each of the logos has its own corresponding color parameter;
[0009] Determine a color operation result according to a plurality of different positions marked with a plurality of logos in the logo map and a color parameter corresponding to each of the logos;
[0010] Obtaining a vector product parameter corresponding to each of the shading points, and multiplying the vector product parameter by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points;
[0011] According to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points, the three-dimensional model of the clothing of the virtual character is rendered to obtain a rendering result.
[0012] The present application also provides a virtual character clothing rendering device, the device comprising:
[0013] A data acquisition unit, configured to acquire a normal direction vector and a roughness of each of a plurality of shading points, wherein the plurality of shading points belong to the same target shading surface, and the target shading surface is any one of a plurality of planes included in the three-dimensional model of the clothing of the virtual character;
[0014] A highlight component calculation unit, used for calculating a target highlight component corresponding to each shading point according to an illumination direction vector, a normal direction vector of each shading point, and a roughness of each shading point;
[0015] An identification map acquisition unit is used to acquire an identification map related to the clothing of the virtual character, wherein the identification map carries a plurality of identifications, the plurality of identifications are respectively marked at a plurality of different positions of the identification map, and each of the identifications has its own corresponding color parameter;
[0016] A color operation result unit, used for determining a color operation result according to a plurality of different positions marked with a plurality of logos in the logo map and a color parameter corresponding to each of the logos;
[0017] A diffuse reflection component unit, used for obtaining a vector product parameter corresponding to each of the shading points, and multiplying the vector product parameter by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points;
[0018] The rendering result acquisition unit is used to render the three-dimensional model of the virtual character's clothing according to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points to obtain a rendering result.
[0019] In some embodiments, the highlight component calculation unit includes:
[0020] A sight direction subunit, configured to determine a sight direction vector according to a world space coordinate value of a target shading point and a world space coordinate value of a current viewpoint, wherein the target shading point is any shading point among the plurality of shading points;
[0021] A midline subunit, configured to determine a midline vector according to the sight direction vector and the illumination direction vector;
[0022] A first dot product result subunit, used for performing a dot product between the midline vector and the normal direction vector of the target shading point to obtain a first dot product result;
[0023] A target highlight sub-unit is used to calculate a target highlight component corresponding to the target shading point according to the first dot product result and the roughness of the target shading point.
[0024] In some embodiments, the sight direction subunit includes:
[0025] A difference sub-subunit, used to calculate the difference between the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint;
[0026] The sight direction sub-subunit is used to normalize the difference to obtain the sight direction vector.
[0027] In some embodiments, the midline subunit comprises:
[0028] A summing sub-subunit, used to obtain the sum of the sight direction vector and the illumination direction vector;
[0029] The midline sub-subunit is used to normalize the sum to obtain the midline vector.
[0030] In some embodiments, the color operation result unit includes:
[0031] A value subunit to be operated, used to obtain a value to be operated at a position corresponding to each of the multiple identifiers;
[0032] A product result subunit, used for multiplying the to-be-operated value corresponding to each identifier by the color parameter corresponding to the identifier to obtain a color parameter product result;
[0033] A summing result subunit, configured to add the color parameter product results corresponding to each of the multiple identifiers to obtain a color parameter summing result;
[0034] The albedo subunit is used to multiply the sum of the color parameters by the albedo map to obtain the color operation result.
[0035] In some embodiments, the multiple logos are digital logos; the logo map includes a plurality of pixels, and the plurality of pixels correspond to the plurality of shading points one by one;
[0036] The numerical subunit to be operated includes:
[0037] a difference calculation sub-subunit, configured to calculate, for each of the plurality of identifiers, a difference between a digital value of the identifier and a digital identifier corresponding to each of the plurality of pixel points;
[0038] A first comparison sub-subunit is used for setting the value to be calculated of the pixel point whose difference is less than the preset difference threshold to 1 when the difference is less than the preset difference threshold;
[0039] The second comparison sub-sub-unit is used for setting the value to be calculated of the pixel point whose difference is not less than the preset difference threshold to 0 when the difference is not less than the preset difference threshold;
[0040] The product result subunit is specifically used to multiply the to-be-calculated values of the plurality of pixel points by the color parameters corresponding to the current annotation to obtain a color parameter product result.
[0041] In some embodiments, the diffuse reflection component unit includes:
[0042] A preliminary vector subunit, used for obtaining a preliminary vector product parameter for each of the shading points;
[0043] A secondary vector selection unit, used for mapping the primary vector product parameter to a preset value range to obtain a secondary vector product parameter;
[0044] The vector product subunit is used to process the second selected vector product parameter by using a smooth step function to obtain the vector product parameter.
[0045] In some embodiments, the preliminary vector subunit is specifically used to perform a dot multiplication operation on the normal direction vector and the illumination direction vector to obtain the preliminary vector product parameter.
[0046] The 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 clothing rendering methods provided in the embodiment of the present application.
[0047] In the virtual character clothing rendering method provided in the embodiment of the present application, for each of the multiple shading points belonging to the same target shading surface, the normal direction vector and roughness of each shading point can be obtained, and then the target highlight component corresponding to each shading point is calculated according to the illumination direction vector, the normal direction vector of each shading point and the roughness of each shading point. The embodiment of the present application can also obtain an identification map, and determine the color operation result according to multiple different positions marked with multiple identifications in the identification map, and the color parameters corresponding to each identification. The embodiment of the present application can also obtain the vector product parameter corresponding to each of the shading points, and multiply the vector product parameter with the color operation result to obtain the diffuse reflection component corresponding to each shading point. After obtaining the target highlight component and diffuse reflection component corresponding to each shading point, the three-dimensional model of the virtual character's clothing can be rendered according to the above-mentioned target highlight component and diffuse reflection component to obtain the rendering result.
[0048] In the present application, for each of the multiple shading points, a target highlight component and a diffuse reflection component can be obtained; wherein, the target highlight component can increase the realistic texture of the leather and metal materials in the clothing during the rendering process, and the diffuse reflection component can contribute to the stylization of the anime style, thereby making the rendering result more realistic on the basis of the stylization of the anime style, and the anime style has lower requirements on the computing power of the terminal device, thereby achieving the goal of lowering the entry threshold of the game while maximizing the sense of immersion of the game players. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] 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.
[0050] Figure 1a It is a scene schematic diagram of a virtual character clothing rendering method provided in an embodiment of the present application;
[0051] Figure 1b It is a flowchart of a method for rendering virtual character clothing provided by an embodiment of the present application;
[0052] Figure 1c A schematic diagram showing a logo map before being labeled with various logos by an artist;
[0053] Figure 2 is a flowchart of a virtual character clothing rendering method provided by another embodiment of the present application;
[0054] Figure 3This is a structural schematic diagram of a virtual character clothing rendering device provided by an embodiment of the present application;
[0055] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] 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.
[0057] Embodiments of the present application provide a method, device, mobile terminal and storage medium for rendering virtual character clothing.
[0058] The virtual character clothing 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.
[0059] In some embodiments, the virtual character clothing rendering method can also be integrated into multiple electronic devices. For example, the virtual character clothing rendering method can be integrated into multiple servers, and the virtual character clothing rendering method of the present application can be implemented by multiple servers.
[0060] In some embodiments, the server may also be implemented in the form of a terminal.
[0061] For example, see Figure 1aIn some embodiments, the electronic device may be a mobile terminal. For each of the multiple shading points, the embodiment may obtain a normal direction vector and a roughness of the shading point, wherein the multiple shading points belong to the same target shading surface, and the target shading surface is any one of the multiple planes included in the three-dimensional model of the virtual character's clothing; according to the illumination direction vector, the normal direction vector of each of the shading points, and the roughness of each of the shading points, the target highlight component corresponding to each of the shading points is calculated; an identification map related to the clothing of the virtual character is obtained, wherein the identification map carries multiple identifications, The multiple logos are respectively marked at multiple different positions of the logo map, and each logo has its own corresponding color parameters; according to the multiple different positions marked with the multiple logos in the logo map and the color parameters corresponding to each logo, the color operation result is determined; the vector product parameter corresponding to each of the shading points is obtained, and the vector product parameter is multiplied by the color operation result to obtain the diffuse reflection component corresponding to each of the shading points; according to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points, the three-dimensional model of the virtual character's clothing is rendered to obtain a rendering result.
[0062] In one embodiment of the present disclosure, a virtual character clothing 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 clothing 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.
[0063] 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 clothing 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 virtual character clothing 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.
[0064] 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.
[0065] 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.
[0066] 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.
[0067] 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.).
[0068] 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.
[0069] 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.
[0070] In some embodiments, the game objects in the game scene include virtual objects controlled by the player user, namely user objects.
[0071] 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.
[0072] 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.
[0073] 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.
[0074] 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.
[0075] In an optional implementation, an embodiment of the present invention provides a method for rendering virtual character clothing, 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.
[0076] It should be noted that the serial numbers of the following embodiments are not intended to limit the preferred order of the embodiments.
[0077] In this embodiment, a method for rendering virtual character clothing is provided. Figure 1b As shown, the specific process of the method may include the following steps 110 to 160:
[0078] 110. For each shading point among a plurality of shading points, obtain a normal direction vector and a roughness of the shading point, wherein the plurality of shading points belong to the same target shading surface, and the target shading surface is any one of a plurality of planes included in the three-dimensional model of the virtual character's clothing.
[0079] The plurality of shading points include three vertex shading points located at vertex positions of the target shading surface and a plurality of non-vertex shading points located at non-vertex positions of the target shading point, wherein 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.
[0080] The normal direction vector is a vector with the same direction as the normal direction and a modulus of 1. The normal direction can be baked into the model tangent space and normal map by the artist, and the artist can adjust the normal direction according to the aesthetic perception. The roughness can be baked into the map by the artist.
[0081] 120. Calculate a target highlight component corresponding to each of the shading points according to the illumination direction vector, the normal direction vector of each of the shading points, and the roughness of each of the shading points.
[0082] The illumination direction vector is a vector whose direction is consistent with the illumination direction in the world space coordinates and whose modulus is 1. The target highlight component is a component reflecting the characteristics of the virtual character's clothing related to highlights. The characteristics of clothing related to highlights are the reflective materials on the clothing surface, such as metal materials, leather materials, etc.
[0083] Optionally, in a specific implementation, step 120 may specifically include the following steps 121 to 124:
[0084] 121. Determine a sight direction vector according to a world space coordinate value of a target shading point and a world space coordinate value of a current viewpoint, wherein the target shading point is any shading point among a plurality of shading points.
[0085] The current viewpoint is the location of the virtual camera. The sight direction vector is a vector with a modulus of 1 and the same direction as the player's view of the game world.
[0086] Optionally, in a specific implementation, step 121 may specifically include the following steps A1 to A2:
[0087] A1. Calculate the difference between the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint.
[0088] A2. Normalize the difference to obtain the sight direction vector.
[0089] In the above implementation, the direction of the sight direction vector can be calculated by calculating the difference between the world space coordinates of the target shading point and the current viewpoint; the above difference is a vector whose modulus is not 1 and whose direction is the direction in which the player views the game world. After obtaining the above difference, the difference is normalized to set the modulus to 1, and the sight direction vector can be obtained.
[0090] 122. Determine a midline vector according to the sight direction vector and the illumination direction vector.
[0091] Optionally, in a specific implementation, step 122 may specifically include the following steps B1 to B2:
[0092] B1. Obtain the sum of the sight direction vector and the illumination direction vector.
[0093] B2. Normalize the sum to obtain the centerline vector.
[0094] In the above implementation, the direction of the midline vector can be calculated by calculating the sum of the sight direction vector and the illumination direction vector. After obtaining the above sum, the sum is normalized and the modulus is set to 1, and the midline vector can be obtained.
[0095] 123. Perform a dot product of the midline vector and the normal direction vector of the target shading point to obtain a first dot product result.
[0096] 124. Calculate a target highlight component corresponding to the target shading point according to the first dot product result and the roughness of the target shading point.
[0097] Specifically, let's assume that the result of the first dot product is NoH, then we can use the following formula:
[0098] Calculate the initial highlight intensity value I 1 , where NoH is the result of the first dot product and R is the roughness. 1 When Compare with 2048 and take the minimum value to avoid extreme over-brightness.
[0099] After calculating the initial highlight intensity value I 1 After that, we can use the following formula:
[0100] I 2 =(0.25×R+0.25)×I 1 Calculate the final highlight intensity value I 2 .
[0101] After calculating the final highlight intensity value I 2 After that, we can use the following formula:
[0102] H L =SpecularColor×NoL×I 2 +M e +Re D Calculate the target highlight component H L , where SpecularColor is an adjustable highlight color parameter that can be determined by the artist; NoL is the dot product of the normal direction vector and the light direction vector; M e Metalness, which can be determined by the artist through baking; D It is the environmental reflection result based on Image Based Lighting (IBL for short), which can be obtained from the real-time rendering process.
[0103] In the above implementation, the sight direction vector can be determined first, and then the midline vector can be determined according to the sight direction vector and the illumination direction vector; after obtaining the midline vector, the midline vector and the normal direction vector of the target shading point are multiplied to obtain the first dot product result; then, according to the first dot product result, the roughness, the normal direction vector and the illumination direction vector, the following initial highlight intensity value I is calculated in sequence: 1 , final highlight intensity value I 2 , and the target highlight component H L The above process of calculating the target highlight component refers to unit vectors in multiple directions, so that the target highlight component is more realistic and natural in the process of rendering the highlight of the virtual character's clothing.
[0104] 130. Obtain a logo map related to the clothing of the virtual character, wherein the logo map carries multiple logos, the multiple logos are respectively marked at multiple different positions of the logo map, and each of the logos has its own corresponding color parameter.
[0105] The logo map is a map related to the avatar's clothing with various logos marked by the artist. For details, see Figure 1c , Figure 1c The image shown is a schematic diagram of the logo map before the artist marks multiple logos. Multiple logos can be marked on multiple different positions of the clothing shown in the map. Specifically, there can be multiple numbers of each of the multiple logos, and each logo can be marked on different positions. Among the multiple logos, multiple positions marked with the same logo represent the same corresponding processing operations, that is, for multiple positions corresponding to the same logo, they can be processed by the same color parameters.
[0106] 140. Determine a color operation result according to a plurality of different positions marked with a plurality of logos in the logo map and a color parameter corresponding to each of the logos.
[0107] The color operation result is an intermediate result in the process of calculating the diffuse reflection component. The color operation result is used to reflect that different positions of the virtual character's clothing have different color processing operations, and the color processing operation is related to the type of the mark.
[0108] Optionally, in a specific implementation, step 140 may specifically include the following steps 141 to 144:
[0109] 141. Obtain a value to be calculated at a position corresponding to each of the multiple identifiers.
[0110] 142. Multiply the to-be-calculated value corresponding to each identifier by the color parameter corresponding to the identifier to obtain a color parameter multiplication result.
[0111] In the above implementation, each mark has its own corresponding position, and the position has a value to be calculated; each mark also has its own corresponding color parameter. Therefore, the type of mark can be used as an index to establish an association between the value to be calculated and the corresponding color parameter at the position corresponding to the same mark, and then the above two can be multiplied to obtain the product result of the color parameter corresponding to each mark.
[0112] In another specific implementation, the multiple logos are digital logos; the logo map includes a plurality of pixel points, and the plurality of pixel points correspond one-to-one to the plurality of shading points.
[0113] Let's assume that there are multiple digital identifiers: 0, 10, 20, 30..., 250, a total of 26 digital identifiers. For the texture of the virtual character's clothing, the artist can mark the corresponding digital identifiers for different positions of the clothing according to different color processing requirements. The different positions of the clothing include the collar, zipper, cuffs, sleeves, buttons, etc. For example, the artist can mark the collar position with the digital identifier 0; mark the cuff position with the digital identifier 10; mark N buttons with N different digital identifiers, or mark N buttons with the same digital identifier, etc.
[0114] Accordingly, step 141 may specifically include the following steps:
[0115] For each of the plurality of identifiers, calculating a difference between a digital value of the identifier and a digital identifier corresponding to each of the plurality of pixel points;
[0116] If the difference is less than the preset difference threshold, the value to be calculated of the pixel point whose difference is less than the preset difference threshold is set to 1;
[0117] If the difference is not less than the preset difference threshold, the value to be calculated of the pixel point whose difference is not less than the preset difference threshold is set to 0.
[0118] In the above implementation, if the difference is less than the preset difference threshold, it means that the pixel point whose difference is less than the preset difference threshold has a strong correlation with the mark currently being processed; if the difference is not less than the preset difference threshold, it means that the pixel point whose difference is not less than the preset difference threshold has a weak correlation with the mark currently being processed. By calculating the difference between the digital value of the mark and the digital mark corresponding to each pixel point in the multiple pixels included in the mark map, and judging whether the difference is less than the preset difference threshold, the pixel points with a strong correlation with each mark can be obtained from the mark map, so that the values to be calculated of these pixel points are set to 1. The above implementation can accurately obtain the pixel points corresponding to each mark.
[0119] Step 142 may specifically include the following steps: multiplying the numerical values to be calculated of the plurality of pixel points by the color parameters corresponding to the current annotation to obtain a color parameter multiplication result.
[0120] By multiplying the value to be calculated by the color parameter corresponding to the current annotation, different results of the color processing operation can be achieved according to different annotation types.
[0121] 143. Add the product results of the color parameters corresponding to each of the multiple identifiers to obtain a color parameter sum result.
[0122] 144. Multiply the sum of the color parameters by the albedo map to obtain the color operation result.
[0123] The color parameter sum result is the sum of the color parameter product results corresponding to each of the multiple identifiers. The sum result can perform refined color processing operations on different positions of the clothing of the same virtual character, which is beneficial to improving the authenticity of the clothing of the virtual character.
[0124] The albedo map is a map baked from the model's surface color. The sum of the color parameters is multiplied by the albedo map to make the overall style of the virtual character's clothing more consistent.
[0125] In the above implementation, the relationship between the position corresponding to the logo in the logo map and the color parameter corresponding to the logo can be established according to the type of the logo, and then the color parameter product results corresponding to different positions and the color parameter sum result obtained by adding multiple color parameter product results are calculated. The color parameter sum result is multiplied with the albedo map to obtain a color operation result. The color operation result can reflect the color parameters corresponding to different positions of the virtual character's clothing, thereby realizing a refined processing process for the virtual character's clothing.
[0126] 150. Obtain a vector product parameter corresponding to each of the shading points, and multiply the vector product parameter by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points.
[0127] The vector product parameter is a parameter obtained by processing multiple unit vectors in different directions. Each shading point has its own corresponding vector product parameter. For each shading point, multiply the vector product parameter with the color operation result to obtain the diffuse reflection component corresponding to each shading point.
[0128] The diffuse component is used to contribute to the anime-style stylization of the avatar's clothing.
[0129] Optionally, in a specific implementation, the step of “obtaining the vector product parameter corresponding to each of the shading points” may specifically include the following steps 151 to 153:
[0130] 151. For each of the shading points, obtain preliminary vector product parameters.
[0131] Optionally, step 151 may specifically include: performing a dot multiplication operation on the normal direction vector and the illumination direction vector to obtain the preliminary vector product parameter.
[0132] 152. Map the initially selected vector product parameter to a preset value range to obtain a second selected vector product parameter.
[0133] The preset value range is a preset value range, and the specific value should not be understood as a limitation of the present application. For example, let the initial vector product parameter be NoL, and the preset value range be [I min ,I max ], then NoL is mapped to the preset value range [I min ,I max ]Specific steps include:
[0134] If NoL is less than I min , then NoL takes the value of I min ; If NoL is greater than I max , then NoL takes the value of Imax ; If NoL is located in [I min ,I max ] interval, the NoL is not transformed.
[0135] Mapping NoL to a preset value range [I min ,I max ], the secondary vector product parameter NoL' can be obtained.
[0136] 153. Use a smooth step function to process the sub-selected vector product parameter to obtain the vector product parameter.
[0137] Alternatively, the following formula can be used: NoL Cel =smoothstep(ms,m+s,NoL') calculates the vector product parameter NoL Cel . Among them, m and s are setting parameters.
[0138] In the above implementation, by limiting the value range of the vector product parameter and performing smooth step function processing, the change of the vector product parameter within the value range is made smoother, thereby making the diffuse reflection component with the vector product parameter as the intermediate parameter smoother and more natural.
[0139] 160. Render the three-dimensional model of the clothing of the virtual character according to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points to obtain a rendering result.
[0140] For each of the multiple shading points belonging to the same target shading surface, the above-mentioned operation process of step 110 to step 160 can be performed, so that multiple target highlight components and multiple diffuse reflection components corresponding to the target shading surface can be obtained, thereby realizing the rendering process of the target shading surface. The target shading surface is any one of the multiple planes included in the three-dimensional model of the virtual character's clothing, so the above-mentioned operation process is repeatedly performed on each plane, and the rendering results of all the planes included in the three-dimensional model of the virtual character's clothing can be obtained.
[0141] In the virtual character clothing rendering method provided in the embodiment of the present application, for each of the multiple shading points belonging to the same target shading surface, the normal direction vector and roughness of each shading point can be obtained, and then the target highlight component corresponding to each shading point is calculated according to the illumination direction vector, the normal direction vector of each shading point and the roughness of each shading point. The embodiment of the present application can also obtain an identification map, and determine the color operation result according to multiple different positions marked with multiple identifications in the identification map, and the color parameters corresponding to each identification. The embodiment of the present application can also obtain the vector product parameter corresponding to each of the shading points, and multiply the vector product parameter with the color operation result to obtain the diffuse reflection component corresponding to each shading point. After obtaining the target highlight component and diffuse reflection component corresponding to each shading point, the three-dimensional model of the virtual character's clothing can be rendered according to the above-mentioned target highlight component and diffuse reflection component to obtain the rendering result. In the present application, for each of the multiple shading points, a target highlight component and a diffuse reflection component can be obtained; wherein, the target highlight component can increase the realistic texture of the leather material and the realistic texture of the metal material in the clothing during the rendering process, and the diffuse reflection component can contribute to the stylization of the anime style, thereby making the rendering result more realistic on the basis of the stylization of the anime style, and the anime style has lower requirements on the computing power of the terminal device.
[0142] In the present application, it is possible to lower the game entry threshold while increasing the sense of immersion of game players as much as possible.
[0143] The method described in the above embodiment will be further described in detail below.
[0144] In this embodiment, the method of the embodiment of the present application is described in detail by taking the identifier being a digital identifier as an example.
[0145] like Figure 2 As shown, a virtual character clothing rendering method has the following specific process:
[0146] 201. For each shading point among a plurality of shading points, obtain a normal direction vector and a roughness of the shading point, wherein the plurality of shading points belong to the same target shading surface, and the target shading surface is any one of a plurality of planes included in the three-dimensional model of the virtual character's clothing.
[0147] 202. Calculate the difference between the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint, normalize the difference, and obtain the sight direction vector.
[0148] 203. Obtain a sum of the sight direction vector and the illumination direction vector, and normalize the sum to obtain the centerline vector.
[0149] 204. Perform a dot product of the midline vector and the normal direction vector of the target shading point to obtain a first dot product result.
[0150] 205. Calculate a target highlight component corresponding to the target shading point according to the first dot product result and the roughness of the target shading point.
[0151] 206. Obtain a logo map related to the clothing of the virtual character, wherein the logo map carries multiple logos, the multiple logos are respectively marked at multiple different positions of the logo map, and each of the logos has its own corresponding color parameter.
[0152] 207. For each of the multiple identifiers, calculate a difference between a digital value of the identifier and a digital identifier corresponding to each of the multiple pixel points.
[0153] 208. If the difference is less than the preset difference threshold, the value to be calculated of the pixel point whose difference is less than the preset difference threshold is set to 1; if the difference is not less than the preset difference threshold, the value to be calculated of the pixel point whose difference is not less than the preset difference threshold is set to 0.
[0154] 209. Multiply the to-be-calculated values of the plurality of pixel points by the color parameter corresponding to the current annotation to obtain a color parameter multiplication result.
[0155] 210. For each of the shading points, perform a dot multiplication operation on the normal direction vector and the illumination direction vector to obtain the preliminary vector product parameter.
[0156] 211. Map the initially selected vector product parameter to a preset value range to obtain a second selected vector product parameter.
[0157] 212. Process the second selected vector product parameter using a smooth step function to obtain the vector product parameter.
[0158] 213. Multiply the vector product parameter by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points.
[0159] 214. Render the three-dimensional model of the clothing of the virtual character according to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points to obtain a rendering result.
[0160] It can be seen from the above that for each of the multiple shading points belonging to the same target shading surface, the normal direction vector and roughness of each shading point can be obtained, and then the target highlight component corresponding to each shading point can be calculated according to the illumination direction vector, the normal direction vector of each shading point and the roughness of each shading point. The embodiment of the present application can also obtain an identification map, and determine the color operation result according to multiple different positions marked with multiple identifications in the identification map, and the color parameters corresponding to each identification. The embodiment of the present application can also obtain the vector product parameter corresponding to each of the shading points, and multiply the vector product parameter with the color operation result to obtain the diffuse reflection component corresponding to each shading point. After obtaining the target highlight component and diffuse reflection component corresponding to each shading point, the three-dimensional model of the virtual character's clothing can be rendered according to the above-mentioned target highlight component and diffuse reflection component to obtain a rendering result. In the present application, for each of the multiple shading points, a target highlight component and a diffuse reflection component can be obtained; wherein, the target highlight component can increase the realistic texture of the leather and metal materials in the clothing during the rendering process, and the diffuse reflection component can contribute to the stylization of the anime style, thereby making the rendering result more realistic on the basis of the stylization of the anime style, and the anime style has lower requirements on the computing power of the terminal device.
[0161] In the present application, it is possible to lower the game entry threshold while increasing the sense of immersion of game players as much as possible.
[0162] In order to better implement the above method, the embodiment of the present application also provides a virtual character clothing rendering device, which can be integrated in 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.
[0163] For example, in this embodiment, the device of the embodiment of the present application is described in detail by taking the virtual character clothing rendering device specifically integrated in the terminal as an example.
[0164] For example, Figure 3 As shown, the virtual character clothing rendering device may include:
[0165] The data acquisition unit 301 is used to acquire a normal direction vector and a roughness of each of a plurality of shading points, wherein the plurality of shading points belong to the same target shading surface, and the target shading surface is any one of a plurality of planes included in the three-dimensional model of the clothing of the virtual character;
[0166] A highlight component calculation unit 302, configured to calculate a target highlight component corresponding to each shading point according to a light direction vector, a normal direction vector of each shading point, and a roughness of each shading point;
[0167] The logo map acquisition unit 303 is used to acquire a logo map related to the clothing of the virtual character, wherein the logo map carries multiple logos, the multiple logos are respectively marked at multiple different positions of the logo map, and each of the logos has its own corresponding color parameter;
[0168] A color operation result unit 304 is used to determine a color operation result according to a plurality of different positions marked with a plurality of logos in the logo map and a color parameter corresponding to each of the logos;
[0169] The diffuse reflection component unit 305 is used to obtain a vector product parameter corresponding to each of the shading points, and multiply the vector product parameter by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points;
[0170] The rendering result acquisition unit 306 is used to render the three-dimensional model of the virtual character's clothing according to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points to obtain a rendering result.
[0171] In some embodiments, the highlight component calculation unit 302 includes:
[0172] A sight direction subunit, configured to determine a sight direction vector according to a world space coordinate value of a target shading point and a world space coordinate value of a current viewpoint, wherein the target shading point is any shading point among the plurality of shading points;
[0173] A midline subunit, configured to determine a midline vector according to the sight direction vector and the illumination direction vector;
[0174] A first dot product result subunit, used for performing a dot product between the midline vector and the normal direction vector of the target shading point to obtain a first dot product result;
[0175] A target highlight sub-unit is used to calculate a target highlight component corresponding to the target shading point according to the first dot product result and the roughness of the target shading point.
[0176] In some embodiments, the sight direction subunit includes:
[0177] A difference sub-subunit, used to calculate the difference between the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint;
[0178] The sight direction sub-subunit is used to normalize the difference to obtain the sight direction vector.
[0179] In some embodiments, the midline subunit comprises:
[0180] A summing sub-subunit, used to obtain the sum of the sight direction vector and the illumination direction vector;
[0181] The midline sub-subunit is used to normalize the sum to obtain the midline vector.
[0182] In some embodiments, the color operation result unit 304 includes:
[0183] A value subunit to be operated, used to obtain a value to be operated at a position corresponding to each of the multiple identifiers;
[0184] A product result subunit, used for multiplying the to-be-operated value corresponding to each identifier by the color parameter corresponding to the identifier to obtain a color parameter product result;
[0185] A summing result subunit, configured to add the color parameter product results corresponding to each of the multiple identifiers to obtain a color parameter summing result;
[0186] The albedo subunit is used to multiply the sum of the color parameters by the albedo map to obtain the color operation result.
[0187] In some embodiments, the multiple logos are digital logos; the logo map includes a plurality of pixels, and the plurality of pixels correspond to the plurality of shading points one by one;
[0188] The numerical subunit to be operated includes:
[0189] a difference calculation sub-subunit, configured to calculate, for each of the plurality of identifiers, a difference between a digital value of the identifier and a digital identifier corresponding to each of the plurality of pixel points;
[0190] A first comparison sub-subunit is used for setting the value to be calculated of the pixel point whose difference is less than the preset difference threshold to 1 when the difference is less than the preset difference threshold;
[0191] The second comparison sub-sub-unit is used for setting the value to be calculated of the pixel point whose difference is not less than the preset difference threshold to 0 when the difference is not less than the preset difference threshold;
[0192] The product result subunit is specifically used to multiply the to-be-calculated values of the plurality of pixel points by the color parameters corresponding to the current annotation to obtain a color parameter product result.
[0193] In some embodiments, the diffuse reflection component unit 305 includes:
[0194] A preliminary vector subunit, used for obtaining a preliminary vector product parameter for each of the shading points;
[0195] A secondary vector selection unit, used for mapping the primary vector product parameter to a preset value range to obtain a secondary vector product parameter;
[0196] The vector product subunit is used to process the second selected vector product parameter by using a smooth step function to obtain the vector product parameter.
[0197] In some embodiments, the preliminary vector subunit is specifically used to perform a dot multiplication operation on the normal direction vector and the illumination direction vector to obtain the preliminary vector product parameter.
[0198] 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.
[0199] As can be seen from the above, in the virtual character clothing rendering method provided by the embodiment of the present application, for each of the multiple shading points belonging to the same target shading surface, the normal direction vector and roughness of each shading point can be obtained, and then the target highlight component corresponding to each shading point is calculated according to the illumination direction vector, the normal direction vector of each shading point and the roughness of each shading point. The embodiment of the present application can also obtain an identification map, and determine the color operation result according to multiple different positions marked with multiple identifications in the identification map, and the color parameters corresponding to each identification. The embodiment of the present application can also obtain the vector product parameter corresponding to each of the shading points, and multiply the vector product parameter with the color operation result to obtain the diffuse reflection component corresponding to each shading point. After obtaining the target highlight component and diffuse reflection component corresponding to each shading point, the three-dimensional model of the virtual character's clothing can be rendered according to the above-mentioned target highlight component and diffuse reflection component to obtain the rendering result. In the present application, for each of the multiple shading points, a target highlight component and a diffuse reflection component can be obtained; wherein, the target highlight component can increase the realistic texture of the leather and metal materials in the clothing during the rendering process, and the diffuse reflection component can contribute to the stylization of the anime style, thereby making the rendering result more realistic on the basis of the stylization of the anime style, and the anime style has lower requirements on the computing power of the terminal device.
[0200] In the present application, it is possible to lower the game entry threshold while increasing the sense of immersion of game players as much as possible.
[0201] 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.
[0202] In some embodiments, the virtual character clothing rendering device may also be integrated into multiple electronic devices. For example, the virtual character clothing rendering device may be integrated into multiple servers, and the virtual character clothing rendering method of the present application may be implemented by multiple servers.
[0203] 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:
[0204] 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.
[0205] 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.
[0206] 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.
[0207] 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.
[0208] 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.
[0209] 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.
[0210] 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:
[0211] For each of the multiple shading points, a normal direction vector and a roughness of the shading point are obtained, wherein the multiple shading points belong to the same target shading surface, and the target shading surface is any one of the multiple planes included in the three-dimensional model of the clothing of the virtual character; a target highlight component corresponding to each of the shading points is calculated according to the illumination direction vector, the normal direction vector of each of the shading points, and the roughness of each of the shading points; an identification map related to the clothing of the virtual character is obtained, wherein the identification map carries a plurality of identifications, and the plurality of identifications are respectively marked at a plurality of different positions of the identification map, and each of the identifications has its own corresponding color parameters; a color operation result is determined according to a plurality of different positions marked with a plurality of identifications in the identification map, and a color parameter corresponding to each of the identifications; a vector product parameter corresponding to each of the shading points is obtained, and the vector product parameter is multiplied by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points; the three-dimensional model of the clothing of the virtual character is rendered according to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points to obtain a rendering result.
[0212] Optionally, the target highlight component corresponding to each shading point is calculated based on the illumination direction vector, the normal direction vector of each shading point, and the roughness of each shading point, including: determining the sight direction vector based on the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint, wherein the target shading point is any shading point among multiple shading points; determining the centerline vector based on the sight direction vector and the illumination direction vector; performing a dot product of the centerline vector and the normal direction vector of the target shading point to obtain a first dot product result; and calculating the target highlight component corresponding to the target shading point based on the first dot product result and the roughness of the target shading point.
[0213] In the above implementation, the process of calculating the target highlight component refers to unit vectors in multiple directions, so that the target highlight component is more realistic and natural in the process of rendering the highlight of the virtual character's clothing.
[0214] Optionally, determining the sight direction vector according to the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint includes: calculating the difference between the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint; and normalizing the difference to obtain the sight direction vector.
[0215] In the above implementation, the direction of the sight direction vector can be calculated by calculating the difference between the world space coordinates of the target shading point and the current viewpoint; the above difference is a vector whose modulus is not 1 and whose direction is the direction in which the player views the game world. After obtaining the above difference, the difference is normalized to set the modulus to 1, and the sight direction vector can be obtained.
[0216] Optionally, determining the centerline vector according to the sight direction vector and the illumination direction vector includes: obtaining a sum of the sight direction vector and the illumination direction vector; and normalizing the sum to obtain the centerline vector.
[0217] In the above implementation, the direction of the midline vector can be calculated by calculating the sum of the sight direction vector and the illumination direction vector. After obtaining the above sum, the sum is normalized and the modulus is set to 1, and the midline vector can be obtained.
[0218] Optionally, the color operation result is determined based on multiple different positions in the logo map marked with multiple logos and color parameters corresponding to each of the logos, including: obtaining the value to be calculated at the position corresponding to each of the multiple logos; multiplying the value to be calculated corresponding to each of the multiple logos with the color parameter corresponding to the logo to obtain a color parameter multiplication result; adding the color parameter multiplication results corresponding to each of the multiple logos to obtain a color parameter sum result; multiplying the color parameter sum result with the albedo map to obtain the color operation result.
[0219] In the above implementation, the color operation result can reflect the color parameters corresponding to different positions of the virtual character's clothing, thereby realizing a refined processing process for the virtual character's clothing.
[0220] Optionally, the multiple identifiers are digital identifiers; the identifier map includes multiple pixel points, and the multiple pixel points correspond to the multiple shading points one by one; the obtaining of the value to be calculated at the position corresponding to each of the multiple identifiers includes: for each of the multiple identifiers, calculating the difference between the digital value of the identifier and the digital identifier corresponding to each of the multiple pixel points; if the difference is less than a preset difference threshold, setting the value to be calculated of the pixel point whose difference is less than the preset difference threshold to 1; if the difference is not less than the preset difference threshold, setting the value to be calculated of the pixel point whose difference is not less than the preset difference threshold to 0;
[0221] The multiplying the numerical value to be calculated corresponding to each identification with the color parameter corresponding to the identification to obtain a color parameter multiplication result includes: multiplying the numerical values to be calculated of the multiple pixel points with the color parameter corresponding to the current annotation to obtain a color parameter multiplication result.
[0222] In the above implementation, by calculating the difference between the digital value of the logo and the digital logo corresponding to each pixel in the multiple pixels included in the logo map, and judging whether the difference is less than a preset difference threshold, the pixels with strong correlation with each logo can be obtained from the logo map, so that the values to be calculated of these pixels are set to 1. The above implementation can accurately obtain the pixels corresponding to each logo.
[0223] Optionally, obtaining the vector product parameters corresponding to each of the shading points includes: for each of the shading points, obtaining preliminary vector product parameters; mapping the preliminary vector product parameters to a preset value range to obtain secondary vector product parameters; and processing the secondary vector product parameters using a smooth step function to obtain the vector product parameters.
[0224] In the above implementation, by limiting the value range of the vector product parameter and performing smooth step function processing, the change of the vector product parameter within the value range is made smoother, thereby making the diffuse reflection component with the vector product parameter as the intermediate parameter smoother and more natural.
[0225] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0226] 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.
[0227] 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 clothing rendering methods provided in the embodiments of the present application. For example, the instructions can execute the following steps:
[0228] For each of the multiple shading points, a normal direction vector and a roughness of the shading point are obtained, wherein the multiple shading points belong to the same target shading surface, and the target shading surface is any one of the multiple planes included in the three-dimensional model of the clothing of the virtual character; a target highlight component corresponding to each of the shading points is calculated according to the illumination direction vector, the normal direction vector of each of the shading points, and the roughness of each of the shading points; an identification map related to the clothing of the virtual character is obtained, wherein the identification map carries a plurality of identifications, and the plurality of identifications are respectively marked at a plurality of different positions of the identification map, and each of the identifications has its own corresponding color parameters; a color operation result is determined according to a plurality of different positions marked with a plurality of identifications in the identification map, and a color parameter corresponding to each of the identifications; a vector product parameter corresponding to each of the shading points is obtained, and the vector product parameter is multiplied by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points; the three-dimensional model of the clothing of the virtual character is rendered according to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points to obtain a rendering result.
[0229] Optionally, the target highlight component corresponding to each shading point is calculated based on the illumination direction vector, the normal direction vector of each shading point, and the roughness of each shading point, including: determining the sight direction vector based on the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint, wherein the target shading point is any shading point among multiple shading points; determining the centerline vector based on the sight direction vector and the illumination direction vector; performing a dot product of the centerline vector and the normal direction vector of the target shading point to obtain a first dot product result; and calculating the target highlight component corresponding to the target shading point based on the first dot product result and the roughness of the target shading point.
[0230] In the above implementation, the process of calculating the target highlight component refers to unit vectors in multiple directions, so that the target highlight component is more realistic and natural in the process of rendering the highlight of the virtual character's clothing.
[0231] Optionally, determining the sight direction vector according to the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint includes: calculating the difference between the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint; and normalizing the difference to obtain the sight direction vector.
[0232] In the above implementation, the direction of the sight direction vector can be calculated by calculating the difference between the world space coordinates of the target shading point and the current viewpoint; the above difference is a vector whose modulus is not 1 and whose direction is the direction in which the player views the game world. After obtaining the above difference, the difference is normalized to set the modulus to 1, and the sight direction vector can be obtained.
[0233] Optionally, determining the centerline vector according to the sight direction vector and the illumination direction vector includes: obtaining a sum of the sight direction vector and the illumination direction vector; and normalizing the sum to obtain the centerline vector.
[0234] In the above implementation, the direction of the midline vector can be calculated by calculating the sum of the sight direction vector and the illumination direction vector. After obtaining the above sum, the sum is normalized and the modulus is set to 1, and the midline vector can be obtained.
[0235] Optionally, the color operation result is determined based on multiple different positions in the logo map marked with multiple logos and color parameters corresponding to each of the logos, including: obtaining the value to be calculated at the position corresponding to each of the multiple logos; multiplying the value to be calculated corresponding to each of the multiple logos with the color parameter corresponding to the logo to obtain a color parameter multiplication result; adding the color parameter multiplication results corresponding to each of the multiple logos to obtain a color parameter sum result; multiplying the color parameter sum result with the albedo map to obtain the color operation result.
[0236] In the above implementation, the color operation result can reflect the color parameters corresponding to different positions of the virtual character's clothing, thereby realizing a refined processing process for the virtual character's clothing.
[0237] Optionally, the multiple identifiers are digital identifiers; the identifier map includes multiple pixel points, and the multiple pixel points correspond to the multiple shading points one by one; the obtaining of the value to be calculated at the position corresponding to each of the multiple identifiers includes: for each of the multiple identifiers, calculating the difference between the digital value of the identifier and the digital identifier corresponding to each of the multiple pixel points; if the difference is less than a preset difference threshold, setting the value to be calculated of the pixel point whose difference is less than the preset difference threshold to 1; if the difference is not less than the preset difference threshold, setting the value to be calculated of the pixel point whose difference is not less than the preset difference threshold to 0;
[0238] The multiplying the numerical value to be calculated corresponding to each identification with the color parameter corresponding to the identification to obtain a color parameter multiplication result includes: multiplying the numerical values to be calculated of the multiple pixel points with the color parameter corresponding to the current annotation to obtain a color parameter multiplication result.
[0239] In the above implementation, by calculating the difference between the digital value of the logo and the digital logo corresponding to each pixel in the multiple pixels included in the logo map, and judging whether the difference is less than a preset difference threshold, the pixels with strong correlation with each logo can be obtained from the logo map, so that the values to be calculated of these pixels are set to 1. The above implementation can accurately obtain the pixels corresponding to each logo.
[0240] Optionally, obtaining the vector product parameters corresponding to each of the shading points includes: for each of the shading points, obtaining preliminary vector product parameters; mapping the preliminary vector product parameters to a preset value range to obtain secondary vector product parameters; and processing the secondary vector product parameters using a smooth step function to obtain the vector product parameters.
[0241] In the above implementation, by limiting the value range of the vector product parameter and performing smooth step function processing, the change of the vector product parameter within the value range is made smoother, thereby making the diffuse reflection component with the vector product parameter as the intermediate parameter smoother and more natural.
[0242] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0243] 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.
[0244] Since the instructions stored in the storage medium can execute the steps in any virtual character clothing rendering method provided in the embodiments of the present application, the beneficial effects that can be achieved by any virtual character clothing 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.
[0245] The above is a detailed introduction to a virtual character clothing rendering method, device, electronic device and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used in this article 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 scope. 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 clothing, characterized in that: The method comprises: For each of the plurality of shading points, a normal direction vector and a roughness of the shading point are obtained, wherein the plurality of shading points belong to the same target shading surface, and the target shading surface is any one of the plurality of planes included in the three-dimensional model of the clothing of the virtual character; Calculate a target highlight component corresponding to each shading point according to a light direction vector, a normal direction vector of each shading point, and a roughness of each shading point; Acquire a logo map related to the clothing of the virtual character, wherein the logo map carries multiple logos, the multiple logos are respectively marked at multiple different positions of the logo map, each of the logos has its own corresponding color parameter, and the multiple logos are digital logos; the logo map includes multiple pixel points, and the multiple pixel points correspond to the multiple coloring points one by one; Determining a color operation result according to a plurality of different positions marked with a plurality of identifiers in the identifier map and a color parameter corresponding to each of the identifiers, including: determining a value to be operated corresponding to each pixel point according to a difference between a digital value of each identifier in the plurality of identifiers and a numerical identifier corresponding to each of the plurality of pixels; and calculating the color operation result based on the values to be operated of the plurality of pixels, the color parameters corresponding to the current marking, and the albedo map; Obtaining a vector product parameter corresponding to each of the shading points, and multiplying the vector product parameter by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points; According to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points, the three-dimensional model of the clothing of the virtual character is rendered to obtain a rendering result.
2. The method according to claim 1, characterized in that The step of calculating a target highlight component corresponding to each shading point according to a light direction vector, a normal direction vector of each shading point, and a roughness of each shading point comprises: Determine a sight direction vector according to a world space coordinate value of a target shading point and a world space coordinate value of a current viewpoint, wherein the target shading point is any shading point among a plurality of shading points; Determining a midline vector according to the sight direction vector and the illumination direction vector; Perform a dot product of the midline vector and the normal direction vector of the target shading point to obtain a first dot product result; A target highlight component corresponding to the target shading point is calculated according to the first dot product result and the roughness of the target shading point.
3. The method according to claim 2, characterized in that Determining the sight direction vector according to the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint includes: Calculate the difference between the world space coordinate value of the target shading point and the world space coordinate value of the current viewpoint; The difference is normalized to obtain the sight direction vector.
4. The method according to claim 2, characterized in that The determining of the midline vector according to the sight direction vector and the illumination direction vector comprises: Obtaining the sum of the sight direction vector and the illumination direction vector; The sum is normalized to obtain the centerline vector.
5. The method according to claim 1, characterized in that The step of determining the color operation result according to the plurality of different positions marked with the plurality of logos in the logo map and the color parameters corresponding to each of the logos includes: Obtaining a value to be calculated at a position corresponding to each of the multiple identifiers; Multiply the value to be calculated corresponding to each identifier by the color parameter corresponding to the identifier to obtain a color parameter product result; Adding the product results of the color parameters corresponding to each of the multiple identifiers to obtain a color parameter sum result; The color parameter sum is multiplied by the albedo map to obtain the color operation result.
6. The method according to claim 5, characterized in that The step of obtaining the value to be calculated at the position corresponding to each of the multiple identifiers includes: For each of the plurality of identifiers, calculating a difference between a digital value of the identifier and a digital identifier corresponding to each of the plurality of pixel points; If the difference is less than the preset difference threshold, the value to be calculated of the pixel point whose difference is less than the preset difference threshold is set to 1; If the difference is not less than the preset difference threshold, the value to be calculated of the pixel point whose difference is not less than the preset difference threshold is set to 0; The step of multiplying the numerical value to be calculated corresponding to each identifier by the color parameter corresponding to the identifier to obtain a color parameter product result includes: The numerical values to be calculated of the plurality of pixel points are multiplied by the color parameters corresponding to the current annotation to obtain a color parameter multiplication result.
7. The method according to claim 1, characterized in that The obtaining of the vector product parameter corresponding to each of the shading points comprises: For each of the shading points, obtaining a preliminary vector product parameter; Mapping the primary vector product parameter to a preset value range to obtain a secondary vector product parameter; The second selected vector product parameter is processed by using a smooth step function to obtain the vector product parameter.
8. The method according to claim 7, characterized in that The step of obtaining the preliminary vector product parameter comprises: Perform a dot multiplication operation on the normal direction vector and the illumination direction vector to obtain the preliminary vector product parameter.
9. A virtual character clothing rendering device, characterized in that: The device comprises: A data acquisition unit, configured to acquire a normal direction vector and a roughness of each of a plurality of shading points, wherein the plurality of shading points belong to the same target shading surface, and the target shading surface is any one of a plurality of planes included in the three-dimensional model of the clothing of the virtual character; A highlight component calculation unit, used for calculating a target highlight component corresponding to each shading point according to an illumination direction vector, a normal direction vector of each shading point, and a roughness of each shading point; an identification map acquisition unit, used to acquire an identification map related to the clothing of the virtual character, wherein the identification map carries a plurality of identifications, the plurality of identifications are respectively marked at a plurality of different positions of the identification map, each of the identifications has its own corresponding color parameter, and the plurality of identifications are digital identifications; the identification map includes a plurality of pixel points, and the plurality of pixel points correspond one-to-one to the plurality of coloring points; A color operation result unit is used to determine a color operation result according to a plurality of different positions marked with a plurality of identifiers in the identifier map and a color parameter corresponding to each of the identifiers, including: determining a value to be operated corresponding to each pixel point according to a difference between a digital value of each identifier in the plurality of identifiers and a numerical identifier corresponding to each of the plurality of pixels; and calculating the color operation result based on the values to be operated of the plurality of pixels, the color parameters corresponding to the current marking, and the albedo map; A diffuse reflection component unit, used for obtaining a vector product parameter corresponding to each of the shading points, and multiplying the vector product parameter by the color operation result to obtain a diffuse reflection component corresponding to each of the shading points; The rendering result acquisition unit is used to render the three-dimensional model of the virtual character's clothing according to the target highlight component corresponding to each of the shading points and the diffuse reflection component corresponding to each of the shading points to obtain a rendering result.
10. 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 clothing rendering method according to any one of claims 1 to 8.
11. 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 clothing rendering method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Direct3D 11-based 3D graphics rendering engine
CN106056661A
Object rendering method and device, storage medium and electronic device
CN111009026A
Face picture highlight removal method based on deep learning and realistic rendering
CN111583128A
Model rendering method and device, storage medium and computer equipment
CN112053423A
Method and device for rendering water body surface, equipment and computer readable storage medium
CN112819941A
