CN112489183A - Unity 3D-based skeletal animation rendering method and system - Google Patents

Unity 3D-based skeletal animation rendering method and system Download PDF

Info

Publication number
CN112489183A
CN112489183A CN202011357225.4A CN202011357225A CN112489183A CN 112489183 A CN112489183 A CN 112489183A CN 202011357225 A CN202011357225 A CN 202011357225A CN 112489183 A CN112489183 A CN 112489183A
Authority
CN
China
Prior art keywords
bone
vertex
animation
frame
target model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011357225.4A
Other languages
Chinese (zh)
Inventor
桑新柱
郑健平
邢树军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing University of Posts and Telecommunications
Original Assignee
Beijing University of Posts and Telecommunications
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing University of Posts and Telecommunications filed Critical Beijing University of Posts and Telecommunications
Priority to CN202011357225.4A priority Critical patent/CN112489183A/en
Publication of CN112489183A publication Critical patent/CN112489183A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T13/00Animation
    • G06T13/203D [Three Dimensional] animation

Abstract

The invention provides a Unity 3D-based skeletal animation rendering method and system, wherein the method comprises the following steps: carrying out texture conversion processing on the skeletal animation data of each frame of the target model example to obtain a skeletal animation data texture map; inputting the bone animation data texture map into a shader program based on Unity3D, and calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, so as to render the bone animation of each frame of the target model instance according to the vertex coordinate vector. According to the invention, a great amount of instantiated model animations can be output only by rendering the pipeline once by one shader program, so that the frame rendering time is greatly reduced.

Description

