A rendering method and system for a large number of 3D animation models
By encoding 3D model skeleton animation onto floating point textures and using GPU instantiation rendering function, the problem of too many drawcalls in animation model rendering is solved, efficient GPU rendering is achieved, and game performance is improved.
Patent Information
- Application Number
- CN202210681751.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-15
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-06-15
AI Technical Summary
The prior art cannot effectively use GPU instantiation drawing technology to render an animation 3D model, resulting in a large number of drawcalls leading to high CPU usage and reduced game frame rate.
By encoding the transformation results of grid vertices in each frame of the 3D model skeleton animation onto floating point textures, and using the GPU instantiation rendering function to generate and execute instantiated rendering data, reducing the number of drawcalls.
It effectively reduces CPU usage, increases game frame rate, and realizes efficient rendering of large-scale animation models.
Smart Images

Figure CN115063519B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of 3D rendering, and particularly relates to a rendering method and system for a large number of 3D animation models. Background Art
[0002] The conventional steps for a game engine to render a 3D model are as follows: 1. Use digital content creation tools (such as 3DSMAX, Photoshop, etc.) to produce model data. If the object has an animation, the matching animation data needs to be produced; 2. Import the mesh vertex data and skeletal animation data into the game engine to generate optimized model data and animation data; 3. Use the data generated in step 2 to implement 3D rendering using the functions provided by the engine; 4. Submit a rendering instruction from the CPU (Central Processing Unit) to the GPU (Graphics Processing Unit) once to complete one rendering of a model. This operation is hereinafter simply referred to as drawcall. Completing the rendering of a model usually requires model vertex data and texture data. If it is an animated model, vertex skinning data and skeletal animation data are also required. The number of drawcalls is an important indicator of game performance. Too many drawcalls will cause the computer's CPU occupancy rate to be too high, resulting in a decrease in the game frame rate and a phenomenon of screen stuttering. With the development of current games, the quality of the game scene and the rendering effect are directly related to the user experience. The higher the scene quality, generally the more models need to be rendered, the greater the consumption of CPU and GPU resources, and the lower the rendering speed. The scene becomes more and more grand, and the demand for the number of models is constantly increasing. If one drawcall is still used for each model rendering, it will not be able to meet the performance requirements of game operation. In order to reduce the number of drawcalls, a batching processing method is generally adopted to complete the rendering of multiple models using one drawcall. Currently, the commonly used batching processing technologies include static batching, dynamic batching, and gpuinstancing (GPU instancing rendering technology). The emergence of GPU instancing rendering technology enables a large number of objects with different states (position, size, color, etc.) to be drawn with only one drawcall for the same model (the same mesh). GPU instancing rendering technology is very easy to implement for rendering a large number of non-animated models, such as stones, buildings, etc., but it cannot be used for models with animations such as NPCs and characters. Summary of the Invention
[0003] The present invention solves the problem that 3D models with animations cannot utilize the GPU instancing rendering technology. Based on the use of the GPU instancing rendering technology, it greatly reduces the number of drawcalls in the case of needing to render a large number of 3D models with animations of the same type, making it possible to display a huge number of animated models in the game scene. The specific solution is as follows:
[0004] A rendering method for a large number of 3D animation models, comprising the following steps:
[0005] S1: The animation texture generation module encodes the transformation results of the mesh vertex coordinates of each frame of the 3D model skeletal animation onto a floating-point texture to obtain an animation texture.
[0006] S2: The GPU instanced rendering state model management module determines whether the animated models in the current scene can be used for GPU instanced rendering, and saves the models with the state available for GPU (Graphics Processing Unit) instanced rendering and the currently played animation to the corresponding model lists.
[0007] S3: The instanced rendering data generation module traverses each type of model list generated in S2 to generate an instanced rendering data list.
[0008] S4: The instanced rendering execution module traverses the instanced rendering data list generated in S3 and performs an instanced rendering operation on each piece of data.
[0009] Further, step S1 is specifically as follows:
[0010] The animation texture generation module, in an offline manner, through a game editor or model data processing tool, according to the animation data of the 3D model, encodes the local space coordinate change results of all vertices of each frame of the skeletal animation with time as the vertical coordinate (V) and vertex index as the horizontal coordinate (U) onto a sufficiently large floating-point texture to obtain an animation texture.
[0011] Further, step S2 is specifically as follows:
[0012] The GPU instanced rendering state model management module determines whether the current frame of all animated models in the managed scene can be used for GPU instanced rendering. When the object is far from the camera to a set distance value, it will enter the state available for GPU instanced rendering; otherwise, the object enters the state not available for GPU instanced rendering, and saves the models with the state available for GPU instanced rendering and the currently played animation to the corresponding model lists.
[0013] Further, step S3 is specifically as follows:
[0014] The instanced rendering data generation module traverses each type of model list generated in S2, collects the model mesh, current animation ID and model material required for each type of model for one instanced rendering, the current animation playing time of each instance, world coordinates, and some other instance-specific data, and generates an instanced rendering data list.
[0015] Further, step S4 is specifically as follows:
[0016] The instantiated rendering execution module performs an instantiated rendering operation on each piece of data in the instantiated rendering data list generated in S4 in sequence. The method is as follows: Set the vertex buffer of the mesh data of the object model to the GPU by calling the IASetVertexBuffers graphics interface; Obtain the animation texture according to the current animation ID and set it to the GPU by calling the VSSetShaderResources graphics interface; Set the vertex shader program for instantiated rendering to the GPU by calling the VSSetShader graphics interface; Set the instance attributes of each instance to the GPU by calling the VSSetConstantBuffers; In the vertex shader program, obtain the current animation playback time from the instance data using the instance ID, obtain the vertex transformation data from the animation texture by combining the vertex index and the current animation playback time, and then calculate the final vertex position by performing calculations on the vertex data and the object world coordinate transformation.
[0017] Specifically, the present invention provides a rendering system for a large number of 3D animation models, including an animation texture generation module, a GPU instantiated rendering state model management module, an instantiated rendering data generation module, and an instantiated rendering execution module:
[0018] The animation texture generation module is used to encode the transformation results of the mesh vertex coordinates of each frame of the 3D model skeletal animation onto a floating-point texture to obtain the animation texture;
[0019] The GPU instantiated rendering state model management module is used to judge whether the animation models in the current scene can be used for GPU instantiated rendering, and save the models with the state available for GPU instantiated rendering and the currently played animation to the corresponding model list;
[0020] The instantiated rendering data generation module is used to traverse each type of model list generated in the GPU instantiated rendering state model management module and generate an instantiated rendering data list;
[0021] The instantiated rendering execution module is used to traverse the instantiated rendering data list generated in the instantiated rendering data generation module and perform an instantiated rendering operation on each piece of data.
[0022] The beneficial effects of the present invention are:
[0023] By using the method and system of the present invention, the transformation of each frame of the model animation on the model mesh vertices is pre-computed offline and encoded into an animation texture, and then the instanced rendering of the animated model is achieved by using the instanced rendering function provided by the 3D graphics acceleration hardware. By this method, it can well solve the problem of the decrease in the game frame rate caused by the high CPU occupancy rate due to the execution of a large number of skeletal animation calculations and excessive drawcalls when rendering a large number of animated models simultaneously. Description of the Drawings
[0024] Figure 1 It is a flowchart of a rendering method for a large number of 3D animation models. Detailed Embodiments
[0025] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments.
[0026] The present invention provides a rendering system for a large number of 3D animation models, including an animation texture generation module, a GPU instanced rendering state model management module, an instanced rendering data generation module, and an instanced rendering execution module:
[0027] The animation texture generation module is used to encode the transformation results of the mesh vertex coordinates of each frame of the 3D model skeletal animation into a floating-point texture to obtain an animation texture;
[0028] The GPU instanced rendering state model management module is used to judge whether the animated models in the current scene can be used for GPU instanced rendering, and save the models with the state available for GPU instanced rendering and the currently played animation into the corresponding model list;
[0029] The instanced rendering data generation module is used to traverse each type of model list generated by the GPU instanced rendering state model management module and generate an instanced rendering data list;
[0030] The instanced rendering execution module is used to traverse the instanced rendering data list generated by the instanced rendering data generation module and perform an instanced rendering operation on each item of data.
[0031] As Figure 1 shown, a rendering method for a large number of 3D animation models includes the following steps:
[0032] S1: The animation texture generation module encodes the transformation results of the mesh vertex coordinates of each frame of the 3D model skeletal animation into a floating-point texture to obtain an animation texture;
[0033] S2: The GPU instantiated rendering state model management module determines the state of whether the animated models in the current scene can be used for GPU instantiated rendering, and saves the models with the state available for GPU (Graphics Processing Unit) instantiated rendering and the currently playing animations to the corresponding model lists;
[0034] S3: The instantiated rendering data generation module traverses each type of model list generated in S2 to generate an instantiated rendering data list;
[0035] S4: The instantiated rendering execution module traverses the instantiated rendering data list generated in S3 and performs an instantiated rendering operation on each piece of data once.
[0036] Specifically, step S1 above is as follows:
[0037] The animated texture generation module, in an offline manner through a game editor or model data processing tool, according to the animation data of the 3D model, encodes the local space coordinate change results of all vertices in each frame of the skeletal animation with time as the vertical coordinate (V) and vertex index as the horizontal coordinate (U) onto a sufficiently large floating-point texture to obtain an animated texture.
[0038] Specifically, step S2 above is as follows:
[0039] The GPU instantiated rendering state model management module determines whether the current frame of all animated models in the managed scene is available for GPU instantiated rendering state. When the object is far from the camera to a set distance value, it will enter the state available for GPU instantiated rendering, otherwise the object enters the state not available for GPU instantiated rendering, and saves the models with the state available for GPU instantiated rendering and the currently playing animations to the corresponding model lists.
[0040] Specifically, step S3 above is as follows:
[0041] The instantiated rendering data generation module traverses each type of model list generated in S2, collects the model mesh, current animation ID and model material required for instantiated rendering for each type of model, the current animation playing time of each instance, world coordinates, and some other instance-specific data, and generates an instantiated rendering data list.
[0042] Specifically, step S4 above is as follows:
[0043] The instanced rendering execution module submits an instanced rendering operation for each data item in turn according to the instanced rendering data list generated in S4, in the following manner: the mesh data vertex buffer of the object model is set to the GPU by calling the IASetVertexBuffers graphics interface; the animation texture is obtained according to the current animation ID and is set to the GPU by calling the VSSetShaderResources graphics interface; the vertex shader program for instanced rendering is set to the GPU by calling the VSSetShader graphics interface; the instance attributes of each instance are set to the GPU by calling VSSetConstantBuffers; the instance ID is used in the vertex shader program to obtain the current animation playback time from the instance data, the vertex transformation data is obtained from the animation texture in combination with the vertex index and the current animation playback time, and the vertex data and the object world coordinate transformation are calculated to obtain the final vertex position.
[0044] The method and system of the present invention pre-calculate the transformation of the model mesh vertices for each frame of the model animation in an offline manner and encode it into an animation texture, and then use the instanced rendering function provided by the 3D graphics acceleration hardware to achieve instanced rendering of the animated model. This method can effectively solve the problem of the game frame rate drop caused by the high CPU occupancy caused by executing a large number of skeletal animation calculations and too many drawcalls when rendering a large number of animated models at the same time.
[0045] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
Claims
1. A rendering method for a large number of 3D animation models, characterized in that, It includes the following steps: S1: The animation texture generation module encodes the transformation results of the mesh vertex coordinates of each frame of the 3D model skeletal animation onto a floating-point texture to obtain an animation texture; S2: The GPU instanced rendering state model management module determines whether the animated models in the current scene can be used for GPU instanced rendering, and saves the models with the state available for GPU instanced rendering and the currently playing animation to the corresponding model lists; Specifically for S2, the GPU instanced rendering state model management module determines whether the current frame of all the animated models in the managed scene can be used for GPU instanced rendering. When the object is far away from the camera to a set distance value, it will enter the state available for GPU instanced rendering, otherwise the object enters the state not available for GPU instanced rendering. Save the models with the state available for GPU instanced rendering and the currently playing animation to the corresponding model lists; S3: The instanced rendering data generation module traverses each type of model list generated in S2 to generate an instanced rendering data list; S4: The instanced rendering execution module traverses the instanced rendering data list generated in S3 and performs an instanced rendering operation on each piece of data once.
2. The rendering method of a large number of 3D animation models according to claim 1, characterized in that, Specifically for step S1: The animation texture generation module, in an offline manner through a game editor or model data processing tool, according to the animation data of the 3D model, encodes the local space coordinate change results of all vertices of each frame of the skeletal animation with time as the ordinate V and vertex index as the abscissa U onto a sufficiently large floating-point texture to obtain an animation texture.
3. The rendering method of a large number of 3D animation models according to claim 1, wherein, Specifically for step S3: The instanced rendering data generation module traverses each type of model list generated in S2, collects the model mesh, the current animation ID and model material required for each instanced rendering, the current animation playback time of each instance, the world coordinates, and some other instance-specific data for each type of model, and generates an instanced rendering data list.
4. The rendering method of a large number of 3D animation models according to claim 1, characterized in that Specifically for step S4: The instanced rendering execution module, according to the instanced rendering data list generated in S4, submits an instanced rendering operation for each piece of data in turn. The method is as follows: Set the vertex buffer of the mesh data of the object model to the GPU by calling the IASetVertexBuffers graphics interface; Obtain the animation texture according to the current animation ID and set it to the GPU by calling the VSSetShaderResources graphics interface; Set the vertex shader program for instanced rendering to the GPU by calling the VSSetShader graphics interface; Set the instance attributes of each instance to the GPU by calling the VSSetConstantBuffers; In the vertex shader program, obtain the current animation playback time from the instance data using the instance ID, obtain the vertex transformation data from the animation texture in combination with the vertex index and the current animation playback time, and then calculate the final vertex position by performing calculations on the vertex data and the object world coordinate transformation.
5. A rendering system for a large number of 3D animation models, characterized in that: The system is used to execute the rendering method according to any one of claims 1-4, and includes an animated texture generation module, a GPU instanced rendering state model management module, an instanced rendering data generation module, and an instanced rendering execution module: The animated texture generation module is used to encode the transformation results of the mesh vertex coordinates of each frame of the 3D model skeleton animation onto a floating-point texture to obtain an animated texture; The GPU instanced rendering state model management module is used to judge whether the animated models in the current scene can be used for GPU instanced rendering, and save the models with the state available for GPU instanced rendering and the currently played animation to the corresponding model lists; The instanced rendering data generation module is used to traverse each type of model list generated in the GPU instanced rendering state model management module and generate an instanced rendering data list; The instanced rendering execution module is used to traverse the instanced rendering data list generated in the instanced rendering data generation module and perform an instanced rendering operation on each item of data once.
Citation Information
Patent Citations
Rendering processing method and device and mobile terminal equipment
CN108711182A