Light and shadow rendering method, device, equipment and storage medium

By adjusting the vertex normals of the virtual character face model and generating a normal map, the problem of disharmonious light and shadow effects in the rendering of virtual characters is solved, and the texture and fidelity of the animation picture are improved.

CN114119851BActive Publication Date: 2025-09-05SHANGHAI PERFECT WORLD SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111486602.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-07
Publication Date
2025-09-05
Estimated Expiration
2041-12-07

AI Technical Summary

Technical Problem

In the light and shadow rendering of virtual character face models, it is difficult to achieve the light and shadow effect of celluloid animation while conforming to real physical lighting, resulting in disharmonious light and shadow effects of the face model and body part model, affecting the texture of the animation picture.

Method used

By adjusting the vertex normal of the virtual character face model, generating a normal map, and rendering the light and shadow effect based on the normal map and the second face model, obtaining the light and shadow effect that meets the expectations.

Benefits of technology

It improves the texture of the animation screen, avoids the dissonance between the face model and the body part model under different lighting, and enhances the fidelity and user experience of the animation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114119851B_ABST
    Figure CN114119851B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a light and shadow rendering method, apparatus, device, and storage medium. The method includes: obtaining a first face model to be rendered for light and shadow effects in a real-time animation scene in a game; adjusting the vertex normals in the first face model; generating a normal map based on the adjusted first face model; rendering light and shadow effects based on the normal map and a second face model to obtain the light and shadow effects of the second face model in the real-time animation scene in the game, wherein the second face model is obtained by adjusting the vertex normals of the face model in the cutscene. In the real-time animation scene in the game, the vertex normals in the first face model are adjusted, and then the normal information corresponding to the adjusted first face model is baked into the second face model to obtain a normal map. Finally, rendering processing is performed based on the normal map and the second face model to obtain the expected light and shadow effects, thereby improving the texture of the animation picture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of animation rendering technology, and in particular to a light and shadow rendering method, device, equipment and storage medium. Background Art

[0002] Cartoon shading involves applying a color scale to the light and shadow transitions of virtual characters, in order to achieve the lighting and shadow effects of cel animation. However, the expression of cel animation is highly subjective. To achieve beautiful lighting and shadow effects, the lighting of virtual characters in cel animation does not completely conform to real physical lighting.

[0003] In the case of completely compliant with real physical lighting, that is, when the face model corresponding to the virtual character is not specially processed, the light and shadow near the mouth of the face model will not only fail to conform to the light and shadow effects of cel animation, but will also become unsightly due to the color gradation of the light and shadow transition, thus affecting the texture of the animation. Figure 1-Figure 2 As shown, Figure 1-Figure 2 The middle left picture shows the lighting effect obtained by rendering the face model corresponding to the virtual character without any special processing. Figure 1-Figure 2 The middle right picture shows the ideal lighting effect that is consistent with cel animation.

[0004] Related technologies have proposed solutions to this problem, primarily by reducing the shadows of the facial model and locking the lighting source to address the lighting and shadow effects of the facial model. However, these solutions produce a lighting and shadow effect that is virtually unaffected by physical lighting, creating a strong sense of dissonance with the lighting and shadow effects of the body model, and the quality of the animation remains poor. Summary of the Invention

[0005] The embodiments of the present invention provide a light and shadow rendering method, apparatus, device and storage medium for improving the texture of animation images.

[0006] In a first aspect, an embodiment of the present invention provides a light and shadow rendering method, the method comprising:

[0007] Obtain the first face model to be rendered for light and shadow effects in a real-time animation scene in the game;

[0008] Adjusting vertex normals in the first face model;

[0009] generating a normal map based on the adjusted first face model;

[0010] Light and shadow effects are rendered based on the normal map and the second face model to obtain light and shadow effects of the second face model in the real-time animation scene of the game, wherein the second face model is obtained by adjusting the vertex normals of the face model in the cutscene animation.

[0011] In a second aspect, an embodiment of the present invention provides a light and shadow rendering device, comprising:

[0012] An acquisition module is used to obtain a first face model to be rendered for light and shadow effects in a real-time animation scene in the game;

[0013] an adjustment module, configured to adjust vertex normals in the first face model;

[0014] a generating module, configured to generate a normal map based on the adjusted first face model;

[0015] A rendering module is used to render light and shadow effects based on the normal map and the second face model to obtain the light and shadow effects of the second face model in the real-time animation scene of the game, wherein the second face model is obtained by adjusting the vertex normals of the face model in the cutscene animation.

[0016] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores executable code, and when the executable code is executed by the processor, the processor can at least implement the light and shadow rendering method in the first aspect.

