Model optimization method, device and electronic equipment

By optimizing the number of vertices and triangles of the static mesh model based on screen-body ratio and position coordinates in Unreal Engine, combined with material merging and replacement, the problem of low rendering performance caused by static rendering in Unreal Engine is solved, and the rendering performance and User experience.

CN118710820BActive Publication Date: 2024-12-03YUNLI ZHIHUI TECH CLOUD WISDOM TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411195864.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-12-03
Estimated Expiration
2044-08-29

AI Technical Summary

Technical Problem

The existing Unreal Engine renders and displays the model in a static way, resulting in increased graphics processor overhead, resulting in image display lag and operation response delays, affecting rendering performance and user experience.

Method used

By obtaining the static mesh model imported by the user, determining the reduction ratio of vertices and triangles based on the model's screen-to-body ratio and position coordinates, dynamically optimize the model to reduce GPU overhead, and merging or replacing materials when necessary to improve rendering performance.

Benefits of technology

It effectively solves the problem of model rendering and display of different sizes and screen-to-body ratios, improves rendering performance and user experience, reduces GPU overhead, and avoids unnecessary rendering operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118710820B_ABST
    Figure CN118710820B_ABST
Patent Text Reader

Abstract

The present invention provides a model optimization method, device and electronic device, which relate to the technical field of three-dimensional model rendering. The model optimization method is used in Unreal Engine, and the method comprises: obtaining a static mesh model imported by a user, wherein the static mesh model comprises vertices and triangles; when it is determined that the vertices of the static mesh model are greater than a first preset threshold, determining the vertex reduction ratio and triangle reduction ratio of the static mesh model based on the screen ratio of the static mesh model, optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio, and obtaining an optimized model to be drawn, which can improve rendering performance and user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of three-dimensional model rendering, and in particular to a model optimization method, device and electronic equipment. Background Art

[0002] The digital twin system realizes the feedback of the real physical system to the digital model and is widely used in smart cities, park rivers, oceans and other fields. Generally, the model can be rendered and displayed through the Unreal Engine to facilitate the creation and operation of the digital twin system. However, at present, the Unreal Engine generally renders and displays the model in a static way, such as using the same rendering technology to render and display models of different sizes; rendering and displaying the same model with different screen ratios at the same level of detail, etc. The Unreal Engine requires graphics processing unit (GPU) overhead for rendering and displaying. Therefore, the Unreal Engine renders and displays the model in a static way, which may increase the graphics processor overhead, cause image display jams, operation response delays and other problems, resulting in poor rendering performance and affecting user experience. Summary of the invention

[0003] The present invention provides a model optimization method, device and electronic device, which are used to solve the defect of rendering and displaying a model in a static manner in the prior art, and improve rendering performance and user experience.

[0004] The present invention provides a model optimization method for Unreal Engine, the method comprising: obtaining a static mesh model imported by a user, wherein the static mesh model comprises vertices and triangles; when it is determined that the vertices of the static mesh model are greater than a first preset threshold, determining a vertex reduction ratio and a triangle reduction ratio of the static mesh model based on a screen ratio of the static mesh model, optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio, and obtaining an optimized model to be drawn.

[0005] According to a model optimization method provided by the present invention, in the case where there are multiple static mesh models, after obtaining the static mesh models imported by the user, the method further includes: determining the position coordinates of each static mesh model in the Unreal Engine; determining a drawing judgment area based on the position coordinates, and taking the static mesh models outside the drawing judgment area as the initial model to be drawn; obtaining the volume of each static mesh model in the drawing judgment area and the distance between each static mesh model and the virtual camera in the Unreal Engine; determining the initial model to be drawn based on the volume and the distance; and determining the static mesh model. When the number of vertices of the model is greater than a first preset threshold, the vertex reduction ratio and the triangle reduction ratio of the static mesh model are determined based on the screen ratio of the static mesh model, and the static mesh model is optimized based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn, including: when it is determined that the vertices of the initial model to be drawn are greater than a first preset threshold, the vertex reduction ratio and the triangle reduction ratio of the initial model to be drawn are determined based on the screen ratio of the initial model to be drawn, and the initial model to be drawn is optimized based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0006] According to a model optimization method provided by the present invention, before determining the initial model to be drawn based on the volume and the distance, the method further includes: determining the model type of each of the static mesh models; determining the initial model to be drawn based on the volume and the distance, specifically including: when it is determined that the model type of the static mesh model is a building model, determining the static mesh model whose volume belongs to a set volume range and whose distance belongs to a set distance range as the initial model to be drawn; when it is determined that the model type of the static mesh model is a vegetation model, determining the static mesh model in the drawing judgment area except the static mesh model with the smallest volume and / or the longest distance as the initial model to be drawn.