Unity 3D-based skeletal animation rendering method and system
Technical Field
The invention relates to the technical field of computer graphics, in particular to a Unity 3D-based skeletal animation rendering method and system.
Background
The traditional skeletal animation rendering process comprises the following steps: calculating the original T model posture as the current frame animation posture in a Central Processing Unit (CPU); secondly, transmitting the vertex data of the model from a CPU (Central Processing Unit) end to a graphic Processing Unit (GPU for short) end; and calling a drawing function, and drawing the vertex data of the model into a final rendering image through a rendering pipeline.
In the game scene created by the Unity3D engine, there are a large number of instances of a certain object, and when the object has skeletal animation, the CPU performs a large number of vertex calculations per frame and calls the rendering and drawing functions multiple times, which results in serious calculation time consumption and greatly reduces the number of rendering frames.
Therefore, a skeletal animation rendering method and system based on Unity3D are needed to solve the above problems.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides a Unity 3D-based skeletal animation rendering method and system.
The invention provides a Unity 3D-based skeletal animation rendering method, which comprises the following steps:
carrying out texture conversion processing on the skeletal animation data of each frame of the target model example to obtain a skeletal animation data texture map;
inputting the bone animation data texture map into a shader program based on Unity3D, and calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, so as to render the bone animation of each frame of the target model instance according to the vertex coordinate vector.
According to the Unity 3D-based skeletal animation rendering method provided by the invention, texture transformation processing is performed on skeletal animation data of each frame of a target model instance to obtain a skeletal animation data texture map, and the method comprises the following steps:
sampling bone animation data of each frame of the target model example to obtain vertex data and a preset rendering animation segment of each frame, and analyzing the bone animation through an Editor plug-in according to the vertex data and the preset rendering animation segment to obtain a corresponding bone posture transformation matrix;
and carrying out data splitting and compression processing on the bone posture transformation matrix to obtain RGBA color values, and generating a bone animation data texture map through the RGBA color values according to the bone vertex index and the frame number sequence.
According to the Unity 3D-based skeletal animation rendering method provided by the invention, before the Unity 3D-based skeletal animation data texture map is input into a shader program, the method further comprises the following steps:
obtaining a bone vertex index and a bone vertex weight corresponding to the bone vertex index according to the bone animation data of each frame of the target model instance;
storing the bone vertex indices and the bone vertex weights into a UV channel of each vertex of a target model.
According to the Unity 3D-based skeletal animation rendering method provided by the invention, before the Unity 3D-based skeletal animation data texture map is input into a shader program, the method further comprises the following steps:
acquiring a current frame animation index and a current frame animation frame number of the target model example;
taking the current frame animation index as a previous frame animation index, taking the current frame animation frame number as a previous frame animation frame number, and calculating a current frame animation actual index and a current frame animation actual frame number according to the current frame time;
and generating a corresponding generated material attribute block according to the previous frame animation frame number, the current frame animation actual index, the current frame animation actual frame number and a frame interpolation coefficient, and sending the generated material attribute block to a shader program of Unity3D, wherein the frame interpolation coefficient is obtained by the current frame moment.
According to the Unity 3D-based bone animation rendering method provided by the invention, the Unity 3D-based bone animation data texture map is input into a shader program, and a vertex coordinate vector of each vertex in the target model instance is calculated according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, and the method comprises the following steps:
determining a skeleton vertex transformation matrix of a frame on each skeleton vertex and a skeleton vertex transformation matrix of a current frame according to the material attribute block, the skeleton animation data texture map and the skeleton vertex index;
according to the frame interpolation coefficient, carrying out linear interpolation operation on the skeleton vertex transformation matrix of the previous frame and the skeleton vertex transformation matrix of the current frame on each skeleton vertex to obtain a corresponding skeleton vertex target transformation matrix;
calculating a vertex coordinate vector of each vertex current frame in the target model instance according to the bone vertex target transformation matrix and the bone vertex weight through a UV channel in which the bone vertex index and the bone vertex weight are stored;
and rendering the skeleton animation of the target model example according to the vertex coordinate vector of each vertex current frame.
According to the skeletal animation rendering method based on Unity3D, the method further comprises the following steps:
and acquiring a corresponding TRS matrix according to the position vector, the rotation vector and the scaling vector of the target model instance, and converting the target model instance from a model space to a clipping space according to the TRS matrix.
According to the Unity 3D-based skeletal animation rendering method provided by the invention, after the skeletal animation data of each frame of the target model instance is subjected to texture transformation processing to obtain a skeletal animation data texture map, the method further comprises the following steps:
and filtering the skeletal animation data texture map according to a preset filtering mode, wherein the preset filtering mode is a point mode.
The invention also provides a Unity 3D-based skeletal animation rendering system, which comprises:
the texture map conversion module is used for carrying out texture conversion processing on the skeleton animation data of each frame of the target model example to obtain a skeleton animation data texture map;
and the bone animation rendering module is used for inputting the bone animation data texture map into a shader program based on a Unity3D technology, calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, and rendering the bone animation of the target model instance according to the vertex coordinate vector.
The invention also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to realize the steps of the Unity 3D-based skeletal animation rendering method.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the Unity 3D-based skeletal animation rendering method as described in any of the above.
According to the Unity 3D-based skeletal animation rendering method and system, a great amount of instantiated model animations can be output only by performing rendering pipeline once by one shader program, and the frame rendering time is greatly reduced.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
FIG. 1 is a flowchart illustrating a Unity 3D-based skeletal animation rendering method according to the present invention;
FIG. 2 is a schematic structural diagram of a Unity 3D-based skeletal animation rendering system according to the present invention;
fig. 3 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the existing bone animation rendering process, if a large number of same models are rendered one by one, draw calls are performed for many times, namely, a CPU commands a GPU to perform rendering operation by calling a graphic library interface, so that the number of rendering frames is greatly reduced. In the Unity3D engine, the GPU Skinning (i.e. skeleton animation Skinning by GPU graphics processor) function is based on GLES version 3.0, and the GPU needs to support Texture Float format (Sample2D _ Float), which is a requirement for running devices and cannot be compatible with a large number of GLES version 2.0 devices. Therefore, the GPU Skinning function and the GPU instant function in the Unity3D engine are combined, when the GPU Skinning function is performed, after a GPU Skinning option in Project Setting is selected, Transform feedback is performed through a Skinning Mesh render, and Vertex Buffer is rewritten by combining a Geometry Shader; when the GPU instant function is performed, that is, through a drawmeshstantized function, a small amount of drawcalls can be used to draw a large number of objects with the same Mesh and different parameters at a time, and through a material property block (material property block), different properties of the batch of objects are transmitted to the shader program at a time, and the properties of each object are obtained through indexing by InstanceID.
Fig. 1 is a flowchart illustrating a skeletal animation rendering method based on Unity3D, as shown in fig. 1, the invention provides a skeletal animation rendering method based on Unity3D, which includes:
step 101, performing texture conversion processing on the skeletal animation data of each frame of the target model instance to obtain a skeletal animation data texture map.
In the invention, bone animation data of each frame of a target model instance is obtained in advance, and the frame animation is analyzed through an Editor plug-in tool, so that a bone posture transformation matrix is obtained; and then converting the processed bone posture transformation matrix into an RGBA color format, writing a 2D texture map to obtain a bone animation data texture map, and establishing coordinates based on the bone animation data texture map, wherein the horizontal axis is animation frame number sequence, and the vertical axis is bone vertex index. Preferably, in the invention, since the texture map of the skeletal animation data is stored according to coordinates, the texture filtering mode may be set to be a Point mode, and the texture map of the skeletal animation data is subjected to texture filtering.
Step 102, inputting the bone animation data texture map into a shader program based on Unity3D, and calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, so as to render the bone animation of each frame of the target model instance according to the vertex coordinate vector.
In the invention, firstly, parameters of each generation Instance are calculated through a Unity3D C # script, wherein the parameters of the GPU Instance comprise a position vector, a rotation vector and a scaling vector; the parameters of the GPU Skinning include the data of the previous frame, the data of the current frame and the interpolation factor. Meanwhile, two UV channels need to be utilized in the Mesh (Mesh object) for storing the bone vertex index value of each frame and the bone weight corresponding to the bone vertex index value, it should be noted that the present invention uses 4 bones, i.e., 4bone vertex indexes, and two UV channels need to be used, i.e., 2 bones, i.e., 2bone vertex indexes, only one UV channel needs to be used, and the step can be completed in the preprocessing stage.
Furthermore, all the bone animation data texture maps are input into a shader program, reading is carried out in a vertex shader, transformation matrixes corresponding to 4bone vertex indexes are calculated according to the bone vertex indexes, the positions of the current frame vertexes are calculated through bone weights, and interpolation is used for smoothing the bone animation. And finally, outputting the skeleton animation to a fragment shader through the transformation from the model space of the rendering pipeline to the clipping space, wherein the fragment shader has the same function as the fragment shader of the rendering pipeline and is responsible for color sampling and output of the model vertex.
According to the Unity 3D-based skeletal animation rendering method, a great amount of instantiated model animations can be output only by performing rendering pipeline once by one shader program, and the frame rendering time is greatly reduced.
On the basis of the above embodiment, the performing texture transformation processing on the skeletal animation data of each frame of the target model instance to obtain a skeletal animation data texture map includes:
sampling bone animation data of each frame of the target model example to obtain vertex data and a preset rendering animation segment of each frame, and analyzing the bone animation through an Editor plug-in according to the vertex data and the preset rendering animation segment to obtain a corresponding bone posture transformation matrix;
and carrying out data splitting and compression processing on the bone posture transformation matrix to obtain RGBA color values, and generating a bone animation data texture map through the RGBA color values according to the bone vertex index and the frame number sequence.
In the invention, vertex data and preset rendering animation segments of a target model example are read, and each skeleton posture transformation matrix is calculated frame by frame through an Editor plug-in. The invention is explained by taking 4 skeleton vertex indexes, a 4 x 4 matrix is subjected to data splitting to be regarded as 4 row vectors, then the data is compressed to be between 0 and 1 and then is converted into RGBA color values, wherein the RGBA color value converted in the fourth row is (0, 0, 0, 1), and the optimized texture size can be omitted. Then, the frame number sequence is taken as a horizontal coordinate, a bone sequence number (bone vertex index) is taken as a vertical coordinate, and the frame number sequence is written into a two-dimensional texture map; and finally generating a bone animation data texture map.
In another embodiment, a createAnimTexture plug-in is used to generate a texture map of the skeletal animation data corresponding to the skeletal animation data, and the specific steps are as follows:
step S1, acquiring the duration, the frame number and the model skeleton vertex number of skeleton animation data, and creating a two-dimensional texture map with a preset size;
step S2, circularly traversing all the skeletal animation data segments, and processing one by one;
step S3, sampling each skeleton animation data segment frame by frame, and calculating a skeleton posture transformation matrix in a model space frame by skeleton vertex;
step S4, processing each bone posture transformation matrix, compressing the matrix according to the number of the lines of travel and then converting the matrix into 4 RGBA color values, wherein the fourth line value is fixed to be (0, 0, 0, 1) negligible, and writing the obtained color values into the two-dimensional texture map pre-created in the step S1, wherein the horizontal axis is the animation frame number, and the vertical axis is the bone vertex index;
and step S5, storing according to the preset path and the preset file name to obtain the bone animation data texture map.
On the basis of the above embodiment, before the Unity 3D-based skeletal animation data texture map is input into a shader program, the method further includes:
obtaining a bone vertex index and a bone vertex weight corresponding to the bone vertex index according to the bone animation data of each frame of the target model instance;
storing the bone vertex indices and the bone vertex weights into a UV channel of each vertex of a target model.
In the present invention, first, in the preprocessing stage, two items of data for animation Skinning, i.e., GPU Skinning, need to be: and storing the bone vertex index and the bone weight for subsequent GPU use. Specifically, the storage mode of the invention is to store 2 UV channels of each vertex of the target model respectively, the UV1 channel of each vertex in the model stores 4bone vertex indexes when the vertex runs animation skinning, and the UV2 channel stores weight values of the 4bone vertices when the vertex runs animation skinning.
On the basis of the above embodiment, before the Unity 3D-based skeletal animation data texture map is input into a shader program, the method further includes:
acquiring a current frame animation index and a current frame animation frame number of the target model example;
taking the current frame animation index as a previous frame animation index, taking the current frame animation frame number as a previous frame animation frame number, and calculating a current frame animation actual index and a current frame animation actual frame number according to the current frame time;
and generating a corresponding generated material attribute block according to the previous frame animation frame number, the current frame animation actual index, the current frame animation actual frame number and a frame interpolation coefficient, and sending the generated material attribute block to a shader program of Unity3D, wherein the frame interpolation coefficient is obtained by the current frame moment.
In the invention, animation related parameters needed by GPU Skinning are calculated, a current frame animation index of each target model instance is stored as a previous frame animation index, and a current frame animation frame number is stored as a previous frame animation frame number; then, according to the current frame time, recalculating the current frame animation actual index and the current frame animation actual frame number, and calculating a frame interpolation coefficient according to the current frame time; and finally, packaging the animation index of the previous frame, the animation frame number of the previous frame, the animation actual index of the current frame, the animation actual frame number of the current frame and the frame interpolation coefficient into a material attribute block, and sending the material attribute block to a GPU Skinning shader program. The GPU Instance function is realized by calling a DrawMeshInstanced function of Unity 3D.
On the basis of the above embodiment, the inputting the bone animation data texture map into a shader program based on Unity3D, and calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, includes:
determining a skeleton vertex transformation matrix of a frame on each skeleton vertex and a skeleton vertex transformation matrix of a current frame according to the material attribute block, the skeleton animation data texture map and the skeleton vertex index;
according to the frame interpolation coefficient, carrying out linear interpolation operation on the skeleton vertex transformation matrix of the previous frame and the skeleton vertex transformation matrix of the current frame on each skeleton vertex to obtain a corresponding skeleton vertex target transformation matrix;
calculating a vertex coordinate vector of each vertex current frame in the target model instance according to the bone vertex target transformation matrix and the bone vertex weight through a UV channel in which the bone vertex index and the bone vertex weight are stored;
and rendering the skeleton animation of the target model example according to the vertex coordinate vector of each vertex current frame.
In the invention, firstly, a bone animation data texture graph obtained by preprocessing is used as a material attribute and is sent to a shader program; then, analyzing a material attribute block obtained based on a GPU Instance function to obtain a previous frame animation index, a previous frame animation frame number, a current frame animation actual index, a current frame animation actual frame number and a frame interpolation coefficient of the current Instance; next, a GPU Skinning computation phase is performed, which is performed in the vertex shader, processing each vertex of the instance, and since the bone vertex index and the bone weight have been stored in the UV1 channel and the UV2 channel of the vertex data, the coordinate of the current vertex is ∑ the coordinate of the bone vertex index i × the bone weight of the bone vertex index i.
Further, a texture map to be processed is determined according to the previous frame animation index, the abscissa (i.e., the number of animation frames corresponding to the texture map) is determined according to the number of the previous frame animation frames, the ordinate is determined according to the skeleton vertex index i, and a transformation matrix of the skeleton vertex index i can be calculated, at this time, an original value needs to be obtained according to an inverse operation of the numerical compression processing when the texture is written. Through the above process, the transformation matrix of the four bone vertices of the previous frame can be obtained, and similarly, the transformation matrix of the four bone vertices of the current frame can also be obtained. Then, linear interpolation operation is carried out on the two transformation matrixes of the same skeleton vertex through a frame interpolation coefficient to obtain a final skeleton vertex transformation matrix, namely a skeleton vertex target transformation matrix, and further, a coordinate vector of the current vertex is obtained through weighting operation of four skeleton vertex weights. And finally, the rendering of the skeleton animation is completed through the transformation from the model space of the rendering pipeline to the clipping space and the output to the fragment shader.
On the basis of the above embodiment, the method further includes:
and acquiring a corresponding TRS matrix according to the position vector, the rotation vector and the scaling vector of the target model instance, and converting the target model instance from a model space to a clipping space according to the TRS matrix.
On the basis of the above embodiment, after the texture transformation processing is performed on the bone animation data of each frame of the target model instance to obtain a bone animation data texture map, the method further includes:
and filtering the skeletal animation data texture map according to a preset filtering mode, wherein the preset filtering mode is a point mode.
Fig. 2 is a schematic structural diagram of a Unity 3D-based skeletal animation rendering system, as shown in fig. 2, the Unity 3D-based skeletal animation rendering system provided by the present invention includes a texture map transformation module 201 and a skeletal animation rendering module 202, where the texture map transformation module is configured to perform texture transformation processing on skeletal animation data of each frame of a target model instance to obtain a skeletal animation data texture map; and the bone animation rendering module is used for inputting the bone animation data texture map into a shader program based on a Unity3D technology, calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, and rendering the bone animation of the target model instance according to the vertex coordinate vector.
According to the Unity 3D-based skeletal animation rendering system, a great amount of instantiated model animations can be output only by performing rendering pipeline once by one shader program, and the frame rendering time is greatly reduced.
The system provided by the embodiment of the present invention is used for executing the above method embodiments, and for details of the process and the details, reference is made to the above embodiments, which are not described herein again.
Fig. 3 is a schematic structural diagram of an electronic device provided in the present invention, and as shown in fig. 3, the electronic device may include: a processor (processor)301, a communication interface (communication interface)302, a memory (memory)303 and a communication bus 304, wherein the processor 301, the communication interface 302 and the memory 303 complete communication with each other through the communication bus 304. Processor 301 may call logic instructions in memory 303 to perform a Unity 3D-based skeletal animation rendering method comprising: carrying out texture conversion processing on the skeletal animation data of each frame of the target model example to obtain a skeletal animation data texture map; inputting the bone animation data texture map into a shader program based on Unity3D, and calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, so as to render the bone animation of each frame of the target model instance according to the vertex coordinate vector.
In addition, the logic instructions in the memory 303 may be implemented in the form of software functional units and stored in a computer readable storage medium when the logic instructions are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
In another aspect, the present invention also provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions, which when executed by a computer, enable the computer to perform a Unity 3D-based skeletal animation rendering method provided by the above methods, the method comprising: carrying out texture conversion processing on the skeletal animation data of each frame of the target model example to obtain a skeletal animation data texture map; inputting the bone animation data texture map into a shader program based on Unity3D, and calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, so as to render the bone animation of each frame of the target model instance according to the vertex coordinate vector.
In yet another aspect, the present invention further provides a non-transitory computer readable storage medium, on which a computer program is stored, the computer program being implemented by a processor to perform the Unity 3D-based skeletal animation rendering method provided in the foregoing embodiments, the method including: carrying out texture conversion processing on the skeletal animation data of each frame of the target model example to obtain a skeletal animation data texture map; inputting the bone animation data texture map into a shader program based on Unity3D, and calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, so as to render the bone animation of each frame of the target model instance according to the vertex coordinate vector.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A Unity 3D-based skeletal animation rendering method is characterized by comprising the following steps:
carrying out texture conversion processing on the skeletal animation data of each frame of the target model example to obtain a skeletal animation data texture map;
inputting the bone animation data texture map into a shader program based on Unity3D, and calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, so as to render the bone animation of each frame of the target model instance according to the vertex coordinate vector.
2. The Unity 3D-based skeletal animation rendering method according to claim 1, wherein the texture transformation processing on the skeletal animation data of each frame of the target model instance to obtain the skeletal animation data texture map comprises:
sampling bone animation data of each frame of the target model example to obtain vertex data and a preset rendering animation segment of each frame, and analyzing the bone animation through an Editor plug-in according to the vertex data and the preset rendering animation segment to obtain a corresponding bone posture transformation matrix;
and carrying out data splitting and compression processing on the bone posture transformation matrix to obtain RGBA color values, and generating a bone animation data texture map through the RGBA color values according to the bone vertex index and the frame number sequence.
3. A Unity 3D-based skeletal animation rendering method according to claim 1, wherein before the Unity 3D-based skeletal animation data texture map is input into a shader program, the method further comprises:
obtaining a bone vertex index and a bone vertex weight corresponding to the bone vertex index according to the bone animation data of each frame of the target model instance;
storing the bone vertex indices and the bone vertex weights into a UV channel of each vertex of a target model.
4. A Unity 3D-based skeletal animation rendering method according to claim 3, wherein before the Unity 3D-based skeletal animation data texture map is input into a shader program, the method further comprises:
acquiring a current frame animation index and a current frame animation frame number of the target model example;
taking the current frame animation index as a previous frame animation index, taking the current frame animation frame number as a previous frame animation frame number, and calculating a current frame animation actual index and a current frame animation actual frame number according to the current frame time;
and generating a corresponding generated material attribute block according to the previous frame animation frame number, the current frame animation actual index, the current frame animation actual frame number and a frame interpolation coefficient, and sending the generated material attribute block to a shader program of Unity3D, wherein the frame interpolation coefficient is obtained by the current frame moment.
5. The Unity 3D-based bone animation rendering method according to claim 4, wherein the Unity 3D-based bone animation data texture map is input into a shader program, and a vertex coordinate vector of each vertex in the target model instance is calculated according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, and the method comprises the following steps:
determining a skeleton vertex transformation matrix of a frame on each skeleton vertex and a skeleton vertex transformation matrix of a current frame according to the material attribute block, the skeleton animation data texture map and the skeleton vertex index;
according to the frame interpolation coefficient, carrying out linear interpolation operation on the skeleton vertex transformation matrix of the previous frame and the skeleton vertex transformation matrix of the current frame on each skeleton vertex to obtain a corresponding skeleton vertex target transformation matrix;
calculating a vertex coordinate vector of each vertex current frame in the target model instance according to the bone vertex target transformation matrix and the bone vertex weight through a UV channel in which the bone vertex index and the bone vertex weight are stored;
and rendering the skeleton animation of the target model example according to the vertex coordinate vector of each vertex current frame.
6. The Unity 3D-based skeletal animation rendering method of claim 1, further comprising:
and acquiring a corresponding TRS matrix according to the position vector, the rotation vector and the scaling vector of the target model instance, and converting the target model instance from a model space to a clipping space according to the TRS matrix.
7. The Unity 3D-based skeletal animation rendering method according to claim 2, wherein after the texture transformation processing is performed on the skeletal animation data of each frame of the target model instance to obtain a skeletal animation data texture map, the method further comprises:
and filtering the skeletal animation data texture map according to a preset filtering mode, wherein the preset filtering mode is a point mode.
8. A Unity 3D-based skeletal animation rendering system, comprising:
the texture map conversion module is used for carrying out texture conversion processing on the skeleton animation data of each frame of the target model example to obtain a skeleton animation data texture map;
and the bone animation rendering module is used for inputting the bone animation data texture map into a shader program based on a Unity3D technology, calculating a vertex coordinate vector of each vertex in the target model instance according to a bone vertex index of the bone animation data texture map and a bone weight corresponding to the bone vertex index, and rendering the bone animation of the target model instance according to the vertex coordinate vector.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the computer program implements the steps of the Unity3D based skeletal animation rendering method according to any of the claims 1 to 7.
10. A non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor, performs the steps of the Unity3D based skeletal animation rendering method according to any of claims 1 to 7.
CN202011357225.4A 2020-11-26 2020-11-26 Unity 3D-based skeletal animation rendering method and system Pending CN112489183A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011357225.4A CN112489183A (en) 2020-11-26 2020-11-26 Unity 3D-based skeletal animation rendering method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011357225.4A CN112489183A (en) 2020-11-26 2020-11-26 Unity 3D-based skeletal animation rendering method and system