[0017] In a fourth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the light and shadow rendering method in the first aspect.

[0018] By adopting the present invention, in a real-time animation scene in a game, the vertex normals in the first face model can be adjusted, and then the normal information corresponding to the adjusted first face model can be baked into the second face model to obtain a normal map. Finally, rendering processing is performed based on the normal map and the second face model to obtain the expected light and shadow effects. By adopting the method provided by the present invention, it is possible to avoid obtaining light and shadow effects by reducing the shadow of the face model or by locking the light source. Furthermore, the present invention can avoid the problem in the prior art that the face model is almost unaffected by physical lighting. Therefore, the present invention can reduce the sense of disharmony caused by different lighting on the face model and the body part model, and improve the texture of the animation picture. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1-Figure 2 A schematic diagram comparing light and shadow rendering results and expectations provided by an embodiment of the present invention;

[0021] Figure 3 A schematic diagram of a light and shadow rendering method according to an embodiment of the present invention;

[0022] Figure 4-Figure 5 A schematic diagram of a first face model provided by an embodiment of the present invention;

[0023] Figures 6-10 A schematic diagram of a key animation frame provided by an embodiment of the present invention;

[0024] Figure 11-Figure 15 A schematic diagram of facial wiring corresponding to a key animation frame provided by an embodiment of the present invention;

[0025] Figure 16-17 A schematic diagram of adjusting a first face model provided by an embodiment of the present invention;

[0026] Figure 18 A schematic diagram of a normal map provided by an embodiment of the present invention;

[0027] Figures 19-22 A schematic diagram of adjusting a second face model provided by an embodiment of the present invention;

[0028] Figure 23-Figure 25 A schematic diagram of adjusting the scalp portion provided by an embodiment of the present invention;

[0029] Figure 26-Figure 27 A schematic diagram of adjusting another second face model provided by an embodiment of the present invention;

[0030] Figure 28 A schematic structural diagram of a light and shadow rendering device provided by an embodiment of the present invention;

[0031] Figure 29 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0032] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0033] The terms used in the embodiments of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. The singular forms "a," "an," "the," and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, and unless the context clearly indicates otherwise, "a plurality" generally includes at least two.

[0034] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to the determination" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)," depending on the context.

[0035] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.

[0036] Figure 3 The flowchart of a light and shadow rendering method provided by an embodiment of the present invention can be applied to electronic devices. Figure 3 As shown, the method includes the following steps:

[0037] 301. Obtain a first face model to be rendered for light and shadow effects in a real-time animation scene in the game.

[0038] 302. Adjust vertex normals in the first face model.

[0039] 303. Generate a normal map based on the adjusted first face model.

[0040] 304. Perform light and shadow effect rendering based on the normal map and the second face model to obtain light and shadow effects of the second face model in a real-time animation scene in the game, wherein the second face model is obtained by adjusting the vertex normals of the face model in the cutscene animation.

[0041] In practical applications, in-game animations can include real-time animations. Real-time animations are animations that users can manipulate during game exploration or combat. In-game animations can also include cutscenes. Cutscenes are animations related to in-game scenes, characters, or plots. They serve to connect the plot during gameplay and enhance the detailed descriptions and plot of the game. To make the animations more realistic and enhance the user experience, a specific lighting scheme is generally used to illuminate the virtual characters. This creates shadows at appropriate locations on the virtual characters, creating the desired lighting effects through the changes in light and dark at different locations on the virtual characters.

[0042] It is understandable that real-time animation may include a model of a virtual character, which may be divided into a face part and a body part. The embodiment of the present invention mainly provides a rendering solution for the face part in real-time animation.

[0043] In the process of rendering real-time animation in the game, a first face model can be obtained, the vertex normals in the first face model can be adjusted, a normal map can be generated based on the adjusted first face model, and light and shadow effects can be rendered based on the normal map and the second face model to obtain the light and shadow effects of the second face model in the real-time animation scene in the game.

[0044] It should be noted that the face model is composed of multiple meshes, and each mesh includes a preset number of vertices. For example, a mesh may include 3 vertices (triangles) or 4 vertices (quads). For each vertex, a corresponding normal is set, and the normal has a certain direction or angle.

[0045] It's worth noting that the surface of a face model can be considered uneven, with normals calculated for each vertex of this uneven surface. By placing a light source at a specific location, the normals can be used to generate precise lighting direction and reflection effects with high detail, even on a face model with low detail.

[0046] Optionally, the above-mentioned process of adjusting the vertex normals in the first face model can be implemented as follows: obtaining a key animation frame; based on the key animation frame, determining multiple face wirings in the first face model, each face wiring in the first face model is composed of multiple vertices connected together; adjusting the normal degrees corresponding to each vertex located on different face wirings in the first face model.