[0007] According to a model optimization method provided by the present invention, after obtaining a static mesh model imported by a user, the method further includes: when it is determined that the vertices of the static mesh model are less than or equal to a first preset threshold, judging whether the vertices of the model to be drawn are less than a second preset threshold; if the vertices of the model to be drawn are less than the second preset threshold, at least obtaining the position coordinates and material of the static mesh model, obtaining the distance between the static mesh models based on the position coordinates of the static mesh model, and obtaining the material difference of the static mesh model based on a preset material index; merging the static mesh models whose distance and material difference are both within the corresponding preset range to obtain an optimized model to be drawn.

[0008] According to a model optimization method provided by the present invention, the vertex reduction ratio and triangle reduction ratio of the static mesh model are determined based on the screen ratio of the static mesh model, including: selecting the drawing level of the static mesh model based on the screen ratio of the static mesh model, and obtaining the corresponding vertex reduction ratio and triangle reduction ratio according to the drawing level.

[0009] According to a model optimization method provided by the present invention, a drawing level of a static mesh model is selected based on the screen ratio of the static mesh model, and after obtaining the corresponding vertex reduction ratio and triangle reduction ratio according to the drawing level, the method also includes: optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio, and displaying the optimized static mesh model; receiving user input instructions; the input instructions are used to determine the vertex reduction ratio and triangle reduction ratio of the static mesh model, which are the vertex reduction ratio and triangle reduction ratio obtained according to the drawing level, or the vertex reduction ratio and triangle reduction ratio input by the user.

[0010] According to a model optimization method provided by the present invention, after obtaining an optimized model to be drawn, the method further includes: obtaining the number of materials of the optimized model to be drawn; when determining that the number of materials is greater than a material number threshold, obtaining a representative material based on similar materials in the optimized model to be drawn, and using the representative material to replace the corresponding similar material; wherein the number of the representative materials is within 10.

[0011] The present invention also provides a model optimization device for use in an Unreal Engine, the device comprising: a model acquisition module, for acquiring a static mesh model imported by a user, wherein the static mesh model comprises vertices and triangles; a model optimization module, for determining a vertex reduction ratio and a triangle reduction ratio of the static mesh model based on a screen ratio of the static mesh model when it is determined that the vertices of the static mesh model are greater than a first preset threshold, and optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0012] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the model optimization method described above is implemented.

[0013] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the model optimization method described in any one of the above is implemented.

[0014] The model optimization method, device and electronic device provided by the present invention obtain a static mesh model imported by a user, and when it is determined that the vertices of the static mesh model are greater than a first preset threshold, dynamically determine whether to optimize the static mesh model for rendering, thereby solving the problem of using the same rendering technology to render and display models of different sizes; dynamically determine the vertex reduction ratio and triangle reduction ratio of the static mesh model based on the screen ratio of the static mesh model to optimize the static mesh model for rendering, and can render and display the same model with different screen ratios at the same level of precision, thereby improving rendering performance and user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0016] Figure 1 It is one of the flow charts of the model optimization method provided by the present invention.

[0017] Figure 2 This is the second flow chart of the model optimization method provided by the present invention.

[0018] Figure 3 It is a structural schematic diagram of the model optimization device provided by the present invention.

[0019] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0021] Combine the following Figure 1-Figure 4 The model optimization method, device and electronic device of the present invention are described.

[0022] Figure 1 It is one of the flow charts of the model optimization method provided by the present invention, which is used in Unreal Engine, such as Figure 1 As shown, the method includes step 110 and step 120.

[0023] Step 110: Obtain a static mesh model imported by a user, wherein the static mesh model includes vertices and triangles.

[0024] Static mesh models can also be called three-dimensional scene models, which may include BIM fine models, oblique photography models, monomer rough models, skeletal animation models, and other models obtained using third-party modeling software.

[0025] It may be to obtain a static mesh model imported by the user into the Unreal Engine. For example, the static mesh model may be a model exported by the user using a third-party modeling tool. The user may use a third-party tool in the Unreal Engine to quickly import the static mesh model into the Unreal Engine, or may directly import the static mesh model into the Unreal Engine flexibly.

[0026] Vertices are the basic points of a static mesh model. Triangles can be obtained based on the positions and connections of vertices. They are the basic units of a static mesh model. The surface of a static mesh model can be obtained by connecting multiple triangles. It is understandable that the polygons of a static mesh model can also be quadrilaterals, pentagons, etc. The triangles here are not considered to limit the range of the polygons of a static mesh model.

[0027] Step 120: When it is determined that the number of vertices of the static mesh model is greater than a first preset threshold, determine a vertex reduction ratio and a triangle reduction ratio of the static mesh model based on the screen ratio of the static mesh model, and optimize the static mesh model based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0028] As mentioned above, triangles can be obtained based on the positions and connection relationships of vertices. There is a correlation between the number of vertices and the number of triangles. On this basis, when the number of vertices of the static mesh model is greater than the first preset threshold, the triangles of the static mesh model are generally also greater than the corresponding threshold.

[0029] The screen ratio may be the ratio of the pixel area of ​​the static mesh model on the screen to the screen size. For example, the number of pixels displaying the static mesh model may be obtained, and the screen ratio of the static mesh model may be obtained by the ratio of the number of pixels of the static mesh model to the number of pixels of the screen.

[0030] The number of vertices of the static mesh model is greater than the first preset threshold, which indicates that the static mesh model is relatively complex. The GPU overhead required to directly render the static mesh model is high. The GPU overhead required to render the static mesh model can be reduced by determining the vertex reduction ratio and triangle reduction ratio of the static mesh model.

[0031] Exemplarily, the vertex reduction ratio may be the ratio between the number of reduced vertices of the static mesh model and its number of vertices, or the ratio between the number of reduced vertices of the static mesh model and the initial number of vertices, etc. The triangle reduction ratio is the ratio between the number of reduced triangles of the static mesh model and the initial number of triangles. In this way, the number of vertices to be reduced in the static mesh model can be obtained based on the vertex reduction ratio, and the number of triangles to be reduced in the static mesh model can be obtained based on the triangle reduction ratio, so as to optimize the static mesh model.

[0032] The model optimization method provided by the embodiment of the present invention obtains a static mesh model imported by a user, and when it is determined that the vertices of the static mesh model are greater than a first preset threshold, dynamically determines whether to optimize the static mesh model for rendering, thereby solving the problem of using the same rendering technology to render and display models of different sizes; dynamically determines the vertex reduction ratio and triangle reduction ratio of the static mesh model based on the screen ratio of the static mesh model to optimize the static mesh model for rendering, and can render and display the same model with different screen ratios at the same level of fineness, thereby improving rendering performance and user experience.

[0033] Based on any of the above embodiments, determining the vertex reduction ratio and triangle reduction ratio of the static mesh model based on the screen ratio of the static mesh model includes: selecting the drawing level of the static mesh model based on the screen ratio of the static mesh model, and obtaining the corresponding vertex reduction ratio and triangle reduction ratio according to the drawing level.

[0034] The static mesh model may include multiple different drawing levels, each drawing level corresponding to a static mesh model complexity, or a level of detail of the static mesh model complexity. For example, multiple levels of detail (LOD) can be applied to automatically select the drawing level of the static mesh model according to the screen ratio of the static mesh model to obtain the corresponding vertex reduction ratio and triangle reduction ratio.

[0035] Based on any of the above embodiments, the drawing level of the static mesh model is selected based on the screen ratio of the static mesh model, and after obtaining the corresponding vertex reduction ratio and triangle reduction ratio according to the drawing level, the method also includes: optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio, and displaying the optimized static mesh model; receiving user input instructions; the input instructions are used to determine the vertex reduction ratio and triangle reduction ratio of the static mesh model, which are the vertex reduction ratio and triangle reduction ratio obtained according to the drawing level, or the vertex reduction ratio and triangle reduction ratio input by the user.

[0036] Displaying the optimized static mesh model can facilitate the user to judge whether the screen ratio display effect of the optimized static mesh model meets the requirements and give corresponding input instructions. When the user judges that the screen ratio display effect of the optimized static mesh model meets the requirements, an input instruction is given to determine the vertex reduction ratio and triangle reduction ratio of the static mesh model, which are the vertex reduction ratio and triangle reduction ratio obtained according to the drawing level. When the user judges that the screen ratio display effect of the optimized static mesh model does not meet the requirements, an input instruction is given to determine the vertex reduction ratio and triangle reduction ratio of the static mesh model, which are the vertex reduction ratio and triangle reduction ratio input by the user.

[0037] For example, the user can determine the optimized static mesh model based on experience, or can determine the optimized static mesh model based on indicators. The specific indicators can be determined based on the screen ratio display effect requirements of the specific static mesh model, and no further limitation is made here.

[0038] In this embodiment, when the screen ratio display effect of the static mesh model is not good by automatically optimizing the static mesh model by selecting the drawing level of the static mesh model, receiving the user's input command to optimize the static mesh model can enhance the screen ratio display effect of the static mesh model.

[0039] When the virtual camera in the Unreal Engine is at a high position, the distance between the virtual camera and the static mesh model is relatively far. When there are many static mesh models in the Unreal Engine, some static mesh models may have a small screen share, and even if these static mesh models are rendered, they are not visually clear. In this way, rendering these static mesh models will increase GPU overhead and reduce the rendering performance of the static mesh models as a whole.

[0040] To solve the above technical problem, based on the above embodiment, in the case where there are multiple static mesh models, after obtaining the static mesh models imported by the user, the method also includes: determining the position coordinates of each of the static mesh models in the Unreal Engine; determining a drawing judgment area based on the position coordinates, and using the static mesh models outside the drawing judgment area as the initial model to be drawn; obtaining the volume of each of the static mesh models in the drawing judgment area and the distance between each of the static mesh models and the virtual camera in the Unreal Engine; and determining the initial model to be drawn based on the volume and the distance.

[0041] The position coordinates of the static mesh model in the Unreal Engine can be obtained according to the properties of the static mesh model, or after the static mesh model is imported into the Unreal Engine, the position coordinates of the static mesh model in the Unreal Engine can be obtained based on the position instructions input by the user.

[0042] Among the multiple static mesh models in the drawing judgment area, some static mesh models are drawn, while other static mesh models are not drawn. Therefore, the drawing judgment area can also be called a culling judgment area, a culling distance volume, etc.

[0043] The position coordinates of the drawing judgment area can be determined based on the position coordinates of each static mesh model in the Unreal Engine. The shape and size of the drawing judgment area can be preset in the Unreal Engine. For example, the drawing judgment area can be preset as a cuboid, and the length, width, and height values ​​of the cuboid can be preset. In this way, the drawing judgment area can be determined based on the position coordinates, shape, and size of the drawing judgment area.

[0044] In this embodiment, within the drawing judgment area, whether to draw the static mesh model is determined by the volume of the static mesh model and the distance between the static mesh model and the virtual camera. This can avoid drawing and rendering static mesh models with a small screen share, reduce GPU overhead, and thus improve the performance of rendering the static mesh model.

[0045] Based on any of the above embodiments, when it is determined that the vertices of the static mesh model are greater than a first preset threshold, the vertex reduction ratio and the triangle reduction ratio of the static mesh model are determined based on the screen ratio of the static mesh model, and the static mesh model is optimized based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn, including: when it is determined that the vertices of the initial model to be drawn are greater than a first preset threshold, the vertex reduction ratio and the triangle reduction ratio of the initial model to be drawn are determined based on the screen ratio of the initial model to be drawn, and the initial model to be drawn is optimized based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0046] The working principle and technical effect of optimizing the initial model to be drawn in this embodiment are basically the same as the working principle and technical effect of optimizing the static mesh model mentioned above, and will not be repeated here.

[0047] Static mesh models have multiple model types. For example, static mesh models may include at least building models and vegetation models, wherein building models may also be referred to as scene building models, and vegetation models may also be referred to as flower and tree models. Static mesh models of different model types may require different display effects. On this basis, static mesh models of different model types may determine whether to draw, or determine the method of initial model to be drawn, which may also be different. To facilitate determining the initial model to be drawn from multiple static mesh models, based on any of the above embodiments, before determining the initial model to be drawn based on the volume and the distance, the method further includes: determining the model type of each static mesh model.

[0048] For example, the model type of the static mesh model may be determined based on relevant properties of the static mesh model.

[0049] Based on any of the above embodiments, determining the initial model to be drawn based on the volume and the distance may include: when it is determined that the model type of the static mesh model is a building model, determining the static mesh model whose volume belongs to a set volume range and whose distance belongs to a set distance range as the initial model to be drawn.

[0050] The volume of the building model belongs to the set volume range and the distance of the building model belongs to the set distance range, which means that after the static mesh model is rendered, the screen proportion of the static mesh model can be visually seen.

[0051] When it is determined that the model type of the static mesh model is a building model, the static mesh model whose volume belongs to the set volume range can be determined as the model to be drawn, and the static mesh model whose distance belongs to the set distance range can be determined as the model to be drawn, or the static mesh model whose volume belongs to the set volume range and whose distance belongs to the set distance range can be determined as the model to be drawn.

[0052] The set volume range may be a volume range greater than a preset volume threshold, and the set distance range may be a distance range greater than a preset distance threshold. The specific preset volume threshold and preset distance threshold may be determined according to the actual situation of the static mesh model in the Unreal Engine, and are not further limited here.

[0053] In one embodiment, when the model type of the static mesh model is determined to be a building model in the drawing judgment area, the culled models in the drawing judgment area are determined by a pre-set culling array, and the static mesh models other than the culled models in the drawing judgment area are determined as models to be drawn. Specifically, a culling array object[] based on the distance D between the static mesh model and the virtual camera and the size S of the static mesh model may be added. If the size of a static mesh model is close to S and the distance between the model and the virtual camera is close to or greater than D, the static mesh model is determined to be a culled model and is not drawn.

[0054] Based on any of the above embodiments, determining the initial model to be drawn based on the volume and the distance may also include: when it is determined that the model type of the static mesh model is a vegetation model, determining the static mesh model in the drawing judgment area except the static mesh model with the smallest volume and / or the farthest distance as the initial model to be drawn.

[0055] The vegetation model with the smallest volume and / or the farthest distance is removed from the multiple vegetation models, indicating that after the vegetation model is rendered, the screen ratio display effect is better.

[0056] In this embodiment, by applying different judgment criteria to the building model and the vegetation model, it is determined whether to draw the static mesh model to determine the initial model to be drawn. This can avoid drawing and rendering the static mesh model with a small screen share, reduce GPU overhead, and thus improve the performance of rendering the static mesh model.

