GPU animation method based on unity, computer readable storage medium and terminal equipment

By transferring the calculation tasks of unity animation from the CPU to the GPU, the problem of excessive CPU computing load in traditional animation technology is solved, and a smoother and more efficient animation playback effect is achieved.

CN119559306APending Publication Date: 2025-03-04BEIJING XIANLAI HUYU NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411607200.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

In traditional unity animation, the calculation tasks such as animation playback, animation switching and animation fusion are completed by the CPU, resulting in excessive CPU computing load, severe equipment heat, and poor animation operation effect.

Method used

By organically splitting the calculation process of animation data, the calculation process of the CPU part of the animation device is handed over to the GPU for the GPU, making full use of the computing power of the GPU and reducing the computing load of the CPU. The specific steps include storing the animation resource information in the map during the animation development stage, and in the animation running stage, the CPU calculates the time information of the current animation frame and transmits it to the GPU, and collects the resource information and renders the animation frame.

Benefits of technology

It effectively reduces the computing load of the CPU, reduces the heating problem of the animation device, makes the playback process of the animation smoother, and improves the implementation speed and playback effect of the animation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119559306A_ABST
    Figure CN119559306A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a GPU animation method based on unity, a computer readable storage medium and terminal equipment. The animation method comprises the following steps: S1, in an animation development stage, storing resource information in an animation in a map according to a time axis; s2, in an animation running stage, calculating time information of a current animation frame by a CPU (Central Processing Unit) of the animation device according to the time dimension information of the animation; s3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device; and S4, the GPU of the animation device collects resource information in the chartlet according to the received time information of the current animation frame, and renders to obtain the current animation frame. According to the unity-based GPU animation method disclosed by the embodiment of the invention, the resource information of the animation is stored in the chartlet, and the partial calculation process of the CPU of the animation device is carried out by the GPU of the animation device, so that the calculation capability of the GPU is fully utilized, the calculation capability of the CPU is greatly released, the calculation load of the CPU is reduced, and the playing process of the animation is smoother.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer information processing, and in particular relates to a unity-based GPU animation method, a computer-readable storage medium and a terminal device. Background Art

[0002] Usually, in Unity animation, the character resources include the character's skeleton information, vertex information, and material maps, which can be understood as corresponding to the skeleton, skin, and skin color of a real person. In Unity animation, there are about 50 skeleton points on the character, each of which corresponds to a three-dimensional position coordinate (x, y, z), and two skeleton points form a skeleton; the appearance of the character corresponds to several vertices, one of which corresponds to multiple vertices, that is, multiple vertex information is associated with one skeleton information, and the essence of the character's action change is the movement of the skeleton, and the corresponding vertex position changes during the movement of the skeleton. This is the basic principle of Unity animation. For example, the skeleton information of the hand is associated with multiple vertex information of the hand, that is, the skin of the hand is associated with the skeleton of the hand, and the skin must move synchronously with the skeleton during the movement of the hand. In Unity animation, the CPU of the animation running device calculates the vertex information based on the skeleton position according to this basic principle, and then the CPU of the animation running device transmits the vertex information to the GPU of the animation running device. According to the received vertex information, the GPU of the animation running device uses the material map for rendering to complete an animation action.

[0003] The animation switching of Unity animation follows the same action logic, but it just becomes the action of another animation.

[0004] The continuous implementation process of Unity animation is: first record the animation of each action, and the conversion of each action during the animation playback is realized by animation switching; however, during the animation switching process of Unity animation, directly converting the current animation action to the next animation action will make the action change too abrupt, and the visual experience is not good. In order to make the animation action switching transition natural and smooth and improve the visual experience, animation fusion is required. Animation fusion usually refers to adding a certain time transition between two animations, so that the animation switches smoothly to the next animation after a certain time, so that the display of the animation action is natural and smooth, the visual effect feels comfortable, and the experience is better; generally, the added certain time transition is realized as follows: the CPU of the animation running device performs time interpolation calculation based on the skeleton information of the two actions and the set time period, so that the skeleton switches smoothly from one action to the next action within the time period. For example, for the two actions of a character walking and attacking, if the walking animation is switched directly to the attacking animation, the hands will swing below when walking and will be instantly raised when attacking. Such movement changes are obviously abrupt and give people a bad visual experience. Therefore, animation fusion is needed. A transition time should be added when the animation is switched. For example, it takes one second to gradually switch from the walking posture to the attack preparation posture. This visual experience is very comfortable.