[0047] like Figure 4 As shown, the unadjusted first face model can be seen Figure 4 , the first face model in the real-time animation after adjusting the face wiring can be seen Figure 5 shown.

[0048] First, you can use the original drawing setting method to manually draw the key animation frames in the real-time animation using drawing software. Figures 6-10 As shown in the figure, the light and shadow effects of a virtual character's face under different lighting conditions can be used as key frame animations. Then, based on the key animation frames, multiple face wirings in the first face model can be determined. In practical applications, the face wirings in the first face model can be determined by manual annotation. Figure 11-Figure 15 As shown, this is the face wiring diagram in the first face model, corresponding to Figures 6-10 The keyframe animation shown. All face wiring results are visible in the first face model of the final real-time animation. Figure 5 As shown, the face wiring of the first face model after the face wiring is adjusted needs to be roughly consistent with the face wiring in the first face model that has not been adjusted.

[0049] It should be noted that the expected lighting and shadow effects of real-time animation mainly include the following parts: nose; side of cheek; front of cheek; Rembrandt light; forehead; philtrum, lips, and chin.

[0050] After obtaining the facial wiring for the first face model in the real-time animation, you can adjust the vertex normals of each face wiring in the first face model. It should be noted that to reduce the effort required to adjust the vertex normals, you can first adjust the right half of the face model and then copy the right half to the left half. This way, you can achieve the overall effect of the first face model in the real-time animation by adjusting only half of the face model.

[0051] Based on this, optionally, the first face model includes a right half face model and a left half face model, and the process of adjusting the vertex normals in the first face model can be implemented as follows: obtaining key animation frames; based on the key animation frames, determining multiple face wirings in the right half face model, each face wiring in the right half face model is composed of multiple vertices connected together; adjusting the normal degrees corresponding to each vertex on different face wirings in the right half face model; and determining the adjusted first face model based on the adjusted right half face model.

[0052] Among them, the method for adjusting the normal degrees corresponding to each vertex located on different face wirings in the right half face model can be: identifying a third vertex set located on a preset type of face wiring in the first face model; determining a fourth vertex set on other face wirings in the first face model except for the face wiring located on the preset type; based on the correspondence between the vertices and normal degrees on the preset face wiring, determining the third degree corresponding to each vertex in the third vertex set located on the preset type of face wiring; based on the third degree corresponding to each vertex in the third vertex set, calculating the fourth degree corresponding to each vertex in the fourth vertex set located on other face wirings; adjusting the normal degree of each vertex in the third vertex set to the corresponding third degree, and adjusting the normal degree of each vertex in the fourth vertex set to the corresponding fourth degree.

[0053] Optionally, the above-mentioned process of calculating the fourth degree corresponding to each vertex in the fourth vertex set located on other human face wirings based on the third degree corresponding to each vertex in the third vertex set can be implemented as follows: based on the positional relationship between other human face wirings and preset types of human face wirings, and the third degree corresponding to each vertex in the third vertex set, calculating the fourth degree corresponding to each vertex in the fourth vertex set located on other human face wirings.

[0054] In the embodiment of the present invention, Figure 16 As shown, the normal angle is the angle in the plane formed by the x-axis and the y-axis, wherein the y-axis is 0° and the x-axis is 90° by default.

[0055] The above-mentioned preset facial routing types can be configured as needed. In certain embodiments, the preset facial routing types may include the profile a-line, cheek and forehead b-line, center c-line, and the inner circle of the Rembrandt light f-line portion of the first facial model in the real-time animation. The normal degrees corresponding to each vertex in the third vertex set on these facial routings are fixed degrees and can be obtained by looking up the correspondence between vertices and normal degrees on the preset facial routing. For example, the normal degrees corresponding to the vertices on the profile a-line of the first facial model in the real-time animation are 85°, the normal degrees corresponding to the vertices on the cheek and forehead b-line are 30°, the normal degrees corresponding to the vertices on the center c-line are 0°, and the normal degrees corresponding to the vertices on the inner circle of the Rembrandt light f-line portion are 3°. The base of the nose can be adjusted downward by 90° along the fixed z-axis.

[0056] In certain optional embodiments, the normal angles corresponding to the vertices on the d-line of the nose portion of the first face model in the real-time animation and the d-line of the transition portion between the front and side faces must be consistent. Furthermore, the normal angles corresponding to the vertices on the e-line of the nose portion of the first face model in the real-time animation and the e-line of the transition portion between the front and side faces must be consistent.