[0057] In one embodiment, when it is determined that the model type of the static mesh model is a vegetation model, after obtaining the model to be drawn, the vegetation shadow mapping method of the model to be drawn can be adjusted to a virtual shadow map or a shadow map, and the shadow quality of the model to be drawn can be adjusted according to the current performance console setting sg.ShadowQuality.

[0058] Managing a large number of models in Unreal Engine will increase GPU overhead. To solve this technical problem, based on any of the above embodiments,

[0059] Figure 2 This is the second flow chart of the model optimization method provided by the present invention, which is used in Unreal Engine, such as Figure 2 As shown, the method includes step 210 and step 240.

[0060] Step 210: Obtain the static mesh model imported by the user.

[0061] Step 220: When it is determined that the number of vertices of the static mesh model is less than or equal to the first preset threshold, determine whether the number of vertices of the model to be drawn is less than a second preset threshold.

[0062] Step 230: If the vertices of the model to be drawn are less than a second preset threshold, at least the position coordinates and material of the static mesh model are obtained, the distance between the static mesh models is obtained based on the position coordinates of the static mesh model, and the material difference of the static mesh model is obtained based on a preset material index.

[0063] Step 240: merge the static mesh models whose distances and material differences are both within corresponding preset ranges to obtain an optimized model to be drawn.

[0064] It can be determined that the second preset threshold is smaller than the first preset threshold.

[0065] The vertices of the model to be drawn are less than the second preset threshold, which can indicate that the static mesh model is relatively simple. Merging this part of the static mesh model can reduce the number of models and improve rendering performance without substantially affecting visual coordination.

[0066] Exemplarily, the position coordinates and material of the static mesh model can be obtained through the properties of the static mesh model. The preset material index can be several indexes selected from the material indexes, which may include reflectivity, roughness, absorbance, color value, etc. The material difference can be the difference or ratio between the indexes corresponding to the preset material indexes in the indexes of the material of the static mesh model. The preset range of distances for determining whether to merge the static mesh model and the preset range of material differences for determining whether to merge the static mesh model can be determined according to the actual situation of the static mesh model in the Unreal Engine, and are not further limited here.

[0067] In this embodiment, by merging static mesh models whose vertices are smaller than a second preset threshold, the number of models is reduced and the rendering performance is improved; and whether to merge static mesh models whose vertices are smaller than the second preset threshold is simply and quickly determined through the position coordinates and material of the static mesh models.

[0068] The GPU overhead required for managing 10 materials of a static mesh model in the Unreal Engine is greater than the GPU overhead required for managing 1 material of a static mesh model in the Unreal Engine. In other words, the more materials a static mesh model is managed in the Unreal Engine, the greater the GPU overhead required. In order to reduce the GPU overhead, based on any of the above embodiments, after obtaining the optimized model to be drawn, the method further includes: obtaining the number of materials of the optimized model to be drawn; when it is determined that the number of materials is greater than a material number threshold, obtaining a representative material based on similar materials in the optimized model to be drawn, and using the representative material to replace the corresponding similar material; wherein the number of representative materials is within 10.

[0069] For example, the number of materials can be obtained through the properties of the static mesh model. The material number threshold can be 100 materials. The material number threshold can be determined according to the actual situation of the static mesh model in the Unreal Engine, and is not considered as a further limitation of the protection scope.

[0070] A Material Count greater than the Material Count Threshold can indicate that managing the number of materials for the merged model to be drawn in Unreal Engine is expensive on the GPU and can degrade performance when rendering Static Mesh models.

[0071] Similar materials can be materials with smaller material differences. For example, similar materials can be materials with the aforementioned material differences less than a second preset threshold. The second preset threshold can be determined according to the actual situation of the static mesh model in the Unreal Engine, and is not further limited here.

[0072] The representative material is a material obtained based on similar materials. There may be multiple groups of similar materials in the model to be drawn, so multiple representative materials may be obtained. Exemplarily, the representative material can be obtained based on the similar materials of the model to be drawn through a feature selection algorithm or a clustering algorithm.

[0073] In this embodiment, by dividing the materials in the model to be drawn into similar materials, obtaining representative materials based on the similar materials, and using the representative materials to replace the corresponding similar materials, the number of materials in the model to be drawn can be reduced without basically affecting the visual coordination, thereby improving the rendering performance.

[0074] In order to specifically illustrate the function of the model optimization method provided by this embodiment, a specific example is provided below.

[0075] At present, the digital models in digital twin scene simulation generally use static mesh models obtained by parametric modeling. The static mesh models are obtained by modeling using third-party software, and then the static mesh models are imported into the Unreal Engine for use. On this basis, optimizing the static mesh models is particularly important and practical for improving rendering performance.

