A deformation animation processing method and electronic device
By caching the texture layer of the deformation target in the GPU, reducing the CPU's transmission of vertex data to the GPU, solving the problems of large and low transmission load and low efficiency in the existing technology, achieving more efficient and flexible deformation animation processing, and improving the smoothness of the animation and authenticity.
Patent Information
- Application Number
- CN202411546559.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-10-31
AI Technical Summary
In the existing deformation animation processing methods, the CPU needs to frequently pass a large amount of vertex data to the GPU, resulting in a large transmission load between the CPU and the GPU, poor deformation animation efficiency and control flexibility, and insufficient fluency and authenticity.
By cached the texture layer corresponding to each deformation target in the GPU, the CPU only needs to write the target weight, and the GPU calculates the new attribute values of multiple vertices by itself and updates the three-dimensional model, reducing the transmission of vertex data.
It reduces the transmission load between the CPU and the GPU, improves the efficiency and control flexibility of deformation animations, and improves the smoothness and authenticity of the animation.
Smart Images

Figure CN119048648B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of graphics processing technology, and in particular to a deformation animation processing method and electronic equipment. Background Art
[0002] With the development of graphics processing technology, deformation animation models based on vertex offset (such as Graphics Language Transmission Format (GLTF) model) are widely used in game development, virtual reality, augmented reality and other fields due to their cross-platform compatibility, fast loading speed and small file size.
[0003] The current deformation animation processing method is as follows: for each vertex, the central processing unit (CPU) calculates the offset of the vertex under multiple attributes according to the offset data of multiple attributes included in the deformation target, and calculates new attribute values of multiple vertices under multiple attributes according to the offsets of multiple vertices under multiple attributes; writes the new attribute values of multiple vertices under multiple attributes into the graphics processing unit (GPU); the GPU updates the three-dimensional (3D) model according to the new attribute values of multiple vertices to form a deformation animation effect.
[0004] In the above deformation animation processing method, the CPU needs to transfer a large amount of vertex data to the GPU for each frame, the transmission load between the CPU and the GPU is large, the flexibility of deformation animation efficiency control is poor, and the smoothness and authenticity of the deformation animation effect are poor. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a deformation animation processing method and electronic device to reduce the transmission load between the CPU and the GPU, improve the deformation animation efficiency and control flexibility, and enhance the smoothness and authenticity of the deformation animation effect. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for processing a deformation animation, which is applied to a CPU, and the method includes:
[0007] Calculate target weights corresponding to a first number of deformation targets in the current frame according to the sampling time sequence and the sampling value sequence;
[0008] The target weights corresponding to the first number of deformation targets are written into a GPU, and a second number of texture layers corresponding to each deformation target is cached in the GPU. Each texture layer in the second number of texture layers stores vertex offset data of an attribute, so that the GPU determines new attribute values of multiple vertices under the second number of attributes according to the target weights corresponding to each deformation target and the vertex offset data included in each texture layer, and updates the three-dimensional model using the new attribute values of the multiple vertices under the second number of attributes.
[0009] In some embodiments, before calculating the target weight corresponding to each deformation target in the current frame, the method further includes:
[0010] According to the first number and the second number, at least one texture layer is created, each deformation target corresponds to the second number of texture layers, and each attribute corresponds to the first number of texture layers;
[0011] Obtaining vertex offset data of the second number of attributes included in each deformation target;
[0012] Writing the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute;
[0013] The texture layer after the data is written is written into the GPU.
[0014] In some embodiments, the step of creating at least one texture layer according to the first number and the second number comprises:
[0015] Determining a target size of the texture layer according to a third number of vertices included in the three-dimensional model, the target size being a power of 2, and a fourth number of pixels included in the texture layer of the target size being greater than or equal to the third number;
[0016] At least one texture layer of the target size is created according to the first number and the second number.
[0017] In some embodiments, the step of writing the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute includes:
[0018] Extracting vertex offset data of the same attribute included in the first number of deformation targets;
[0019] Writing vertex offset data of the same attribute included in the first number of deformation targets into the first number of consecutive texture layers in the at least one texture layer.
[0020] In some embodiments, the method further comprises:
[0021] Determine a level value of a starting texture layer corresponding to each attribute in the at least one texture layer as a level offset value of each attribute;
[0022] The level offset value of each attribute is written into the GPU, so that the GPU obtains the vertex offset data included in the texture layer corresponding to each attribute according to the level offset value of each attribute.
[0023] In some embodiments, the step of writing the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute includes:
[0024] Determine the pixel in each texture layer corresponding to each vertex;
[0025] For each vertex offset data of each attribute included in each deformation target, multiple component data included in the vertex offset data are written into multiple color spaces of the deformation target and the pixels corresponding to the attribute.
[0026] In some embodiments, the method further comprises:
[0027] If the number of color spaces included in a pixel is greater than the number of component data included in the vertex offset data of an attribute, then in the first number of texture layers corresponding to the attribute, component data is supplemented for each vertex offset data, and the number of component data included in the supplemented vertex offset data is the same as the number of color spaces included in a pixel.
[0028] In a second aspect, an embodiment of the present application provides a method for processing a deformation animation, which is applied to a GPU, wherein a second number of texture layers corresponding to each deformation target is cached in the GPU, and each texture layer in the second number of texture layers stores vertex offset data of an attribute, and the method includes:
[0029] Receive target weights corresponding to the first number of deformation targets written by the CPU;
[0030] Determining new attribute values of a plurality of vertices under the second number of attributes according to a target weight corresponding to each deformation target and vertex offset data included in each texture layer;
[0031] The three-dimensional model is updated using new attribute values of the plurality of vertices under the second number of attributes.
[0032] In some embodiments, the step of determining new attribute values of the plurality of vertices under the second number of attributes according to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer comprises:
[0033] Extracting offset data of each vertex under each attribute from a second number of texture layers corresponding to each deformation target according to the indexes of the plurality of vertices and the level offset value of each attribute;
[0034] Using the offset data of each vertex under each attribute and the target weight corresponding to each deformation target, calculate the new attribute value of each vertex corresponding to each attribute.
[0035] In some embodiments, the level offset value of each attribute is the level value of the starting texture layer corresponding to each attribute;
[0036] The step of extracting offset data of each vertex under each attribute from a second number of texture layers corresponding to each deformation target according to the indexes of the plurality of vertices and the level offset value of each attribute comprises:
[0037] Determine the UV coordinates of each vertex according to the indexes of the plurality of vertices and the size of the texture layer;
[0038] For each attribute, traverse the deformation target; calculate the sum of the level offset value of the attribute and the index of the traversed deformation target to obtain a sampling depth; read the offset data at the UV coordinate of each vertex in the texture layer at the sampling depth; re-execute the step of traversing the deformation target until the first number of deformation targets are traversed.
[0039] In some embodiments, a plurality of threads are run in the GPU, each thread corresponding to a group of vertices among the plurality of vertices;
[0040] The step of determining new attribute values of a plurality of vertices under the second number of attributes according to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer comprises:
[0041] According to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer, new attribute values of the corresponding group of vertices under the second number of attributes are determined in parallel using the multiple threads.
[0042] In a third aspect, an embodiment of the present application provides a deformation animation processing device, which is applied to a CPU, and the device includes:
[0043] A calculation module, used for calculating target weights corresponding to a first number of deformation targets in a current frame according to a sampling time sequence and a sampling value sequence;
[0044] A first writing module is used to write target weights corresponding to the first number of deformation targets into a GPU, wherein a second number of texture layers corresponding to each deformation target is cached in the GPU, and each texture layer in the second number of texture layers stores vertex offset data of an attribute, so that the GPU determines new attribute values of multiple vertices under the second number of attributes according to the target weights corresponding to each deformation target and the vertex offset data included in each texture layer, and updates the three-dimensional model using the new attribute values of the multiple vertices under the second number of attributes.
[0045] In some embodiments, the apparatus further comprises:
[0046] a creation module, configured to create at least one texture layer according to the first number and the second number before calculating the target weight corresponding to each deformation target in the current frame, wherein each deformation target corresponds to the second number of texture layers, and each attribute corresponds to the first number of texture layers;
[0047] An acquisition module, used for acquiring vertex offset data of the second number of attributes included in each deformation target;
[0048] A second writing module is used to write the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute;
[0049] The third writing module is used to write the texture layer after the data is written into the GPU.
[0050] In some embodiments, the creation module is specifically used to:
[0051] Determining a target size of the texture layer according to a third number of vertices included in the three-dimensional model, the target size being a power of 2, and a fourth number of pixels included in the texture layer of the target size being greater than or equal to the third number;
[0052] At least one texture layer of the target size is created according to the first number and the second number.
[0053] In some embodiments, the second writing module is specifically used to:
[0054] Extracting vertex offset data of the same attribute included in the first number of deformation targets;
[0055] Writing vertex offset data of the same attribute included in the first number of deformation targets into the first number of consecutive texture layers in the at least one texture layer.
[0056] In some embodiments, the apparatus further comprises:
[0057] A determination module, configured to determine a level value of a starting texture layer corresponding to each attribute in the at least one texture layer as a level offset value of each attribute;
[0058] The fourth writing module is used to write the level offset value of each attribute into the GPU, so that the GPU obtains the vertex offset data included in the texture layer corresponding to each attribute according to the level offset value of each attribute.
[0059] In some embodiments, the fourth writing module is specifically used to:
[0060] Determine the pixel in each texture layer corresponding to each vertex;
[0061] For each vertex offset data of each attribute included in each deformation target, multiple component data included in the vertex offset data are written into multiple color spaces of the deformation target and the pixels corresponding to the attribute.
[0062] In some embodiments, the fourth writing module is further used to:
[0063] If the number of color spaces included in a pixel is greater than the number of component data included in the vertex offset data of an attribute, then in the first number of texture layers corresponding to the attribute, component data is supplemented for each vertex offset data, and the number of component data included in the supplemented vertex offset data is the same as the number of color spaces included in a pixel.
[0064] In a fourth aspect, an embodiment of the present application provides a deformation animation processing device, which is applied to a GPU, wherein a second number of texture layers corresponding to each deformation target is cached in the GPU, and each texture layer in the second number of texture layers stores vertex offset data of an attribute, and the device includes:
[0065] A receiving module, configured to receive target weights corresponding to a first number of deformation targets written by a central processing unit CPU;
[0066] a determination module, configured to determine new attribute values of a plurality of vertices under the second number of attributes according to a target weight corresponding to each deformation target and vertex offset data included in each texture layer;
[0067] An updating module is used to update the three-dimensional model using new attribute values of the plurality of vertices under the second number of attributes.
[0068] In some embodiments, the determining module is specifically configured to:
[0069] Extracting offset data of each vertex under each attribute from a second number of texture layers corresponding to each deformation target according to the indexes of the plurality of vertices and the level offset value of each attribute;
[0070] Using the offset data of each vertex under each attribute and the target weight corresponding to each deformation target, calculate the new attribute value of each vertex corresponding to each attribute.
[0071] In some embodiments, the level offset value of each attribute is the level value of the starting texture layer corresponding to each attribute;
[0072] The determining module is specifically used for:
[0073] Determine the UV coordinates of each vertex according to the indexes of the plurality of vertices and the size of the texture layer;
[0074] For each attribute, traverse the deformation target; calculate the sum of the level offset value of the attribute and the index of the traversed deformation target to obtain a sampling depth; read the offset data at the UV coordinate of each vertex in the texture layer at the sampling depth; re-execute the step of traversing the deformation target until the first number of deformation targets are traversed.
[0075] In some embodiments, a plurality of threads are run in the GPU, each thread corresponding to a group of vertices among the plurality of vertices;
[0076] The determination module is specifically used to: determine new attribute values of corresponding groups of vertices under the second number of attributes in parallel using the multiple threads according to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer.
[0077] In a fifth aspect, an embodiment of the present application provides an electronic device, including:
[0078] Memory, used to store computer programs;
[0079] A CPU, configured to implement any deformation animation processing method provided in the first aspect when executing a program stored in the memory;
[0080] The GPU is used to implement any deformation animation processing method provided in the second aspect when executing the program stored in the memory.
[0081] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the computer program implements a processing method for any deformation animation provided in the first aspect. When the computer program is executed by a processor, the computer program implements a processing method for any deformation animation provided in the second aspect.
[0082] In the seventh aspect, the embodiment of the present application provides an embodiment of the present application also provides a computer program product comprising instructions, which, when run on a computer, enables the computer to execute any deformation animation processing method provided in the first aspect, or execute any deformation animation processing method provided in the second aspect.
[0083] Beneficial effects of the embodiments of the present application:
[0084] In the technical solution provided in the embodiment of the present application, a second number of texture layers corresponding to the second number of attributes included in each deformation target are cached in the GPU, and each texture layer includes multiple vertex offset data of one attribute. For each frame, the CPU only needs to calculate the first number of target weights corresponding to the first number of deformation targets, and write the target weights corresponding to each deformation target to the GPU. The GPU extracts the multiple vertex offset data of each attribute from the texture layer, and uses the target weights written by the CPU to calculate the new attribute values of multiple vertices by itself, and then updates the three-dimensional model. The number of target weights is much smaller than the number of vertices. In the embodiment of the present application, for each frame, the CPU only needs to write the first number of target weights to the GPU without transmitting a large amount of vertex data, which reduces the transmission load between the CPU and the GPU, improves the efficiency of the deformation animation and the flexibility of control, and enhances the smoothness and authenticity of the deformation animation effect.
[0085] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0086] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0087] Figure 1 A schematic diagram of a first flow chart of a method for processing a deformation animation provided in an embodiment of the present application;
[0088] Figure 2a A first schematic diagram of a texture image provided in an embodiment of the present application;
[0089] Figure 2b A second schematic diagram of a texture image provided in an embodiment of the present application;
[0090] Figure 3 A second flow chart of the method for processing a deformation animation provided in an embodiment of the present application;
[0091] Figure 4A third flow chart of the method for processing a deformation animation provided in an embodiment of the present application;
[0092] Figure 5 A first schematic diagram of a storage structure of a texture layer provided in an embodiment of the present application;
[0093] Figure 6 A fourth flow chart of the method for processing a deformation animation provided in an embodiment of the present application;
[0094] Figure 7 A schematic diagram of an implementation of step S62 provided in an embodiment of the present application;
[0095] Figure 8 A schematic diagram of a processing flow of a deformation animation provided in an embodiment of the present application;
[0096] Fig. 9 A second schematic diagram of a storage structure of a texture layer provided in an embodiment of the present application;
[0097] Fig.10 A schematic diagram of a CPU performing interpolation calculation on weights provided in an embodiment of the present application;
[0098] Fig.11 A schematic diagram of a first structure of a deformation animation processing device provided in an embodiment of the present application;
[0099] Fig.12 A second structural schematic diagram of the deformation animation processing device provided in an embodiment of the present application;
[0100] Fig.13 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0101] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0102] To facilitate understanding, the terms appearing in the embodiments of the present application are explained below.
[0103] GLTF model: A 3D model saved using GLTF. First of all, GLTF models are used with Blender. GLTF models contain data about the 3D scene, node hierarchy, materials, descriptors, and animations stored as text in JavaScript Object Notation (JSON) format.
[0104] Morph Targets: Each mesh that supports deformation animation will have one or more morph targets. A morph target represents a different form of the model, defined by the offset data of the vertex position. A morph target can include offset data for attributes such as vertex position, normal (also called normal vector) and tangent.
[0105] Morph Animation: A technique for achieving smooth transitions of shapes in 3D models. Morph Animation is also called MorphTarget animation. This animation technique does not define the actions of the model over time based on keyframes, but rather achieves the deformation effect of the surface of the object by interpolating between different shapes (or "targets").
[0106] Shader: An editable program used to implement image rendering and can replace the fixed rendering pipeline. Shaders can include vertex shaders, fragment shaders, and compute shaders. Vertex shaders are mainly responsible for the calculation of vertex geometric relationships, fragment shaders are mainly responsible for the calculation of fragment colors, and compute shaders mainly provide GPU high-speed computing and parallel processing.
[0107] UV coordinates: The basis for mapping the texture to the surface of the 3D model. UV is a coordinate system. U and V represent the horizontal and vertical coordinates of the image on the screen, respectively. The coordinate values of U and V are between (0, 0) and (1, 1).
[0108] Attribute level offset value: According to the status of the 3D model, each deformation target vertex includes vertex offset data of attributes such as position, normal vector, tangent, etc. When storing the vertex offset data of these attributes as texture data, they need to be isolated to avoid data confusion. Therefore, the attribute level offset value is needed to isolate the vertex offset data of different attributes of different deformation targets, so that there will be no data confusion when the GPU performs texture sampling.
[0109] The related technology processes deformation animation as follows: in each frame, the CPU calculates new attribute values of multiple vertices and writes them to the GPU; the GPU uses a shader to update the three-dimensional (3D) model based on the new attribute values of the multiple vertices to form a deformation animation effect. In this solution, the transmission load between the CPU and the GPU is large, the flexibility of deformation animation efficiency control is poor, and the smoothness and authenticity of the deformation animation effect are poor.
[0110] To solve the above problems, the present application provides a method for processing a deformation animation, such as Figure 1 As shown, applied to a CPU, the method includes:
[0111] Step S11, calculating target weights corresponding to a first number of deformation targets in the current frame according to the sampling time sequence and the sampling value sequence;
[0112] Step S12, writing the target weights corresponding to the first number of deformation targets into the GPU, wherein a second number of texture layers corresponding to each deformation target is cached in the GPU, wherein each texture layer of the second number of texture layers stores vertex offset data of an attribute, so that the GPU determines new attribute values of multiple vertices under the second number of attributes according to the target weights corresponding to each deformation target and the vertex offset data included in each texture layer, and updates the three-dimensional model using the new attribute values of multiple vertices under the second number of attributes.
[0113] In the technical solution provided in the embodiment of the present application, a second number of texture layers corresponding to the second number of attributes included in each deformation target are cached in the GPU, and each texture layer includes multiple vertex offset data of one attribute. For each frame, the CPU only needs to calculate the first number of target weights corresponding to the first number of deformation targets, and write the target weights corresponding to each deformation target to the GPU. The GPU extracts the multiple vertex offset data of each attribute from the texture layer, and uses the target weights written by the CPU to calculate the new attribute values of multiple vertices by itself, and then updates the three-dimensional model. The number of target weights is much smaller than the number of vertices. In the embodiment of the present application, for each frame, the CPU only needs to write the first number of target weights to the GPU without transmitting a large amount of vertex data, which reduces the transmission load between the CPU and the GPU, improves the efficiency of the deformation animation and the flexibility of control, and enhances the smoothness and authenticity of the deformation animation effect.
[0114] In the above step S11, the CPU configures a deformation target set, the length of which is a first number, that is, the deformation target set includes a first number of deformation targets. The first number can be set according to actual needs, for example, the first number can be 1, 2, 3 or 5.
[0115] The sampling time sequence is the time sequence for performing weight update. The sampling time sequence may include multiple time points, and the interval between adjacent time points is the duration of one frame of animation. The sampling value sequence is the weight sequence required for sampling. The sampling value sequence may include the starting weight and ending weight of the first number of deformation targets, as well as the starting time point and the ending time point. For example, the sampling value sequence is {(w A1 , w B1 , t A1 , t B1 ), (w A2 , w B2 , t A2 , t B2 )}, where w A1 and w B1 are the starting weight and ending weight of deformation target 1, t A1 and t B1 are the start time point and end time point of deformation target 1, respectively, w A2 and w B2 are the starting weight and ending weight of deformation target 2, respectively, t A2 and t B2 They are the start time point and end time point of deformation target 2 respectively.
[0116] The CPU determines the current frame, uses the sampling time sequence and the sampling value sequence, and adopts a preset interpolation algorithm to calculate the target weights corresponding to the first number of deformation targets in the current frame. The preset interpolation algorithm can be a linear interpolation algorithm, a Bezier interpolation algorithm, etc., which is not limited.
[0117] Take the preset interpolation algorithm as a linear interpolation algorithm as an example. The CPU can obtain the time t1 of the current frame from the sampling time sequence, and extract the starting weight, ending weight, starting time point and ending time point (w A , w B , t A , t B The CPU uses the following formula (1) and formula (2) to calculate the target weight corresponding to each deformation target in the current frame.
[0118] Ratio=(t1-t A ) / (t B -t A ) (1)
[0119] Value=w A +Ratio×(w B -w A ) (2)
[0120] In formula (1) and formula (2), Ratio is the interpolation ratio of the current frame; Value is the target weight corresponding to the deformation target.
[0121] In the above step S12, the second number is the number of attributes included in a deformation target. The second number can be set according to actual needs, for example, the second number can be 1, 2 or 3.
[0122] In the embodiment of the present application, a texture image is cached in the GPU, and the texture depth of the texture image may be the first number × the second number, that is, the texture image includes the first number × the second number of texture layers. At this time, one deformation target corresponds to the second number of texture layers, and each texture layer in the second number of texture layers stores vertex offset data of one attribute, that is, for the first number of deformation targets, one attribute corresponds to the first number of texture layers.
[0123] For example, the first number is 2 and the second number is 3. In this case, the texture image is as follows: Figure 2a and Figure 2b As shown. The texture image includes 2×3=6 texture layers, namely, texture layer 1 to texture layer 6. Among them, deformation target 1 corresponds to 3 texture layers, among which attribute 1 corresponds to one texture layer, attribute 2 corresponds to one texture layer, and attribute 3 corresponds to one texture layer; deformation target 2 corresponds to 3 texture layers, among which attribute 1 corresponds to one texture layer, attribute 2 corresponds to one texture layer, and attribute 3 corresponds to one texture layer. Figure 2a and Figure 2b In the above diagram, each small rectangular box represents a pixel, which is used to store the offset data of a vertex (i.e., vertex offset data). For example, in the texture layer corresponding to deformation target 1 and attribute 1, each pixel stores a vertex offset data of attribute 1 included in deformation target 1. The arrangement order of the texture layers corresponding to various deformation targets and various attributes in the texture image can be set according to actual needs. Figure 2a and Figure 2b This is merely an example and is not intended to be limiting.
[0124] The 3D model can adopt GLTF model or other deformation animation model based on vertex offset.
[0125] After obtaining the target weights corresponding to the first number of deformation targets, the CPU may create a weight buffer in the GPU and write the target weights corresponding to the first number of deformation targets into the weight buffer.
[0126] In this case, the GPU can determine the offset of each vertex under the second number of attributes according to the target weights corresponding to the first number of deformation targets and the vertex offset data included in the first number of texture layers corresponding to the same attribute, and then determine the new attribute values of the multiple vertices under the second number of attributes, and update the three-dimensional model using the new attribute values of the multiple vertices under the second number of attributes. The specific algorithm can be found in the relevant technology, which will not be repeated here.
[0127] After completing one 3D model update, the CPU may re-execute step S11 to update the 3D model of the next frame to achieve a deformation animation effect.
[0128] In some embodiments, Figure 3 As shown, a method for processing a deformation animation is also provided, which may include the following steps:
[0129] Step S31, creating at least one texture layer according to a first number and a second number, each deformation target corresponds to the second number of texture layers, and each attribute corresponds to the first number of texture layers;
[0130] Step S32, obtaining vertex offset data of a second number of attributes included in each deformation target;
[0131] Step S33, writing the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute;
[0132] Step S34, writing the texture layer after the data is written into the GPU.
[0133] Step S35, calculating the target weights corresponding to the first number of deformation targets in the current frame according to the sampling time sequence and the sampling value sequence; the same as the above step S11.
[0134] Step S36, writing the target weights corresponding to the first number of deformation targets into the GPU, so that the GPU determines new attribute values of the plurality of vertices under the second number of attributes according to the target weights corresponding to each deformation target and the vertex offset data included in each texture layer, and updates the three-dimensional model using the new attribute values of the plurality of vertices under the second number of attributes. This is the same as the above step S12.
[0135] In the technical solution provided in the embodiment of the present application, the CPU textures the layer according to the number of deformation targets (i.e., the first number) and the number of attributes of vertex offset data included in a deformation target (i.e., the second number), and manages the vertex offset data in a hierarchical manner according to the deformation targets and attributes, which can effectively save memory, facilitate the use of controls, and access the vertex offset data in the texture layer on demand, thereby optimizing data management.
[0136] In the above step S31, the CPU directly creates the first number × the second number of texture layers according to the first number and the second number, so as to avoid creating too many texture layers and causing memory waste, and also avoid creating too few texture layers, which makes it impossible to isolate and store the vertex offset data of the second number of attributes included in the first number of deformation targets, thereby causing data confusion when the GPU performs texture sampling.
[0137] In the embodiment of the present application, the size of the created texture layer can be a size pre-set based on experience. For example, based on experience, the user determines that the maximum number of vertices included in the three-dimensional model is 600, and the size of the texture layer can be pre-set to be 20×30, that is, the width of the texture layer is 20 pixels and the height is 30 pixels. This method can quickly complete the creation of the texture layer and ensure that the offset data of all vertices are written into the texture layer.
[0138] In some embodiments, in order to optimize the use efficiency of the inner layer, the CPU can determine the target size of the texture layer based on the three-dimensional model including a third number of vertices, the target size is a power of 2, and the texture layer of the target size includes a fourth number of pixels greater than or equal to the third number; according to the first number and the second number, create at least one texture layer of the target size.
[0139] The third number is the number of vertices included in the three-dimensional model, and the fourth number is the number of pixels included in a texture layer. According to the third number of vertices included in the three-dimensional model, the CPU can determine that the size of the texture layer (i.e., the target size) is a power of 2, that is, the width and height of the texture layer are respectively powers of 2, and the texture layer includes at least the third number of pixels.
[0140] A texture layer is created based on the target size, and the vertex offset data of one attribute included in one deformation target can all be written into one texture layer. In addition, the GPU requires that the size of the texture layer meets the power of 2, which ensures that the GPU accurately processes the data in the texture layer and improves the efficiency of the inner layer.
[0141] In addition, in this embodiment, the target size can make the fourth number greater than or equal to the third number and the minimum value of the power of 2, which avoids excessive allocation of memory and further improves the use efficiency of the inner layer.
[0142] For example, if the number of vertices in a 3D model is n, the CPU can calculate the ideal size d=n 1 / 2 , and calculate m=log2d, round m up to get p, at this time, the target size is 2 p , that is, the width and height of the texture layer are 2 p This method accurately obtains the size of the texture layer and avoids excessive memory allocation.
[0143] In the above step S32, for each deformation target, the CPU obtains vertex offset data of the second number of attributes included in the deformation target. When the three-dimensional model includes multiple vertices, multiple vertex offset data of the second number of attributes included in the deformation target are obtained.
[0144] For example, the three-dimensional model includes 1000 vertices, the first number is 2, there are 2 deformation targets, namely deformation target 1 and deformation target 2; the second number is 3, that is, there are 3 attributes, namely attribute 1, attribute 2 and attribute 3. For deformation target 1, the CPU obtains 1000 offset data of attribute 1, 1000 offset data of attribute 2, and 1000 offset data of attribute 3 included in deformation target 1, and obtains 1000 offset data of attribute 1, 1000 offset data of attribute 2, and 1000 offset data of attribute 3 included in deformation target 2.
[0145] In the above step S33, after obtaining the vertex offset data included in the first number of deformation targets, for each deformation target, the CPU writes the vertex offset data of each attribute included in the deformation target into the texture layer corresponding to the deformation target and the attribute.
[0146] Still Figure 2b Take an example for explanation. The CPU writes the vertex offset data of attribute 1 included in deformation target 1 into texture layer 1, writes the vertex offset data of attribute 2 included in deformation target 1 into texture layer 3, and writes the vertex offset data of attribute 3 included in deformation target 1 into texture layer 5; writes the vertex offset data of attribute 1 included in deformation target 2 into texture layer 2, writes the vertex offset data of attribute 2 included in deformation target 2 into texture layer 4, and writes the vertex offset data of attribute 3 included in deformation target 2 into texture layer 6.
[0147] In the embodiment of the present application, the CPU can use any of the following methods to complete the writing of vertex offset data into the texture layer.
[0148] Method 1: The CPU traverses the first number of deformation targets; each time a deformation target is traversed, the CPU extracts the vertex offset data of each attribute from the deformation target in turn, and writes the extracted vertex offset data into a texture layer, completing the data writing of the second number of texture layers; thereafter, the CPU continues to traverse the first number of deformation targets until the traversal of the first number of deformation targets is completed.
[0149] In a second method, the CPU extracts vertex offset data of the same attribute included in a first number of deformation targets; and writes the vertex offset data of the same attribute included in the first number of deformation targets into a first number of texture layers in at least one texture layer.
[0150] In the embodiment of the present application, the CPU groups the vertex offset data, groups the vertex offset data included in the first number of deformation targets of the same attribute into one group, and the group of vertex offset data includes the vertex offset data of the same attribute corresponding to the first number of deformation targets; and stores the group of vertex offset data in a first number of consecutive texture layers. In the embodiment of the present application, the CPU groups and stores the vertex offset data, which is convenient for CPU operation and optimizes memory layout.
[0151] After writing the vertex offset data of the second number of attributes included in the first number of deformation targets into the corresponding texture layer, the CPU executes step S34 to write the texture layer after the data is written (ie, the texture image after the vertex offset data is written) into the GPU.
[0152] In an embodiment of the present application, after the CPU has written the vertex offset data into the corresponding texture layer, the CPU can merge the multiple texture layers in a preset order to obtain a texture image with a texture depth of the first number × the second number. The CPU then writes the texture image into the GPU. The GPU can create a texture buffer, and after receiving the texture image written by the CPU, the GPU writes the texture image into the texture buffer. The multiple texture layers included in the texture image are cached in a continuous buffer for GPU processing.
[0153] After writing the texture image into the GPU, the CPU may execute step S35 to step S36 in a loop to achieve a deformation animation effect.
[0154] In the embodiment of the present application, in order to enable the GPU to accurately read the vertex offset data of various attributes of various deformation targets, the GPU and the CPU can pre-agree on the level offset value of the texture layer corresponding to various attributes of various deformation targets. The level offset value is the offset value of the texture layer relative to the first texture layer. In this way, the GPU can accurately read the vertex offset data of various attributes according to the level offset value of the texture layer corresponding to various attributes of various deformation targets, and then accurately calculate the new attribute values of multiple vertices under various attributes.
[0155] In the embodiment of the present application, in order to enable the GPU to accurately read the vertex offset data of various attributes of various deformation targets, the CPU can record the level offset values of the texture layers corresponding to the various attributes of various deformation targets, and write the level offset values of the texture layers corresponding to the various attributes of various deformation targets into the GPU. This ensures that the GPU accurately reads the vertex offset data of various attributes of various deformation targets, and can realize the deformation animation effect according to actual needs, thereby improving the flexibility of deformation animation control.
[0156] In some embodiments, the CPU may store the vertex offset data in groups. In this case, the CPU determines the level value of the starting texture layer corresponding to each attribute in at least one texture layer as the level offset value of each attribute; the level offset value of each attribute is written to the GPU, so that the GPU obtains the vertex offset data included in the texture layer corresponding to each attribute according to the level offset value of each attribute.
[0157] For example, the CPU obtains two deformation targets, namely deformation target 1 and deformation target 2. Each deformation target includes vertex offset data of three attributes, namely vertex offset data of attribute 1 to attribute 3. When storing vertex offset data in groups, the six texture layers obtained by the CPU can be seen in Figure 2b As shown. Among them, the starting texture layer corresponding to attribute 1 is texture layer 1, and the level value of texture layer 1 is 0, so the level offset value of attribute 1 is 0; the starting texture layer corresponding to attribute 2 is texture layer 3, and the level value of texture layer 2 is 2, so the level offset value of attribute 2 is 2; the starting texture layer corresponding to attribute 3 is texture layer 5, and the level value of texture layer 5 is 4, so the level offset value of attribute 3 is 4.
[0158] According to the hierarchical offset values of attributes 1 to 3, the GPU can quickly read the vertex offset data of attribute 1 included in deformation target 1 and deformation target 2 from texture layer 1 to texture layer 2, and then calculate the new attribute value 1 of multiple vertices under attribute 1; read the vertex offset data of attribute 2 included in deformation target 1 and deformation target 2 from texture layer 3 to texture layer 4, and then calculate the new attribute value 2 of multiple vertices under attribute 2; read the vertex offset data of attribute 3 included in deformation target 1 and deformation target 2 from texture layer 5 to texture layer 6, and then calculate the new attribute value 4 of multiple vertices under attribute 3.
[0159] In some embodiments, Figure 4 As shown, the embodiment of the present application also provides a method for processing a deformation animation, which may include the following steps:
[0160] Step S41, creating at least one texture layer according to the first quantity and the second quantity, each deformation target corresponds to the second quantity of texture layers, and each attribute corresponds to the first quantity of texture layers; the same as the above step S31.
[0161] Step S42, obtaining vertex offset data of a second number of attributes included in each deformation target; the same as the above step S32.
[0162] Step S43, determining the pixel in each texture layer corresponding to each vertex;
[0163] In the embodiment of the present application, the number of pixels in the texture layer (i.e., the fourth number) is greater than or equal to the number of vertices included in the three-dimensional model (i.e., the third number). One vertex corresponds to one pixel in the texture layer. For example, the third number is 90, the vertex index is 0 to 89, and the size of the texture layer is 10×10, that is, the fourth number is 100, and the texture layer includes 100 pixels. Vertices 0 to 89 correspond to pixels 0 to 89 in the texture layer, respectively.
[0164] Step S44, for each vertex offset data of each attribute included in each deformation target, write multiple component data included in the vertex offset data into multiple color spaces of pixels corresponding to the attribute included in the deformation target;
[0165] In the embodiment of the present application, a pixel may have four color spaces of red, green, blue, and alpha (RGBA), and a vertex offset data of an attribute may include 1 to 4 component data. For example, the vertex offset data of the position attribute includes 3 component data, namely, an X coordinate, a Y coordinate, and a Z coordinate.
[0166] For each vertex offset data of each attribute included in each deformation target, the CPU writes multiple component data included in the vertex offset data into multiple color spaces of corresponding pixels in the texture layer corresponding to the deformation target and the attribute.
[0167] In the embodiment of the present application, the number of color spaces included in a pixel is likely to be greater than the number of component data included in the vertex offset data of an attribute. To ensure data alignment, if the number of color spaces included in a pixel is greater than the number of component data included in the vertex offset data of an attribute, the CPU supplements the component data for each vertex offset data in the first number of texture layers corresponding to an attribute, and the number of component data included in the supplemented vertex offset data is the same as the number of color spaces included in a pixel. The supplemented component data can be a preset value, such as 0 or 1, or a random value, which is not limited.
[0168] For example, the CPU obtains one deformation target, namely deformation target 1, which includes vertex offset data of two attributes, namely, vertex offset data of position attribute and vertex offset data of normal vector attribute. Figure 5 The storage structure of the texture layer shown in the figure, each pixel includes four color spaces: RGBA. The three-dimensional model includes 90 vertices, namely vertex 0 to vertex 89.
[0169] In texture layer 1 corresponding to deformation target 1 and position attribute, the CPU writes the offset data (X1, Y1, Z1) of vertex 0 of deformation target 1 including the position attribute into the three color spaces of R, G, and B included in pixel 0, and fills 0 in the color space A; and so on, writes the offset data vertices of vertex 1 to vertex 89 of the position attribute into texture layer 1.
[0170] In texture layer 2 corresponding to deformation target 1 and normal vector attribute, the CPU writes the offset data (a1, b1, c1) of vertex 0 of deformation target 1 including the normal vector attribute into the three color spaces of R, G, and B included in pixel 0, and fills 0 in the color space A; and so on, writes the offset data vertices of vertex 1 to vertex 89 of the normal vector attribute into texture layer 2.
[0171] Step S45, writing the texture layer after the data is written into the GPU, which is the same as the above step S34.
[0172] Step S46, calculating the target weights corresponding to the first number of deformation targets in the current frame according to the sampling time sequence and the sampling value sequence; the same as the above step S11.
[0173] Step S47, writing the target weights corresponding to the first number of deformation targets into the GPU, so that the GPU determines new attribute values of the plurality of vertices under the second number of attributes according to the target weights corresponding to each deformation target and the vertex offset data included in each texture layer, and updates the three-dimensional model using the new attribute values of the plurality of vertices under the second number of attributes. This is the same as the above step S12.
[0174] In the technical solution provided in the embodiment of the present application, the CPU fills the vertex offset data in the texture layer according to the texture format requirements to optimize the memory layout and reduce memory fragmentation. In addition, in the embodiment of the present application, the CPU can also supplement the vertex offset data with component data so that the supplemented vertex offset data is aligned with the pixel data, thereby making the limited GPU memory resources more reasonably allocated and used.
[0175] Corresponding to the above-mentioned deformation animation processing method applied to the CPU, the embodiment of the present application also provides a deformation animation processing method, such as Figure 6 As shown, it is applied to a GPU, a second number of texture layers corresponding to each deformation target is cached in the GPU, and each texture layer in the second number of texture layers stores vertex offset data of an attribute. The method includes:
[0176] Step S61, receiving target weights corresponding to a first number of deformation targets written by the CPU;
[0177] Step S62, determining new attribute values of a plurality of vertices under a second number of attributes according to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer;
[0178] Step S63: updating the three-dimensional model using the new attribute values of the plurality of vertices under the second number of attributes.
[0179] In the technical solution provided in the embodiment of the present application, a second number of texture layers corresponding to the second number of attributes included in each deformation target are cached in the GPU, and each texture layer includes multiple vertex offset data of one attribute. For each frame, the CPU only needs to calculate the first number of target weights corresponding to the first number of deformation targets, and write the target weights corresponding to each deformation target to the GPU. The GPU extracts the multiple vertex offset data of each attribute from the texture layer, and uses the target weights written by the CPU to calculate the new attribute values of multiple vertices by itself, and then updates the three-dimensional model. The number of target weights is much smaller than the number of vertices. In the embodiment of the present application, for each frame, the CPU only needs to write the first number of target weights to the GPU without transmitting a large amount of vertex data, which reduces the transmission load between the CPU and the GPU, improves the efficiency of the deformation animation and the flexibility of control, and enhances the smoothness and authenticity of the deformation animation effect.
[0180] In the above step S61, the CPU obtains the target weights corresponding to the first number of deformation targets. Figure 1 The relevant description of some parts will not be repeated here.
[0181] In the above steps S62 to S63, the GPU determines the offset of each vertex under the second number of attributes according to the target weights corresponding to the first number of deformation targets and the vertex offset data included in the first number of texture layers corresponding to the same attribute, and then determines the new attribute values of the multiple vertices under the second number of attributes, and updates the three-dimensional model using the new attribute values of the multiple vertices under the second number of attributes. The specific algorithm can be found in the relevant technology, which will not be repeated here.
[0182] In some embodiments, in order to improve the overall rendering efficiency and meet the requirements of high-performance real-time rendering, the parallel computing characteristics of the GPU itself can be used to parallelly calculate new attribute values of multiple groups of vertices. Specifically, the multiple vertices included in the three-dimensional model are divided into multiple groups of vertices, and multiple threads are run in the GPU, and each thread corresponds to a group of vertices among the multiple vertices; in this case, the above-mentioned step S62 can be: according to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer, multiple threads are used to parallelly determine the new attribute values of the corresponding group of vertices under the second number of attributes.
[0183] For example, two threads, such as thread 0 and thread 1, are run in the GPU, and multiple vertices included in the three-dimensional model are divided into two groups of vertices, such as vertex group 0 and vertex group 1. Thread 0 corresponds to vertex group 0, and thread 1 corresponds to vertex group 1. The GPU uses thread 0 to determine new attribute values of each vertex in vertex group 0 under the second number of attributes. At the same time, the GPU uses thread 1 to determine new attribute values of each vertex in vertex group 1 under the second number of attributes. Thread 0 and thread 1 run in parallel.
[0184] In the embodiment of the present application, multiple threads calculate new attribute values of vertices in parallel, which greatly improves the overall rendering efficiency.
[0185] In some embodiments, in order to determine the accurate calculation of the new attribute value of each vertex, such as Figure 7 As shown, the GPU can use steps S71 to S72 to implement the above step S62.
[0186] Step S71, extracting a first number of offset data of each vertex under each attribute from a second number of texture layers corresponding to each deformation target according to the indexes of the plurality of vertices and the level offset value of each attribute;
[0187] In the embodiment of the present application, the level offset value of each attribute may be pre-agreed between the GPU and the CPU. Figure 2a For example, the GPU and CPU pre-agreed that the level offset value of texture layer 1 corresponding to deformation target 1 and attribute 1 is 0, the level offset value of texture layer 4 corresponding to deformation target 1 and attribute 1 is 3, and so on.
[0188] The level offset value of each attribute can also be calculated by the CPU after creating the texture layer and written to the GPU, for example. The CPU can group and store the vertex offset data, and the CPU determines the level value of the starting texture layer corresponding to each attribute in at least one texture layer as the level offset value of each attribute. For details, please refer to the above related description, which will not be repeated here.
[0189] Using the indexes of the multiple vertices and the level offset values of each attribute, for each deformation target, the GPU can extract one offset data for each vertex under each attribute from the second number of texture layers corresponding to the deformation target. For the first number of deformation targets, one attribute, and one vertex, the GPU can extract the first number of offset data.
[0190] Step S72, using the offset data of each vertex under each attribute and the target weight corresponding to each deformation target, calculate the new attribute value of each vertex corresponding to each attribute.
[0191] In the extracted vertex offset data, for a first number of deformation targets, an attribute, and a vertex, the GPU extracts a first number of offset data in total, one offset data corresponds to one deformation target, and correspondingly, one offset data corresponds to one target weight.
[0192] For each offset data of each vertex under each attribute, the GPU can calculate the product of the offset data and the target weight corresponding to the deformation target to which the offset data belongs, obtain the sub-offset corresponding to the offset data, and calculate the sum of the first number of sub-offsets of the vertex corresponding to the attribute to obtain the offset of the vertex under the attribute; superimpose the original value and offset of each vertex under each attribute to obtain the new attribute value of each vertex under each attribute.
[0193] For example, the CPU obtains two deformation targets, namely, deformation target 1 and deformation target 2. Each deformation target includes vertex offset data of three attributes, namely, vertex offset data of attribute 1 to attribute 3. The three-dimensional model includes 90 vertices, namely, vertex 0 to vertex 89. The target weight corresponding to deformation target 1 is 1, and the target weight corresponding to deformation target 2 is 2.
[0194] The offset data 00 of vertex 0 under attribute 1 belongs to deformation target 1, and the offset data 01 of vertex 0 under attribute 1 belongs to deformation target 2. The GPU calculates the product of offset data 00 and target weight 1 corresponding to deformation target 1 to obtain sub-offset 00 corresponding to the offset data 00, and calculates the product of offset data 01 and target weight 2 corresponding to deformation target 2 to obtain sub-offset 01 corresponding to the offset data 01; calculates the sum of sub-offset 00 and sub-offset 01 to obtain offset 0 of vertex 0 under attribute 0; superimposes the original value of vertex 0 under attribute 1 and offset 0 to obtain the new attribute value 0 of vertex 0 under attribute 1.
[0195] Similarly, the GPU can obtain the new attribute values of vertices 1 to 89 under attribute 1, and obtain the new attribute values of vertices 0 to 89 under attribute 2 to attribute 3.
[0196] In some embodiments, the GPU can implement step S71 as follows: determine the UV coordinates of each vertex based on the index of multiple vertices and the size of the texture layer; determine the first number of texture layers corresponding to each attribute based on the level offset value of each attribute; extract the data at the UV coordinates of each vertex from the first number of texture layers corresponding to each attribute, and obtain the first number of offset data for each vertex under each attribute.
[0197] In the embodiment of the present application, the GPU can use the following formula to determine the UV coordinates of each vertex:
[0198] U coordinate = vertex index % texture layer size (width value);
[0199] V coordinate = (vertex index - U coordinate) / vertex index.
[0200] Based on the UV coordinates, the GPU can determine the location of the offset data that needs to be read in the texture layer. According to the level offset value of each attribute, the GPU can determine the location of the texture layer that needs to be read. Combining the location of the offset data in the texture layer and the location of the texture layer, the GPU can accurately read the first amount of offset data of the same attribute, different deformation targets, and the same vertex.
[0201] In some embodiments, the level offset value of each attribute is the level value of the starting texture layer corresponding to each attribute; in this case, the data at the UV coordinate of each vertex extracted above may be:
[0202] For each attribute, traverse the deformation target; calculate the sum of the level offset value of the attribute and the index of the traversed deformation target to obtain the sampling depth; read the offset data at the UV coordinate in the texture layer at the sampling depth, and then re-execute the step of traversing the deformation target until the first number of deformation targets are traversed.
[0203] Whenever the offset data at a UV coordinate is extracted, the GPU can calculate the product of the offset data and the target weight corresponding to the traversed deformation target to obtain a sub-offset corresponding to the attribute.
[0204] For example, the CPU obtains two deformation targets, namely deformation target 1 and deformation target 2. Each deformation target includes vertex offset data of three attributes, namely vertex offset data of attribute 1 to attribute 3. The three-dimensional model includes 90 vertices, namely vertex 0 to vertex 89. The target weight corresponding to deformation target 1 is 1, and the index of deformation target 1 is 0. The target weight corresponding to deformation target 2 is 2, and the index of deformation target 2 is 1. The 6 texture layers obtained by the CPU can be seen in Figure 2b As shown. Among them, the starting texture layer corresponding to attribute 1 is texture layer 1, and the level value of texture layer 1 is 0, so the level offset value of attribute 1 is 0; the starting texture layer corresponding to attribute 2 is texture layer 3, and the level value of texture layer 2 is 2, so the level offset value of attribute 2 is 2; the starting texture layer corresponding to attribute 3 is texture layer 5, and the level value of texture layer 5 is 4, so the level offset value of attribute 3 is 4.
[0205] For attribute 1, traverse the deformation targets, such as the traversed deformation target 1; calculate the sum of the level offset value 0 of attribute 1 and the index 0 of the traversed deformation target 1, and obtain the sampling depth 0+0=0; read the offset data 0 at the UV coordinate in the texture layer 1 at the sampling depth 0, calculate the product of the offset data 0 and the target weight 1 corresponding to the deformation target 1, and obtain a sub-offset 0 corresponding to the attribute 1.
[0206] After that, traverse the deformation targets again, such as the deformation target 2 traversed; calculate the sum of the level offset value 0 of attribute 1 and the index 1 of the traversed deformation target 2, and get the sampling depth 0+1=1; read the offset data 1 at the UV coordinate in the texture layer 2 at the sampling depth 1, calculate the product of the offset data 1 and the target weight 2 corresponding to the deformation target 2, and get a sub-offset 1 corresponding to the attribute 1. In addition, traverse to 2 deformation targets, and the traversal corresponding to the attribute is completed.
[0207] Combine the following Figure 8 The processing flow of the deformation animation shown in the figure describes in detail the processing method of the deformation animation provided in the embodiment of the present application.
[0208] Step S81: The CPU calculates the size and depth of the texture layer according to the number of vertices.
[0209] For example, if the number of vertices in a 3D model is n, the CPU can calculate the ideal size d=n 1 / 2 , and calculate m=log2d, round m up to get p, at this time, the target size is 2 p , that is, the width and height of the texture layer are 2 p .
[0210] Additionally, the CPU can calculate the product of the number of deformation targets and the number of attributes to obtain the texture layer depth.
[0211] In step S82, the CPU stores the multiple vertex offset data included in the multiple deformation targets in a continuous buffer.
[0212] The CPU writes the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute.
[0213] In the embodiment of the present application, the CPU can group and store the vertex offset data, and store the vertex offset data of the same attribute in a continuous texture layer. In addition, the CPU fills each vertex offset data with 0 so that the vertex offset data is aligned with the pixel data to meet the texture format requirements.
[0214] Step S83: The GPU creates a texture buffer and writes the data passed in by the CPU into the texture buffer.
[0215] In the embodiment of the present application, the pixel format and texture dimension of the texture buffer are consistent with the texture layer created by the CPU and meet the texture format requirements, which ensures that the texture layer created by the CPU is correctly mapped to the GPU.
[0216] In step S84, the CPU performs interpolation calculation on the weights. For details, please refer to the relevant description in the above step S11.
[0217] The CPU calculates the weights and writes them to the GPU.
[0218] Step S85: GPU uses multithreading to calculate new attribute values of multiple vertices.
[0219] In the embodiment of the present application, the weights are traversed in a loop, and the GPU determines the UV coordinates of the vertex according to the vertex index, determines the sampling depth using the traversed weight index and the level offset value of the deformation target, and inputs the UV coordinates and the sampling depth into a specified function (such as textureLoad(t:texture_2d_array <st>,coords: vec2 <c>,array_index: A,level: L) -> vec4 <st>Function), obtain the offset data of the corresponding vertex, and calculate the product of the offset data and the weight corresponding to the deformation target to obtain the offset value of the corresponding vertex, and superimpose the offset values of multiple vertices on the original positions of multiple vertices to obtain new attribute values of multiple vertices. In the embodiment of the present application, there is padding data in the offset data, such as 0. In the above calculation, the padding data can be ignored to reduce the amount of calculation.
[0220] After obtaining new attribute values of multiple vertices, the GPU can update the 3D model.
[0221] In addition, after executing step S85, the CPU updates the frame queue, that is, updates the weight, and re-executes step S84 to achieve the animation effect.
[0222] Combine the following Fig. 9 The storage structure of the texture layer shown is used to describe in detail the processing method of the deformation animation provided in the embodiment of the present application. Fig. 9 In the example, deformation target 0 corresponds to weight 0, and deformation target 1 corresponds to weight 1. Attributes include position and normal vector. The 3D model includes 9 vertices, namely vertex 0 to vertex 8. Among them, the numerical numbers of deformation targets, weights, and vertices are the values of indexes. The GPU has 2 threads, among which thread 0 processes the data of vertex 0 to vertex 3, and thread 1 processes the data of vertex 4 to vertex 8. Thread 0 and thread 1 process vertex data in parallel.
[0223] In the embodiment of the present application, the CPU creates 2×2=4 texture layers of size 3×3, namely, texture layer 0 to texture layer 3. The CPU writes the position offset data of deformation target 0 including vertex 0 to vertex 8 into the RGB color space of pixel 0 to pixel 8 in texture layer 0, and fills 0 in the A color space of pixel 0 to pixel 8; the CPU writes the position offset data of deformation target 1 including vertex 0 to vertex 8 into the RGB color space of pixel 0 to pixel 8 in texture layer 1, and fills 0 in the A color space of pixel 0 to pixel 8. At this time, the CPU can determine that the level offset value of the position is 0.
[0224] The CPU writes the normal vector offset data of deformation target 0 including vertex 0 to vertex 8 into the RGB color space of pixel 0 to pixel 8 in texture layer 2, and fills 0 in the A color space of pixel 0 to pixel 8; the CPU writes the normal vector offset data of deformation target 1 including vertex 0 to vertex 8 into the RGB color space of pixel 0 to pixel 8 in texture layer 3, and fills 0 in the A color space of pixel 0 to pixel 8. At this time, the CPU can determine that the level offset value of the normal vector is 2.
[0225] The CPU merges the texture layers 0 to 3 after the data is written and writes them into the GPU, and writes the level offset value of the position and the level offset value of the normal vector into the GPU.
[0226] In each subsequent frame, the CPU performs interpolation calculations on the weights and updates weights 0 to 1, such as Fig.10 The weight array [1,0.5] shown in the figure writes the updated weights 0 to 1 to the GPU. In the weight array [1,0.5], 1 is the value of weight 0 and 0.5 is the value of weight 1. Fig.10 Only vertices 0 to 2 are shown.
[0227] Thread 0 in the GPU determines UV coordinate 0 of vertex 0 using vertex index 0.
[0228] The GPU loops through weight 0~weight 1. If it traverses to weight 0, it calculates the index of weight 0 and the sum of the level offset value 0 of the position to obtain sampling depth 0, inputs UV coordinate 0 and sampling depth 0 into the specified function, obtains the position offset data of vertex 0 in texture layer 0, calculates the product of the position offset data of vertex 0 and weight 0, and obtains the sub-position offset value 00 of vertex 0; continues to loop through weight 0~weight 1. If it traverses to weight 1, it calculates the index of weight 1 and the sum of the level offset value 0 of the position to obtain sampling depth 1, inputs UV coordinate 0 and sampling depth 1 into the specified function, obtains the position offset data of vertex 0 in texture layer 1, calculates the product of the position offset data of vertex 0 and weight 1, and obtains the sub-position offset value 01 of vertex 0 under the position attribute; superimposes sub-position offset value 00 and sub-position offset value 01 on the original position of vertex 0 to obtain the new position 0 of vertex 0.
[0229] Thread 0 in the GPU loops through weight 0~weight 1. If it traverses to weight 0, it calculates the index of weight 0 and the sum of the level offset value 2 of the normal vector to obtain sampling depth 2, inputs UV coordinate 0 and sampling depth 2 into the specified function, obtains the normal vector offset data of vertex 0 in texture layer 2, calculates the product of the normal vector offset data of vertex 0 and weight 0, and obtains the sub-normal vector offset value 00 of vertex 0; continues to loop through weight 0~weight 1. If it traverses to weight 1, it calculates the index of weight 1 and the sum of the level offset value 2 of the normal vector to obtain sampling depth 3, inputs UV coordinate 0 and sampling depth 3 into the specified function, obtains the normal vector offset data of vertex 0 in texture layer 3, calculates the product of the normal vector offset data of vertex 0 and weight 1, and obtains the sub-normal vector offset value 01 of vertex 0 under the normal vector attribute; superimposes the sub-normal vector offset value 00 and the sub-normal vector offset value 01 on the original normal vector of vertex 0 to obtain a new normal vector 0 of vertex 0.
[0230] Similarly, thread 0 in the GPU calculates the new positions 1 to 3 and the new normal vectors 1 to 3 of vertices 1 to 3. In addition, thread 1 in the GPU calculates the new positions 4 to 8 and the new normal vectors 4 to 8 of vertices 4 to 8 in parallel.
[0231] The GPU updates the 3D model using the new positions 0 to 8 of vertices 0 to 8 and the new normal vectors 0 to 8.
[0232] The technical solution provided in the embodiment of the present application has the following characteristics:
[0233] 1) Textured storage of vertex offset data: Vertex offset data is stored in a texture format and managed at multiple levels. This method effectively saves memory and control usage, allows large amounts of vertex offset data to be accessed on demand, and optimizes data management.
[0234] 2) GPU dynamically calculates UV coordinates and sampling depth: UV coordinates and sampling depth are calculated in real time on the GPU side, so that each frame no longer needs to transmit a large amount of vertex data from the CPU to the GPU. The GPU directly obtains the offset data of each vertex from the texture layer, achieving more efficient data flow and improving rendering performance.
[0235] 3) GPU parallel computing and vertex offset optimization: Utilize the parallel computing characteristics of the GPU to effectively parallelize the calculation of vertex offset. This method allows the offset calculation of multiple vertices to be processed simultaneously, improving the overall rendering efficiency and being suitable for high-performance real-time rendering requirements.
[0236] Based on the above technical solution features, the embodiments of the present application have the following beneficial effects:
[0237] 1) Significantly improve rendering performance: By adaptively calculating the size and depth of the texture layer and using an efficient data alignment strategy, the redundancy and transmission delay of texture data are reduced, making the overall rendering process more efficient. At the same time, using the hardware acceleration capabilities of WebGPU, the rendering speed and frame rate of 3D animations are significantly improved, providing users with a smoother visual experience.
[0238] 2) Optimize memory usage efficiency: By accurately calculating the size of the texture layer to meet the GPU's requirements for the power of 2, over-allocation of memory is avoided and memory usage efficiency is improved. In addition, data alignment and padding strategies further optimize memory layout, reduce fragmentation, and make limited GPU memory resources more reasonably allocated and utilized.
[0239] 3) Enhance animation smoothness and realism: The introduction of dynamic weight interpolation technology, especially support for advanced interpolation algorithms such as linear and Bezier, makes the deformation animation transition more natural and smooth, and improves the realism and viewing experience of the deformation animation. The real-time weight update mechanism ensures the continuity of the animation over time, enhancing interactivity and immersion.
[0240] 4) Promote cross-platform compatibility and accessibility: Based on the lightweight model format of GLTF and the cross-platform capabilities of Web GPU, the technical solution provided in the embodiment of the present application can run stably in different operating systems and browser environments, lowering the user's entry threshold and expanding the audience range of 3D content.
[0241] 5) Promote the innovative development of Web 3D technology: The implementation of the technical solution provided in the embodiments of this application not only solves the bottleneck problems in related technologies, but also opens up a new direction for the future development of Web 3D animation, thereby encouraging the exploration of more innovative applications, such as more complex physical simulations, more sophisticated lighting effects, etc., and promoting technological progress and content richness.
[0242] The embodiment of the present application provides a deformation animation technology based on a 3D model (such as a GLTF model) and a GPU texture layer to transmit vertex offset data. Its efficient data processing capability and powerful real-time rendering performance are suitable for a variety of high-demand 3D graphics application scenarios, including but not limited to the following aspects:
[0243] 1. Online games and interactive entertainment scenarios: In web games or interactive entertainment applications, the deformation animation technology provided in the embodiments of the present application can realize real-time character expression animation, clothing simulation or environmental interaction effects, such as ripples on the water surface, swaying leaves, etc., to enhance the realism and immersion of the user experience.
[0244] 2. Virtual reality and augmented reality (VR / AR) scenarios: In VR / AR applications, the deformation animation technology provided by the embodiments of the present application can provide efficient vertex offset deformation, and efficient vertex offset deformation is essential for creating a dynamic virtual environment, such as the character's body language, facial expression changes, and the dynamic response of the environment, which can enhance the interactivity and realism of the virtual environment. In other words, the deformation animation technology provided by the embodiments of the present application can enhance the interactivity and realism of the virtual environment.
[0245] 3. 3D modeling and design tool scenarios: Using the deformation animation technology provided in the embodiment of the present application, users can directly preview and edit the deformation animation of the 3D model on the network (Web), such as the flow line changes of the car body, the shape transformation of furniture, etc., without downloading and installing professional software, thereby improving the convenience and efficiency of design.
[0246] 4. Digital twin and simulation scenarios: In the fields of industrial manufacturing, urban planning, etc., the deformation animation technology provided in the embodiments of the present application can be applied to the real-time simulation of the digital twin system, such as displaying the operating status of equipment and the visual deformation of the stress analysis of the building structure, which is helpful for rapid evaluation and decision support.
[0247] The deformation animation technology provided in the embodiment of the present application can bring movie-level three-dimensional animation effects to the Web platform by combining the lightweight model format of GLTF with the high-performance graphics processing capabilities of WebGPU. It can be widely used in various scenarios that require high-quality dynamic graphics display, thereby promoting the development of Web 3D technology and the expansion of its application scope.
[0248] In the technical solution of this application, the operations involved in obtaining, storing, using, processing, transmitting, providing and disclosing user personal information are all carried out with the user's authorization.
[0249] Corresponding to the processing method applied to the deformation animation, the embodiment of the present application also provides a processing device for the deformation animation, such as Fig.11 As shown, applied to a CPU, the device comprises:
[0250] A calculation module 111 is used to calculate target weights corresponding to a first number of deformation targets in a current frame according to a sampling time sequence and a sampling value sequence;
[0251] The first writing module 112 is used to write the target weights corresponding to the first number of deformation targets into the graphics processing unit GPU. The GPU caches a second number of texture layers corresponding to each deformation target. In the second number of texture layers, each texture layer stores vertex offset data of an attribute, so that the GPU determines new attribute values of multiple vertices under the second number of attributes according to the target weights corresponding to each deformation target and the vertex offset data included in each texture layer, and updates the three-dimensional model using the new attribute values of multiple vertices under the second number of attributes.
[0252] In some embodiments, the above-mentioned deformation animation processing device may further include:
[0253] A creation module, configured to create at least one texture layer according to a first number and a second number before calculating a target weight corresponding to each deformation target in a current frame, wherein each deformation target corresponds to the second number of texture layers, and each attribute corresponds to the first number of texture layers;
[0254] An acquisition module, used for acquiring vertex offset data of a second number of attributes included in each deformation target;
[0255] A second writing module is used to write the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute;
[0256] The third writing module is used to write the texture layer after the data is written into the GPU.
[0257] In some embodiments, a creation module may be specifically used to:
[0258] Determining a target size of the texture layer according to a third number of vertices included in the three-dimensional model, the target size being a power of 2, and a fourth number of pixels included in the texture layer of the target size being greater than or equal to the third number;
[0259] At least one texture layer of a target size is created according to the first quantity and the second quantity.
[0260] In some embodiments, the second writing module may be specifically used for:
[0261] Extracting vertex offset data of the same attribute included in the first number of deformation targets;
[0262] Writing vertex offset data of the same attribute included in the first number of deformation targets into a first number of consecutive texture layers in the at least one texture layer.
[0263] In some embodiments, the above-mentioned deformation animation processing device may further include:
[0264] A determination module, used to determine a level value of a starting texture layer corresponding to each attribute in at least one texture layer as a level offset value of each attribute;
[0265] The fourth writing module is used to write the level offset value of each attribute into the GPU, so that the GPU obtains the vertex offset data included in the texture layer corresponding to each attribute according to the level offset value of each attribute.
[0266] In some embodiments, the fourth writing module may be specifically used for:
[0267] Determine the pixel in each texture layer corresponding to each vertex;
[0268] For each vertex offset data of each attribute included in each deformation target, multiple component data included in the vertex offset data are written into multiple color spaces of the deformation target and the pixels corresponding to the attribute.
[0269] In some embodiments, the fourth writing module may also be used to:
[0270] If the number of color spaces included in a pixel is greater than the number of component data included in the vertex offset data of an attribute, then in a first number of texture layers corresponding to an attribute, component data is supplemented for each vertex offset data, and the number of component data included in the supplemented vertex offset data is the same as the number of color spaces included in a pixel.
[0271] In the technical solution provided in the embodiment of the present application, a second number of texture layers corresponding to the second number of attributes included in each deformation target are cached in the GPU, and each texture layer includes multiple vertex offset data of one attribute. For each frame, the CPU only needs to calculate the first number of target weights corresponding to the first number of deformation targets, and write the target weights corresponding to each deformation target to the GPU. The GPU extracts the multiple vertex offset data of each attribute from the texture layer, and uses the target weights written by the CPU to calculate the new attribute values of multiple vertices by itself, and then updates the three-dimensional model. The number of target weights is much smaller than the number of vertices. In the embodiment of the present application, for each frame, the CPU only needs to write the first number of target weights to the GPU without transmitting a large amount of vertex data, which reduces the transmission load between the CPU and the GPU, improves the efficiency of the deformation animation and the flexibility of control, and enhances the smoothness and authenticity of the deformation animation effect.
[0272] Corresponding to the above-mentioned deformation animation processing method applied to GPU, the embodiment of the present application also provides a deformation animation processing device, such as Fig.12 As shown, it is applied to a GPU, a second number of texture layers corresponding to each deformation target is cached in the GPU, and each texture layer in the second number of texture layers stores vertex offset data of one attribute, and the device includes:
[0273] The receiving module 121 is used to receive the target weights corresponding to the first number of deformation targets written by the CPU;
[0274] A determination module 122, configured to determine new attribute values of a plurality of vertices under a second number of attributes according to a target weight corresponding to each deformation target and vertex offset data included in each texture layer;
[0275] The updating module 123 is used to update the three-dimensional model using new attribute values of multiple vertices under the second number of attributes.
[0276] In some embodiments, the determination module 122 may be specifically configured to:
[0277] Extracting offset data of each vertex under each attribute from a second number of texture layers corresponding to each deformation target according to the indexes of the plurality of vertices and the level offset value of each attribute;
[0278] Using the offset data of each vertex under each attribute and the target weight corresponding to each deformation target, calculate the new attribute value of each vertex corresponding to each attribute.
[0279] In some embodiments, the level offset value of each attribute is the level value of the starting texture layer corresponding to each attribute;
[0280] The determination module 122 may be specifically used for:
[0281] Determine the UV coordinates of each vertex based on the indices of multiple vertices and the size of the texture layer;
[0282] For each attribute, traverse the deformation target; calculate the sum of the level offset value of the attribute and the index of the traversed deformation target to obtain the sampling depth; read the offset data at the UV coordinate of each vertex in the texture layer at the sampling depth; re-execute the step of traversing the deformation target until the first number of deformation targets are traversed.
[0283] In some embodiments, a plurality of threads are run in the GPU, and each thread corresponds to a group of vertices among the plurality of vertices; the determination module 122 may be specifically used to:
[0284] According to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer, multiple threads are used to determine new attribute values of the corresponding group of vertices under the second number of attributes in parallel.
[0285] In the technical solution provided in the embodiment of the present application, a second number of texture layers corresponding to the second number of attributes included in each deformation target are cached in the GPU, and each texture layer includes multiple vertex offset data of one attribute. For each frame, the CPU only needs to calculate the first number of target weights corresponding to the first number of deformation targets, and write the target weights corresponding to each deformation target to the GPU. The GPU extracts the multiple vertex offset data of each attribute from the texture layer, and uses the target weights written by the CPU to calculate the new attribute values of multiple vertices by itself, and then updates the three-dimensional model. The number of target weights is much smaller than the number of vertices. In the embodiment of the present application, for each frame, the CPU only needs to write the first number of target weights to the GPU without transmitting a large amount of vertex data, which reduces the transmission load between the CPU and the GPU, improves the efficiency of the deformation animation and the flexibility of control, and enhances the smoothness and authenticity of the deformation animation effect.
[0286] Corresponding to the above-mentioned deformation animation processing method applied to CPU and GPU, the embodiment of the present application also provides an electronic device, such as Fig.13 As shown, including:
[0287] A memory 131, used for storing computer programs;
[0288] CPU 132, used to implement the above-mentioned processing method of any deformation animation applied to the CPU when executing the program stored in the memory 131;
[0289] The GPU 133 is used to implement any deformation animation processing method applied to the GPU when executing the program stored in the memory 131 .
[0290] In addition, the electronic device may further include a communication bus and / or a communication interface, and the CPU 132 , the GPU 133 , the communication interface, and the memory 131 communicate with each other via the communication bus.
[0291] The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0292] The communication interface is used for communication between the above electronic device and other devices.
[0293] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0294] In another embodiment provided in the present application, a computer-readable storage medium is also provided, in which a computer program is stored. When the computer program is executed by a processor, the processing method for any deformation animation applied to the CPU is implemented, or the processing method for any deformation animation applied to the GPU is implemented.
[0295] In another embodiment provided in the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned deformation animation processing methods applied to the CPU, or to execute any of the above-mentioned deformation animation processing methods applied to the GPU.
[0296] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.
[0297] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0298] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, storage medium and program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0299] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.< / st> < / c> < / st>
Claims
1. A method for processing a deformation animation, characterized in that: Applied to a central processing unit (CPU), the method comprises: Calculate target weights corresponding to a first number of deformation targets in the current frame according to the sampling time sequence and the sampling value sequence; Writing target weights corresponding to the first number of deformation targets into a graphics processor GPU, wherein a second number of texture layers corresponding to each deformation target is cached in the GPU, wherein each texture layer of the second number of texture layers stores vertex offset data of an attribute, so that the GPU determines new attribute values of a plurality of vertices under the second number of attributes according to the target weights corresponding to each deformation target and the vertex offset data included in each texture layer, and updates the three-dimensional model using the new attribute values of the plurality of vertices under the second number of attributes; The level offset value of each attribute is the level value of the starting texture layer corresponding to each attribute; The step of determining new attribute values of a plurality of vertices under the second number of attributes according to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer comprises: Determine the UV coordinates of each vertex according to the indexes of the plurality of vertices and the size of the texture layer; For each attribute, traverse the deformation target; calculate the sum of the level offset value of the attribute and the index of the traversed deformation target to obtain a sampling depth; read the offset data at the UV coordinate of each vertex in the texture layer at the sampling depth; re-execute the step of traversing the deformation target until the first number of deformation targets are traversed; Using the offset data of each vertex under each attribute and the target weight corresponding to each deformation target, calculate the new attribute value of each vertex corresponding to each attribute.
2. The method according to claim 1, characterized in that Before calculating the target weights corresponding to the first number of deformation targets in the current frame, the method further includes: According to the first number and the second number, at least one texture layer is created, each deformation target corresponds to the second number of texture layers, and each attribute corresponds to the first number of texture layers; Obtaining vertex offset data of the second number of attributes included in each deformation target; Writing the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute; The texture layer after the data is written is written into the GPU.
3. The method according to claim 2, characterized in that The step of creating at least one texture layer according to the first number and the second number comprises: Determining a target size of the texture layer according to a third number of vertices included in the three-dimensional model, the target size being a power of 2, and a fourth number of pixels included in the texture layer of the target size being greater than or equal to the third number; At least one texture layer of the target size is created according to the first number and the second number.
4. The method according to claim 2, characterized in that: The step of writing the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute includes: Extracting vertex offset data of the same attribute included in the first number of deformation targets; Writing vertex offset data of the same attribute included in the first number of deformation targets into the first number of consecutive texture layers in the at least one texture layer.
5. The method according to claim 4, characterized in that The method further comprises: Determine a level value of a starting texture layer corresponding to each attribute in the at least one texture layer as a level offset value of each attribute; The level offset value of each attribute is written into the GPU, so that the GPU obtains the vertex offset data included in the texture layer corresponding to each attribute according to the level offset value of each attribute.
6. The method according to claim 2, characterized in that The step of writing the vertex offset data of each attribute included in each deformation target into the texture layer corresponding to each deformation target and each attribute includes: Determine the pixel in each texture layer corresponding to each vertex; For each vertex offset data of each attribute included in each deformation target, multiple component data included in the vertex offset data are written into multiple color spaces of the deformation target and the pixels corresponding to the attribute.
7. A method for processing a deformation animation, characterized in that: The method is applied to a graphics processor (GPU), wherein a second number of texture layers corresponding to each deformation target is cached in the GPU, wherein each texture layer in the second number of texture layers stores vertex offset data of an attribute, and a level offset value of each attribute is a level value of a starting texture layer corresponding to each attribute; the method comprises: Receive target weights corresponding to a first number of deformation targets written by a central processing unit CPU; Determining new attribute values of a plurality of vertices under the second number of attributes according to a target weight corresponding to each deformation target and vertex offset data included in each texture layer; Updating the three-dimensional model using new attribute values of the plurality of vertices under the second number of attributes; The step of determining new attribute values of a plurality of vertices under the second number of attributes according to the target weight corresponding to each deformation target and the vertex offset data included in each texture layer comprises: Determine the UV coordinates of each vertex according to the indexes of the plurality of vertices and the size of the texture layer; For each attribute, traverse the deformation target; calculate the sum of the level offset value of the attribute and the index of the traversed deformation target to obtain a sampling depth; read the offset data at the UV coordinate of each vertex in the texture layer at the sampling depth; re-execute the step of traversing the deformation target until the first number of deformation targets are traversed; Using the offset data of each vertex under each attribute and the target weight corresponding to each deformation target, calculate the new attribute value of each vertex corresponding to each attribute.
8. An electronic device, characterized in that: include: Memory, used to store computer programs; A CPU, configured to implement any of the methods of claims 1 to 6 when executing a program stored in the memory; The GPU is used to implement the method of claim 7 when executing a program stored in the memory.
Citation Information
Patent Citations
Animation Techniques for Mobile Devices
US20170358118A1
3D scene description data, scene rendering apparatus for rendering a scene from 3D scene description data, and apparatus for encoding a scene into 3D scene description data
US20230394744A1