[0005] Therefore, in traditional Unity animations, a series of calculations such as animation playback, animation switching, and animation fusion are all performed by the CPU of the animation running device, which results in excessive CPU computing load on the animation running device, severe heating of the animation running device, and poor animation running effect. Summary of the invention

[0006] In view of this, on one hand, some embodiments disclose a GPU animation method based on Unity, comprising the steps of:

[0007] S1, animation development stage, save the animation resource information in the map according to the timeline;

[0008] S2, animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the time information of the current animation frame;

[0009] S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device;

[0010] S4, the GPU of the animation device collects resource information in the texture according to the received time information of the current animation frame, and renders to obtain the current animation frame;

[0011] S5. Repeat steps S2 to S4 continuously to achieve animation playback.

[0012] Furthermore, some embodiments disclose a GPU animation method based on Unity, including an animation implementation method, specifically including:

[0013] S1, animation development stage, save the animation vertex information in the vertex information map according to the timeline;

[0014] S2, animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the time information of the current animation frame;

[0015] S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device;

[0016] S4, the GPU of the animation device collects vertex information of the current animation frame in the vertex information map according to the received time information of the current animation frame, and renders the current animation frame using the material map information to obtain the current animation frame;

[0017] S5. Repeat steps S2 to S4 continuously to achieve animation playback.

[0018] Some embodiments disclose a Unity-based animation method, including an animation implementation method, which specifically includes:

[0019] S1, animation development stage, save the animation skeleton information in the skeleton information map according to the timeline, and store the association information between the animation skeleton and the vertex in the skeleton relationship map;

[0020] S2, animation running stage, the CPU of the animation device calculates the time information of the current animation frame according to the time dimension information of the animation;

[0021] S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device;

[0022] S4, the GPU of the animation device collects the skeleton information of the current animation frame in the skeleton information map and the association information of the skeleton and the vertex of the current animation frame in the skeleton relationship map according to the received current animation frame time information, and then calculates the vertex information through the shader, and renders the current animation frame using the material map information to obtain the current animation frame;

[0023] S5. Repeat steps S2 to S4 continuously to achieve animation playback.

[0024] Some embodiments disclose a Unity-based animation method, including a method for continuously playing multiple animations, specifically including:

[0025] S1. In the animation development stage, the vertex information of multiple animations is saved in the same vertex information map according to the timeline;

[0026] S2. During the animation running phase, according to the time dimension information of the animation, the CPU of the animation device calculates the playback position of the current animation according to the starting point offset time and playback duration of the current animation;

[0027] S3, the CPU of the animation device transmits the playback position of the current animation to the GPU of the animation device;

[0028] S4, the GPU of the animation device loops and plays the current animation according to the playback position and playback duration of the current animation;

[0029] S5, continuously repeating steps S2 to S4 to complete the continuous playback of multiple animations;

[0030] The current animation is played according to an animation implementation method based on a unity-based GPU animation method.

[0031] In some embodiments, the Unity-based animation method disclosed includes a fusion process of the two animations when switching between the two animations, specifically including:

[0032] S1. In the animation development stage, the starting offset time and playback duration of the two animations are saved in the same map according to the timeline;

[0033] S2. During the animation running phase, according to the time dimension information of the animation, the CPU of the animation device transmits the starting point offset time, the playing duration and the interpolation coefficient of the two animations to the GPU of the animation device;

[0034] S3, the GPU of the animation device receives the starting point offset time, the playing duration and the interpolation coefficient of the two animations;

[0035] S4. The GPU of the animation device first samples the vertex information of the currently playing animation, and then samples the vertex information of the animation to be switched, performs interpolation calculation according to the interpolation coefficient, obtains the final position information of the fused animation, and then renders.

[0036] In some embodiments of the unity-based animation method disclosed, the value of the interpolation coefficient P is between 0 and 1, and is determined based on the playback time; the interpolation calculation formula for the final position information is:

[0037] T1×P+T2×(1-P);

[0038] Among them, T1 is the vertex information of the currently playing animation, T2 is the vertex information of the switching animation, and P is the interpolation coefficient.

[0039] Some embodiments disclose a Unity-based GPU animation method, including a method for continuously playing multiple animations, specifically including:

[0040] S1. In the animation development stage, the skeleton information of multiple animations is saved in the same skeleton information map according to the timeline, and the association information between bones and vertices is stored in the same skeleton relationship map;

