An Efficient Vertex Animation Playing Method Based on GPU

By correcting compression and texture baking of skeletal cartoon clips, the problem of GPU memory waste in GPU vertex animation technology is solved, improving game performance and reducing lag.

CN115624745BActive Publication Date: 2025-05-30XIAMEN WOOBEST INTERACTIVE NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211097665.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-08
Publication Date
2025-05-30
Estimated Expiration
2042-09-08

AI Technical Summary

Technical Problem

The existing GPU vertex animation technology has serious problem of GPU memory waste, especially when there are many characters and animations in the game, which leads to a decrease in the game frame rate and a worse player experience.

Method used

By obtaining the vertex position of each frame in the skeleton cartoon clip to be baked, after correction and compression, baking it into the texture, and baking multiple skeleton cartoon clips in the same texture, reducing texture accuracy to reduce memory usage.

Benefits of technology

It effectively reduces the texture's consumption of GPU memory, converts the CPU consumption of skeleton animation into memory consumption, improves game performance, and reduces lag.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115624745B_ABST
    Figure CN115624745B_ABST
Patent Text Reader

Abstract

The present invention discloses an efficient vertex animation playing method based on GPU, comprising the following steps: S1, obtaining vertex positions; S2, correcting and compressing the values of each vertex position; S3, baking multiple skeletal animation segments in the same texture; S4, serializing the animation information of each skeletal animation segment and storing it as an.asset file; S5, the GPU reads the corresponding.asset file and reads the texture to index to the initial texture pixels of the corresponding animation; S6, sampling and restoring the texture for playing. The method of the present invention, on the premise of ensuring the original playing effect, transfers the consumption of the skeletal animation on the CPU to the memory, reduces the consumption of the CPU, effectively improves the game performance, and reduces the phenomenon of stuttering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of game development, and in particular to a GPU-based efficient vertex animation playback method. Background Art

[0002] There are currently two ways to animate models, namely vertex animation and skeletal animation. In skeletal animation, the model has a skeleton structure composed of interconnected "bones", and animation is generated for the model by changing the orientation and position of the bones. Each frame of skeletal animation requires CPU calculation. As the number of game characters on the same screen increases, the CPU runs at high load, and the game will freeze, resulting in a lower game frame rate and a worse player experience. The GPU has much higher computing power than the CPU, so the calculation of updating vertices is performed on the GPU side, which has derived the technology of baking skeletal animation to textures. This is the current GPU vertex animation technology. However, in vertex animation, there is still a serious waste of GPU memory. This is because: the texture editor that bakes skeletal animation to vertex animation is only suitable for single animation baking. When baking a single animation into the corresponding single vertex animation texture, the texture needs to be a power of 2, so there will be a lot of blank pixels. When there are many game characters and animations, it will seriously waste GPU memory. In addition, the RGBAHalf texture format used by the existing vertex animation itself occupies a memory size of 512*512 pixels, which requires 2M memory, which further aggravates the occupation of GPU memory and is not conducive to the display of animation playback effects. Summary of the invention

[0003] To solve the above problems, the present invention provides a GPU-based efficient vertex animation playback method.

[0004] The present invention adopts the following technical solutions:

[0005] An efficient vertex animation playback method based on GPU includes the following steps:

[0006] S1. Get the vertex position of each frame in the skeleton animation clip to be baked;

[0007] S2, correcting and compressing the value of each vertex position;

[0008] S3, baking the corrected compressed vertex position data into a texture, wherein each texture pixel coordinate in the texture corresponds to a frame of skeletal animation, baking multiple skeletal animation clips into the same texture, and using the initial texture pixel and the end texture pixel of each skeletal animation clip as the start index and the end index of the skeletal animation clip respectively;

[0009] S4. Serialize the animation information of each of the bone animation clips separately and store it as an.asset file. The.asset file is named after the bone animation clip name and indexed to the corresponding texture;

[0010] S5. The GPU obtains the corresponding bone animation clip name and its corresponding.asset file according to the planning configuration list, and reads the texture to index to the initial texture pixels of the corresponding animation;

[0011] S6. In step S5, sample and restore the indexed texture and play it.

[0012] Further, in step S1, the vertex positions are obtained through the built-in functions of Unity.

[0013] Further, in step S2, the values of each of the vertex positions are corrected and compressed. Specifically, it includes the following steps:

[0014] S21. Customize and set an offset value offset, and add the values (x, y, z) of the vertex positions to the offset value offset respectively to obtain the values (x1, y1, z1) of the corrected new vertex positions, and each component of the values of the new vertex positions is non-negative;