Publications (1)

Publication Number Publication Date
CN112489183A true CN112489183A (en) 2021-03-12

Family

ID=74935961

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011357225.4A Pending CN112489183A (en) 2020-11-26 2020-11-26 Unity 3D-based skeletal animation rendering method and system

Country Status (1)

Country Link
CN (1) CN112489183A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113688341A (en) * 2021-10-25 2021-11-23 深圳市明源云空间电子商务有限公司 Dynamic picture decomposition method and device, electronic equipment and readable storage medium
CN113902609A (en) * 2021-03-17 2022-01-07 广州市保伦电子有限公司 Method and device for smoothly rendering control animation based on OpenGL embedded device
CN115661310A (en) * 2022-12-22 2023-01-31 海马云(天津)信息技术有限公司 Virtual digital human expression approximation method and device, storage medium and electronic equipment
CN116704150A (en) * 2023-08-09 2023-09-05 威创软件南京有限公司 Three-dimensional presentation method and system for dynamic flow of energy of cold-hot gas electric grid frame pipeline

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2308224A2 (en) * 2008-08-04 2011-04-13 Microsoft Corporation Gpu scene composition and animation
CN103606180A (en) * 2013-11-29 2014-02-26 广州菲动软件科技有限公司 Rendering method and device of 3D skeletal animation
CN108711182A (en) * 2018-05-03 2018-10-26 广州爱九游信息技术有限公司 Render processing method, device and mobile terminal device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2308224A2 (en) * 2008-08-04 2011-04-13 Microsoft Corporation Gpu scene composition and animation
CN103606180A (en) * 2013-11-29 2014-02-26 广州菲动软件科技有限公司 Rendering method and device of 3D skeletal animation
CN108711182A (en) * 2018-05-03 2018-10-26 广州爱九游信息技术有限公司 Render processing method, device and mobile terminal device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
伊恩·克鲁克 等: "动态图形设计基础 从理论到实践", 中国青年出版社, pages: 88 - 91 *
宋丽丽等: "基于VTF的海洋生物骨骼动画系统设计与实现", 《计算机与现代化》, no. 05, 15 May 2013 (2013-05-15) *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113902609A (en) * 2021-03-17 2022-01-07 广州市保伦电子有限公司 Method and device for smoothly rendering control animation based on OpenGL embedded device
CN113688341A (en) * 2021-10-25 2021-11-23 深圳市明源云空间电子商务有限公司 Dynamic picture decomposition method and device, electronic equipment and readable storage medium
CN115661310A (en) * 2022-12-22 2023-01-31 海马云(天津)信息技术有限公司 Virtual digital human expression approximation method and device, storage medium and electronic equipment
CN116704150A (en) * 2023-08-09 2023-09-05 威创软件南京有限公司 Three-dimensional presentation method and system for dynamic flow of energy of cold-hot gas electric grid frame pipeline
CN116704150B (en) * 2023-08-09 2023-11-17 威创软件南京有限公司 Three-dimensional presentation method and system for dynamic flow of energy of cold-hot gas electric grid frame pipeline