[0041] S2. During the animation running phase, according to the multiple animation time dimension information, the CPU of the animation device calculates the playback position of the current animation according to the starting point offset time and playback duration of the current animation;

[0042] S3, the CPU of the animation device transmits the playback position of the current animation to the GPU of the animation device;

[0043] S4, the GPU of the animation device plays the current animation according to the playback position of the current animation and the playback duration of the first animation;

[0044] S5. Repeat S2 to S4 continuously to complete the continuous playback of multiple animations.

[0045] Some embodiments disclose a unity-based GPU animation method, wherein when two animations are switched, a fusion process of the two animations is further included, specifically including:

[0046] S1. In the animation development stage, the starting offset time and playback duration of the two animations are saved in the same map according to the timeline;

[0047] S2. During the animation running phase, the CPU of the animation device transmits the starting point offset time, the playing duration and the interpolation coefficient of the two animations to the GPU of the animation device;

[0048] S3, the GPU of the animation device receives the starting point offset time, the playing duration and the interpolation coefficient of the two animations;

[0049] S4. The GPU of the animation device collects the bone information in the bone information map of the current animation and the animation to be switched, and the association information between the bones and vertices in the bone relationship map, and then calculates the vertex information of the current animation and the animation to be switched through the shader, performs interpolation calculation according to the interpolation coefficient, obtains the final position information of the fused animation, and then renders it.

[0050] On the other hand, some embodiments disclose a computer-readable storage medium having a computer program stored thereon. When the computer program is read and executed, the Unity-based GPU animation method disclosed in the embodiments of the present invention is implemented.

[0051] On the other hand, some embodiments disclose a terminal device, which includes a memory, a CPU and a GPU. The memory stores a computer program. When the CPU and the GPU are running, the Unity-based GPU animation method disclosed in the embodiments of the present invention is implemented.

[0052] The Unity-based GPU animation method disclosed in the embodiment of the present invention organically splits the calculation process of animation data, splits part of the calculation process of the CPU of the animation device, and hands it over to the GPU of the animation device, thereby fully utilizing the calculation power of the GPU, while greatly releasing the calculation power of the CPU, reducing the calculation load of the CPU, and effectively solving the heating problem of the animation device, while making the animation playback process smoother. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 , one Flowchart of the GPU animation method based on Unity disclosed in some embodiments;

[0054] Figure 2 , one An animation implementation method disclosed in some embodiments Figure 1 ;

[0055] Figure 3 , one Multiple animation continuous playback processes disclosed in some embodiments Figure 1 ;

[0056] Figure 4 , one The animation fusion process disclosed in some embodiments Figure 1 ;

[0057] Figure 5 , one An animation implementation method disclosed in some embodiments Figure 2 ;

[0058] Figure 6 , one Multiple animation continuous playback processes disclosed in some embodiments Figure 2 ;

[0059] Figure 7 , one The animation fusion process disclosed in some embodiments Figure 2 . DETAILED DESCRIPTION

[0060] The word "embodiment" used herein as an "exemplary" does not necessarily mean that any embodiment described is superior or better than other embodiments. Performance index tests in the embodiments of the present invention are performed using conventional test methods in the art unless otherwise specified. It should be understood that the terms described in the embodiments of the present invention are only used to describe specific implementation methods and are not intended to limit the contents disclosed in the embodiments of the present invention.

[0061] Unless otherwise specified, the technical and scientific terms used herein have the same meanings as commonly understood by ordinary technicians in the technical field to which the embodiments of the present invention belong; other experimental methods and technical means not specifically specified in the embodiments of the present invention refer to experimental methods and technical means commonly used by ordinary technicians in the field.

[0062] The terms "substantially" and "approximately" used herein are used to describe small fluctuations. For example, they can refer to less than or equal to ±5%, such as less than or equal to ±2%, such as less than or equal to ±1%, such as less than or equal to ±0.5%, such as less than or equal to ±0.2%, such as less than or equal to ±0.1%, such as less than or equal to ±0.05%. The numerical data represented or presented in the range format herein are used only for convenience and brevity, and should therefore be flexibly interpreted as including not only the values ​​clearly listed as the limits of the range, but also all independent values ​​or sub-ranges contained in the range. For example, the numerical range of "1-5%" should be interpreted as including not only the clearly listed values ​​of 1% to 5%, but also the independent values ​​and sub-ranges within the range shown. Therefore, independent values ​​such as 2%, 3.5% and 4% and sub-ranges such as 1%-3%, 2%-4% and 3%-5% are included in this numerical range. This principle also applies to the range of only one numerical value. In addition, such an interpretation applies regardless of the width of the range or the characteristics described.