[0076] The model optimization method in this embodiment is used for Unreal Engine 5 (UE5), specifically for the optimization method of building models and vegetation models in urban parks and river simulations. Building models and vegetation models are specific model type divisions of static mesh models. Static mesh models are three-dimensional models created by artists using third-party modeling software such as 3D StudioMax (3ds max for short), Revit, CityEngine, Blender, etc. Exemplarily, the building model can be exported as a corresponding DataSmith model file, and UE5 can read the DataSmith model file to import the building model into UE5. The vegetation model can export a UE5 model file, and UE5 can read the UE5 model file, and the vegetation model can be imported into UE5 by planting through the UE5 vegetation mode.

[0077] When the virtual camera is at a high position and the scene contains a large number of building models and vegetation models, some building models and vegetation models may have a small screen share. Even if these building models and vegetation models are rendered, they are not visually clear.

[0078] To solve this problem, the position coordinates of each static mesh model in the Unreal Engine can be determined; the drawing judgment area can be determined based on the position coordinates, and the static mesh models outside the drawing judgment area can be used as the initial models to be drawn; the volume of each static mesh model in the drawing judgment area and the distance between each static mesh model and the virtual camera in the Unreal Engine can be obtained. The model type of each static mesh model is determined, and when the model type of the static mesh model is determined to be a building model, the static mesh model whose volume belongs to the set volume range and whose distance belongs to the set distance range is determined as the initial model to be drawn; when the model type of the static mesh model is determined to be a vegetation model, the static mesh model in the drawing judgment area except for the one with the smallest volume and / or the farthest distance is determined as the initial model to be drawn.

[0079] When direct rendering is used for static building models and vegetation models, static mesh models with a large number of vertices and triangles will cause high GPU overhead. When multi-level rendering is used for static building models and vegetation models, static mesh models with a small number of vertices and triangles will cause high GPU overhead, or the display effect of the static mesh models will be unsatisfactory.

[0080] To solve this problem, when it is determined that the vertices of the initial model to be drawn are greater than the first preset threshold, the drawing level of the static mesh model is selected based on the screen ratio of the initial model to be drawn, and the corresponding vertex reduction ratio and triangle reduction ratio are obtained according to the drawing level. Then, the screen ratio display index after optimizing the static mesh model based on the reduction ratio is obtained; when it is determined that the screen ratio display index does not meet the preset display index, the user input instruction is further received, and the corresponding vertex reduction ratio and triangle reduction ratio are obtained according to the instruction input by the user. The initial model to be drawn is optimized based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0081] Too many models will also increase GPU overhead. To solve this problem, when it is determined that the vertices of the static mesh model are less than or equal to the first preset threshold, determine whether the vertices of the model to be drawn are less than the second preset threshold; if the vertices of the model to be drawn are less than the second preset threshold, at least the position coordinates and material of the static mesh model are obtained, the distance between the static mesh models is obtained based on the position coordinates of the static mesh model, and the material difference of the static mesh model is obtained based on the preset material index; merge the static mesh models whose distance and material difference are both within the corresponding preset range.

[0082] As mentioned before, static mesh models are generally obtained by modeling using third-party modeling software. When modeling using third-party modeling software, the materials of the static mesh models are generally selected randomly, resulting in a large number of materials in the merged static mesh model, even exceeding a hundred. Too many materials in the model will also increase GPU overhead and reduce rendering performance.

[0083] To solve this problem, after merging the static mesh models whose distance and material difference are within the corresponding preset range, the number of materials of the optimized model to be drawn is obtained; when it is determined that the number of materials is greater than the material number threshold, the representative material is obtained based on the similar materials in the optimized model to be drawn, and the corresponding similar materials are replaced with the representative material; the optimized model to be drawn is obtained, in which the number of representative materials is within 10.

[0084] The model optimization device provided by the present invention is described below. The model optimization device described below and the model optimization method described above can be referenced to each other.

[0085] Figure 3 is a schematic diagram of the structure of the model optimization device provided by the present invention, such as Figure 3 As shown, the device includes a model acquisition module 210 and a model optimization module 220.

[0086] A model acquisition module 210 is used to acquire a static mesh model imported by a user, wherein the static mesh model includes vertices and triangles;

[0087] The model optimization module 220 is used to determine the vertex reduction ratio and triangle reduction ratio of the static mesh model based on the screen ratio of the static mesh model when it is determined that the vertices of the static mesh model are greater than a first preset threshold, and optimize the static mesh model based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0088] Based on any of the above embodiments, the model optimization device also includes a position coordinate determination module, which is used to determine the position coordinates of each static mesh model in the Unreal Engine after obtaining the static mesh model imported by the user when there are multiple static mesh models.

[0089] The initial model to be drawn is determined by a module, which is used to determine a drawing judgment area based on the position coordinates, and use the static mesh model outside the drawing judgment area as the initial model to be drawn; obtain the volume of each static mesh model in the drawing judgment area and the distance between each static mesh model and the virtual camera in the Unreal Engine; and determine the initial model to be drawn based on the volume and the distance.