[0057] In some optional embodiments, such as Figure 17 As shown in the real-time animation, the normal angle corresponding to the vertices on line a of the first face model's profile is 85°. The normal angles corresponding to the vertices on the facial wiring lines adjacent to line a decrease by 5°, gradually transitioning to line e, the position of the frontal face transition. The normal angle corresponding to the vertices on line e, the frontal face transition, is 65°, and the normal angle corresponding to the vertices on line d, the frontal face transition adjacent to the right of line e, is 70°. Based on this, the normal angle corresponding to the vertices on line d of the nose is 70°, and the normal angle corresponding to the vertices on line e of the nose is 65°. The shadows of the side of the nose and the base of the nose should be connected and not disconnected.

[0058] In addition, the normal degree corresponding to the vertices on the cheek and forehead b-line of the first face model in real-time animation is 30°. The normal degree corresponding to each facial wiring of the front forehead portion of the first face model in real-time animation can be calculated based on the normal degrees corresponding to the cheek and forehead b-line and the center c-line, as well as the number of wiring segments between the two lines. The number of wiring segments between the two lines is 7, and the normal degree is adjusted by 4.286° each time from the cheek and forehead b-line to the center c-line. During the rotation process, a fixed rotation angle of 4.286° can be set.

[0059] For the forehead transition, the e-line corresponds to a 65° normal, the b-line to a 30° normal, and the number of segments between the two lines is 2. Therefore, the normal adjustment is 17.5° per adjustment. This means that the normal adjustment for the rest of the face between the two lines is 65° - 17.5° = 47.5°. For the cheek transition, the e-line corresponds to a 65° normal, the b-line to a 30° normal, and the number of segments between the two lines is 4. Therefore, the normal adjustment is 8.75° per adjustment.

[0060] For the Rembrandt light of the first face model in the real-time animation, the normal angle corresponding to the middle harvest point is 3°. The transition to the b-line position has a total of 5 segments, so the normal angle is adjusted by 5.4° each time. Based on this, the normal angle corresponding to the outermost circle of the Rembrandt light is 30° - 5.4° = 24.6°.

[0061] In the real-time animation, the normal degree corresponding to the e-line of the nose of the first face model is 65°, the normal degree corresponding to the outermost circle of the Rembrandt light is 24.6°, and the number of wiring segments between the two lines is 4, so the normal degree adjusted each time is 10.1°.

[0062] Based on the above method, we first locate the facial wiring lines of two known normal degrees, and then determine the number of wiring segments between the two lines. In this way, we can calculate the progressive degree by dividing the normal degree difference between the two lines by the number of wiring segments. Then, the normal degrees corresponding to other facial wiring lines between the two lines are calculated according to the number of wiring segments between them and a line in the two lines.

[0063] For the nose base area of ​​the first face model in real-time animation, the original normal angle is 0°. Now we can rotate the normal 90° toward the bottom of the face. In this way, the shadow of the nose base area will not have a diamond-shaped effect, but will have a straight top.

[0064] In addition, the normal angle of the eye white area of ​​the first face model in real-time animation is fixed at 30 degrees. The normal angle corresponding to the mouth corner axis must be set to the same.

[0065] Through the method introduced above, the normal degrees corresponding to the vertices on the facial wiring in the right half face model can be calculated. After determining the normal degrees corresponding to the vertices on the facial wiring in the right half face model, the adjusted first face model in the real-time animation can be determined based on the adjusted right half face model.

[0066] Optionally, the above process of determining the adjusted first face model based on the adjusted right half face model can be implemented as follows: copying the adjusted right half face model; flipping the normal direction corresponding to each vertex in the copied face model; and determining the adjusted first face model based on the adjusted right half face model and the flipped face model.

[0067] In practice, you can first delete the unadjusted left half of the first face model in the real-time animation, then mirror-copy the adjusted right half of the face model to the position of the deleted left half. Since the normal directions of the vertices in the copied face model are opposite, you can flip the normal directions of the vertices in the copied face model.

[0068] Optionally, after flipping, the flipped face model can be used to replace the left half face model in the first face model; the adjusted right half face model and the face model that replaces the left half face model are merged; and the vertices in the merged face model that meet the preset distance conditions are welded to obtain the adjusted first face model.

[0069] It should be noted that after welding, the normals will be broken, that is, some vertices in the first face model correspond to two normals, one of which is the original normal and the other is the adjusted normal. The two normals need to be merged into one.

[0070] Next, a normal map can be generated based on the adjusted first face model in the real-time animation. Optionally, the process of generating a normal map based on the adjusted first face model can be implemented as follows: obtaining normal information of the adjusted first face model; and baking the normal information into the second face model to generate a normal map. An example of the resulting normal map can be seen in Figure 18 shown.