[0063] In this document, including in the claims, transitional words such as "comprises," "includes," "with," "having," "containing," "involving," "accommodating," etc. are understood to be open-ended, i.e., meaning "including but not limited to." Only the transitional words "consisting of" and "composed of" are closed transitional words.

[0064] Central Processing Unit, or CPU for short, is usually the computing and control core of a computer and the final execution unit for information processing and program execution. The central processing unit of an animation device is the computing center and control core of the device to realize the animation process.

[0065] Graphics Processing Unit, or GPU for short, is also called display core, visual processor, display chip or drawing chip. It is a microprocessor that is specially designed to run drawing operations on personal computers, workstations, game consoles and mobile devices (such as tablets, smart phones, etc.). GPU is designed based on the characteristics of graphics and image computing. For animation devices, a GPU device usually integrates hundreds to thousands of lightweight computing cores, which have extremely high computing power for independent SIMD and MIMD calculations, can convert and drive the display information required by the device system, and provide line scanning signals to the display to control the correct display of the display.

[0066] In order to better illustrate the present invention, numerous specific details are provided in the specific examples below. It should be understood by those skilled in the art that the present invention can be implemented without certain specific details. In the embodiments, some methods, means, instruments, equipment, etc. well known to those skilled in the art are not described in detail in order to highlight the gist of the present invention.

[0067] Under the premise of no conflict, the technical features disclosed in the embodiments of the present invention may be arbitrarily combined, and the resulting technical solutions belong to the contents disclosed in the embodiments of the present invention.

[0068] In some embodiments, Figure 1 As shown, the GPU animation method based on Unity includes the following steps:

[0069] S1. In the animation development stage, the resource information of the animation is saved in the texture according to the time axis. Usually, the resource information of the animation usually includes skeleton information, skin vertex information and skin material information. The moving objects in the animation usually include characters, equipment and other objects that need to move, move or change. In the animation development stage, the resource information of all objects in the animation is collected, and the resource information is stored in the corresponding texture according to the time axis, so as to locate and collect the resource information according to the time axis during the animation running stage.

[0070] S2, animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the time information of the current animation frame; usually, an animation includes multiple animation frames, and the continuous playback of multiple animations realizes the playback of an animation; the time information of the animation frame includes the starting playback time and the playback duration. In the animation running stage, according to the time dimension information of the animation running, the CPU calculates the time information of the current animation frame;

[0071] S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device; usually, the CPU transmits the calculated time information of the current animation frame to the GPU for further processing;

[0072] S4, the GPU of the animation device collects resource information in the texture according to the received time information of the current animation frame, and renders to obtain the current animation frame. Usually, after receiving the time information of the current animation frame, the GPU collects resource information of the current animation frame stored in the texture, and further renders to complete the animation;

[0073] S5. Continuously repeat steps S2 to S4 to achieve animation playback. Generally, according to the animation playback time dimension, steps S2 to S4 are repeated to achieve continuous playback of animation frames in the animation.

[0074] In the Unity-based GPU animation method, preliminary work has been done in the animation development stage. The animation resource information is calculated in advance according to the timeline and written into the texture. In the running stage, the CPU only needs to calculate the time of each animation frame according to the time dimension information of the animation, and then push the time data to the GPU according to the playback time dimension information. The GPU samples from the texture according to the time information, obtains the animation resource data, and renders the animation. In this way, a large amount of animation calculation work is completed in advance, and part of the CPU's calculation amount in the animation playback stage is allocated to the GPU and completed by the GPU calculation, which greatly reduces the CPU's calculation time and improves the animation implementation speed and playback effect.

[0075] Some embodiments disclose a unity-based GPU animation method, including an animation implementation method, which is suitable for implementing small animations, such as Figure 2 As shown, specifically including:

[0076] S1. In the animation development stage, the vertex information of the animation is saved in the vertex information map according to the timeline. In the animation development stage, the animation resources are not stored in the traditional fbx file, but the vertex information in the animation is stored in the vertex information map according to the timeline through the tool. For example, in the map, the first line is the time 0, and the data in the first line are all the stored vertex position information. In this way, all the vertex data in the animation can be written into the map. Usually, the size of the animation model is determined by the number of bones and vertices. Animation models with relatively small number of bones and vertices belong to small animations, such as animation models with about 50 bones and about 1000 vertices. Animation models with relatively large number of bones and vertices belong to complex animations, such as animation models with more than 100 bones or more than 10,000 vertices.

