Three-dimensional model rendering method and device, equipment and storage medium
By concatenating vertex and index data from multiple 3D models into combined data and storing it in a pair of buffers, the problem of insufficient rendering convenience caused by large buffer requirements is solved, and more efficient 3D model rendering is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN TENCENT NETWORK INFORMATION TECH CO LTD
- Filing Date
- 2024-11-29
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, the large buffer requirements during the rendering of 3D models result in insufficient rendering convenience.
The vertex and index datasets of multiple 3D models are sequentially concatenated into a combined dataset, which is then stored using a pair of vertex and index buffers, reducing buffer requirements and improving rendering efficiency.
By reducing buffer requirements, the ease and efficiency of rendering 3D models are improved, and the resource consumption of the buffer is reduced.
Smart Images

Figure CN122115657A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics technology, and in particular to a method, apparatus, device, and storage medium for rendering three-dimensional models. Background Technology
[0002] Vertex animation is a technique used in computer graphics that creates animation effects by changing the positions of the vertices of a 3D model. When a 3D model is drawn by a GPU (Graphics Processing Unit), the vertex data of the 3D model is passed into the vertex buffer, and the vertex indices of the 3D model are input into the index buffer, waiting to be drawn (DrawCall).
[0003] For vertex animation corresponding to each 3D model in different frames, the relevant technology allocates a pair of vertex buffers and index buffers for each 3D model, so that the GPU can extract vertex data and vertex indexes from the pair of vertex buffers and index buffers allocated to each 3D model to realize the rendering of the 3D model and thus obtain vertex animation.
[0004] However, the related technologies require a large amount of buffer space, which is not conducive to improving the ease of rendering 3D models. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for rendering three-dimensional models. The technical solution provided by this application can be as follows:
[0006] According to one aspect of the embodiments of this application, a method for rendering a three-dimensional model is provided, the method comprising:
[0007] Obtain the vertex dataset and index dataset of at least two 3D models in the 3D model sequence. The vertex dataset of the 3D model is used to describe at least one vertex of the 3D model, and the index dataset of the 3D model is used to indicate the connection relationship between at least one vertex of the 3D model by vertex index.
[0008] The vertex datasets of the at least two 3D models are sequentially concatenated to obtain combined vertex data, and the index datasets of the at least two 3D models are sequentially concatenated to obtain combined index data.
[0009] Based on the combined vertex data and the combined index data, the at least two 3D models are rendered respectively.
[0010] According to one aspect of the embodiments of this application, a rendering apparatus for a three-dimensional model is provided, the apparatus comprising:
[0011] A dataset acquisition module is used to acquire the vertex dataset and index dataset of at least two 3D models in a 3D model sequence. The vertex dataset of the 3D model is used to describe at least one vertex of the 3D model, and the index dataset of the 3D model is used to indicate the connection relationship between at least one vertex of the 3D model by vertex index.
[0012] The dataset stitching module is used to stitch together the vertex datasets of the at least two 3D models in sequence to obtain combined vertex data, and to stitch together the index datasets of the at least two 3D models in sequence to obtain combined index data.
[0013] The model rendering module is used to render the at least two 3D models based on the combined vertex data and the combined index data.
[0014] According to one aspect of the embodiments of this application, a computer device is provided, the computer device including a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above-described rendering method for a three-dimensional model.
[0015] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, the computer program being loaded and executed by a processor to implement the above-described rendering method for a three-dimensional model.
[0016] According to one aspect of the embodiments of this application, a computer program product is provided, the computer program product including a computer program stored in a computer-readable storage medium, and a processor reading from the computer-readable storage medium and executing the computer program to implement the above-described rendering method for a three-dimensional model.
[0017] The technical solutions provided in this application have at least the following beneficial effects:
[0018] By sequentially concatenating the vertex datasets of all 3D models into combined vertex data and sequentially concatenating the index datasets of all 3D models into combined index data, this application only needs to use a pair of vertex buffers and an index buffer to store the combined vertex data and combined index data respectively, thus realizing the storage of the vertex datasets and index datasets of all 3D models, without the need to use multiple pairs of buffers, thereby effectively reducing the demand for buffers.
[0019] In addition, since there is only one pair of vertex buffers and index buffers, there is no need to frequently switch buffers when rendering each 3D model. This is beneficial to improving the convenience of rendering 3D models, and thus improving the rendering efficiency of 3D models. Attached Figure Description
[0020] Figure 1 This is a schematic diagram of a computer system provided in one embodiment of this application;
[0021] Figure 2 This is a flowchart of a three-dimensional model rendering method provided in one embodiment of this application;
[0022] Figure 3 This is a schematic diagram of combined index data and combined vertex data provided in one embodiment of this application;
[0023] Figure 4 This is a flowchart of a three-dimensional model rendering method provided in another embodiment of this application;
[0024] Figure 5 This is a flowchart of a vertex animation model rendering method provided in one embodiment of this application;
[0025] Figure 6 This is a flowchart of a rendering method for a vertex animation model provided in another embodiment of this application;
[0026] Figure 7 This is a schematic diagram of an animation frame provided in one embodiment of this application;
[0027] Figure 8 This is a block diagram of a rendering apparatus for a three-dimensional model provided in one embodiment of this application;
[0028] Figure 9 This is a block diagram of a rendering apparatus for a three-dimensional model provided in another embodiment of this application;
[0029] Figure 10 This is a structural block diagram of a computer device provided in one embodiment of this application. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0031] Before introducing the technical solutions of this application, some terms involved in this application will be explained. The following related explanations are optional solutions and can be arbitrarily combined with the technical solutions of the embodiments of this application, all of which fall within the protection scope of the embodiments of this application. The embodiments of this application include at least some of the following contents.
[0032] A 3D model is a polygonal representation of an object. 3D models can be used to represent real-world entities or virtual objects. A 3D model can be a model with 3D data constructed in a virtual 3D space.
[0033] A mesh, also known as a mesh face, is the basic unit that makes up a 3D model. In computer graphics, a mesh is a data representation of a 3D object composed of vertices, edges, and faces. It defines the shape and structure of a 3D object in 3D space and is commonly used in game development, virtual reality, and film special effects. During rendering, mesh data is submitted to a graphics processing unit (GPU) to generate an image. Optionally, the surface of a 3D model can be composed of multiple meshes, which together construct the shape of the 3D model. Mesh types can include triangular patches, quadrilateral patches, and any other polygonal patches. A mesh can consist of vertices, edges, and faces.
[0034] Vertex: The smallest unit of geometry, a single point in three-dimensional space, used to define the corners and intersections of a mesh. Vertices connect to form edges and faces, collectively constituting the surface and shape of a 3D model. The vertices of a 3D model are the vertices of its mesh.
[0035] Rendering a 3D model refers to the process of converting a 3D model into a 2D image. The rendering process simulates how light interacts with the 3D model in a virtual 3D space, thus giving the rendered 2D image (hereinafter referred to as the rendered image) visual representations such as depth, lighting, and shadow effects. Rendering of a 3D model can be performed on a vertex or mesh basis.
[0036] Rendering optimization: There are many performance bottlenecks in the process of rendering 3D models. Rendering optimization refers to finding these performance bottlenecks and making targeted optimizations to improve rendering efficiency.
[0037] Offline computation phase: In rendering optimization, many large-scale intensive calculations in the solution are pre-calculated before the actual rendering run. This process is the offline computation phase.
[0038] Real-time rendering phase: This refers to the real-time execution phase in graphics products, where computer equipment typically needs to complete image rendering and submit it to the monitor within a very short time. The number of frames submitted per second is called the frame rate. To ensure the smoothness of dynamic images, the frame rate can be 30 frames, 60 frames, or even more.
[0039] GPU: Graphics Processing Unit, also known as display core, visual processor, or display chip, is a microprocessor specifically designed for performing image and graphics-related calculations on personal computers, game consoles, and mobile devices (such as tablets and smartphones).
[0040] Vertex buffer: A memory buffer containing vertex data. During rendering, the GPU processes the vertex data in the vertex buffer, performing operations such as transformations, lighting, and clipping to render the 3D model. Vertex data can contain at least one of the following information about a vertex: coordinates, color, texture coordinates, and normal direction. Furthermore, to use the GPU to process vertex data, the following steps are required: 1. Create a vertex buffer; 2. Store the vertex data in the vertex buffer.
[0041] Index Buffer: When the GPU renders a 3D model, the vertex data of the 3D model is passed to the vertex buffer. The index buffer, on the other hand, arranges the vertex indices of the 3D model into another array according to the mesh (such as triangles) of the 3D model, and also passes it to the GPU to await rendering. The information stored in the index buffer is the vertex indices of the 3D model. For example, every three vertex indices represent a triangle facet (mesh), and the triangle facests can be stored in no particular order. The vertex indices can be unsigned integer data variables.
[0042] The implementation environment of the technical solutions provided in the embodiments of this application is described below.
[0043] Please refer to Figure 1 This diagram illustrates a computer system provided in one embodiment of this application. The computer system can implement the technical solutions provided in the embodiments of this application within a specific environment. The computer system may include: a terminal device 10 and a server 20.
[0044] Terminal device 10 can be an electronic device such as a mobile phone, tablet computer, multimedia playback device, PC (Personal Computer), wearable device, in-vehicle terminal device, VR (Virtual Reality) device, AR (Augmented Reality) device, MR (Mixed Reality) device, etc. Terminal device 10 can run a client of the target application. The target application can be an application that needs to render a 3D model. For example, the target application can include at least one of the following: vertex animation generation application, image rendering application, video application, engine application, modeling application, simulation application, social entertainment application, design and development application; this embodiment does not limit this.
[0045] In some embodiments, the terminal device 10 also has a rendering application installed for automatically rendering 3D models. The 3D models in the target application are exported to the rendering application for rendering. In some embodiments, the target application may have the ability to render 3D models independently. This application does not limit the implementation form of the target application; for example, it may be an application that requires downloading and installation, a small program that does not require installation, a web application, etc.
[0046] Optionally, the target application may also include game applications, which may be any of the following: Massive Multiplayer Online Role-Playing Game (MMORPG), casual games, party games, sandbox games, tower defense games, action-adventure games, multiplayer online battle arena (MOBA) games, first-person shooter (FPS) games, multiplayer shooting survival games, third-person shooter (TPS) games, simulation games (SLG), simulation management games, survival building games, real-time strategy games, etc. This application embodiment does not limit this.
[0047] Optionally, Figure 1 Only one terminal device 10 is shown in the embodiment, but in different embodiments there are multiple other terminal devices that can access the server 20. This application does not limit this.
[0048] Server 20 can be used to provide background services for the clients of the aforementioned target applications (such as vertex animation generation applications). For example, server 20 can be a backend server for the aforementioned target applications. Server 20 can be a single server, a server cluster consisting of multiple servers, or a cloud computing service center.
[0049] Terminal device 10 can communicate with server 20 via network 30, such as a wireless or wired network.
[0050] The technical solutions provided in this application are applicable to any scenario requiring the rendering of 3D models, such as vertex animation generation, video generation, film generation, and game development. For example, the technical solutions provided in this application can be used to generate vertex animations based on a sequence of 3D models of a specified object, or to generate game CG (Computer Graphics) based on a sequence of game models of game characters.
[0051] For example, taking a vertex animation generation scenario, after the target application's client obtains the sequence of 3D models used to generate vertex animation, it sends the vertex datasets and index datasets of multiple 3D models in the sequence to the server. During the offline computation phase, the server's CPU (Central Processing Unit) sequentially concatenates the vertex datasets of multiple 3D models into combined vertex data, and sequentially concatenates the index datasets of multiple 3D models into combined index data. The server then stores the combined vertex data in the vertex buffer area and the combined index data in the index buffer. During the real-time rendering phase, for any 3D model in the sequence, the server's GPU reads the corresponding index dataset from the index buffer, and then reads the corresponding vertex data from the vertex buffer based on the index dataset to render the 3D model, obtaining animation frames and thus the vertex animation.
[0052] Optionally, the rendering process of the 3D model can also be executed by the client of the target application. For example, the client of the target application can use its own terminal device to render multiple 3D models in real time to obtain vertex animation. This application embodiment does not limit this.
[0053] It should be noted that the technical solutions provided in this application can be widely applied to the rendering process of mobile devices, high-performance hosts, or personal computers, and can achieve the purpose of optimizing rendering performance. Furthermore, the application scenarios described above are only for illustrating the embodiments of this application and are not intended to limit the scope. In actual implementation, the technical solutions provided in this application can be flexibly applied according to actual needs.
[0054] The technical solutions provided in the embodiments of this application will be described below using method embodiments. For content not described in the method embodiments, please refer to the above embodiments, which will not be repeated here.
[0055] Please refer to Figure 2 The diagram illustrates a flowchart of a three-dimensional model rendering method according to an embodiment of this application. The execution entity for each step of this method is a computer device; however, the execution entity for each step of this method may be... Figure 2 The terminal device 10 in the computer system shown can be a client, such as a server 20. Taking the server as the executing entity of each step of the method as an example, the method may include at least one of the following steps 210 to 230.
[0056] Step 210: Obtain the vertex dataset and index dataset of at least two 3D models in the 3D model sequence. The vertex dataset of the 3D model is used to describe at least one vertex of the 3D model, and the index dataset of the 3D model is used to indicate the connection relationship between at least one vertex of the 3D model by vertex index.
[0057] The aforementioned 3D model sequence can refer to a sequence obtained by arranging at least two 3D models in a specified order. The specified order can be set and adjusted according to actual usage requirements. For example, if the 3D model sequence includes at least two 3D models of the same object at different times, the at least two 3D models can be arranged in chronological order to obtain the 3D model sequence. For instance, the at least two 3D models can be arranged in the order in which they were constructed. Alternatively, the at least two 3D models can be arranged in the order of change between them to obtain the 3D model sequence. For example, corresponding to the growth and change order of the object, the change order between the 3D models can be determined, and then the at least two 3D models can be arranged in the order of change between them. This application does not limit this approach.
[0058] Optionally, when a 3D model sequence includes at least two 3D models of the same object at different times, the 3D models in the sequence can be used to render animation frames to form vertex animations about the object. For example, if a 3D model sequence includes 3D models of a virtual plant at different growth stages, the sequence can be rendered to create vertex animations depicting the growth process of the virtual plant. Similarly, if a 3D model sequence includes 3D models of a virtual character at different movement stages, the sequence can be rendered to create vertex animations depicting the movement of the virtual character.
[0059] For example, the 3D model sequence may also include 3D models corresponding to at least two objects at the same time. At least two 3D models can be randomly arranged to obtain the 3D model sequence. Optionally, the 3D models in the 3D model sequence can be used to render animation frames, which are related to the at least two objects. This application embodiment does not limit the type of the objects mentioned above; for example, the type of objects may include at least one of the following: people, animals, plants, buildings, mountains, and water. This application embodiment also does not limit the type of 3D model; it may be fictional, semi-fictional, or obtained by simulating real objects.
[0060] In one example, the vertex topology between at least two of the above 3D models is not fixed. Here, "not fixed vertex topology" means that for different 3D models, the number of vertices, the connections between vertices (hereinafter referred to as vertex connections), and the topology of the mesh (i.e., the connections between meshes, hereinafter referred to as mesh connections) can vary.
[0061] For example, in a 3D model sequence, the number of vertices in the first 3D model and the number of vertices in the second 3D model can be different, as can the vertex connection relationships in the first 3D model and the second 3D model, and the mesh connection relationships in the first 3D model and the second 3D model. The first 3D model can refer to any 3D model in the 3D model sequence, and the second 3D model can refer to any 3D model in the 3D model sequence other than the first 3D model.
[0062] In one example, the vertex topology between at least two of the above 3D models remains fixed. Fixed vertex topology means that for different 3D models, the number of vertices, the connections between vertices (hereinafter referred to as vertex connections), and the topology of the mesh (i.e., the connections between meshes, hereinafter referred to as mesh connections) remain constant.
[0063] For example, in a sequence of three-dimensional models, the number of vertices in the first three-dimensional model and the number of vertices in the second three-dimensional model can be the same, the vertex connection relationship of the first three-dimensional model and the vertex connection relationship of the second three-dimensional model can also be the same, and the mesh connection relationship of the first three-dimensional model and the mesh connection relationship of the second three-dimensional model can also be the same.
[0064] A vertex dataset for a 3D model can refer to a collection composed of at least one vertex data point from the 3D model. Each vertex data point describes a vertex of the 3D model. For example, vertex data may contain at least one of the following information about the vertex: coordinates, color, texture coordinates, and normal direction. The aforementioned vertex data can be used to render a corresponding rendered image of the 3D model.
[0065] An index dataset for a 3D model can refer to a collection composed of at least one vertex index of the 3D model. The vertex indices in the index dataset can be combined and sorted at the grid level. For example, the vertex indices of each vertex included in a grid are arranged consecutively, while the vertex indices of different grids are arranged unordered, resulting in the index dataset. The vertex index is used to identify vertices. For the same 3D model, each vertex corresponds to a unique vertex index, which can be an unsigned integer data variable.
[0066] Optionally, the vertex index of the 3D model can be constructed based on the index of the vertex in the vertex dataset. For example, the vertex index of the first vertex in the vertex dataset can be 1. This application does not limit the method for constructing the vertex index.
[0067] For example, in a 3D model that includes vertex data A, vertex data B, vertex data C, and vertex data D, and vertex index 1 corresponding to vertex data A, vertex index 2 corresponding to vertex data B, vertex index 3 corresponding to vertex data C, and vertex index 4 corresponding to vertex data D, if the vertices corresponding to vertex data A, vertex data B, and vertex data C form a mesh, and the vertices corresponding to vertex data B, vertex data C, and vertex data D form a mesh, then the index dataset of the 3D model is: 1, 2, 3, 2, 3, and 4, and the vertex dataset is: vertex data A, vertex data B, vertex data C, and vertex data D.
[0068] The embodiments of this application do not limit the source of the three-dimensional model sequence. It can be uploaded to the client by the user, constructed by the user through the client, or collected online through the client.
[0069] Step 220: Sequentially concatenate the vertex datasets of at least two 3D models to obtain combined vertex data, and sequentially concatenate the index datasets of at least two 3D models to obtain combined index data.
[0070] Optionally, the vertex datasets of at least two 3D models can be sequentially concatenated according to their arrangement order in the 3D model sequence to obtain combined vertex data. Similarly, the index datasets of at least two 3D models can be sequentially concatenated according to their arrangement order in the 3D model sequence to obtain combined index data. The combined vertex data includes the vertex datasets of all 3D models in the 3D model sequence, and the combined index data includes the index datasets of all 3D models in the 3D model sequence. The combined vertex data and combined index data can be considered as data possessed by a new 3D model.
[0071] Here, concatenation can refer to the process of appending the head of the next dataset to the tail of the previous dataset. For example, appending the head of the next vertex dataset to the tail of the previous vertex dataset in sequence will yield combined vertex data, and appending the head of the next index dataset to the tail of the previous index dataset in sequence will yield indexed vertex data.
[0072] For example, refer to Figure 3 If the sequence of 3D models includes s 3D models, and the i-th 3D model has x i vertices and ti If there are 3 triangular facets, then by sequentially splicing the vertex datasets of s 3D models, we can obtain combined vertex data 301, which is a continuous sequence from the vertex dataset of the first 3D model to the vertex dataset of the s-th 3D model.
[0073] By sequentially concatenating the index datasets of s three-dimensional models, we can obtain combined index data 302, which is a continuous sequence from the index dataset of the first three-dimensional model to the index dataset of the s-th three-dimensional model.
[0074] In one example, after the server obtains the combined vertex data and combined index data, it stores the combined vertex data in a first buffer and the combined index data in a second buffer, which are different from each other.
[0075] The first buffer mentioned above can refer to a vertex buffer, and the second buffer can refer to an index buffer. The first and second buffers can be collectively referred to as the model buffer. Optionally, the starting pointer of the first buffer points to the first vertex data in the combined vertex data, and the starting pointer of the second buffer points to the first vertex index in the combined index data. The first buffer stores data at the vertex data granularity, with each pointer pointing to one vertex data point; the second buffer stores data at the vertex index granularity, with each pointer pointing to one vertex index.
[0076] This application embodiment can store the vertex datasets of the above-mentioned at least two 3D models in the same vertex buffer by storing the combined vertex data in the first buffer, and can store the index datasets of the above-mentioned at least two 3D models in the same index buffer by storing the combined index data in the second buffer. This allows the server to render different 3D models without switching buffers, which is beneficial to improving the rendering convenience of new 3D models, and also saves buffer resources by eliminating the need to use multiple buffers.
[0077] Alternatively, the above process can be implemented by the server's CPU during the offline computing phase.
[0078] Optionally, the vertex buffer and index buffer are located on the server's GPU. By sending the combined vertex data and combined index data to the GPU, instead of sending the rendering results of the 3D model sequence to the GPU, the data transfer burden from CPU to GPU is reduced.
[0079] Step 230: Render at least two 3D models based on the combined vertex data and combined index data.
[0080] Optionally, for any three-dimensional model in the three-dimensional model sequence, the index dataset corresponding to the three-dimensional model can be extracted from the combined index data, and then the vertex data corresponding to the three-dimensional model can be extracted from the combined vertex data according to the index dataset corresponding to the three-dimensional model, thereby realizing the rendering of the three-dimensional model.
[0081] In one example, this embodiment of the application also generates inter-frame information for a 3D model sequence. This inter-frame information indicates the positions of the vertex datasets of at least two 3D models in the combined vertex data, and the positions of the index datasets of at least two 3D models in the combined index data. The server can sequentially extract the vertex indexes and vertex data of the 3D model based on its sequence number in the 3D model sequence and the inter-frame information, thereby rendering the 3D model.
[0082] For example, refer to Figure 4 The following steps may also be included before step 230:
[0083] Step S1: Obtain the length of the vertex dataset for each of at least two 3D models, and obtain the length of the index dataset for each of at least two 3D models.
[0084] The length of the vertex dataset can be used to indicate the number of vertex data in the vertex dataset. The number of vertex data is the number of vertices in the 3D model. For example, the number of vertices in the 3D model can be directly determined as the length of the vertex dataset of the 3D model.
[0085] The length of the index dataset can be used to indicate the number of vertex index groups in the index dataset. The number of vertex index groups is the number of meshes in the 3D model. For example, the number of meshes in the 3D model can be directly determined as the length of the index dataset of the 3D model.
[0086] For example, in the case of a 3D model that includes 4 vertices and 2 meshes, the length of the vertex dataset of the 3D model can be determined to be 4, and the length of the index dataset of the 3D model can be determined to be 2.
[0087] Step S2: Based on the length of the vertex datasets of at least two 3D models and the length of the index datasets of at least two 3D models, generate inter-frame information. The inter-frame information is used to indicate the position of the vertex datasets of at least two 3D models in the combined vertex data and the position of the index datasets of at least two 3D models in the combined index data.
[0088] Optionally, based on the length of the vertex datasets of at least two 3D models, the positions of the vertex datasets of each of the two 3D models in the combined vertex data are determined, and based on the length of the index datasets of at least two 3D models, the positions of the index datasets of each of the two 3D models in the combined index data are determined. This allows the embodiments of this application to determine the vertex data and vertex indexes of any 3D model from the combined vertex data and combined index data based on inter-frame information, without fixing the vertex topology of the 3D model, thereby enabling the embodiments of this application to support the rendering of 3D model sequences with variable vertex topology.
[0089] In one example, the inter-frame information mentioned above includes at least two parameter groups, with different parameter groups corresponding to different 3D models. Each parameter group may include a first parameter, a second parameter, a third parameter, and a fourth parameter. Specifically, the first and second parameters corresponding to the 3D model indicate the position of the 3D model's vertex dataset within the combined vertex data, while the third and fourth parameters indicate the position of the 3D model's index dataset within the combined index data.
[0090] For example, the process of determining the parameter set corresponding to each 3D model may include the following:
[0091] 1. For the i-th 3D model among at least two 3D models, obtain the first parameter of the i-th 3D model based on the length of the index dataset of the i-1 3D models preceding the i-th 3D model.
[0092] Here, the i-th 3D model can refer to any one of at least two 3D models. The first parameter of the i-th 3D model is used to indicate the starting position of the index dataset of the i-th 3D model in the combined index data, where i is a positive integer.
[0093] Optionally, the lengths of the index datasets of the (i-1)th 3D models preceding the i-th 3D model are summed to obtain a first sum. Then, the first parameter is determined based on this first sum and the number of vertices included in the mesh. For example, when the mesh consists of triangular faces, three times the first sum can be used as the first parameter. Therefore, the first parameter of the i-th 3D model can be expressed as follows:
[0094]
[0095] Among them, |t k | represents the length of the index dataset for the k-th 3D model.
[0096] For example, taking a 3D model sequence consisting of two 3D models as an example, if the index dataset of the first 3D model is: 1, 2, 3, 2, 3, 4 (i.e., vertex indices), and the vertex dataset is: A, B, C, D (referring to vertex data); and the index dataset of the second 3D model is: 1, 3, 4, 1, 2, 4, and the vertex dataset is: E, F, G, H, then we have:
[0097] The composite index data is: 1, 2, 3, 2, 3, 4, 1, 3, 4, 1, 2, 4;
[0098] The combined vertex data are: A, B, C, D, E, F, G, H.
[0099] For the first 3D model in the 3D model sequence, its first parameter is 3*0 = 0. For the second 3D model in the 3D model sequence, its first parameter is 3*2 = 6. Corresponding to the index buffer, the pointer with the value of the first parameter of the first 3D model (or the pointer whose position is the first parameter) points to the first vertex index in the combined index data: 1, that is, the first vertex index in the index dataset of the first 3D model; the pointer with the value of the first parameter of the second 3D model points to the 7th vertex index in the combined index data: 1, that is, the first vertex index in the index dataset of the second 3D model.
[0100] 2. Based on the length of the index dataset of the i-th 3D model, obtain the second parameter of the i-th 3D model. The second parameter of the i-th 3D model is used to indicate the span of the index dataset of the i-th 3D model in the combined index data.
[0101] Optionally, the product of the length of the index dataset of the i-th 3D model and the number of vertices included in the mesh can be directly used as the second parameter of the i-th 3D model.
[0102] For example, when the mesh consists of triangular patches, three times the length of the index dataset of the i-th 3D model can be used as the second parameter. The second parameter of the i-th 3D model can then be expressed as follows:
[0103] indexcount i =3×|t i |
[0104] For example, based on the above embodiment, for the first 3D model in the 3D model sequence, its corresponding second parameter is 3*2=6, and for the second 3D model in the 3D model sequence, its corresponding second parameter is 3*2=6. Corresponding to the index buffer, the span of the index dataset of the first 3D model is 0-5, that is, from the 1st vertex index to the 6th vertex index, and the span of the index dataset of the second 3D model is 6-11, that is, from the 7th vertex index to the 12th vertex index.
[0105] 3. Based on the length of the vertex dataset of the i-1 preceding 3D models, obtain the third parameter of the i-th 3D model. The third parameter of the i-th 3D model is used to indicate the starting position of the vertex dataset of the i-th 3D model in the combined vertex data.
[0106] Optionally, the lengths of the vertex datasets of the (i-1)th 3D models preceding the i-th 3D model are summed to obtain a second sum, which can be directly used to determine the third parameter of the i-th 3D model. For example, the third parameter of the i-th 3D model can be represented as follows:
[0107]
[0108] Where, |x k | represents the length of the vertex dataset of the k-th 3D model.
[0109] For example, based on the above embodiment, for the first 3D model, its corresponding third parameter is 0, and for the second 3D model, its corresponding third parameter is 0+4=4. Corresponding to the vertex buffer, the pointer with the value of the third parameter of the first 3D model points to the first vertex data in the combined vertex data: A, that is, the first vertex data in the vertex dataset of the first 3D model; the pointer with the value of the third parameter of the second 3D model points to the fifth vertex data in the combined vertex data: E, that is, the first vertex data in the vertex dataset of the second 3D model.
[0110] 4. Based on the length of the vertex dataset of the i-th 3D model, obtain the fourth parameter of the i-th 3D model. The fourth parameter of the i-th 3D model is used to indicate the span of the vertex dataset of the i-th 3D model in the combined vertex data.
[0111] Alternatively, the length of the vertex dataset of the i-th 3D model can be directly determined as the fourth parameter of the i-th 3D model. For example, the fourth parameter of the i-th 3D model can be represented as follows:
[0112] vertexcount i =|x i |
[0113] For example, based on the above embodiment, for the first 3D model, its corresponding fourth parameter is 4, and for the second 3D model, its corresponding second parameter is also 4. Corresponding to the vertex buffer, the span of the vertex dataset of the first 3D model is 0-3, that is, from the 1st vertex data to the 4th vertex data, and the span of the vertex dataset of the second 3D model is 4-7, that is, from the 5th vertex data to the 8th vertex data.
[0114] 5. Based on the first, second, third, and fourth parameters of the i-th 3D model, obtain the parameter set of the i-th 3D model.
[0115] Optionally, the first, second, third, and fourth parameters of the i-th 3D model can be combined into a parameter group to obtain the parameter group of the i-th 3D model. The parameter group of the i-th 3D model can then be used as the i-th parameter group in the inter-frame information.
[0116] In one example, inter-frame information can be implemented as a one-dimensional array. The length of the array is the same as the number of 3D models in the 3D model sequence. Each element in the array includes four parameters, meaning each element corresponds to a parameter set. Each element in the array is a one-to-one object with a 3D model, and the order of the elements in the array corresponds to the order of the 3D models in the 3D model sequence. For example, the first element in the array corresponds to the parameter set of the first 3D model in the 3D model sequence.
[0117] Optionally, the inter-frame information can be packaged and stored together with the combined vertex data and combined index data. For example, the file containing the inter-frame information, the file containing the combined vertex data, and the file containing the combined index data can be stored in the same folder.
[0118] This application embodiment constructs inter-frame information by building four parameters for each 3D model. This allows the server to accurately extract vertex data and vertex indexes of any 3D model during the rendering process based on the inter-frame information, thereby helping to ensure the rendering accuracy of the 3D model.
[0119] In one example, step 230 above may also include the following: rendering at least two 3D models based on combined vertex data, combined index data, and inter-frame information.
[0120] Optionally, for any one of the at least two 3D models, the server can extract the index dataset of the 3D model from the combined index data based on inter-frame information, and then extract the vertex data of the 3D model from the combined vertex data based on the index dataset of the 3D model, so as to realize the rendering of the 3D model.
[0121] In one feasible example, the server's GPU may extract the vertex index and vertex data of any 3D model based on the combined vertex data, combined index data, and inter-frame information for rendering the 3D model; alternatively, the server's CPU may extract the vertex index and vertex data of any 3D model based on the combined vertex data, combined index data, and inter-frame information for rendering the 3D model; or the CPU may extract the vertex index of the 3D model based on inter-frame information and combined index data, and then the GPU may extract the vertex data of the 3D model based on the vertex index for rendering the 3D model. This application does not limit the specific implementation of this method.
[0122] For example, the rendering process of a 3D model may include the following:
[0123] 1. For the i-th 3D model among at least two 3D models, obtain the parameter set of the i-th 3D model from the inter-frame information.
[0124] Optionally, the server can render each 3D model in the 3D model sequence sequentially, or it can selectively render 3D models based on the input information. This embodiment of the application does not limit this. The input information may include at least one of the following: the sequence number of the 3D model in the 3D model sequence, the identification information of the 3D model, the frame number of a key animation frame (the frame number of the key animation frame is bound to a 3D model in a one-to-one correspondence), and the sequence number of the parameter group of the 3D model in the inter-frame information. The above input information can be set by the user, the developer, or the client; this embodiment of the application does not limit this.
[0125] For example, the server can obtain the parameter set of the i-th 3D model from the inter-frame information based on the frame number of the key animation frame corresponding to the i-th 3D model. For instance, if the 3D model sequence includes 60 3D models, there are 60 key animation frames. These 60 key animation frames can be used to obtain more animation frames through interpolation and other operations to form vertex animation. If the frame number range of the 60 key animation frames is [0, 59], when the input frame number is 0, the server can obtain the first parameter set, i.e., the parameter set of the first 3D model, from the inter-frame information; when the input frame number is 1, the server can obtain the second parameter set, i.e., the parameter set of the second 3D model, from the inter-frame information.
[0126] 2. Based on the parameter set of the i-th 3D model, obtain the index dataset of the i-th 3D model from the combined index data.
[0127] Optionally, the server determines the starting position of the index dataset of the i-th 3D model based on the first parameter in the parameter group of the i-th 3D model; determines the number of vertex indices n to be read from the i-th 3D model based on the second parameter in the parameter group of the i-th 3D model, where n is a positive integer; and reads n vertex indices from the combined index data starting from the starting position to obtain the index dataset of the i-th 3D model.
[0128] For example, based on the above embodiment, for the second 3D model, the server can determine the starting position of the index dataset of the second 3D model as the 7th vertex index based on the first parameter of the second 3D model: 6, such that the pointer 6 in the index buffer points to the 7th vertex index. And based on the second parameter of the second 3D model: 6, the server determines the number of vertex indices to be read, n = 6, that is, the pointer span is [6, 11]. Starting from the 7th vertex index, the server reads 6 vertex indices sequentially from the combined index data, that is, the server sequentially reads the index datasets of the two 3D models from the index buffer according to the pointer [6, 11].
[0129] Based on inter-frame information, the embodiments of this application can accurately extract the index dataset of any 3D model, which helps to improve the accuracy of vertex data acquisition.
[0130] 3. Based on the index dataset of the i-th 3D model and the parameter set of the i-th 3D model, obtain the vertex data of the i-th 3D model from the combined vertex data to obtain the mesh data of the i-th 3D model. The mesh data of the i-th 3D model is used to describe the mesh of the i-th 3D model.
[0131] Because of the discrepancy between the vertex indices and the vertex data after concatenating the vertex dataset, it is impossible to accurately extract vertex data based on the vertex indices. For example, based on the above embodiment, the vertex indices of the second 3D model can only access A, B, C, and D, but cannot access E, F, G, and H. For example, vertex index 1 of the second 3D model accesses A, and vertex index 3 of the second 3D model accesses C.
[0132] Therefore, after obtaining the index dataset of the i-th 3D model, it is necessary to adjust the vertex index of the i-th 3D model according to the parameter group of the i-th 3D model so that the adjusted vertex index of the i-th 3D model corresponds to the position of the vertex data of the i-th 3D model in the combined vertex data, thereby achieving the correct acquisition of vertex data.
[0133] For example, the server determines the offset based on the third parameter in the parameter group of the i-th 3D model; adjusts the index dataset of the i-th 3D model according to the offset to obtain the adjusted index dataset of the i-th 3D model; and obtains the vertex data of the i-th 3D model from the combined vertex data according to the adjusted index dataset of the i-th 3D model to obtain the mesh data of the i-th 3D model.
[0134] Specifically, the server can directly determine the third parameter in the parameter group of the i-th 3D model as the offset. The server can then add the vertex indices in the index dataset of the i-th 3D model to each vertex using its offset to obtain the adjusted index dataset of the i-th 3D model. The adjusted index dataset includes at least one adjusted vertex index, which can be used to indicate the position of the corresponding vertex data within the combined vertex data.
[0135] For example, based on the above embodiment, if the third parameter of the second 3D model is 4, then for the first vertex index of the second 3D model: 1, the adjusted first vertex index is 1+4=5. That is, the server can determine the 5th vertex data in the combined vertex data (corresponding to pointer 4, i.e., E, in the vertex buffer area) as the vertex data corresponding to the first vertex index. For the second vertex index of the second 3D model: 3, the adjusted second vertex index is 3+4=7. That is, the server can determine the 7th vertex data in the combined vertex data (corresponding to pointer 6, i.e., G, in the vertex buffer area) as the vertex data corresponding to the second vertex index, and so on. Every three vertex data can be combined into one mesh data.
[0136] This application embodiment uses a third parameter to offset the vertex index, thereby enabling the server to accurately extract the corresponding vertex data from the combined vertex data, which helps to improve the accuracy of vertex data acquisition.
[0137] 4. Render the i-th 3D model based on the mesh data of the i-th 3D model.
[0138] Optionally, each mesh data can be used to render a mesh of a 3D model. For example, based on the vertex connection relationship corresponding to the mesh, the connection relationship between each vertex included in the mesh can be determined, and based on the vertex data of each vertex, the coordinates, color, texture coordinates, normal direction and other information of each vertex can be determined, and then the rendered image of the i-th 3D model can be obtained.
[0139] Optionally, the above rendering process can be implemented by the server's GPU during the offline computing phase or the real-time rendering phase. For example, for offline vertex animation generation scenarios, the rendering process can be implemented by the server's GPU during the offline computing phase; for real-time vertex animation generation scenarios, the rendering process can be implemented by the server's GPU during the real-time rendering phase.
[0140] In summary, the technical solution provided by the embodiments of this application, by sequentially concatenating the vertex datasets of all three-dimensional models into combined vertex data and sequentially concatenating the index datasets of all three-dimensional models into combined index data, enables the storage of the vertex datasets and index datasets of all three-dimensional models to be achieved by using only one pair of vertex buffers and one pair of index buffers to store the combined vertex data and combined index data respectively, without the need to use multiple pairs of buffers, thereby effectively reducing the demand for buffers.
[0141] In addition, since there is only one pair of vertex buffers and index buffers, there is no need to frequently switch buffers when rendering each 3D model. This is beneficial to improving the convenience of rendering 3D models, and thus improving the rendering efficiency of 3D models.
[0142] In some embodiments, the technical solutions provided in this application are applicable to the "vertex animation generation" scenario, see reference. Figure 5 The embodiments of this application may also include the following contents.
[0143] 1. Obtain the vertex animation model sequence.
[0144] Taking the embedding of Unity's rendering engine scripts into the vertex animation rendering development process as an example, this application embodiment involves three script files, introduced into the Editor folder. This Editor folder contains the CreateVertexAnimationMesh script, the VertexAnimationData script, and the VertexAnimationRuntime script. The CreateVertexAnimationMesh script is used when creating vertex animation resources (such as vertex animation model sequences) in the editor; the VertexAnimationData script is used to associate vertex animation resources with their corresponding inter-frame information; and the VertexAnimationRuntime script is used to render the specified vertex animation model. Optionally, other engines, platforms, products, etc., can also be used to implement the technical solution provided in this application embodiment, and this application embodiment does not limit this.
[0145] For example, the vertex animation model mentioned above can refer to a 3D model constructed for different growth stages of a virtual plant by executing the CreateVertexAnimationMesh script. The vertex animation models in the vertex animation model sequence are ordered sequentially according to the order of their growth stages.
[0146] Optionally, each vertex animation model in the vertex animation model sequence can be recorded in the same folder and named sequentially as frame0001, frame0002, ...
[0147] 2. Combine vertex animation models.
[0148] Optionally, after the above folder is selected, the server can execute the CreateVertexAnimationMesh script to combine vertex animation models, resulting in two resource files: PlantGrowData and PlantGrowMesh. PlantGrowData records the inter-frame information corresponding to the vertex animation model sequence, while PlantGrowMesh records the combined vertex data and combined index data of the vertex animation model sequence. The names of both resource files can be arbitrarily modified. The individual vertex animation models in the above folder are no longer needed; only the PlantGrowData and PlantGrowMesh files need to be packaged during product packaging and building.
[0149] For example, the process of building PlantGrowData files and PlantGrowMesh files can be as follows:
[0150] During the design process of vertex animation, the number of vertices, the number of triangles, and the vertex topology of the vertex animation model may change with each animation frame. For example, the vertex animation 3D model corresponding to the 10th animation frame includes 160 vertices and 134 triangles, while the vertex animation 3D model corresponding to the 60th animation frame may include 1896 vertices and 2915 triangles.
[0151] In this embodiment, the vertex animation models in the vertex animation model sequence are combined into a large vertex animation model. That is, the vertex datasets of each vertex animation model are concatenated sequentially to obtain combined vertex data, and the index datasets of each vertex animation model are concatenated sequentially to obtain combined index data. Then, the combined vertex data and the combined index data are packaged into a PlantGrowMesh file.
[0152] This application embodiment can also generate inter-frame information corresponding to vertex animation models by executing the VertexAnimationData script, and package the inter-frame information into a PlantGrowData file. The PlantGrowData file includes an array of ShortSubmesh type variables, the length of which is the number of vertex animation models (i.e., the number of animation frames). The ShortSubmesh data structure includes four integers: indexStart, indexCount, vertexStart, and vertexCount (corresponding to the first, second, third, and fourth parameters mentioned above, respectively). Each vertex animation model corresponds to one ShortSubmesh; packaging all ShortSubmesh files yields the PlantGrowData file.
[0153] 3. Save the vertex animation model.
[0154] Alternatively, the PlantGrowData file and PlantGrowMesh file can be packaged and stored together by executing the VertexAnimationData script for use during rendering runtime.
[0155] 4. Render the vertex animation model.
[0156] Optionally, a game object (i.e., the virtual plant mentioned above) is added to the scene, and a component built with a VertexAnimationRuntime script is added to the game object. By executing the VertexAnimationRuntime script, the vertex index and vertex data of the specified vertex animation model can be extracted from the PlantGrowMesh file based on the PlantGrowData file and the frame number of the animation frame, so as to render the specified vertex animation model.
[0157] Optionally, during scene execution, the rendering vertex animation model can be switched by modifying the frame number of the animation frame. For example, changing the frame number of the animation frame to 1 will allow the server to switch to the first vertex animation model in the rendering vertex animation sequence. Optionally, the frame number of the animation frame can also be modified by other scripts to achieve programmatic control of the frame number, such as by using a script to automatically play animation frames based on time.
[0158] Since the PlantGrowMesh file contains composite vertex data, the GPU cannot directly render based on the PlantGrowMesh file. When each animation frame is updated, the SubMesh needs to be dynamically updated based on the PlantGrowData file. That is, the parameter group of the vertex animation model corresponding to the current frame number is obtained to read the corresponding vertex index and vertex data, thereby realizing the rendering of the specified vertex animation model.
[0159] For example, refer to Figure 6 The rendering process for vertex animation models may also include the following:
[0160] 1. Update the frame number of the animation frame.
[0161] Optionally, the frame number of the animation frame can be controlled by the user or developer, or it can be set by code; this application embodiment does not limit this.
[0162] 2. Obtain the current frame number fi.
[0163] 3. If the current frame number fi is equal to the set frame number ci, update SubMesh.
[0164] Set the frame number ci to a cached frame number variable, with an initial value of 0. Setting the frame number ci can be used to cache fi, so that the GPU does not need to update the SubMesh for every animation frame.
[0165] For example, the SubMesh update process can be represented as follows: Retrieve the fi-th ShortSubmesh from the PlantGrowData file based on the current frame number fi, and update the SubMesh according to the following code:
[0166]
[0167]
[0168] The code above describes the process of obtaining the parameter set for the fi-th vertex animation model. Here, baseVertex is the offset mentioned above. The GPU can obtain the index dataset of the fi-th vertex animation model from the PlantGrowData file based on the SubMesh. Then, during the process of extracting vertex data from the PlantGrowMesh file based on the vertex index, baseVertex is automatically added to adjust the vertex index, thereby achieving correct extraction of vertex data.
[0169] Optionally, if the current frame number fi is not equal to the set frame number ci, skip directly to step 5.
[0170] 4. Let ci = fi.
[0171] Optionally, the current frame number fi is assigned to the set frame number ci to update the set frame number ci.
[0172] 5. Submit for rendering.
[0173] Optionally, the GPU can extract the vertex index of the vertex animation model corresponding to the current frame number fi from the PlantGrowMesh file based on the SubMesh. Then, based on the sum of the vertex index and the baseVertex, it can extract the vertex data of the vertex animation model corresponding to the current frame number fi from the PlantGrowMesh file, thereby rendering the vertex animation model corresponding to the current frame number fi and obtaining the animation frame corresponding to the current frame number fi.
[0174] For example, refer to Figure 7 Animation frames 701 and 702 are rendered from the vertex animation model of the virtual plant at different growth stages. The transformation process is smooth and natural, vividly showing the growth process of a virtual plant from seedling to mature plant.
[0175] In some embodiments, in the field of real-time rendering and 3D animation, VAT (Vertex Animation Texture) technology is a method of encoding vertex animation data into textures for the efficient application of complex vertex animations in real-time rendering.
[0176] However, VAT technology requires a fixed vertex topology for the vertex animation model sequence, which makes the construction of the vertex animation model sequence costly. In contrast, the embodiments of this application support a variable vertex topology for the vertex animation model sequence, which can reduce the construction constraints of the vertex animation model sequence and help reduce the construction cost of the vertex animation model sequence.
[0177] In addition, VAT technology arranges the vertex animation model according to the maximum number of vertices to construct the VAT texture, while the embodiments of this application do not require the vertex animation model to be arranged according to the maximum number of vertices. This helps to reduce the memory required for vertex data and vertex index storage, and avoids the storage of useless information, thereby improving memory utilization.
[0178] For example, taking the aforementioned virtual plant as an example, its corresponding VAT texture requires 60 frames × 1896 vertices = 113760 pixel data. Since this application supports variable vertex topology and can remove useless vertices from the early animation models, it only requires 46272 vertex data. Under the same precision conditions, the memory usage of this application is only 40.7%, and the average rendering overhead is also lower than this percentage. Therefore, this application supports vertex animation rendering while reducing memory requirements, which is beneficial for improving GPU memory access friendliness and rendering performance.
[0179] In addition, compared to VAT technology, this application does not require the generation of VAT maps, which avoids the limitations of model building tools, such as the inability to force VAT maps to be stored row by row on many platforms and devices, which makes the process of vertex shaders reading VAT maps not cache-friendly, and the limitation that vertex shading needs to be repeated for VAT maps in mobile architecture. This is conducive to improving the convenience of vertex animation model generation, thereby improving the generation efficiency of vertex animation models, and making this application widely applicable to vertex animation rendering needs of mobile devices, high-performance hosts, or PCs.
[0180] In addition, since this application does not require the generation of VAT maps, it can convert the overhead of Texture Fetch (which requires reading texture data from VAT maps to recover vertex data) into the more efficient overhead of VertexLoad (which allows direct loading of vertex data without extracting texture data), thereby significantly reducing the computational burden on the GPU and improving the GPU's rendering performance under more flexible conditions.
[0181] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0182] Please refer to Figure 8 This diagram illustrates a block diagram of a rendering apparatus for a three-dimensional model according to an embodiment of this application. The apparatus has the function of implementing the aforementioned rendering method for the three-dimensional model; this function can be implemented in hardware or by hardware executing corresponding software. The apparatus 800 can be a computer device or can be installed within a computer device. The apparatus 800 may include: a dataset acquisition module 801, a dataset stitching module 802, and a model rendering module 803.
[0183] The dataset acquisition module 801 is used to acquire the vertex dataset and index dataset of at least two 3D models in the 3D model sequence. The vertex dataset of the 3D model is used to describe at least one vertex of the 3D model, and the index dataset of the 3D model is used to indicate the connection relationship between at least one vertex of the 3D model by vertex index.
[0184] The dataset splicing module 802 is used to sequentially splice the vertex datasets of the at least two 3D models to obtain combined vertex data, and to sequentially splice the index datasets of the at least two 3D models to obtain combined index data.
[0185] The model rendering module 803 is used to render the at least two 3D models based on the combined vertex data and the combined index data.
[0186] In some embodiments, such as Figure 9 As shown, the device 800 further includes a length acquisition module 804 and an information generation module 805.
[0187] The length acquisition module 804 is used to acquire the length of the vertex dataset of each of the at least two 3D models, and to acquire the length of the index dataset of each of the at least two 3D models.
[0188] The information generation module 805 is used to generate inter-frame information based on the length of the vertex dataset of each of the at least two 3D models and the length of the index dataset of each of the at least two 3D models. The inter-frame information is used to indicate the position of the vertex dataset of each of the at least two 3D models in the combined vertex data and the position of the index dataset of each of the at least two 3D models in the combined index data.
[0189] The model rendering module 803 is also used to render the at least two 3D models based on the combined vertex data, the combined index data and the inter-frame information.
[0190] In some embodiments, the inter-frame information includes at least two parameter groups, different parameter groups corresponding to different 3D models, and each parameter group includes a first parameter, a second parameter, a third parameter, and a fourth parameter; the information generation module 805 is used for:
[0191] For the i-th 3D model among the at least two 3D models, the first parameter of the i-th 3D model is obtained based on the length of the index dataset of the i-1 3D models preceding the i-th 3D model. The first parameter of the i-th 3D model is used to indicate the starting position of the index dataset of the i-th 3D model in the combined index data, where i is a positive integer.
[0192] Based on the length of the index dataset of the i-th 3D model, a second parameter of the i-th 3D model is obtained. The second parameter of the i-th 3D model is used to indicate the span of the index dataset of the i-th 3D model in the combined index data.
[0193] Based on the length of the vertex dataset of the i-1 preceding 3D models, the third parameter of the i-th 3D model is obtained. The third parameter of the i-th 3D model is used to indicate the starting position of the vertex dataset of the i-th 3D model in the combined vertex data.
[0194] Based on the length of the vertex dataset of the i-th 3D model, the fourth parameter of the i-th 3D model is obtained. The fourth parameter of the i-th 3D model is used to indicate the span of the vertex dataset of the i-th 3D model in the combined vertex data.
[0195] Based on the first, second, third, and fourth parameters of the i-th 3D model, the parameter set of the i-th 3D model is obtained.
[0196] In one embodiment, such as Figure 9 As shown, the model rendering module 803 includes: a parameter group acquisition submodule 803a, an index extraction submodule 803b, a mesh determination submodule 803c, and a model rendering submodule 803d.
[0197] The parameter group acquisition submodule 803a is used to acquire the parameter group of the i-th three-dimensional model from the inter-frame information for the i-th three-dimensional model among the at least two three-dimensional models.
[0198] The index extraction submodule 803b is used to obtain the index dataset of the i-th three-dimensional model from the combined index data according to the parameter group of the i-th three-dimensional model.
[0199] The mesh determination submodule 803c is used to obtain the vertex data of the i-th 3D model from the combined vertex data based on the index dataset of the i-th 3D model and the parameter group of the i-th 3D model, and to obtain the mesh data of the i-th 3D model. The mesh data of the i-th 3D model is used to describe the mesh of the i-th 3D model.
[0200] The model rendering submodule 803d is used to render the i-th three-dimensional model based on the mesh data of the i-th three-dimensional model.
[0201] In some embodiments, the mesh determination submodule 803c is configured to:
[0202] The offset is determined based on the third parameter in the parameter group of the i-th 3D model;
[0203] The index dataset of the i-th 3D model is adjusted according to the offset to obtain the adjusted index dataset of the i-th 3D model;
[0204] Based on the adjusted index dataset of the i-th 3D model, the vertex data of the i-th 3D model is obtained from the combined vertex data to obtain the mesh data of the i-th 3D model.
[0205] In some embodiments, the index extraction submodule 803b is used for:
[0206] Based on the first parameter in the parameter group of the i-th 3D model, determine the starting position of the index dataset of the i-th 3D model;
[0207] Based on the second parameter in the parameter set of the i-th 3D model, determine the number of vertex indices n to be read for the i-th 3D model, where n is a positive integer;
[0208] Starting from the aforementioned starting position, n vertex indices are read from the combined index data to obtain the index dataset of the i-th 3D model.
[0209] In some embodiments, such as Figure 9 As shown, the device 800 further includes a data storage module 806.
[0210] The data storage module 806 is used to store the combined vertex data in a first buffer and the combined index data in a second buffer, wherein the first buffer and the second buffer are different.
[0211] In some embodiments, the 3D model sequence includes at least two 3D models of the same object at different times, and the 3D models in the 3D model sequence are used to render animation frames to form vertex animations about the object.
[0212] In summary, the technical solution provided by the embodiments of this application, by sequentially concatenating the vertex datasets of all three-dimensional models into combined vertex data and sequentially concatenating the index datasets of all three-dimensional models into combined index data, enables the storage of the vertex datasets and index datasets of all three-dimensional models to be achieved by using only one pair of vertex buffers and one pair of index buffers to store the combined vertex data and combined index data respectively, without the need to use multiple pairs of buffers, thereby effectively reducing the demand for buffers.
[0213] In addition, since there is only one pair of vertex buffers and index buffers, there is no need to frequently switch buffers when rendering each 3D model. This is beneficial to improving the convenience of rendering 3D models, and thus improving the rendering efficiency of 3D models.
[0214] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0215] Please refer to Figure 10 It shows a structural block diagram of a computer device provided in one embodiment of this application.
[0216] Typically, computer device 1000 includes a processor 1001 and a memory 1002.
[0217] Processor 1001 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1001 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1001 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1001 may integrate a GPU, which is responsible for rendering and drawing the content required to be displayed on the screen. In some embodiments, processor 1001 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0218] The memory 1002 may include one or more computer-readable storage media, which may be tangible and non-transitory. The memory 1002 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1002 stores a computer program that is loaded and executed by the processor 1001 to implement the rendering method of the three-dimensional model described above.
[0219] Those skilled in the art will understand that Figure 10 The structure shown does not constitute a limitation on the computer device 1000, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0220] In some embodiments, a computer-readable storage medium is also provided, wherein a computer program is stored therein, the computer program being loaded and executed by a processor to implement the above-described method for rendering the three-dimensional model.
[0221] Optionally, the computer-readable storage medium may include: ROM (Read-Only Memory), RAM (Random-Access Memory), SSD (Solid State Drives), or optical disc, etc. The random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0222] In some embodiments, a computer program product is also provided, the computer program product including a computer program stored in a computer-readable storage medium, and a processor reading from the computer-readable storage medium and executing the computer program to implement the above-described method for rendering the three-dimensional model.
[0223] It should be understood that "multiple" as used herein refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the step numbers described herein are merely illustrative of one possible execution order. In some other embodiments, the steps may not be executed in numerical order, such as two steps with different numbers being executed simultaneously, or two steps with different numbers being executed in the reverse order of the illustration. This application does not limit this.
[0224] The above are merely exemplary embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application shall be included within the protection scope of this application.
Claims
1. A method for rendering a three-dimensional model, characterized in that, The method includes: Obtain the vertex dataset and index dataset of at least two 3D models in the 3D model sequence. The vertex dataset of the 3D model is used to describe at least one vertex of the 3D model, and the index dataset of the 3D model is used to indicate the connection relationship between at least one vertex of the 3D model by vertex index. The vertex datasets of the at least two 3D models are sequentially concatenated to obtain combined vertex data, and the index datasets of the at least two 3D models are sequentially concatenated to obtain combined index data. Based on the combined vertex data and the combined index data, the at least two 3D models are rendered respectively.
2. The method according to claim 1, characterized in that, Before rendering the at least two 3D models based on the combined vertex data and the combined index data, the process further includes: Obtain the length of the vertex dataset of each of the at least two 3D models, and obtain the length of the index dataset of each of the at least two 3D models; Based on the length of the vertex dataset of each of the at least two 3D models and the length of the index dataset of each of the at least two 3D models, inter-frame information is generated. The inter-frame information is used to indicate the position of the vertex dataset of each of the at least two 3D models in the combined vertex data and the position of the index dataset of each of the at least two 3D models in the combined index data. The rendering of the at least two 3D models based on the combined vertex data and the combined index data includes: Based on the combined vertex data, the combined index data, and the inter-frame information, the at least two 3D models are rendered respectively.
3. The method according to claim 2, characterized in that, The inter-frame information includes at least two parameter groups, with different parameter groups corresponding to different 3D models. Each parameter group includes a first parameter, a second parameter, a third parameter, and a fourth parameter. The generation of inter-frame information based on the lengths of the vertex datasets of the at least two 3D models and the lengths of the index datasets of the at least two 3D models includes: For the i-th 3D model among the at least two 3D models, the first parameter of the i-th 3D model is obtained based on the length of the index dataset of the i-1 3D models preceding the i-th 3D model. The first parameter of the i-th 3D model is used to indicate the starting position of the index dataset of the i-th 3D model in the combined index data, where i is a positive integer. Based on the length of the index dataset of the i-th 3D model, a second parameter of the i-th 3D model is obtained. The second parameter of the i-th 3D model is used to indicate the span of the index dataset of the i-th 3D model in the combined index data. Based on the length of the vertex dataset of the i-1 preceding 3D models, the third parameter of the i-th 3D model is obtained. The third parameter of the i-th 3D model is used to indicate the starting position of the vertex dataset of the i-th 3D model in the combined vertex data. Based on the length of the vertex dataset of the i-th 3D model, the fourth parameter of the i-th 3D model is obtained. The fourth parameter of the i-th 3D model is used to indicate the span of the vertex dataset of the i-th 3D model in the combined vertex data. Based on the first, second, third, and fourth parameters of the i-th 3D model, the parameter set of the i-th 3D model is obtained.
4. The method according to claim 3, characterized in that, The rendering of the at least two 3D models based on the combined vertex data, the combined index data, and the inter-frame information includes: For the i-th three-dimensional model among the at least two three-dimensional models, the parameter group of the i-th three-dimensional model is obtained from the inter-frame information; Based on the parameter group of the i-th 3D model, obtain the index dataset of the i-th 3D model from the combined index data; Based on the index dataset of the i-th 3D model and the parameter set of the i-th 3D model, the vertex data of the i-th 3D model is obtained from the combined vertex data to obtain the mesh data of the i-th 3D model. The mesh data of the i-th 3D model is used to describe the mesh of the i-th 3D model. Render the i-th 3D model based on the mesh data of the i-th 3D model.
5. The method according to claim 4, characterized in that, The process of obtaining vertex data of the i-th 3D model from the combined vertex data based on the index dataset of the i-th 3D model and the parameter set of the i-th 3D model, and obtaining mesh data of the i-th 3D model, includes: The offset is determined based on the third parameter in the parameter group of the i-th 3D model; The index dataset of the i-th 3D model is adjusted according to the offset to obtain the adjusted index dataset of the i-th 3D model; Based on the adjusted index dataset of the i-th 3D model, the vertex data of the i-th 3D model is obtained from the combined vertex data to obtain the mesh data of the i-th 3D model.
6. The method according to claim 4 or 5, characterized in that, The step of obtaining the index dataset of the i-th 3D model from the combined index data based on the parameter group of the i-th 3D model includes: Based on the first parameter in the parameter group of the i-th 3D model, determine the starting position of the index dataset of the i-th 3D model; Based on the second parameter in the parameter set of the i-th 3D model, determine the number of vertex indices n to be read for the i-th 3D model, where n is a positive integer; Starting from the aforementioned starting position, n vertex indices are read from the combined index data to obtain the index dataset of the i-th 3D model.
7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: The combined vertex data is stored in a first buffer, and the combined index data is stored in a second buffer, the first buffer being different from the second buffer.
8. The method according to any one of claims 1 to 7, characterized in that, The three-dimensional model sequence includes at least two three-dimensional models of the same object at different times. The three-dimensional models in the three-dimensional model sequence are used to render animation frames to form vertex animations about the object.
9. A rendering device for a three-dimensional model, characterized in that, The device includes: A dataset acquisition module is used to acquire the vertex dataset and index dataset of at least two 3D models in a 3D model sequence. The vertex dataset of the 3D model is used to describe at least one vertex of the 3D model, and the index dataset of the 3D model is used to indicate the connection relationship between at least one vertex of the 3D model by vertex index. The dataset stitching module is used to stitch together the vertex datasets of the at least two 3D models in sequence to obtain combined vertex data, and to stitch together the index datasets of the at least two 3D models in sequence to obtain combined index data. The model rendering module is used to render the at least two 3D models based on the combined vertex data and the combined index data.
10. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program that is loaded and executed by the processor to implement the method as claimed in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the method as described in any one of claims 1 to 8.
12. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium, which a processor reads from and executes to implement the method as described in any one of claims 1 to 8.