[0071] After obtaining the normal map, lighting and shadow effects can be rendered based on the normal map and the second face model to achieve the lighting and shadow effects of the second face model in real-time animation scenes in the game. This process requires the use of the second face model, which is actually a face model obtained by adjusting the vertex normals of the initial second face model. The second face model can be used to render lighting and shadow effects for cutscenes.

[0072] When adjusting the initial second face model, such as Figure 19 As shown, the normal angle is the angle in the plane formed by the x-axis and the y-axis, wherein the y-axis is 0° and the x-axis is 90° by default.

[0073] Optionally, the above-mentioned process of adjusting the vertex normals in the initial second face model can be implemented as follows: identifying a first set of vertices in the initial second face model that are located on a preset type of face wiring; determining a second set of vertices in the initial second face model that are on other face wirings except for the preset type of face wiring; based on the correspondence between the vertices and normal degrees on the preset face wiring, determining the first degree corresponding to each vertex in the first set of vertices located on the preset type of face wiring; based on the first degree corresponding to each vertex in the first vertex set, calculating the second degree corresponding to each vertex in the second set of vertices located on other face wirings; adjusting the normal degree of each vertex in the first vertex set to the corresponding first degree, and adjusting the normal degree of each vertex in the second vertex set to the corresponding second degree.

[0074] The above-mentioned preset types of face wiring can be set according to the needs. In some embodiments, such as Figure 20 As shown, the preset types of facial wiring can be the side face a line, the cheek and forehead b line, the center c line, and the inner circle of the Rembrandt light f line. The normal degree corresponding to each vertex in the first vertex set on these facial wirings is a fixed degree, which can be obtained by looking up the correspondence between the vertices and normal degrees on the preset facial wiring. For example, the normal degree corresponding to the vertex on the side face a line is 85°, the normal degree corresponding to the vertex on the cheek and forehead b line is 30°, the normal degree corresponding to the vertex on the center c line is 0°, and the normal degree corresponding to the vertex on the inner circle of the Rembrandt light f line is 3°. In addition, as Figure 21As shown, the normal degrees corresponding to the vertices at the eyes and whites of the eyes can also be adjusted to 0°.

[0075] After determining the first degree corresponding to each vertex in the first vertex set, the second degree corresponding to each vertex in the second vertex set can be calculated based on the first degree corresponding to each vertex in the first vertex set. The second face model includes multiple face wirings, and the second vertex set is vertices on face wirings other than the aforementioned preset type of face wirings in the multiple face wirings. After determining the first degree and the second degree, the normal degree of each vertex in the first vertex set can be adjusted to the corresponding first degree, and the normal degree of each vertex in the second vertex set can be adjusted to the corresponding second degree.

[0076] For example, the normal degree corresponding to the vertex on the side face line a is 85°, and the normal degree corresponding to the side face wiring gradually decreases by 5° from the side face line a to the corner of the eye. The normal degree corresponding to the first face wiring from the side face line a to the corner of the eye is 80°, and so on. The normal degree corresponding to the third face wiring is 70°, and the normal degree corresponding to the fourth face wiring next to the corner of the eye is 65°.

[0077] The third facial wiring mentioned above can also be called the d-line of the front-side face turning part. In some optional embodiments, the normal angles corresponding to the vertices on the d-line of the nose part and the d-line of the front-side face turning part must be consistent. The fourth facial wiring mentioned above next to the eye corner can also be called the e-line of the front-side face turning part. In some optional embodiments, the normal angles corresponding to the vertices on the e-line of the nose part and the e-line of the front-side face turning part must be consistent. Based on this, after determining the normal angles corresponding to the vertices on the d-line of the front-side face turning part and the e-line of the front-side face turning part, the determined normal angles can be copied to the triangular area on the side of the nose, that is, the normal angle corresponding to the d-line of the nose part is adjusted to 70°, and the normal angle corresponding to the e-line of the nose part is adjusted to 65°.

[0078] Optionally, the above process of calculating the second degrees corresponding to each vertex in the second vertex set located on other human face wirings based on the first degrees corresponding to each vertex in the first vertex set can be implemented as follows: based on the positional relationship between other human face wirings and preset types of human face wirings, and the first degrees corresponding to each vertex in the first vertex set, calculating the second degrees corresponding to each vertex in the second vertex set located on other human face wirings.

[0079] The positional relationship between the aforementioned other face wirings and the preset face wiring type can be the number of wiring segments between the other face wirings and the preset face wiring type. Based on this, the second degree corresponding to each vertex in the second vertex set located on the other face wirings can be calculated based on the number of wiring segments between the other face wirings and the preset face wiring type and the first degree corresponding to each vertex in the first vertex set.