[0090] The model optimization module 220 is specifically used for: when it is determined that the vertices of the initial model to be drawn are greater than a first preset threshold, determining the vertex reduction ratio and triangle reduction ratio of the initial model to be drawn based on the screen ratio of the initial model to be drawn, and optimizing the initial model to be drawn based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0091] Based on any of the above embodiments, the model optimization device further includes: a model type determination module, used to determine the model type of each of the static mesh models.

[0092] The module for determining an initial model to be drawn is used to, when it is determined that the model type of the static mesh model is a building model, determine the static mesh model whose volume belongs to a set volume range and whose distance belongs to a set distance range as the initial model to be drawn; when it is determined that the model type of the static mesh model is a vegetation model, exclude the model with the smallest volume and / or the farthest distance in the drawing judgment area, and determine the static mesh model as the initial model to be drawn.

[0093] Based on any of the above embodiments, the model optimization device also includes a merging optimization module, which is used to obtain the static mesh model imported by the user, and when it is determined that the vertices of the static mesh model are less than or equal to the first preset threshold, determine whether the vertices of the model to be drawn are less than a second preset threshold; if the vertices of the model to be drawn are less than the second preset threshold, at least obtain the position coordinates and material of the static mesh model, obtain the distance between the static mesh models based on the position coordinates of the static mesh model, and obtain the material difference of the static mesh model based on the preset material index; merge the static mesh models whose distance and material difference are both within the corresponding preset range to obtain the optimized model to be drawn.

[0094] Based on any of the above embodiments, the model optimization module 220 includes a first reduction ratio determination unit, which is used to: select the drawing level of the static mesh model based on the screen ratio of the static mesh model, and obtain the corresponding vertex reduction ratio and triangle reduction ratio according to the drawing level.

[0095] Based on any of the above embodiments, the model optimization module 220 also includes a second reduction ratio determination unit, which is used to: optimize the static mesh model based on the vertex reduction ratio and the triangle reduction ratio, and display the optimized static mesh model; receive user input instructions; the input instructions are used to determine the vertex reduction ratio and triangle reduction ratio of the static mesh model, which are the vertex reduction ratio and triangle reduction ratio obtained according to the drawing level, or the vertex reduction ratio and triangle reduction ratio input by the user.

[0096] Based on any of the above embodiments, the model optimization module 220 also includes a material replacement unit, which is used to obtain the number of materials of the optimized model to be drawn after obtaining the optimized model to be drawn; when it is determined that the number of materials is greater than a material number threshold, a representative material is obtained based on similar materials in the optimized model to be drawn, and the representative material is used to replace the corresponding similar material; wherein the number of representative materials is within 10.

[0097] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the model optimization method, which includes: obtaining a static mesh model imported by a user, wherein the static mesh model includes vertices and triangles; when it is determined that the vertices of the static mesh model are greater than a first preset threshold, determining the vertex reduction ratio and the triangle reduction ratio of the static mesh model based on the screen ratio of the static mesh model, optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio, and obtaining an optimized model to be drawn.

[0098] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0099] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the model optimization method provided by the above-mentioned methods, the method including: obtaining a static mesh model imported by a user, wherein the static mesh model includes vertices and triangles; when it is determined that the vertices of the static mesh model are greater than a first preset threshold, determining the vertex reduction ratio and triangle reduction ratio of the static mesh model based on the screen ratio of the static mesh model, and optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0100] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the model optimization method provided by the above-mentioned methods, the method comprising: obtaining a static mesh model imported by a user, wherein the static mesh model comprises vertices and triangles; when it is determined that the vertices of the static mesh model are greater than a first preset threshold, determining a vertex reduction ratio and a triangle reduction ratio of the static mesh model based on a screen ratio of the static mesh model, and optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn.

[0101] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0102] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0103] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A model optimization method, characterized in that: For use with Unreal Engine, the method comprises: Acquire a static mesh model imported by a user, wherein the static mesh model includes vertices and triangles; When it is determined that the number of vertices of the static mesh model is greater than a first preset threshold, determining a vertex reduction ratio and a triangle reduction ratio of the static mesh model based on a screen ratio of the static mesh model, and optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn; In the case where there are multiple static mesh models, after obtaining the static mesh model imported by the user, the method further includes: Determine the position coordinates of each of the static mesh models in the Unreal Engine; Determine a drawing judgment area based on the position coordinates, and use the static mesh model outside the drawing judgment area as an initial model to be drawn; Acquire the volume of each of the static mesh models in the drawing judgment area and the distance between each of the static mesh models and the virtual camera in the Unreal Engine; determine an initial model to be drawn based on the volume and the distance; The method further comprises: determining, when it is determined that the number of vertices of the static mesh model is greater than a first preset threshold, a vertex reduction ratio and a triangle reduction ratio of the static mesh model based on a screen ratio of the static mesh model, optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn, including: In a case where it is determined that the number of vertices of the initial model to be drawn is greater than a first preset threshold, determining a vertex reduction ratio and a triangle reduction ratio of the initial model to be drawn based on a screen ratio of the initial model to be drawn, and optimizing the initial model to be drawn based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn; Before determining the initial model to be drawn based on the volume and the distance, the method further includes: determining a model type for each of the Static Mesh models; Determining an initial model to be drawn based on the volume and the distance specifically includes: In the case where it is determined that the model type of the static mesh model is a building model, determining the static mesh model whose volume belongs to a set volume range and whose distance belongs to a set distance range as an initial model to be drawn; When it is determined that the model type of the static mesh model is a vegetation model, the static mesh model excluding the one with the smallest volume and / or the farthest distance in the drawing judgment area is determined as an initial model to be drawn.