[0015] S22. Obtain the largest component among the values of the new vertex positions as the compression multiple m, and divide each component of the new vertex positions by the compression multiple m, so as to compress each component into the range of [0, 1]. The values of the compressed vertex positions are (x2, y2, z2), and the m value is used as the w component of the texture pixel.

[0016] Further, in step S3, the texture pixel coordinates are composed of the values of the corrected and compressed vertex positions and the compression multiple, that is, the texture pixel coordinates are (x2, y2, z2, m).

[0017] Further, in step S4, the animation information includes the animation clip name, the number of frames, the length, the start index, the end index, and the number of loops.

[0018] Further, in step S5, the planning configuration list is configured through the inspector view of the animation control script. The planning configuration list is a list of animation names, and each animation name is pre-configured with the corresponding bone animation clip.

[0019] Further, when sampling and playing in step S6, multiply x2, y2, and z2 in the texture pixel coordinates by the compression multiple m respectively, and then subtract the offset value offset to restore the values of the vertex positions to (x, y, z).

[0020] After adopting the above technical solution, compared with the background art, the present invention has the following advantages:

[0021] The method of the present invention bakes all the skeletal animations of the game character onto the same vertex animation texture, and reduces the texture precision by correcting and compressing the vertex data, thereby reducing the occupancy of the texture on the GPU memory. And by sampling and restoring the vertex animation texture in the GPU to play the corresponding animation, on the premise of ensuring the original playback effect, the consumption of the skeletal animation on the CPU is transferred to the memory, reducing the consumption of the CPU, effectively improving the game performance, and reducing the phenomenon of lag. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 It is a flowchart of the method of the present invention. DETAILED DESCRIPTION OF THE INVENTION

[0023] In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0024] Embodiment

[0025] As Figure 1 shown, an efficient vertex animation playback method based on GPU includes the following steps:

[0026] S1. Obtain the vertex positions of each frame in the skeletal animation segment to be baked through the built-in function of Unity. The values of the vertex positions include three components x, y, and z, that is, the value of the vertex position is (x, y, z);

[0027] S2. Correct and compress the values of the vertex positions, which specifically includes the following steps:

[0028] S21. After obtaining the values of the vertex positions of the skeletal animation, set a custom offset value offset, and add the values of the vertex positions (x, y, z) to the offset value respectively to obtain the corrected new vertex position values (x1, y1, z1), and each component of the new vertex position value is not negative, that is, x1, y1, and z1 are all not negative;

[0029] S22. Compare the three components x1, y1, z1 of the new vertex position, obtain the largest component in the values of the new vertex position as the compression multiple m, and divide each component of the new vertex position by the compression multiple m, so as to compress each component into the range of [0, 1]. The compressed vertex position values are (x2, y2, z2), and the m value is used as the w component of the texture pixel.

[0030] Existing vertex animations use the RGBAHalf texture format. Each channel of RGBAHalf is 16 bits, with a range of [-6000, 6000], which occupies a large amount of memory and may have negative values. Each channel of RBGA32 is 8 bits, occupying less memory, but for vertex animations, its range is obviously insufficient. Therefore, in this embodiment, the data of the vertex positions is corrected and compressed through step S2 to reduce the precision and compress it to the range of [0, 1].

[0031] S3. Bake the corrected and compressed vertex position data into the texture. Each segment of texture pixel coordinates in the texture corresponds to one frame of bone animation (because there are about hundreds of vertex positions in one frame of bone animation). Bake multiple bone animation segments in the same texture, and use the initial texture pixel (i.e., the first texture pixel) and the end texture pixel (i.e., the last texture pixel) of each bone animation segment as the start index and end index of the bone animation segment respectively; the texture pixel coordinates are composed of the value of the corrected and compressed vertex position and the compression multiple, that is, the texture pixel coordinates are (x2, y2, z2, m), where w = m. Here, the size of the texture is automatically set according to the pixels required by the bone animation segments to be baked.

[0032] S4. Serialize the animation information of each bone animation segment and store it as an.asset file. The.asset file is named after the bone animation segment name and indexed to the corresponding texture; the animation information includes the animation segment name, the number of frames, the length, the start index, the end index, and the number of loop times. When playing the animation later, sampling and playing will be performed according to the animation information here.

[0033] Through steps S1 - S4, we obtain a vertex animation texture storing multiple bone animation segments and.asset files respectively storing their animation information.