[0077] S2, animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the time information of the current animation frame;

[0078] S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device;

[0079] S4, the GPU of the animation device collects vertex information of the current animation frame in the vertex information map according to the received time information of the current animation frame, and renders using the material map information to display the current animation frame;

[0080] S5. Repeat steps S2 to S4 continuously to realize animation playback. Usually, the continuous playback of an animation can be realized by looping steps S2 to S4. For example, for the animation action of a person walking, the complete action of the person walking one step can be realized according to steps S2 to S4.

[0081] In the GPU animation method based on unity, the preparatory work has been done in the animation development stage. The vertex information of the animation is calculated in advance according to the time axis and written into the map. In the running stage, only the CPU needs to calculate the time information of the current animation according to the animation playback time dimension information, and then push the time data to the GPU. The GPU samples the current animation frame according to the time information map to obtain the vertex data of the current animation frame, and renders the current animation frame; the rendering of the current animation frame is repeated continuously according to the playback time dimension information, and the continuous playback of an animation can be achieved. Therefore, in the method disclosed in this embodiment, a large amount of animation calculation work is completed in advance, and part of the CPU calculation amount is allocated to the GPU to complete, which greatly reduces the CPU calculation time and improves the animation realization speed and playback effect. The method disclosed in this embodiment is more suitable for the production and playback of small animations, because the vertex data of the animation needs to be written into the map in the method. If the animation scale is large, it is often necessary to use a large number of maps to store the vertex data, resulting in a large amount of map resource occupancy, and the animation running rate will not be well improved.

[0082] Some embodiments disclose a Unity-based animation method, including a method for continuously playing multiple animations, such as Figure 3 As shown, specifically including:

[0083] S1. In the animation development stage, the vertex information of multiple animations is saved in the same vertex information map according to the timeline;

[0084] S2. During the animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the playback position of the current animation according to the starting offset time and the playback duration of the current animation; wherein the starting offset time is the starting playback time of the current animation, the playback duration is the continuous playback time, and the playback position is the position where the GPU samples in the texture;

[0085] S3, the CPU of the animation device transmits the playback position of the current animation to the GPU of the animation device;

[0086] S4, the GPU of the animation device loops and plays the current animation according to the playback position and playback duration of the current animation;

[0087] S5. Repeat steps S2 to S4 continuously to complete the continuous playback of multiple animations. Usually, in the process of repeating steps S2 to S4, the current animation switches to the next animation according to the time dimension information, and the switching process is continuously performed according to the time dimension information, and the animations are played continuously. Among them, for the playback of each animation, it is necessary to collect the vertex information in the information map and use the material map information for rendering. The playback method of each animation is referred to Figure 2 The illustrated embodiment discloses a GPU animation method.

[0088] For example, the first animation realizes the character walking, and the second animation realizes the character attacking the target; in the map information, lines 0 to 29 are the data of the first animation, and lines 30 to 44 are the data of the second animation; the first animation is 30 frames of data, and the animation frame rate is generally 30 frames. It is calculated that the playback time of the first animation is 1 second, and the playback time of the second animation is 0.5 seconds; the starting point offset time of the first animation is 0s, and the starting point offset time of the second animation is 1s;

[0089] When the first animation is played in a loop, the animation time counter will increase according to the frame time, and will subtract 1 after exceeding one second. In this way, the animation time dimension information will always cycle between 0 and 1 second, so that the character can walk continuously. When the CPU passes the animation time to the GPU, the offset time 0 is added.

[0090] When the second animation is played in a loop, it is only 0.5 seconds long. The animation time dimension information keeps looping between 0 and 0.5 seconds to enable the character to attack the target continuously. When the CPU passes the animation time to the GPU, the starting point offset time of 1 second is added.

[0091] After the GPU obtains the starting point offset time and playback duration, it multiplies the time by the frame rate 30 to calculate the position information of the animation in the current sampling map, samples the vertex data based on the position information, and then renders;

[0092] When switching animations, just reset the animation time to 0, and then use the starting offset time of the animation to be switched to achieve the switch between animation 1 and animation 2.

[0093] In some embodiments of the disclosed Unity-based animation method, when two animations are switched during continuous animation playback, animation fusion needs to be performed. The fusion process of the two animations is as follows: Figure 4 As shown, specifically including:

[0094] S1. In the animation development stage, the starting offset time and the playing duration of the two animations are saved in the same map according to the timeline;

[0095] S2. During the animation running phase, according to the animation playing time dimension information, the CPU of the animation device transmits the starting point offset time, playing time and interpolation coefficient of the two animations to the GPU of the animation device;

[0096] S3, the GPU of the animation device receives the starting point offset time, the playing duration and the interpolation coefficient of the two animations;

[0097] S4. The GPU of the animation device first samples the vertex information of the currently playing animation, and then samples the vertex information of the animation to be switched, performs interpolation calculation according to the interpolation coefficient, obtains the final position information of the fused animation, and then renders.

[0098] Generally, animation fusion is required to make the switching process continuous and smooth when switching animations. The CPU of the animation device will store two sets of animation data and an interpolation coefficient, one set is the animation play time and starting point offset time of the current animation, and the other set is the play time and starting point offset time of the animation to be switched. The interpolation coefficient is a value between 0 and 1; at this time, the CPU gives all this data to the GPU, and the GPU first samples the currently playing animation to obtain vertex data, and then samples the animation to be switched to obtain vertex data, and finally performs interpolation calculations based on the interpolation coefficients to calculate the final position information of the fused animation, and then renders it.

[0099] Usually, the interpolation coefficient is a transition weight value, which is calculated by the CPU according to the fusion time. For example, the transition weight value is 0 at 0s. According to the linear relationship, the transition weight value is 0.5 at 0.5s and 1 at 1s, which means that the animation needs to be fused within 1s. After the animation is fused, the current play time and starting point offset of the animation are the new play time and starting point offset, and the weight coefficient is reset to 0.

[0100] In some embodiments of the unity-based animation method disclosed, the value of the interpolation coefficient P is between 0 and 1, and is determined by calculation based on the playback time; generally, the interpolation calculation of the GPU is a linear calculation, and the interpolation calculation formula of the final position information is:

[0101] T1×P+T2×(1-P);

[0102] Among them, T1 is the vertex information of the currently playing animation, T2 is the vertex information of the switching animation, and P is the interpolation coefficient.

[0103] Some embodiments disclose a Unity-based animation method, including an animation implementation method suitable for implementing complex animations, such as Figure 5 As shown, specifically including:

[0104] S1, animation development stage, save the animation skeleton information in the skeleton information map according to the timeline, and store the association information between the animation skeleton and the vertex in the skeleton relationship map;

[0105] S2, animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the time information of the current animation frame;

[0106] S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device;

[0107] S4, the GPU of the animation device collects the skeleton information of the current animation frame in the skeleton information map and the association information of the skeleton and the vertex of the current animation frame in the skeleton relationship map according to the received time information of the current animation frame, and then calculates the vertex information through the shader and renders the current animation frame using the material map information to obtain the current animation frame;

[0108] S5. Continuously repeat steps S2 to S4 to achieve animation playback. Generally, according to the animation playback time dimension, steps S2 to S4 are repeated to achieve continuous playback of animation frames in the animation.

[0109] This embodiment discloses a GPU animation method suitable for complex animations, which is suitable for the production and playback of complex animations, because in this method, only the skeleton information data of the animation needs to be written into the skeleton information map in the time dimension, and the relationship between the vertex and the skeleton is written into the skeleton relationship map. The GPU collects the information of the skeleton information map and the skeleton relationship map, and calculates the vertex data; a large number of maps will not be used to store the vertex data, so the calculation time of the CPU is greatly reduced, the computing power of the GPU is fully utilized, and the animation realization speed and playback effect are improved. For example, the number of object models in the animation is about 50, and the animation with more than 1000 vertices is a complex animation.

[0110] Some embodiments disclose a GPU animation method based on Unity, including a method for continuously playing multiple animations, such as Figure 6 As shown, specifically including:

[0111] S1. In the animation development stage, the skeleton information of multiple animations is saved in the same skeleton information map according to the timeline, and the association information between the skeletons and vertices of multiple animations is stored in the same skeleton relationship map;

[0112] S2. During the animation running stage, according to the animation time dimension information, the CPU of the animation device calculates the playback position of the current animation according to the starting offset time and playback duration of the current animation; wherein the starting offset time is the starting playback time of the current animation, the playback duration is the continuous playback time, and the playback position is the position where the GPU samples in the texture;

[0113] S3, the CPU of the animation device transmits the playback position of the current animation to the GPU of the animation device;

