Method, device, electronic device and storage medium for generating virtual model
By automatically building the basic model and passing normal information, the problems of low efficiency and poor effect of virtual model normal transmission are solved, and efficient and unified model generation and presentation effects are achieved.
Patent Information
- Application Number
- CN202210169766.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-23
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-02-23
AI Technical Summary
In the prior art, the normal transmission of virtual models requires manual production for model generation, which is inefficient and has poor model presentation effect, and the production levels of different artists are uneven, resulting in different model quality.
By automatically building the basic model of the initial virtual model, obtaining the normal information of the basic model, normal transmission is performed, and target virtual model is generated, including spreading points to obtain point cloud data, generating voxel data, converting basic model and normal information transmission.
It improves the efficiency of normal transmission and the presentation effect of the model, while reducing the workload of artists, ensuring the fit and quality consistency of the model.
Smart Images

Figure CN114549783B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer graphics processing, and in particular to a method for generating a virtual model, a device for generating a virtual model, an electronic device, and a computer-readable storage medium. Background Art
[0002] In game or animation scene production, a large number of virtual landscapes are often created to enhance the visual aesthetic and enrich the display content of virtual scenes. For example, virtual vegetation models, such as grass and tree models, can serve as important components of virtual landscapes and are widely used in virtual scene production. However, when processing virtual models, it is often necessary to customize the vertex normals of the models. This often requires artists to manually create the models and transfer the normals. This entire process is often time-consuming and labor-intensive, and the production skills of different artists vary, resulting in inconsistent model quality. This can easily lead to poor rendering of the resulting virtual models and fail to meet actual needs. Summary of the Invention
[0003] An embodiment of the present invention provides a method, device, electronic device and computer-readable storage medium for generating a virtual model to solve or partially solve the problem that in the process of making a virtual model, a model for transferring normals needs to be manually made, the model generation efficiency is low and the model presentation effect cannot meet actual needs.
[0004] An embodiment of the present invention discloses a method for generating a virtual model, comprising:
[0005] Obtaining an initial virtual model;
[0006] Scattering points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model;
[0007] generating voxel data corresponding to the initial virtual model based on the point cloud data;
[0008] Converting the voxel data into a base model corresponding to the initial virtual model, and obtaining normal information of the base model;
[0009] Normals of the initial virtual model are transferred according to the normal information to generate a target virtual model.
[0010] Optionally, scattering points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model includes:
[0011] Acquiring density information of the initial virtual model;
[0012] Points are scattered on the initial virtual model according to the density information to obtain model vertices corresponding to the initial virtual model, where the model vertices include vertex coordinates.
[0013] Optionally, the point cloud data includes model vertices and vertex coordinates of the model vertices, and generating voxel data corresponding to the initial virtual model based on the point cloud data includes:
[0014] Acquiring a model surface corresponding to the initial virtual model;
[0015] Calculating a target distance from the model vertex to the model surface using the vertex coordinates, and using the target distance as a signed distance field corresponding to the model vertex;
[0016] The model vertex whose signed distance field meets a preset threshold is used as the target model vertex, and voxel data corresponding to the target model vertex is constructed.
[0017] Optionally, the step of taking a model vertex whose signed distance field satisfies a preset threshold as a target model vertex and constructing voxel data corresponding to the target model vertex includes:
[0018] The model vertices whose signed distance fields are target values are used as target model vertices, and the target model vertices are converted into voxel data.
[0019] Optionally, the point cloud data includes model vertices and vertex coordinates of the model vertices, and converting the voxel data into a base model corresponding to the initial virtual model includes:
[0020] Converting the voxel data into polygonal meshes, and composing the polygonal meshes into an initial base model corresponding to the initial virtual model;
[0021] Obtaining the normal direction of the initial base model and the adjustment distance for the vertex of the model;
[0022] Adjusting the position of the vertex coordinates of the model vertex using the normal direction and the adjustment distance to generate target vertex coordinates of the model vertex;
[0023] The target vertex coordinates are used to modify the vertex positions of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0024] Optionally, modifying the vertex positions of the initial basic model using the target vertex coordinates to generate a target basic model corresponding to the initial virtual model includes:
[0025] Obtaining smoothing parameters for the model vertices;
[0026] The smoothing parameters and the target vertex coordinates are used to modify vertex positions and adjust surface details of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0027] Optionally, performing normal transfer on the initial virtual model according to the normal information to generate a target virtual model includes:
[0028] Using the model vertex of the basic model as the first model vertex and the model vertex of the initial virtual model as the second model vertex;
[0029] Obtaining a vertex distance between a vertex of the first model and a vertex of the second model;
[0030] The normal information of the first model vertex is transferred to a second model vertex whose vertex distance is less than or equal to a preset distance threshold, to generate a target virtual model.
[0031] Optionally, the initial virtual model includes an initial tree model, the initial tree model includes a leaf model, and scattering points on the initial virtual model according to the density information to obtain model vertices of the initial virtual model and vertex coordinates of the model vertices includes:
[0032] Obtaining position information of the leaf model in the initial tree model;
[0033] At the position corresponding to the position information, scattering points on the leaf model according to the size of the density information to obtain model vertices corresponding to the initial tree model;
[0034] and obtaining vertex coordinates of the model vertices.
[0035] Optionally, performing normal transfer on the initial virtual model according to the normal information to generate a target virtual model includes:
[0036] Normal transfer is performed on the leaf model according to the normal information to generate a target tree model.
[0037] The embodiment of the present invention further discloses a device for generating a virtual model, comprising:
[0038] A virtual model acquisition module is used to obtain an initial virtual model;
[0039] a point cloud data acquisition module, configured to scatter points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model;
[0040] a voxel data generating module, configured to generate voxel data corresponding to the initial virtual model based on the point cloud data;
[0041] a normal information acquisition module, configured to convert the voxel data into a base model corresponding to the initial virtual model and acquire normal information of the base model;
[0042] The virtual model generation module is used to perform normal transfer on the initial virtual model according to the normal information to generate a target virtual model.
[0043] Optionally, the point cloud data acquisition module is specifically used to:
[0044] Acquiring density information of the initial virtual model;
[0045] Points are scattered on the initial virtual model according to the density information to obtain model vertices corresponding to the initial virtual model, where the model vertices include vertex coordinates.
[0046] Optionally, the point cloud data includes model vertices and vertex coordinates of the model vertices, and the voxel data generation module is specifically configured to:
[0047] Acquiring a model surface corresponding to the initial virtual model;
[0048] Calculating a target distance from the model vertex to the model surface using the vertex coordinates, and using the target distance as a signed distance field corresponding to the model vertex;
[0049] The model vertex whose signed distance field meets a preset threshold is used as the target model vertex, and voxel data corresponding to the target model vertex is constructed.
[0050] Optionally, the voxel data generation module is specifically configured to:
[0051] The model vertices whose signed distance fields are target values are used as target model vertices, and the target model vertices are converted into voxel data.
[0052] Optionally, the point cloud data includes model vertices and vertex coordinates of the model vertices, and the normal information acquisition module is specifically used to:
[0053] Converting the voxel data into polygonal meshes, and composing the polygonal meshes into an initial base model corresponding to the initial virtual model;
[0054] Obtaining the normal direction of the initial base model and the adjustment distance for the vertex of the model;
[0055] Adjusting the position of the vertex coordinates of the model vertex using the normal direction and the adjustment distance to generate target vertex coordinates of the model vertex;
[0056] The target vertex coordinates are used to modify the vertex positions of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0057] Optionally, the normal information acquisition module is specifically used to:
[0058] Obtaining smoothing parameters for the model vertices;
[0059] The smoothing parameters and the target vertex coordinates are used to modify vertex positions and adjust surface details of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0060] Optionally, the virtual model generation module is specifically used to:
[0061] Using the model vertex of the basic model as the first model vertex and the model vertex of the initial virtual model as the second model vertex;
[0062] Obtaining a vertex distance between a vertex of the first model and a vertex of the second model;
[0063] The normal information of the first model vertex is transferred to a second model vertex whose vertex distance is less than or equal to a preset distance threshold, to generate a target virtual model.
[0064] Optionally, the initial virtual model includes an initial tree model, and the initial tree model includes a leaf model. The point cloud data acquisition module is specifically configured to:
[0065] Obtaining position information of the leaf model in the initial tree model;
[0066] At the position corresponding to the position information, scattering points on the leaf model according to the size of the density information to obtain model vertices corresponding to the initial tree model;
[0067] and obtaining vertex coordinates of the model vertices.
[0068] Optionally, the virtual model generation module is specifically used to:
[0069] Normal transfer is performed on the leaf model according to the normal information to generate a target tree model.
[0070] An embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0071] The memory is used to store computer programs;
[0072] The processor is configured to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0073] An embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the method according to the embodiment of the present invention.
[0074] The embodiments of the present invention include the following advantages:
[0075] In an embodiment of the present invention, when performing normal transfer on a virtual model, the initial virtual model that needs normal transfer can be obtained first, and then the initial virtual model can be scattered to obtain point cloud data corresponding to the initial virtual model, and then voxel data corresponding to the initial virtual model can be generated based on the point cloud data. Then, the voxel data can be converted into a basic model corresponding to the initial virtual model, and the normal information of the basic model can be obtained. Then, the normal transfer is performed on the initial virtual model based on the normal information to generate a target virtual model, thereby constructing a basic model corresponding to the virtual model that needs normal transfer. On the one hand, the basic model constructed based on the virtual model can ensure the fit between the basic model and the virtual model. On the other hand, by transferring the normal information of the basic model to the virtual model, the efficiency of the normal transfer is effectively improved, and while ensuring the fit of the model, the presentation effect of the model after the normal transfer can also be effectively improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 is a flowchart of the steps of a method for generating a virtual model provided in an embodiment of the present invention;
[0077] Figure 2 is a schematic diagram of a virtual model provided in an embodiment of the present invention;
[0078] Figure 3 is a schematic diagram of point cloud data provided in an embodiment of the present invention;
[0079] Figure 4 is a schematic diagram of voxel data provided in an embodiment of the present invention;
[0080] Figure 5 is a schematic diagram of a polygonal mesh provided in an embodiment of the present invention;
[0081] Figure 6 This is a structural block diagram of a virtual model generation device provided in an embodiment of the present invention;
[0082] Figure 7 is a block diagram of an electronic device provided in an embodiment of the present invention;
[0083] Figure 8is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0084] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0085] As an example, in the process of making games or animation scenes, in order to improve the artistic effect of the picture and enrich the display content of the virtual scene, a large number of virtual landscapes are usually produced. For example, virtual vegetation models such as grass models and tree models can be used as important components of virtual landscapes and are widely used in the production of virtual scenes. For example, in 3D games on mobile terminals, it is usually necessary to customize the vertex normals of the vegetation models in the game, and this usually requires the artists to manually make the corresponding models themselves, and then transfer the normals through the made models. However, in this process, it is necessary to manually make the models for normal transfer, and the whole process often takes a long time and effort. In addition, the production levels of different artists are uneven, and the quality of the models produced is inconsistent, which can easily lead to the final generated virtual model having a poor presentation effect and cannot meet actual needs.
[0086] In this regard, one of the core inventive aspects of an embodiment of the present invention is that when performing normal transfer on a virtual model, a base model corresponding to the virtual model requiring normal transfer is automatically constructed, and the normal information of the base model is transferred to the virtual model requiring normal transfer, thereby achieving normal transfer. Specifically, an initial virtual model requiring normal transfer can be first obtained, and then points can be scattered on the initial virtual model to obtain point cloud data corresponding to the initial virtual model. Then, voxel data corresponding to the initial virtual model is generated based on the point cloud data. Then, the voxel data can be converted into a base model corresponding to the initial virtual model, and normal information of the base model is obtained. Then, normal transfer is performed on the initial virtual model based on the normal information to generate a target virtual model. Thus, by constructing a base model corresponding to the virtual model requiring normal transfer, on the one hand, the base model constructed based on the virtual model can ensure the fit between the base model and the virtual model. On the other hand, by transferring the normal information of the base model to the virtual model, the efficiency of the normal transfer is effectively improved. While ensuring the fit of the models, the rendering effect of the model after the normal transfer can also be effectively improved.
[0087] In order to enable those skilled in the art to better understand the technical solutions of the embodiments of the present invention, some technical terms involved in the embodiments of the present invention are explained and illustrated below:
[0088] Vertex normal: It is an attribute of a vertex in a three-dimensional model, which refers to the direction vector related to a specific vertex in a three-dimensional model in computer graphics.
[0089] Point cloud: refers to a set of vectors in a three-dimensional coordinate system. Each point contains three-dimensional coordinates and may also contain color information (RGB) or reflection intensity information (Intensity).
[0090] SDF (signed distance field): a signed distance field, which can be a sampling grid of the closest distance to the surface of a (polygonal model) object. As a convention, negative values can be used to represent the interior of the object, positive values can be used to represent the exterior of the object, and zero represents the boundary.
[0091] Vertex: A point in 3D space that contains information about normal direction, texture coordinates, and other mesh properties.
[0092] Polygons: A closed geometric figure in a plane, consisting of more than two line segments connected end to end.
[0093] Voxel: A voxel can represent a regular grid of values in three-dimensional space. Compared to 2D bitmaps of pixels, voxels themselves usually do not have their own positions (i.e. coordinates) with their values explicitly encoded. Instead, the rendering system can infer the position of the voxel based on its position relative to other voxels (i.e., its position in the data structure that makes up a single volume image).
[0094] Specifically, refer to Figure 1 , shows a flowchart of a method for generating a virtual model provided in an embodiment of the present invention, which may specifically include the following steps:
[0095] Step 101, obtaining an initial virtual model;
[0096] Optionally, the technical solutions of the embodiments of the present invention can be applied to Houdini. By constructing an automated modeling script corresponding to the virtual model generation method, this script can be used to automatically transfer normals for the virtual model in Houdini. The initial virtual model can be a virtual model that requires normal transfer, such as a vegetation model in a 3D game for a mobile terminal, including grass models, flower models, tree models, and so on. It should be noted that the embodiments of the present invention can also be applied to other types of image processing software, and the present invention is not limited to this.
[0097] Step 102: scattering points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model;
[0098] In an embodiment of the present invention, the initial virtual model can be imported into the image processing software through the plug-in's entry point. Points can then be scattered on the initial virtual model for which normals need to be transferred, obtaining point cloud data corresponding to the initial virtual model. The point cloud data can include the model vertices of the initial virtual model and the vertex coordinates corresponding to the model vertices.
[0099] Specifically, the density information of the initial virtual model can be first obtained, and then points can be scattered on the initial virtual model according to the density information to obtain the model vertices corresponding to the initial virtual model and the vertex coordinates of the model vertices. The density information can be determined for each length unit of the curve or each area unit of the surface in the initial virtual model. By scattering points on the initial virtual model according to the density information, the corresponding model vertices on the virtual model can be obtained, and the general outline of the initial virtual model can be obtained through the model vertices.
[0100] In one example, the initial virtual model can be scattered with the Scatter node of Houdini. Assuming that the initial virtual model is a tree model, which can include a leaf model, the position information of the leaf model in the tree model can be obtained, and then the leaf model can be scattered at the position corresponding to the position information according to the size of the density information to obtain the model vertices corresponding to the tree model and the vertex coordinates of the model vertices. Thus, the points can be distributed volumetrically according to the position of the leaf model to obtain the point cloud data of the virtual model that needs to be transferred normals, so as to construct the corresponding basic model through the point cloud data, and then transfer the normals through the basic model.
[0101] Step 103: generating voxel data corresponding to the initial virtual model based on the point cloud data;
[0102] In an embodiment of the present invention, after obtaining the point cloud data, a dynamic SDF can be generated based on the vertex coordinates of the model vertices contained in the point cloud data, and the point cloud can be converted into voxel data based on the SDF, so that the voxels generated by each model vertex can be seamlessly connected.
[0103] It should be noted that the data types corresponding to the 3D model may include point clouds, voxels, polygonal meshes and multi-view representations, among which point clouds can be a collection of points in three-dimensional space (XYZ coordinates); voxels can be pixels in 3D space, quantized, fixed-size point clouds, each unit of which is a fixed size and discrete coordinates; polygonal meshes can be a collection of facets; multi-view representations can be a collection of 2D images rendered from different simulated viewpoints, etc.
[0104] In a specific implementation, the model surface corresponding to the initial virtual model can be obtained, and then the target distance from the model vertex to the model surface can be calculated using the vertex coordinates. The target distance is used as the signed distance field corresponding to the model vertex, and the model vertex whose signed distance field meets a preset threshold is used as the target model vertex, and voxel data corresponding to the target model vertex is constructed. A preset threshold can be defined first to filter out the model vertices used to represent the model surface. The closest distance from each model vertex to the model surface can then be output using Houdini's vdb from particle fluid node, and this distance can be used as the signed distance field corresponding to the model vertex.
[0105] In one example, for a signed distance field, negative values can be used to represent the interior of an object, positive values can be used to represent the exterior of an object, and zero can be used to represent the boundary. Model vertices with a signed distance field of zero can be used as target model vertices, and model vertices that can be used to represent the boundary of the virtual model can be screened out. The target model vertices are then converted into voxel data, and the point cloud is converted into voxels by outputting the signed distance field (SDF) corresponding to the model vertices. The matching degree with the initial virtual model is adjusted at the voxel stage to generate the corresponding base model.
[0106] It should be noted that for the conforming distance field, other values can also be set to distinguish the inside of an object, the outside of an object, the boundary, etc. For example, the preset threshold is set to 1, when it is 1, it indicates the boundary, when it is less than 1, it indicates the inside of the object, and when it is greater than 1, it indicates the outside of the object; the preset threshold can also be set to -1, when it is -1, it indicates the boundary, when it is less than -1, it indicates the inside of the object, and when it is greater than -1, it indicates the inside of the object, etc. In addition, a value greater than the preset threshold can be characterized as being outside the object, and a value less than the preset threshold can be characterized as being inside the object, etc. The present invention does not impose any restrictions on this.
[0107] Step 104: converting the voxel data into a base model corresponding to the initial virtual model, and obtaining normal information of the base model;
[0108] In a specific implementation, after adjusting the degree of matching with the initial virtual model at the voxel stage, the voxel data can be converted into polygonal meshes, and the various polygonal meshes can be combined to form an initial basic model corresponding to the initial virtual model, and the normal direction of the initial basic model and the adjustment distance for the model vertices can be obtained. Then, the normal direction and the adjustment distance can be used to adjust the position of the vertex coordinates of the model vertices to generate the target vertex coordinates of the model vertices, and then the target vertex coordinates can be used to modify the vertex position of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0109] Optionally, the initial base model constructed by the polygonal mesh can itself carry corresponding normal information, which is the information that needs to be transferred to the initial virtual model later. After the initial base model is constructed, there is still a certain deviation in the fit between the base model and the virtual model. To this end, the vertex position can be modified by the normal direction based on the initial base model to make a secondary modification so that the fit between the base model and the virtual model can meet the conditions. Specifically, by extracting the normal direction from the normal information of the initial base model, the vertex position can be calculated by the following formula, and then the vertex position of the initial base model can be adjusted according to the vertex position:
[0110] Target vertex coordinates = original vertex coordinates + normal direction * adjustment distance
[0111] Among them, the adjustment distance can be the distance set by the artist in practice, which can be set according to the actual needs of the model. Therefore, through the above process, the basic model can be adjusted to a model with a high degree of fit with the virtual model, so that when the normal is transferred subsequently, the accuracy and pertinence of the normal transfer can be guaranteed.
[0112] In addition, in the process of adjusting the vertex positions of the base model, the smoothing parameters for the model vertices can also be obtained, and then the smoothing parameters and the target vertex coordinates are used to modify the vertex positions and adjust the surface details of the initial base model to generate a target base model corresponding to the initial virtual model. By combining the smoothing parameters (smooth strength), the vertex positions can be controlled to achieve the effect of adjusting the degree of surface details, and finally the target base model that can be used for normal transfer is obtained.
[0113] Step 105 : performing normal transfer on the initial virtual model according to the normal information to generate a target virtual model.
[0114] After obtaining the adjusted base model, normals can be transferred between the base model and the initial virtual model. Normal transfer can be done by transferring attributes from one model to the nearest vertices on the other model, thereby achieving normal transfer between models.
[0115] In a specific implementation, the model vertex of the base model can be used as the first model vertex, and the model vertex of the initial virtual model can be used as the second model vertex. Then, the vertex distance between the first model vertex and the second model vertex can be obtained, and then the normal information of the first model vertex is transferred to the second model vertex whose vertex distance is less than or equal to the preset distance threshold to generate a target virtual model. By constructing a base model corresponding to the virtual model that needs to perform normal transfer, on the one hand, the base model constructed based on the virtual model can ensure the fit between the base model and the virtual model. On the other hand, by transferring the normal information of the base model to the virtual model, the efficiency of the normal transfer is effectively improved. Moreover, while ensuring the fit of the models, the presentation effect of the model after the normal transfer can also be effectively improved.
[0116] Specifically, a corresponding transfer distance can be set for the first model vertex. In the process of comparing the base model with the initial virtual model, the normal of the second model vertex located within the transfer distance of the first model vertex can be transferred. The transferred normal information is the normal information of the first model vertex. Therefore, in the process of modifying the vertex normal of the virtual model, a base model corresponding to the virtual model can be constructed, and the normal information of the base model can be transferred to the virtual model. This not only realizes the automatic processing of normal information, but also improves the presentation effect of the model after normal transfer while ensuring model fit, effectively reducing the workload of artists and improving the efficiency of model normal transfer.
[0117] In one example, assuming that the virtual model is a tree model, taking the processing of the vertex normals of the tree model as an example, refer to Figure 2 , shows a schematic diagram of a virtual model provided in an embodiment of the present invention. In Houdini, a tree model that needs normal transfer can be input through the plug-in port, and then points can be scattered on the initial virtual model that needs normal transfer to obtain point cloud data corresponding to the initial virtual model. Figure 3 , shows a schematic diagram of the point cloud data provided in an embodiment of the present invention. The initial virtual model can be scattered with points through the Scatter node of Houdini. Specifically, the position information of the leaf model in the tree model can be obtained, and then the leaf model can be scattered with points according to the density information at the position corresponding to the position information to obtain the model vertices corresponding to the tree model and the vertex coordinates of the model vertices. Figure 4, shows a schematic diagram of voxel data provided in an embodiment of the present invention. After obtaining the point cloud data, Houdini's vdb from particle fluid node can be used to generate a dynamic SDF based on the point cloud's Position information (i.e., the vertex coordinates of the model's vertices). Then, based on the SDF, the point cloud is converted into voxels to achieve seamless connection of the voxels corresponding to each model vertex. Figure 5 , shows a schematic diagram of a polygon mesh provided in an embodiment of the present invention. After adjusting the matching degree at the voxel stage, the voxels can be converted into polygons using the Convert VDB function, thereby generating a base model for fixed-point transfer. To improve the fit between the base model and the tree model, the vertex positions can be modified by adjusting the normal direction to adjust the fit. The vertex positions can also be controlled by adjusting the smoothing intensity to adjust the surface detail, resulting in a base model suitable for normal transfer. During the normal transfer process, Houdini's AttribTransfer node can be used to set a corresponding transfer distance to transfer the vertex normal information from the base model to the tree model, completing the vertex normal adjustment of the tree model. By constructing a base model corresponding to the virtual model to which normal transfer is required, the base model constructed based on the virtual model can ensure fit between the base model and the virtual model. Furthermore, by transferring the base model's normal information to the virtual model, the efficiency of normal transfer is effectively improved. While ensuring model fit, the rendering quality of the model after normal transfer is also effectively enhanced.
[0118] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It is understandable that under the guidance of the ideas of the embodiments of the present invention, those skilled in the art can also make settings according to actual needs, and the present invention is not limited to this.
[0119] In an embodiment of the present invention, when performing normal transfer on a virtual model, the initial virtual model that needs normal transfer can be obtained first, and then the initial virtual model can be scattered to obtain point cloud data corresponding to the initial virtual model, and then voxel data corresponding to the initial virtual model can be generated based on the point cloud data. Then, the voxel data can be converted into a basic model corresponding to the initial virtual model, and the normal information of the basic model can be obtained. Then, the normal transfer is performed on the initial virtual model based on the normal information to generate a target virtual model, thereby constructing a basic model corresponding to the virtual model that needs normal transfer. On the one hand, the basic model constructed based on the virtual model can ensure the fit between the basic model and the virtual model. On the other hand, by transferring the normal information of the basic model to the virtual model, the efficiency of the normal transfer is effectively improved, and while ensuring the fit of the model, the presentation effect of the model after the normal transfer can also be effectively improved.
[0120] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0121] Reference Figure 6 , shows a structural block diagram of a virtual model generation device provided in an embodiment of the present invention, which may specifically include the following modules:
[0122] A virtual model acquisition module 601 is used to acquire an initial virtual model;
[0123] The point cloud data acquisition module 602 is used to scatter points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model;
[0124] A voxel data generating module 603 is configured to generate voxel data corresponding to the initial virtual model based on the point cloud data;
[0125] a normal information acquisition module 604, configured to convert the voxel data into a base model corresponding to the initial virtual model, and acquire normal information of the base model;
[0126] The virtual model generation module 605 is configured to perform normal transfer on the initial virtual model according to the normal information to generate a target virtual model.
[0127] In an optional embodiment, the point cloud data acquisition module 602 is specifically configured to:
[0128] Acquiring density information of the initial virtual model;
[0129] Points are scattered on the initial virtual model according to the density information to obtain model vertices corresponding to the initial virtual model, where the model vertices include vertex coordinates.
[0130] In an optional embodiment, the point cloud data includes model vertices and vertex coordinates of the model vertices, and the voxel data generation module 603 is specifically configured to:
[0131] Acquiring a model surface corresponding to the initial virtual model;
[0132] Calculating a target distance from the model vertex to the model surface using the vertex coordinates, and using the target distance as a signed distance field corresponding to the model vertex;
[0133] The model vertex whose signed distance field meets a preset threshold is used as the target model vertex, and voxel data corresponding to the target model vertex is constructed.
[0134] In an optional embodiment, the voxel data generating module 603 is specifically configured to:
[0135] The model vertices whose signed distance fields are target values are used as target model vertices, and the target model vertices are converted into voxel data.
[0136] In an optional embodiment, the point cloud data includes model vertices and vertex coordinates of the model vertices, and the normal information acquisition module 604 is specifically configured to:
[0137] Converting the voxel data into polygonal meshes, and composing the polygonal meshes into an initial base model corresponding to the initial virtual model;
[0138] Obtaining the normal direction of the initial base model and the adjustment distance for the vertex of the model;
[0139] Adjusting the position of the vertex coordinates of the model vertex using the normal direction and the adjustment distance to generate target vertex coordinates of the model vertex;
[0140] The target vertex coordinates are used to modify the vertex positions of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0141] In an optional embodiment, the normal information acquisition module 604 is specifically configured to:
[0142] Obtaining smoothing parameters for the model vertices;
[0143] The smoothing parameters and the target vertex coordinates are used to modify vertex positions and adjust surface details of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0144] In an optional embodiment, the virtual model generation module 605 is specifically configured to:
[0145] Using the model vertex of the basic model as the first model vertex and the model vertex of the initial virtual model as the second model vertex;
[0146] Obtaining a vertex distance between a vertex of the first model and a vertex of the second model;
[0147] The normal information of the first model vertex is transferred to a second model vertex whose vertex distance is less than or equal to a preset distance threshold, to generate a target virtual model.
[0148] In an optional embodiment, the initial virtual model includes an initial tree model, and the initial tree model includes a leaf model. The point cloud data acquisition module 602 is specifically configured to:
[0149] Obtaining position information of the leaf model in the initial tree model;
[0150] At the position corresponding to the position information, scattering points on the leaf model according to the size of the density information to obtain model vertices corresponding to the initial tree model;
[0151] and obtaining vertex coordinates of the model vertices.
[0152] In an optional embodiment, the virtual model generation module 605 is specifically configured to:
[0153] Normal transfer is performed on the leaf model according to the normal information to generate a target tree model.
[0154] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0155] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 7 As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.
[0156] Memory 703, for storing computer programs;
[0157] The processor 701 is configured to execute the program stored in the memory 703 by performing the following steps:
[0158] Obtaining an initial virtual model;
[0159] Scattering points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model;
[0160] generating voxel data corresponding to the initial virtual model based on the point cloud data;
[0161] Converting the voxel data into a base model corresponding to the initial virtual model, and obtaining normal information of the base model;
[0162] Normals of the initial virtual model are transferred according to the normal information to generate a target virtual model.
[0163] In an optional embodiment, scattering points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model includes:
[0164] Acquiring density information of the initial virtual model;
[0165] Points are scattered on the initial virtual model according to the density information to obtain model vertices corresponding to the initial virtual model, where the model vertices include vertex coordinates.
[0166] In an optional embodiment, the point cloud data includes model vertices and vertex coordinates of the model vertices, and generating voxel data corresponding to the initial virtual model based on the point cloud data includes:
[0167] Acquiring a model surface corresponding to the initial virtual model;
[0168] Calculating a target distance from the model vertex to the model surface using the vertex coordinates, and using the target distance as a signed distance field corresponding to the model vertex;
[0169] The model vertex whose signed distance field meets a preset threshold is used as the target model vertex, and voxel data corresponding to the target model vertex is constructed.
[0170] In an optional embodiment, taking a model vertex that satisfies a condition of the signed distance field as a target model vertex and constructing voxel data corresponding to the target model vertex includes:
[0171] The model vertices whose signed distance fields are target values are used as target model vertices, and the target model vertices are converted into voxel data.
[0172] In an optional embodiment, the point cloud data includes model vertices and vertex coordinates of the model vertices, and converting the voxel data into a base model corresponding to the initial virtual model includes:
[0173] Converting the voxel data into polygonal meshes, and composing the polygonal meshes into an initial base model corresponding to the initial virtual model;
[0174] Obtaining the normal direction of the initial base model and the adjustment distance for the vertex of the model;
[0175] Adjusting the position of the vertex coordinates of the model vertex using the normal direction and the adjustment distance to generate target vertex coordinates of the model vertex;
[0176] The target vertex coordinates are used to modify the vertex positions of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0177] In an optional embodiment, modifying the vertex positions of the initial basic model using the target vertex coordinates to generate a target basic model corresponding to the initial virtual model includes:
[0178] Obtaining smoothing parameters for the model vertices;
[0179] The smoothing parameters and the target vertex coordinates are used to modify vertex positions and adjust surface details of the initial basic model to generate a target basic model corresponding to the initial virtual model.
[0180] In an optional embodiment, the step of transferring the normals of the initial virtual model according to the normal information to generate the target virtual model includes:
[0181] Using the model vertex of the basic model as the first model vertex and the model vertex of the initial virtual model as the second model vertex;
[0182] Obtaining a vertex distance between a vertex of the first model and a vertex of the second model;
[0183] The normal information of the first model vertex is transferred to a second model vertex whose vertex distance is less than or equal to a preset distance threshold, to generate a target virtual model.
[0184] In an optional embodiment, the initial virtual model includes an initial tree model, the initial tree model includes a leaf model, and scattering points on the initial virtual model according to the density information to obtain model vertices of the initial virtual model and vertex coordinates of the model vertices includes:
[0185] Obtaining position information of the leaf model in the initial tree model;
[0186] At the position corresponding to the position information, scattering points on the leaf model according to the size of the density information to obtain model vertices corresponding to the initial tree model;
[0187] and obtaining vertex coordinates of the model vertices.
[0188] In an optional embodiment, the step of performing normal transfer on the initial virtual model according to the normal information to generate a target virtual model includes:
[0189] Normal transfer is performed on the leaf model according to the normal information to generate a target tree model.
[0190] The communication bus mentioned in the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0191] The communication interface is used for communication between the above terminal and other devices.
[0192] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0193] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0194] like Figure 8 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 801 is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the method for generating a virtual model described in the above embodiment.
[0195] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the method for generating a virtual model described in the above embodiment.
[0196] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0197] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0198] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.
[0199] The above description is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included in the scope of protection of the present invention.
Claims
1. A method for generating a virtual model, characterized in that: include: Obtaining an initial virtual model; Scattering points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model; the point cloud data includes model vertices and vertex coordinates of the model vertices; generating voxel data corresponding to the initial virtual model based on the point cloud data; Converting the voxel data into polygonal meshes, and composing the polygonal meshes into an initial base model corresponding to the initial virtual model; Obtaining the normal direction of the initial base model and the adjustment distance for the vertex of the model; Adjusting the position of the vertex coordinates of the model vertex using the normal direction and the adjustment distance to generate target vertex coordinates of the model vertex; Modifying vertex positions of the initial basic model using the target vertex coordinates to generate a target basic model corresponding to the initial virtual model, and obtaining normal information of the target basic model; Normal transfer is performed on the initial virtual model according to the normal information to generate a target virtual model.
2. The method according to claim 1, characterized in that The step of scattering points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model includes: Acquiring density information of the initial virtual model; Points are scattered on the initial virtual model according to the density information to obtain model vertices corresponding to the initial virtual model, where the model vertices include vertex coordinates.
3. The method according to claim 1, characterized in that The point cloud data includes model vertices and vertex coordinates of the model vertices, and generating voxel data corresponding to the initial virtual model based on the point cloud data includes: Acquiring a model surface corresponding to the initial virtual model; Calculating a target distance from the model vertex to the model surface using the vertex coordinates, and using the target distance as a signed distance field corresponding to the model vertex; The model vertex whose signed distance field meets a preset threshold is used as the target model vertex, and voxel data corresponding to the target model vertex is constructed.
4. The method according to claim 3, characterized in that The method of taking a model vertex whose signed distance field satisfies a preset threshold as a target model vertex and constructing voxel data corresponding to the target model vertex includes: The model vertices whose signed distance fields are target values are used as target model vertices, and the target model vertices are converted into voxel data.
5. The method according to claim 1, wherein The step of modifying the vertex positions of the initial basic model using the target vertex coordinates to generate a target basic model corresponding to the initial virtual model includes: Obtaining smoothing parameters for the model vertices; The smoothing parameters and the target vertex coordinates are used to modify vertex positions and adjust surface details of the initial basic model to generate a target basic model corresponding to the initial virtual model.
6. The method according to claim 1, characterized in that The step of transferring the normals of the initial virtual model according to the normal information to generate the target virtual model includes: Using the model vertex of the basic model as the first model vertex and the model vertex of the initial virtual model as the second model vertex; Obtaining a vertex distance between a vertex of the first model and a vertex of the second model; The normal information of the first model vertex is transferred to a second model vertex whose vertex distance is less than or equal to a preset distance threshold, to generate a target virtual model.
7. The method according to claim 2, characterized in that The initial virtual model includes an initial tree model, and the initial tree model includes a leaf model. The initial virtual model is scattering points according to the density information to obtain model vertices of the initial virtual model and vertex coordinates of the model vertices, including: Obtaining position information of the leaf model in the initial tree model; At the position corresponding to the position information, scattering points on the leaf model according to the size of the density information to obtain model vertices corresponding to the initial tree model; and obtaining vertex coordinates of the model vertices.
8. The method according to claim 7, characterized in that The step of transferring the normals of the initial virtual model according to the normal information to generate a target virtual model includes: Normal transfer is performed on the leaf model according to the normal information to generate a target tree model.
9. A device for generating a virtual model, characterized in that: include: A virtual model acquisition module is used to obtain an initial virtual model; a point cloud data acquisition module, configured to scatter points on the initial virtual model to obtain point cloud data corresponding to the initial virtual model; the point cloud data includes model vertices and vertex coordinates of the model vertices; a voxel data generating module, configured to generate voxel data corresponding to the initial virtual model based on the point cloud data; a normal information acquisition module, configured to convert the voxel data into polygonal meshes, and assemble the polygonal meshes into an initial base model corresponding to the initial virtual model; obtain normal directions of the initial base model and adjustment distances for the model vertices; adjust the positions of the vertex coordinates of the model vertices using the normal directions and adjustment distances to generate target vertex coordinates of the model vertices; modify the vertex positions of the initial base model using the target vertex coordinates to generate a target base model corresponding to the initial virtual model, and obtain normal information of the target base model; The virtual model generation module is used to perform normal transfer on the initial virtual model according to the normal information to generate a target virtual model.
10. An electronic device, characterized in that: comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1 to 8 when executing a program stored in the memory.
11. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Virtual character face model processing method and device
CN111768488A