2. The model optimization method according to claim 1, characterized in that: After obtaining the static mesh model imported by the user, the method further includes: In a case where it is determined that the number of vertices of the static mesh model is less than or equal to a first preset threshold, determining whether the number of vertices of the static mesh model is less than a second preset threshold; If the number of vertices of the static mesh model is less than a second preset threshold, at least obtaining the position coordinates and material of the static mesh model, obtaining the distance between the static mesh models based on the position coordinates of the static mesh model, and obtaining the material difference of the static mesh model based on a preset material index; The static mesh models whose distances and material differences are both within corresponding preset ranges are merged to obtain an optimized model to be drawn.

3. The model optimization method according to claim 1, characterized in that: Determining a vertex reduction ratio and a triangle reduction ratio of the static mesh model based on a screen ratio of the static mesh model includes: A drawing level of the static mesh model is selected based on a screen ratio of the static mesh model, and a corresponding vertex reduction ratio and a triangle reduction ratio are obtained according to the drawing level.

4. The model optimization method according to claim 3, characterized in that: The method further comprises: selecting a drawing level of the static mesh model based on the screen ratio of the static mesh model, and obtaining a corresponding vertex reduction ratio and a triangle reduction ratio according to the drawing level. Optimizing the static mesh model based on the vertex reduction ratio and the triangle reduction ratio, and displaying the optimized static mesh model; Receive user input instructions; the input instructions are used to determine the vertex reduction ratio and triangle reduction ratio of the static mesh model, which are the vertex reduction ratio and triangle reduction ratio obtained according to the drawing level, or the vertex reduction ratio and triangle reduction ratio input by the user.

5. The model optimization method according to claim 2, characterized in that: After obtaining the optimized model to be drawn, the method further includes: Obtaining the number of materials of the optimized model to be drawn; When it is determined that the number of materials is greater than a material number threshold, a representative material is obtained based on similar materials in the optimized model to be drawn, and the representative material is used to replace the corresponding similar material; wherein the number of the representative materials is within 10.

6. A model optimization device, characterized in that: For Unreal Engine, the device comprises: A model acquisition module, used to acquire a static mesh model imported by a user, wherein the static mesh model includes vertices and triangles; A model optimization module, configured to determine a vertex reduction ratio and a triangle reduction ratio of the static mesh model based on a screen ratio of the static mesh model when it is determined that the number of vertices of the static mesh model is greater than a first preset threshold, and optimize the static mesh model based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn; The model optimization device further includes a position coordinate determination module, which is used to determine the position coordinates of each static mesh model in the Unreal Engine after acquiring the static mesh model imported by the user when there are multiple static mesh models; An initial model to be drawn determining module is used to determine a drawing judgment area based on the position coordinates, and use the static mesh model outside the drawing judgment area as the initial model to be drawn; obtain the volume of each static mesh model in the drawing judgment area and the distance between each static mesh model and the virtual camera in the Unreal Engine; and determine the initial model to be drawn based on the volume and the distance; The model optimization module is specifically used to determine the vertex reduction ratio and triangle reduction ratio of the initial model to be drawn based on the screen ratio of the initial model to be drawn when it is determined that the number of vertices of the initial model to be drawn is greater than a first preset threshold, and optimize the initial model to be drawn based on the vertex reduction ratio and the triangle reduction ratio to obtain an optimized model to be drawn; The apparatus further comprises a model type determination module, configured to determine a model type of each of the static mesh models; The initial model to be drawn determining module is further used to, when it is determined that the model type of the static mesh model is a building model, determine the static mesh model whose volume belongs to a set volume range and whose distance belongs to a set distance range as the initial model to be drawn; when it is determined that the model type of the static mesh model is a vegetation model, determine the static mesh model in the drawing judgment area excluding the static mesh model with the smallest volume and / or the longest distance as the initial model to be drawn.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the model optimization method according to any one of claims 1 to 5 is implemented.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the model optimization method according to any one of claims 1 to 5 is implemented.