[0114] S4, the GPU of the animation device loops and plays the current animation according to the playback position and playback duration of the current animation;

[0115] S5, continuously repeating steps S2 to S4 to complete the continuous playback of multiple animations; wherein the playback of the current animation is based on the reference image Figure 5 The illustrated embodiment discloses a Unity-based GPU animation method.

[0116] In some embodiments of the GPU animation method based on Unity, during the continuous playback of animations, when two animations are switched, it is necessary to perform animation fusion. The fusion process of the two animations, such as Figure 7 As shown, specifically including:

[0117] S1. In the animation development stage, the starting offset time and the playing duration of the two animations are saved in the same map according to the timeline;

[0118] S2. During the animation running phase, the CPU of the animation device transmits the starting point offset time, the playing duration and the interpolation coefficient of the two animations to the GPU of the animation device;

[0119] S3, the GPU of the animation device receives the starting point offset time, the playing duration and the interpolation coefficient of the two animations;

[0120] S4. The GPU of the animation device collects the bone information in the bone information map of the current animation and the animation to be switched, and the association information between the bones and vertices in the bone relationship map, and then calculates the vertex information of the current animation and the animation to be switched through the shader, performs interpolation calculation according to the interpolation coefficient, obtains the final position information of the fused animation, and then renders and plays the animation.

[0121] Generally, when switching animations, animation fusion is required to make the switching process continuous and smooth. The CPU of the animation device will store two sets of animation data and an interpolation coefficient. One set is the animation playback time and starting point offset time of the current animation, and the other set is the playback time and starting point offset time of the animation to be switched. The interpolation coefficient is a value between 0 and 1. At this time, the CPU gives all these data to the GPU. The GPU first samples the currently playing animation to obtain vertex data, and then samples the animation to be switched to obtain vertex data. Finally, interpolation calculation is performed according to the interpolation coefficient to calculate the final position information of the animation to be switched, and then renders. In some embodiments, the value of the interpolation coefficient P is between 0 and 1, which is determined based on the playback time calculation. Usually, the interpolation calculation of the GPU is a linear calculation, and the interpolation calculation formula for the final position information is:

[0122] T1×P+T2×(1-P);

[0123] Among them, T1 is the vertex information of the currently playing animation, T2 is the order information of the switching animation, and P is the interpolation coefficient.

[0124] Some embodiments disclose a computer-readable storage medium, on which a computer program is stored. When the computer program is read and executed, the Unity-based GPU animation method disclosed in the embodiments of the present invention is implemented.

[0125] Some embodiments disclose a terminal device, which includes a memory, a CPU and a GPU. The memory stores a computer program. When the CPU and the GPU are running, the Unity-based GPU animation method disclosed in the embodiments of the present invention is implemented.

[0126] The Unity-based GPU animation method disclosed in the embodiment of the present invention organically splits the calculation process of animation data, splits part of the calculation process of the CPU of the animation device, and hands it over to the GPU of the animation device, thereby fully utilizing the calculation power of the GPU, while greatly releasing the calculation power of the CPU, reducing the calculation load of the CPU, and effectively solving the heating problem of the animation device, while making the animation playback process smoother.

[0127] The technical solutions disclosed in the embodiments of the present invention and the technical details disclosed in the embodiments are merely illustrative of the inventive concept of the present invention and do not constitute a limitation on the technical solutions of the embodiments of the present invention. Any conventional changes, replacements or combinations of the technical details disclosed in the embodiments of the present invention have the same inventive concept as the present invention and are within the protection scope of the claims of the present invention.

Claims

1. The GPU animation method based on Unity is characterized by: Includes steps: S1, animation development stage, save the animation resource information in the map according to the timeline; S2, animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the time information of the current animation frame; S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device; S4, the GPU of the animation device collects resource information in the texture according to the received time information of the current animation frame, and renders to obtain the current animation frame; S5. Repeat steps S2 to S4 continuously to achieve animation playback.

2. The GPU animation method based on Unity according to claim 1, characterized in that: Includes an animation implementation method, including: S1, animation development stage, save the animation vertex information in the vertex information map according to the timeline; S2, animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the time information of the current animation frame; S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device; S4, the GPU of the animation device collects vertex information of the current animation frame in the vertex information map according to the received time information of the current animation frame, and renders the current animation frame using the material map information to obtain the current animation frame; S5. Repeat steps S2 to S4 continuously to achieve animation playback.

3. The Unity-based animation method according to claim 1, characterized in that: Includes an animation implementation method, including: S1, animation development stage, save the animation skeleton information in the skeleton information map according to the timeline, and store the association information between the animation skeleton and the vertex in the skeleton relationship map; S2, animation running stage, according to the time dimension information of the animation, the CPU of the animation device calculates the time information of the current animation frame; S3, the CPU of the animation device transmits the time information of the current animation frame to the GPU of the animation device; S4, the GPU of the animation device collects the skeleton information of the current animation frame in the skeleton information map and the association information of the skeleton and the vertex of the current animation frame in the skeleton relationship map according to the received time information of the current animation frame, and then calculates the vertex information through the shader and renders the current animation frame using the material map information to obtain the current animation frame; S5. Repeat steps S2 to S4 continuously to achieve animation playback.

4. A GPU animation method based on Unity, characterized in that: Includes continuous playback of multiple animations, including: S1. In the animation development stage, the vertex information of multiple animations is saved in the same vertex information map according to the timeline; S2. During the animation running phase, according to the time dimension information of the animation, the CPU of the animation device calculates the playback position of the current animation according to the starting point offset time and playback duration of the current animation; S3, the CPU of the animation device transmits the playback position of the current animation to the GPU of the animation device; S4, the GPU of the animation device loops and plays the current animation according to the playback position and playback duration of the current animation; S5, continuously repeating steps S2 to S4 to complete the continuous playback of multiple animations; The current animation is played according to the GPU animation method based on Unity described in claim 2.

5. The GPU animation method based on Unity according to claim 4, characterized in that: The switching between two animations includes the fusion process of the two animations, which includes: S1. In the animation development stage, the starting offset time and the playing duration of the two animations are saved in the same map according to the timeline; S2. During the animation running phase, according to the time dimension information of the animation, the CPU of the animation device transmits the starting point offset time, the playing duration and the interpolation coefficient of the two animations to the GPU of the animation device; S3, the GPU of the animation device receives the starting point offset time, the playing duration and the interpolation coefficient of the two animations; S4. The GPU of the animation device first samples the vertex information of the currently playing animation, and then samples the vertex information of the animation to be switched, performs interpolation calculation according to the interpolation coefficient, obtains the final position information of the fused animation, and then renders.

6. The GPU animation method based on Unity according to claim 5, characterized in that: The value of the interpolation coefficient P is between 0 and 1 and is determined according to the fusion time; The interpolation calculation formula for the final position information is: T1×P+T2×(1-P); Among them, T1 is the vertex information of the currently playing animation, T2 is the vertex information of the switching animation, and P is the interpolation coefficient.

7. The GPU animation method based on Unity is characterized by: Includes a method for continuous playback of multiple animations, including: S1. In the animation development stage, the skeleton information of multiple animations is saved in the same skeleton information map according to the timeline, and the association information of the skeletons and vertices of multiple animations is stored in the same skeleton relationship map; S2. During the animation running phase, according to the time dimension information of the animation, the CPU of the animation device calculates the playback position of the current animation according to the starting point offset time and playback duration of the current animation; S3, the CPU of the animation device transmits the playback position of the current animation to the GPU of the animation device; S4, the GPU of the animation device plays the current animation according to the playback position and playback duration of the current animation; S5, continuously repeating steps S2 to S4 to complete the continuous playback of multiple animations; The current animation is played according to the GPU animation method based on Unity described in claim 3.

8. The GPU animation method based on Unity according to claim 7, characterized in that: The switching between two animations includes the fusion process of the two animations, which includes: S1. In the animation development stage, the starting offset time and the playing duration of the two animations are saved in the same map according to the timeline; S2. During the animation running phase, the CPU of the animation device transmits the starting point offset time, the playing duration and the interpolation coefficient of the two animations to the GPU of the animation device; S3, the GPU of the animation device receives the starting point offset time, the playing duration and the interpolation coefficient of the two animations; S4. The GPU of the animation device collects the bone information in the bone information map of the current animation and the animation to be switched, and the association information between the bones and vertices in the bone relationship map, and then calculates the vertex information of the current animation and the animation to be switched through the shader; performs interpolation calculation according to the interpolation coefficient to obtain the final position information of the fused animation, and then renders it.

9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is read and executed, the animation method according to any one of claims 1 to 8 is implemented.

10. A terminal device, characterized in that: The invention comprises a memory, a CPU and a GPU, wherein the memory stores a computer program, and when the CPU and the GPU are running, the animation method according to any one of claims 1 to 8 is implemented.