[0034] S5. The GPU obtains the corresponding bone animation segment name and its corresponding.asset file according to the planning configuration list, and reads the texture to index to the initial texture pixel of the corresponding animation; the planning configuration list is configured through the inspector view of the animation control script. The planning configuration list is a list of animation names, and each animation name is pre-configured with the corresponding bone animation segment.

[0035] Generally speaking, the names of the animations played in the game are fixed when they are imported, that is to say, the animation names are fixed. Therefore, we pre-configure these animation names in the script (the animation names are not equal to the names of the currently played animation clips. The animation names are just general names, such as attack, idle, run, etc.). The actual corresponding animation clip names are selected by the planners from the names of the corresponding.asset files, and any animation clips contained in the texture can be selected.

[0036] In this way, during the running process, when called externally, only the name of the animation to be played currently needs to be concerned about, and there is no need to care about what the specific animation clip actually played is, because the actual played animations are configured by the planners, thus realizing the flexible configuration of animations; while during the internal running, the name of the animation clip to be played currently can be obtained through the animation name, and then all the animation information of the corresponding animation clip can be obtained from the.asset file according to the animation clip name. The GPU will find the start index and the number of frames of the animation clip in the texture based on this animation information, and then the shader will perform sampling and playing.

[0037] S6. Sample and restore the texture indexed in step S5 through the shader in Unity and play it. When sampling and playing, multiply x2, y2, and z2 in the texture pixel coordinates by the compression multiple m respectively, and then subtract the offset value offset to restore the vertex position value to (x, y, z). In this way, the final playing effect obtained is the same as the playing effect directly calculated by the CPU, but the memory is reduced by half, effectively improving the performance of the game.

[0038] As described above, only the specific preferred embodiments of the present invention are provided, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. An efficient vertex animation playback method based on GPU, Characterized in that: It includes the following steps: S1. Obtain the vertex positions of each frame in the skeletal animation segment to be baked; S2. Correct and compress the values of each of the vertex positions; S3. Bake the corrected and compressed vertex position data into a texture, where each segment of texture pixel coordinates in the texture corresponds to one frame of skeletal animation. Multiple skeletal animation segments are baked in the same texture, and the initial texture pixel and the ending texture pixel of each skeletal animation segment are used as the start index and the end index of the skeletal animation segment respectively; S4. Serialize the animation information of each of the skeletal animation segments and store it as an.asset file. The.asset file is named after the skeletal animation segment name and is indexed to the corresponding texture; S5. The GPU reads the corresponding skeletal animation segment name and its corresponding.asset file according to the planning configuration list, and reads the texture to index to the initial texture pixel of the corresponding animation; S6. Sample and restore the texture indexed in step S5 and play it.

2. An efficient vertex animation playback method based on GPU as described in claim 1, Characterized in that: In step S1, the vertex positions are obtained through the built-in functions of Unity.

3. An efficient vertex animation playback method based on GPU as described in claim 2, Characterized in that: In step S2, correcting and compressing the values of each of the vertex positions specifically includes the following steps: S21. Customize and set an offset value offset, and add the values (x, y, z) of the vertex positions to the offset value offset respectively to obtain the values (x1, y1, z1) of the corrected new vertex positions, and each component of the values of the new vertex positions is non-negative; S22. Obtain the largest component in the values of the new vertex positions as the compression multiple m, and divide each component of the new vertex positions by the compression multiple m, so as to compress each component into the range of [0, 1]. The compressed values of the vertex positions are (x2, y2, z2), and the m value is used as the w component of the texture pixel.

4. An efficient vertex animation playback method based on GPU as described in claim 3, Characterized in that: In step S3, the texture pixel coordinates are composed of the values of the corrected and compressed vertex positions and the compression multiple, that is, the texture pixel coordinates are (x2, y2, z2, m).

5. An efficient vertex animation playback method based on GPU as described in claim 4, Characterized in that: In step S4, the animation information includes the animation segment name, the number of frames, the length, the start index, the end index, and the number of loops.

6. An efficient vertex animation playback method based on GPU as described in claim 5, Characterized in that: In step S5, the planning configuration list is configured through the inspector view of the animation control script. The planning configuration list is a list of animation names, and each of the animation names is pre-configured with the corresponding skeletal animation segment.

7. An efficient vertex animation playback method based on GPU as described in claim 6, Characterized in that: When sampling and playing as described in step S6, multiply x2, y2, and z2 in the texture pixel coordinates by the compression multiple m respectively, and then subtract the offset value offset to restore the vertex position value to (x, y, z).

Citation Information

Patent Citations

  • A game picture optimization method

    CN109671158A

  • Three-dimensional model rendering method and device, medium and computer equipment

    CN114898048A