[0080] In practical applications, the number of wiring segments from one face wiring to another face wiring in two preset types of face wiring can be determined, and multiple other face wirings will be sandwiched between the two preset types of face wiring. Knowing the normal degrees corresponding to the two preset types of face wiring, the normal degree difference between the two preset types of face wiring can be calculated. According to the normal degree difference and the above-mentioned number of wiring segments, the progressive gradient is calculated. After obtaining the progressive degree, the normal degree corresponding to any face wiring in the other face wirings can be determined based on the number of wiring segments between the face wiring with the largest normal degree in the two preset types of face wirings and the progressive degree. Among them, the formula for calculating the progressive gradient is as follows:

[0081] Progressive degree = normal degree difference ÷ number of wiring segments

[0082] For example, if Figure 22 As shown above, the normal degree corresponding to the vertices on the center line c is 0°, and the normal degree corresponding to the vertices on the cheek and forehead lines b is 30°. There are 7 wiring segments from line c to line b, so the progressive degree is (30°-0°) ÷ 7 = 4.286°. Starting from line d, the normal degree corresponding to the first facial wiring adjacent to line d is 30°-4.286° = 25.714°, and the normal degree corresponding to the second facial wiring is 25.714°-4.286° = 21.428°... and so on. The normal degrees corresponding to the other facial wirings sandwiched between lines c and b can be calculated.

[0083] For another example, the normal degree corresponding to line e is 65°, the normal degree corresponding to line b is 30°, and there are 2 wiring segments from line e to line b. Then the normal degree corresponding to the face wiring is 65°-(65°-30°)÷2=47.5°.

[0084] In addition, for the head in the second face model, a sphere can be created, and the normal degree corresponding to each vertex in the sphere is preset. Figure 23-24 As shown, the normal degree corresponding to the sphere is transmitted to the head. After the transmission, as Figure 25 As shown, the user can manually adjust the position of the z-axis so that the normal of the head and the normal of the forehead are seamlessly connected.

[0085] like Figure 26-Figure 27 As shown, to achieve optimal lighting and shadow effects, the facial wiring for the brow arch and upper eyelid in the second face model must be designed very regularly, and the corresponding normal angles must be consistent. It should be noted that the shape of the shadows is directly linked to the facial wiring, and the normal angles and lighting and shadow effects are directly determined by the shape of the facial wiring.

[0086] The present invention can satisfy the requirements of clean edges of ultra-close-up shadows and subjectively controllable light and shadow, while also ensuring natural transitions in real-time animation battles in games and light and shadow effects that conform to celluloid animation.

[0087] The facial models rendered in real-time animation scenes using this invention are suitable for full-frame game combat and world exploration, and they don't feel out of place in games running at 60 frames per second or higher. This method allows for smooth transitions between light and shadow in intermediate frames where the facial model isn't needed, while also preventing unsightly lingering in unsightly areas. Therefore, a first facial model is generated, and the vertex normals corresponding to the first facial model are adjusted to create a first facial model for real-time animation scenes that produces natural transitions and cel-shaded effects.

[0088] Because the transition between light and shadow follows the facial wiring, the adjusted facial wiring of the first face model is not suitable for animation, especially animation with exaggerated expressions. Therefore, the normal information of the adjusted first face model needs to be baked onto the second face model to form a normal map.

[0089] The method provided by the embodiments of the present invention is also applicable to multiple levels of detail (LOD) of various specifications. This allows for natural transitions of shadows on facial models and consistent lighting effects in real-time animated combat and world exploration in games. Even in extreme close-ups, soft edge processing can mitigate minor jagged edges in shadows.

[0090] The present invention allows users to experience a game closer to two-dimensional animation, providing a better immersive experience and allowing users to more easily feel the charm of the original and two-dimensional animation. The quality of real-time animation in the game is improved from the screen, and the game can be made longer and more vibrant.

[0091] By adopting the present invention, in a real-time animation scene in a game, the vertex normals in the first face model can be adjusted, and then the normal information corresponding to the adjusted first face model can be baked into the second face model to obtain a normal map. Finally, rendering processing is performed based on the normal map and the second face model to obtain the expected light and shadow effects. By adopting the method provided by the present invention, it is possible to avoid obtaining light and shadow effects by reducing the shadow of the face model or by locking the light source. Furthermore, the present invention can avoid the problem in the prior art that the face model is almost unaffected by physical lighting. Therefore, the present invention can reduce the sense of disharmony caused by different lighting on the face model and the body part model, and improve the texture of the animation picture.

[0092] The following describes in detail one or more embodiments of the light and shadow rendering device of the present invention. Those skilled in the art will appreciate that these light and shadow rendering devices can be constructed using commercially available hardware components and configured according to the steps taught in this solution.

[0093] Figure 28 A structural diagram of a light and shadow rendering device provided by an embodiment of the present invention is shown in FIG. Figure 28 As shown, the device includes:

[0094] An acquisition module 281 is used to acquire a first face model to be rendered with light and shadow effects in a real-time animation scene in a game;

[0095] An adjustment module 282, configured to adjust vertex normals in the first face model;

[0096] A generating module 283, configured to generate a normal map based on the adjusted first face model;

[0097] A rendering module 284 is configured to render light and shadow effects based on the normal map and the second facial model to obtain light and shadow effects of the second facial model in a real-time animation scene in the game, wherein the second facial model is obtained by adjusting the vertex normals of the facial model in the cutscene.

[0098] Optionally, the adjustment module 282 is configured to:

[0099] Get key animation frames;

[0100] Determining, based on the key animation frame, a plurality of facial wirings in the first facial model, each facial wiring in the first facial model being composed of a plurality of vertices connected together;

[0101] The normal degrees corresponding to the vertices on different face wirings in the first face model are adjusted.

[0102] Optionally, the first face model includes a left half face model and a right half face model, and the adjustment module 282 is configured to:

[0103] Get key animation frames;

[0104] Determining, based on the key animation frame, a plurality of facial wirings in the right half face model, each facial wiring in the right half face model being composed of a plurality of vertices connected together;

[0105] Adjusting the normal degrees corresponding to the vertices on different face wirings in the right half face model;

[0106] Based on the adjusted right half face model, an adjusted first face model is determined.

[0107] Optionally, the adjustment module 282 is configured to:

[0108] Copy the adjusted right half face model;

[0109] Flip the normal direction corresponding to each vertex in the copied face model;

[0110] An adjusted first face model is determined based on the adjusted right half face model and the flipped face model.

[0111] Optionally, the adjustment module 282 is configured to:

[0112] Replace the left half face model in the first face model with the flipped face model;

[0113] Merging the adjusted right half face model and the face model replacing the left half face model;

[0114] Vertices that meet a preset distance condition in the merged face model are welded to obtain an adjusted first face model.

[0115] Optionally, the generating module 283 is configured to:

[0116] Obtaining normal information of the adjusted first face model;

[0117] The normal information is baked into the second face model to generate a normal map.

[0118] Optionally, the adjustment module 282 is further configured to:

[0119] Obtain an initial second face model;

[0120] The vertex normals in the initial second face model are adjusted to obtain the second face model.

[0121] Optionally, the adjustment module 282 is configured to:

[0122] Identifying a first vertex set located on a face wiring of a preset type in the initial second face model;

[0123] Determining a second set of vertices on other face wirings other than the face wirings of the preset type in the initial second face model;

[0124] Determining, based on a correspondence between vertices and normal degrees on a preset face wiring, a first degree corresponding to each vertex in the first vertex set on the preset type of face wiring;

[0125] Calculating, based on the first degrees corresponding to the vertices in the first vertex set, the second degrees corresponding to the vertices in the second vertex set located on the other face wirings;

[0126] The degree of the normal of each vertex in the first vertex set is adjusted to a corresponding first degree, and the degree of the normal of each vertex in the second vertex set is adjusted to a corresponding second degree.

[0127] Optionally, the adjustment module 282 is configured to:

[0128] Based on the positional relationship between the other human face wirings and the preset type of human face wirings, and the first degrees corresponding to each vertex in the first vertex set, the second degrees corresponding to each vertex in the second vertex set located on the other human face wirings are calculated.

[0129] Figure 28 The device shown can perform the aforementioned Figures 1 to 27 The light and shadow rendering method provided in the illustrated embodiment, the detailed execution process and technical effects are described in the aforementioned embodiments and will not be repeated here.

[0130] In one possible design, the above Figure 28 The structure of the light and shadow rendering device shown can be implemented as an electronic device, such as Figure 29 As shown, the electronic device may include: a processor 91 and a memory 92. The memory 92 stores executable code, and when the executable code is executed by the processor 91, the processor 91 can at least implement the above-mentioned Figures 1 to 27 The light and shadow rendering method provided in the illustrated embodiment.

[0131] Optionally, the electronic device may further include a communication interface 93 for communicating with other devices.

[0132] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the aforementioned Figures 1 to 27 The light and shadow rendering method provided in the illustrated embodiment.

[0133] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Those skilled in the art can understand and implement the present invention without inventive effort.

[0134] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by a combination of hardware and software. Based on this understanding, the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0135] The light and shadow rendering method provided in the embodiment of the present invention can be executed by a certain program / software, which can be provided by the network side. The electronic device mentioned in the above embodiment can download the program / software to a local non-volatile storage medium, and when it needs to execute the above light and shadow rendering method, the program / software is read into the memory by the CPU, and then the CPU executes the program / software to implement the light and shadow rendering method provided in the above embodiment. The execution process can be referred to in the above Figures 1 to 27 Instructions in .

[0136] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A light and shadow rendering method, characterized in that: include: Obtaining a first face model to be rendered for light and shadow effects in a real-time animation scene in a game; the first face model includes a left half face model and a right half face model; Get key animation frames; Determining, based on the key animation frame, a plurality of facial wirings in the right half face model, each facial wiring in the right half face model being composed of a plurality of vertices connected together; Adjusting the normal degrees corresponding to the vertices on different face wirings in the right half face model; Copy the adjusted right half face model; Flip the normal direction corresponding to each vertex in the copied face model; Determining an adjusted first face model based on the adjusted right half face model and the flipped face model; generating a normal map based on the adjusted first face model; Light and shadow effects are rendered based on the normal map and the second face model to obtain light and shadow effects of the second face model in the real-time animation scene of the game, wherein the second face model is obtained by adjusting the vertex normals of the face model in the cutscene animation.

2. The method according to claim 1, characterized in that The adjusting the vertex normals in the first face model includes: Get key animation frames; Determining, based on the key animation frame, a plurality of facial wirings in the first facial model, each facial wiring in the first facial model being composed of a plurality of vertices connected together; The normal degrees corresponding to the vertices on different face wirings in the first face model are adjusted.

3. The method according to claim 1, characterized in that The step of determining the adjusted first face model based on the adjusted right half face model and the flipped face model includes: Replace the left half face model in the first face model with the flipped face model; Merging the adjusted right half face model and the face model replacing the left half face model; Vertices that meet a preset distance condition in the merged face model are welded to obtain an adjusted first face model.

4. The method according to claim 1, wherein Generating a normal map based on the adjusted first face model includes: Obtaining normal information of the adjusted first face model; The normal information is baked into the second face model to generate a normal map.

5. The method according to claim 1, wherein Before performing light and shadow effect rendering based on the normal map and the second face model, the method further includes: Obtain an initial second face model; The vertex normals in the initial second face model are adjusted to obtain the second face model.

6. The method according to claim 5, characterized in that The adjusting of the vertex normals in the initial second face model includes: Identifying a first vertex set located on a face wiring of a preset type in the initial second face model; Determining a second set of vertices on other face wirings other than the face wirings of the preset type in the initial second face model; Determining, based on a correspondence between vertices and normal degrees on a preset face wiring, a first degree corresponding to each vertex in the first vertex set on the preset type of face wiring; Calculating, based on the first degrees corresponding to the vertices in the first vertex set, the second degrees corresponding to the vertices in the second vertex set located on the other face wirings; The degree of the normal of each vertex in the first vertex set is adjusted to a corresponding first degree, and the degree of the normal of each vertex in the second vertex set is adjusted to a corresponding second degree.

7. The method according to claim 6, characterized in that The calculating, based on the first degrees corresponding to the vertices in the first vertex set, the second degrees corresponding to the vertices in the second vertex set located on the other face wirings, includes: Based on the positional relationship between the other human face wirings and the preset type of human face wirings, and the first degrees corresponding to each vertex in the first vertex set, the second degrees corresponding to each vertex in the second vertex set located on the other human face wirings are calculated.

8. A light and shadow rendering device, characterized in that: include: An acquisition module is used to acquire a first face model to be rendered for light and shadow effects in a real-time animation scene in a game; the first face model includes a left half face model and a right half face model; an adjustment module configured to obtain a key animation frame; determine, based on the key animation frame, multiple facial wirings in the right half face model, each facial wiring in the right half face model being composed of a plurality of vertices connected together; and adjust the normal degrees corresponding to respective vertices located on different facial wirings in the right half face model; Copying the adjusted right half face model; flipping the normal direction corresponding to each vertex in the copied face model; and determining an adjusted first face model based on the adjusted right half face model and the flipped face model; a generating module, configured to generate a normal map based on the adjusted first face model; A rendering module is used to render light and shadow effects based on the normal map and the second face model to obtain the light and shadow effects of the second face model in the real-time animation scene of the game, wherein the second face model is obtained by adjusting the vertex normals of the face model in the cutscene animation.

9. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the light and shadow rendering method according to any one of claims 1 to 7.

10. A non-transitory machine-readable storage medium, characterized in that The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the light and shadow rendering method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Garment 3D modeling method

    CN109598780A

  • Virtual character face model processing method and device

    CN111768488A