Similar Documents

Publication Publication Date Title
CN112489183A (en) Unity 3D-based skeletal animation rendering method and system
JP5451285B2 (en) Image processing apparatus and image processing method
CN111161392B (en) Video generation method and device and computer system
CN112785674A (en) Texture map generation method, rendering method, device, equipment and storage medium
US20140071124A1 (en) Image processing apparatus
CN110570506B (en) Map resource management method, device, computing equipment and storage medium
CN113838176A (en) Model training method, three-dimensional face image generation method and equipment
US11763514B1 (en) Hard ware-assisted emulation of graphics pipeline
GB2504815A (en) A graphics processing unit and method for performing tessellation operations
US11087511B1 (en) Automated vectorization of a raster image using a gradient mesh with arbitrary topology
CN113592711A (en) Three-dimensional reconstruction method, system and equipment for point cloud data nonuniformity and storage medium
CN112734910A (en) Real-time human face three-dimensional image reconstruction method and device based on RGB single image and electronic equipment
CN115222879A (en) Model surface reduction processing method and device, electronic equipment and storage medium
CN109542574B (en) Pop-up window background blurring method and device based on OpenGL
CN114092611A (en) Virtual expression driving method and device, electronic equipment and storage medium
CN113379886A (en) Three-dimensional rendering method, device and equipment of geographic information system and storage medium
CN112132941B (en) Text rendering method, device, equipment and storage medium
CN117292039A (en) Vertex coordinate generation method, vertex coordinate generation device, electronic equipment and computer storage medium
CN115836317A (en) Incremental triple index compression
CN114491352A (en) Model loading method and device, electronic equipment and computer readable storage medium
CN115861510A (en) Object rendering method, device, electronic equipment, storage medium and program product
US11417058B2 (en) Anti-aliasing two-dimensional vector graphics using a multi-vertex buffer
US8274513B1 (en) System, method, and computer program product for obtaining a boundary attribute value from a polygon mesh, during voxelization
CN112416489A (en) Engineering drawing display method and related device
US11869123B2 (en) Anti-aliasing two-dimensional vector graphics using a compressed vertex buffer

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination