Method and device for constructing multi-level-of-detail model
By merging and scaling the textures of the 3D model to generate a multi-level-of-detail model, the problem of inconsistent model appearance before and after simplification is solved, loading efficiency and resource utilization are improved, and the risk of computer terminal lag is reduced.
Patent Information
- Application Number
- CN202510633994.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-09-23
AI Technical Summary
When simplifying a three-dimensional model, existing technologies cannot guarantee the appearance consistency of the model before and after simplification, resulting in computer terminals freezing or crashing during loading and low resource utilization efficiency.
The zero-level model is generated by merging multiple original textures in the original 3D model, and other level models are constructed through sampling and scaling to ensure the texture quality of each level model. All level models are combined to build a multi-level detail model to ensure appearance consistency.
Improved the loading efficiency of 3D models, reduced the probability of computer terminals freezing and crashing during the loading process, and improved resource utilization efficiency and appearance consistency.
Smart Images

Figure CN120689548A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of real-time three-dimensional graphics processing, and in particular to a method and device for constructing a multi-level-of-detail model. Background Art
[0002] In the field of real-time 3D computer graphics processing, multi-level-of-detail models are used to represent the same object or scene using 3D models with different levels of detail based on the location, importance or user needs of the 3D model; rich details are provided when high-precision 3D models are required, and reduced when not required to save computing resources, thereby improving the user experience.
[0003] In order to improve the image rendering efficiency of computer terminals and optimize resource utilization, it is often necessary to construct three-dimensional models with complex textures at multiple levels of detail. A mesh is generally used to describe the surface shape of a three-dimensional object. A mesh is a three-dimensional model representation composed of triangular or square facets. During the multi-level detail construction process, existing technologies often simplify the three-dimensional model by reducing the number of vertices and facets in the mesh, thereby simplifying the fine three-dimensional model into a coarse three-dimensional model. This in turn improves the efficiency of loading the three-dimensional model by directly loading the coarse three-dimensional model.
[0004] However, this simplification method will cause the morphology of the three-dimensional model to change, and it is impossible to guarantee the consistency of the appearance of the three-dimensional model before and after simplification. For example, a straight road will become curved or disappear after simplification, which is less practical.
[0005] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in this technical field. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to provide a method and device for constructing a multi-level-of-detail model. The purpose is to generate a zero-level model by merging multiple original textures in the original three-dimensional model, ensuring the accuracy of the most refined zero-level model, and constructing other level models on this basis by sampling and scaling, and finally combining all the generated hierarchical models to construct a multi-level-of-detail model of the original three-dimensional model through multi-level textures. Under the premise of ensuring loading efficiency, the consistency in appearance of the three-dimensional model before simplification and the three-dimensional model after simplification is guaranteed.
[0007] The present invention adopts the following technical solutions:
[0008] In a first aspect, the present invention provides a method for constructing a multi-level-of-detail model, comprising:
[0009] Performing texture merging on multiple original textures in the original three-dimensional model to generate a zero-level model;
[0010] Obtaining an initial first-level texture based on the zero-level model to generate an initial model; performing texture merging on multiple initial first-level textures in the initial model to generate a first-level model;
[0011] Starting from the second level, sampling and scaling the zero-level texture of the zero-level model according to the scaling factors of different levels until the zero-level texture cannot be sampled and scaled according to the corresponding scaling factors, so as to generate at least one level model;
[0012] All generated hierarchical models are combined to obtain a multi-level detail model of the original three-dimensional model.
[0013] Furthermore, the merging of the multiple original textures in the original three-dimensional model to generate the zero-level model includes:
[0014] Determining textures in the original three-dimensional model whose sizes are smaller than a first small texture threshold as original textures; merging multiple original textures into a target texture;
[0015] Determine target texture coordinate values of the target texture;
[0016] updating the material description file of the original three-dimensional model according to the target texture and the target texture coordinate value to obtain a zeroth description file;
[0017] All the target textures are merged into a zero-level texture; a zero-level model is initialized, and the zero-level texture, the mesh of the original three-dimensional model and the zero-th description file are added to the initialized zero-level model to generate a zero-level model.
[0018] Furthermore, determining the target texture coordinate value of the target texture includes:
[0019] Obtaining the offset position (x, y) of each original texture on the target texture, the size (w, h) of the original texture, and the size (W, H) of the target texture;
[0020] Obtain all associated texture coordinates (u, v) associated with the original texture from the material description file; and obtain corresponding original texture pixel coordinates (u*w, v*h) based on the associated texture coordinates (u, v);
[0021] Based on the size (w, h) of the original texture, obtaining the target pixel coordinates (x+u*w, y+v*h) of the associated texture coordinates (u, v) on the target texture;
[0022] Based on the size (W, H) of the target texture and the target pixel coordinates (x+u*w, y+v*h), a target texture coordinate value ((x+u*w) / W, (y+v*h) / H) of the associated texture coordinate (u, v) on the target texture is obtained.
[0023] Furthermore, the updating of the material description file of the original three-dimensional model according to the target texture and the target texture coordinate value to obtain the zeroth description file includes:
[0024] Converting the target texture into a compressed texture file;
[0025] Using the compressed texture file and the target texture coordinate value, the description information of the multiple original textures in the material description file is updated to the description information of the target texture to obtain a zeroth description file.
[0026] Furthermore, the number of empty pixels in the target texture is less than a preset value.
[0027] Furthermore, obtaining an initial first-level texture based on the zero-level model to generate an initial model; and merging textures of multiple initial first-level textures in the initial model to generate a first-level model includes:
[0028] Scaling the height and width of the zero-level texture to half of the original size to obtain an initial first-level texture;
[0029] Initializing an initial model, adding the initial first-level texture, the mesh of the zero-level texture, and the zero-th description file of the zero-level model to the initialized initial model to generate an initial model;
[0030] Determining textures whose sizes are smaller than a second minimum texture threshold in the initial first-level textures in the initial model as textures to be merged; merging multiple textures to be merged into a merged texture; and determining a first texture coordinate value of the merged texture;
[0031] Using the first texture coordinate value to update the zeroth description file in the initial model to obtain a first description file;
[0032] The multiple textures to be merged in the initial model are replaced with the merged textures, and the zeroth description file of the initial model is replaced with the first description file to generate a first-level model.
[0033] Furthermore, starting from the second level, sampling and scaling the zero-level texture of the zero-level model according to the scaling factors of different levels until the zero-level texture cannot be sampled and scaled according to the corresponding scaling factors to generate at least one level model includes:
[0034] Set the zoom factor of the nth level to 2 -n ; Wherein, n is greater than or equal to 2;
[0035] According to the scaling factor of the nth level, the height and width of the zeroth level texture are scaled respectively to obtain the nth level texture;
[0036] combining the nth level texture, the mesh of the zeroth level texture, and the zeroth description file of the zeroth level model to obtain the nth level model;
[0037] When the zero-th level texture cannot be sampled and scaled according to the corresponding scaling factor, the generation of the at least one level model is stopped.
[0038] Furthermore, when the scaling factor is greater than the scalable level of the zero-th level texture, the zero-th level texture cannot be sampled and scaled according to the corresponding scaling factor;
[0039] The expression of the scalability level is: Log(s) / Log(2);
[0040] Where s is the minimum height or minimum width of the texture in the zero-level model, and Log(·) is used to calculate the logarithmic value with a constant e as the base.
[0041] In a second aspect, the present invention further provides a device for constructing a multi-level-of-detail model, comprising:
[0042] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the method for constructing a multi-level-of-detail model described in the first aspect.
[0043] In a third aspect, the present invention further provides a non-volatile computer storage medium storing computer executable instructions, which are executed by one or more processors to complete the method of constructing a multi-level-of-detail model described in the first aspect.
[0044] In a fourth aspect, a computer program product comprising instructions is provided, which, when executed on a computer or a processor, causes the computer or the processor to execute the method for constructing a multi-level-of-detail model as described in the first to third aspects and any one of the above.
[0045] In the fifth aspect, the present invention also provides a system for constructing a multi-level-of-detail model, including an apparatus for constructing a multi-level-of-detail model as in the second aspect, and using the method for constructing a multi-level-of-detail model as described in the first aspect to complete the interaction of the apparatus for constructing a multi-level-of-detail model as in the second aspect.
[0046] Different from the prior art, the present invention has at least the following beneficial effects:
[0047] Before rendering the original three-dimensional model containing complex textures, the present invention generates a zero-level model by merging multiple original textures in the original three-dimensional model, avoiding directly reducing the number of vertices and facets in the mesh of the original three-dimensional model, so as to improve the loading efficiency of the corresponding texture when in use, and constructs the first-level and other-level models through sampling and scaling on the basis of the zero-level model, so as to retain the original pixel details in the zero-level model as much as possible, so as to achieve the purpose of ensuring the texture quality in the first-level and other-level models, and ensure the consistency in appearance between the original three-dimensional model before simplification and the various level models in the simplified multi-level detail model; finally, all the generated level models are combined to construct the multi-level detail model of the original three-dimensional model through multi-level textures, so as to realize the improvement of loading efficiency by loading data of different levels in the multi-level detail model, and greatly reduce the probability of computer terminal freezing or crashing during the loading process; while ensuring loading efficiency, the practicality is strong. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive effort.
[0049] Figure 1 1 is a flow chart of a method for constructing a multi-level-of-detail model provided by an embodiment of the present invention;
[0050] Figure 2 is a schematic diagram of a specific example of mapping texture coordinates onto a triangle provided by an embodiment of the present invention;
[0051] Figure 3 is a flow chart of step 10 provided in an embodiment of the present invention;
[0052] Figure 4 is a flow chart of step 102 provided in an embodiment of the present invention;
[0053] Figure 5 is a flow chart of step 103 provided by an embodiment of the present invention;
[0054] Figure 6 This is a flow chart of step 20 provided in an embodiment of the present invention.
[0055] Figure 7 is a flow chart of step 30 provided in an embodiment of the present invention;
[0056] Figure 8 This is a schematic diagram of a process for constructing a multi-level-of-detail model provided by an embodiment of the present invention;
[0057] Figure 9 This is a schematic diagram of a specific example of appearance deformation caused by a change in fineness provided by an embodiment of the present invention;
[0058] Figure 10 Schematic diagram of the architecture of an apparatus for constructing a multi-level-of-detail model provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0060] Unless the context requires otherwise, throughout the specification and claims, the term "including" is to be interpreted as meaning open inclusion, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "example", "specific example" or "some examples" and the like are intended to indicate that the specific features, structures, materials or characteristics associated with the embodiment or example are included in at least one embodiment or example of the present disclosure. The schematic representation of the above terms does not necessarily refer to the same embodiment or example. In addition, the specific features, structures, materials or characteristics may be included in any one or more embodiments or examples in any appropriate manner, that is, although they may be carried in the embodiments or examples of the above terms due to reasons such as the order and position of appearance, it is not limited to that they can be carried in combination by one embodiment or example.
[0061] In the description of the present invention, it should be understood that the terms "center", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present disclosure.
[0062] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, for example, the description may also use the method of adding "A" and "B" at the end to describe the same type of nouns as two independent individuals. In this case, the corresponding features defined as "A" and "B" are only used to distinguish the description purposes of the same type of individuals, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0063] When describing some embodiments, the expressions “coupled”, “coupled” and “connected” and their derivatives may be used. For example, when describing some embodiments, the term “connected” may be used to indicate that two or more components are in direct physical or electrical contact with each other. For another example, when describing some embodiments, the term “coupled” may be used to indicate that two or more components are in direct physical or electrical contact. However, the term “connected” or “coupled” may also mean that two or more components are not in direct contact with each other, but still cooperate or interact with each other, such as “optical coupling”, “wireless connection”, etc. The embodiments disclosed herein are not necessarily limited to the contents of the present invention.
[0064] In the description of the present invention, the expression "A and / or B" (where A and B are used to formally represent specific characteristic contents) will be involved, and the corresponding expressions include the following three combinations: only A, only B, and a combination of A and B.
[0065] As used herein, "about," "substantially," or "approximately" includes the stated value and an average value that is within an acceptable range of deviation from the particular value as determined by one of ordinary skill in the art taking into account the measurements in question and the errors associated with the measurement of the particular quantity (i.e., the limitations of the measurement system).
[0066] Example 1:
[0067] In order to solve the above problems, Figure 1 As shown, an embodiment of the present invention provides a method for constructing a multi-level-of-detail model, including:
[0068] Step 10: Perform texture merging on multiple original textures in the original 3D model to generate a zero-level model.
[0069] The original 3D model consists of a mesh and texture. The mesh defines the shape and structure of the 3D object, while the texture can be the pattern, color, or material effect on the surface of the 3D object, such as the grain of wood or the texture of skin. Textures are images applied to the surface of the original 3D model to increase the detail and realism of the original 3D model. Original textures are textures within the original 3D model that are below a certain size. The maximum size of an original texture is determined by those skilled in the art based on specific usage scenarios and experience.
[0070] The embodiment of the present invention ultimately requires generating a multi-level-of-detail model of the original 3D model. This multi-level-of-detail model is composed of multiple layers of models, including a level-0 model, a level-1 model, and a level-2 model. The level-0 model is generated by merging the original textures from the original 3D model. This level-0 model will serve as the model at the finest level in the subsequently constructed multi-level-of-detail model.
[0071] Step 20: Obtain an initial first-level texture based on the zero-level model to generate an initial model; and perform texture merging on multiple initial first-level textures in the initial model to generate a first-level model.
[0072] In order to generate the first-level model, the zero-th texture, mesh and zero-th description file of the zero-th level model are processed to obtain the initial model, and then, the initial first-level texture in the initial model is merged in the same manner as the texture merging in step 10 to generate the first-level model.
[0073] Step 30: Starting from the second level, the zero-level texture of the zero-level model is sampled and scaled according to the scaling factors of different levels until the zero-level texture cannot be sampled and scaled according to the corresponding scaling factors, so as to generate at least one level model.
[0074] Among them, one scaling factor corresponds to generating a first-level model, that is: sampling and scaling the zero-level texture according to the second-level scaling factor to obtain the second-level model; sampling and scaling the zero-level texture according to the scaling factor corresponding to the third level to obtain the third-level model, and so on.
[0075] Since the minimum size of the texture is 1*1, the size to which the zero-level texture can be scaled is limited, so it is necessary to determine whether sampling and scaling the zero-level texture can generate the texture (that is, meet the minimum size of the texture). When the minimum size of the texture cannot be met, stop generating the new first-level model so that a multi-level-of-detail model can be constructed based on the model of the currently generated level.
[0076] Step 40: Combine all generated hierarchical models to obtain a multi-level detail model of the original three-dimensional model.
[0077] Here, all hierarchical models include the zero-level model, the first-level model, and all hierarchical models generated according to step 30. Combining all generated hierarchical models means constructing a multi-level-of-detail model that includes models at each level. In one embodiment, the combination can be performed in the following manner: first, based on the application scenario requirements, determining the conditions under which the multi-level-of-detail model needs to switch to displaying a certain level of model in different situations, such as the switching conditions such as frame rate and memory usage; then, based on each situation and the corresponding switching conditions, writing switching logic code in the real-time 3D graphics processing system to dynamically select the appropriate level of model for rendering based on the switching conditions; to avoid obvious jumps in the image when switching between different levels, while generating a highly continuous image according to steps 10, 20, and 30, a smooth transition effect can also be achieved using methods such as geometric transitions; finally, testing the constructed multi-level-of-detail model, and based on the test results, adjusting and optimizing the models at each level, the textures at each level, the material description files at each level, and the switching logic code to achieve the best balance between performance and visual effects.
[0078] In the prior art, when a computer terminal displays and loads an original three-dimensional model, the corresponding grid loads different levels of model data according to different viewing angles to improve loading efficiency. However, when rendering an original three-dimensional model containing complex textures, due to the performance characteristics of the computer terminal's graphics card, when the model data is loaded to a certain amount of data, the computer terminal will freeze or even crash. In order to improve the efficiency of rendering operations, the allocation of rendering computing resources is often determined directly based on the position and importance of the nodes in the original three-dimensional model in the display environment. The model data to be loaded is simplified by reducing the number of faces and detail of non-important nodes. However, this simplification method cannot effectively select important details for display, and thus cannot coordinate the relationship between the continuity of the displayed image and the model resolution. Therefore, there will be inconsistencies in the appearance of the three-dimensional model before simplification and the three-dimensional model after simplification (for example, a straight road will become curved or disappear after simplification).
[0079] Before rendering the original three-dimensional model containing complex textures, the present invention generates a zero-level model by merging multiple original textures in the original three-dimensional model, avoiding directly reducing the number of vertices and facets in the mesh of the original three-dimensional model, so as to improve the loading efficiency of the corresponding texture when in use, and constructs the first-level and other-level models through sampling and scaling on the basis of the zero-level model, so as to retain the original pixel details in the zero-level model as much as possible, so as to achieve the purpose of ensuring the texture quality in the first-level and other-level models, and ensure the consistency in appearance between the original three-dimensional model before simplification and the various level models in the simplified multi-level detail model; finally, all the generated level models are combined to construct the multi-level detail model of the original three-dimensional model through multi-level textures, so as to realize the improvement of loading efficiency by loading data of different levels in the multi-level detail model, and greatly reduce the probability of computer terminal freezing or crashing during the loading process; while ensuring loading efficiency, the practicality is strong.
[0080] To further illustrate the method for constructing a multi-level-of-detail model according to an embodiment of the present invention, the mesh in the three-dimensional model is explained below:
[0081] In 3D modeling, a mesh is composed of multiple points (Vertex), lines (Edge) and faces (Face). These points, lines and faces together constitute the shape of a 3D object in a 3D space. Specifically, Figure 2 As shown, a mesh is usually composed of triangles, quadrilaterals or other simple polygons, which are interconnected to form a complex three-dimensional structure. By adjusting the position and shape of these polygons, the appearance of a three-dimensional object can be accurately simulated. A mesh is the basic unit for describing the shape of a three-dimensional object; for example, a mesh can be used to describe the motion trajectory and deformation process of a three-dimensional object, and can also be used to calculate the physical behaviors of a three-dimensional object such as collision and deformation. During the rendering process, the mesh is the basis for calculating visual effects such as lighting and shadows. In an embodiment of the present invention, by creating multiple mesh models with different levels of detail for the same three-dimensional object (for example, the zero-level model and the first-level model of the embodiment of the present invention), after the creation is completed, and based on the position and importance of the three-dimensional object in the scene, a mesh model of a certain level in the multi-level-of-detail model is dynamically selected for rendering to achieve efficient rendering performance and realistic visual effects.
[0082] like Figure 2 As shown, there are texture coordinates in the grid. The texture coordinates are on the x-axis and y-axis and range from 0 to 1 (it should be noted that this is limited to two-dimensional texture images); using texture coordinates to obtain texture color is called sampling. The texture coordinates start at (0,0), which is the lower left corner of the texture image, and the texture coordinates end at (1,1), which is the upper right corner of the texture image. Figure 2Shows how to map texture coordinates onto triangles.
[0083] In order to illustrate the process of obtaining the zero-level model, Figure 3 As shown, the step 10 includes:
[0084] Step 101: Determine textures in the original three-dimensional model whose sizes are smaller than a first small texture threshold as original textures; and merge multiple original textures into a target texture.
[0085] The first small texture threshold defines the maximum size of the original texture. This threshold is selected by those skilled in the art based on specific usage scenarios. In an optional embodiment, the first small texture threshold can be 512*512. The specific method for texture merging is selected by those skilled in the art based on specific usage scenarios and is not limited here.
[0086] In the process of generating the target texture, the original texture is used to fill the generated target texture as much as possible to avoid generating empty pixels, so that the number of empty pixels in the target texture is less than a preset value. The preset value is determined by those skilled in the art based on the specific usage scenario and experience. In an optional embodiment, since the size of the texture image is generally 2 N ×2 N , so when merging, we can construct a size of 2 N+1 ×2 N+1 The target texture will be 4 with a size of 2 N ×2 N When merging, if the number of original textures in multiple original textures is odd, only 4 of them will be merged. N Original texture.
[0087] Step 102: Determine target texture coordinate values of the target texture.
[0088] After merging the original textures of the original 3D model, it is necessary to recalculate the corresponding texture coordinate values and update the associated texture materials.
[0089] Step 103: updating the material description file of the original three-dimensional model according to the target texture and the target texture coordinate value to obtain a zeroth description file.
[0090] The embodiment of the present invention merges multiple original textures into a target texture so that all target textures are used as zero-level textures, that is, the target texture is used to replace the corresponding multiple original textures; therefore, when replacing, it is also necessary to update the texture coordinates of the multiple original textures in the material description file to the target texture coordinate values of the target texture to ensure that in the subsequently obtained zero-level model, the texture material information defined in the zero-th description file can correspond to the texture at the corresponding position, thereby ensuring that the zero-level model can be loaded normally subsequently.
[0091] Step 104: Merge all the target textures into a zero-level texture; initialize a zero-level model, and add the zero-level texture, the mesh of the original three-dimensional model, and the zero-level description file to the initialized zero-level model to generate a zero-level model.
[0092] Adding the zero-level texture, the mesh of the original three-dimensional model, and the zero-level description file to the initialized zero-level model to generate the zero-level model refers to: constructing a zero-level model that includes the zero-level texture, the mesh of the original three-dimensional model, and the zero-level description file. In one embodiment, the zero-level model can be constructed in the following manner: mapping the zero-level texture to the corresponding mesh according to the target texture coordinate value to ensure that the zero-level texture can be correctly covered on the mesh surface; applying the zero-level description file to the integrated combination of the zero-level texture and the mesh to assign material properties such as color and glossiness to the model so that it presents the expected appearance when rendered, and ensuring consistency between the zero-level texture, the mesh, and the zero-level description file to avoid rendering errors or visual inconsistencies.
[0093] The zero-level model of the embodiment of the present invention is the most refined first-level model in the multi-level-of-detail model finally generated; on the one hand, when the graphics card performance of the computer terminal is good, the computing resources for object rendering are sufficient, and the user has high requirements for display accuracy, the details in the original three-dimensional model can be read by loading the zero-level model; on the other hand, the embodiment of the present invention generates subsequent hierarchical models based on the zero-level model to construct a multi-level-of-detail model of the original three-dimensional model through multi-level textures, which will be explained below.
[0094] To illustrate the process of determining the target texture coordinate value, Figure 4 As shown, step 102 includes:
[0095] Step 1021: Obtain the offset position (x, y) of each original texture on the target texture, the size (w, h) of the original texture, and the size (W, H) of the target texture.
[0096] Step 1022: Obtain all associated texture coordinates (u, v) associated with the original texture from the material description file; based on the associated texture coordinates (u, v), obtain corresponding original texture pixel coordinates (u*w, v*h).
[0097] Since the associated texture coordinates are relative coordinates, the texture pixel coordinates on the texture corresponding to each associated texture coordinate are the product of the original texture size in the x-axis and y-axis directions and the associated texture coordinates.
[0098] Step 1023: Based on the size (w, h) of the original texture, obtain the target pixel coordinates (x+u*w, y+v*h) of the associated texture coordinates (u, v) on the target texture.
[0099] The pixel coordinates of the associated texture coordinates on the merged target texture are further obtained, that is, the target pixel coordinates (x+u*w, y+v*h).
[0100] Step 1024: Based on the size (W, H) of the target texture and the target pixel coordinates (x+u*w, y+v*h), obtain the target texture coordinate value ((x+u*w) / W, (y+v*h) / H) of the associated texture coordinate (u, v) on the target texture.
[0101] For each target texture, all texture coordinate values are calculated in turn, and the texture coordinate values of all target textures are calculated.
[0102] In order to illustrate the process of obtaining the zeroth description file, Figure 5 As shown, step 103 includes:
[0103] Step 1031: Convert the target texture into a compressed texture file.
[0104] In an optional embodiment, the compressed texture file may be a texture file in Ericsson Texture Compression (ETC) format; the target texture is compressed and converted into the ETC format supported by the graphics card, so that it can be directly loaded through the graphics processing unit (GPU), reducing the decoding operations of the central processing unit (CPU) and improving the loading performance.
[0105] Step 1032: Using the compressed texture file and the target texture coordinate value, update the description information of the multiple original textures in the material description file to the description information of the target texture, and obtain a zeroth description file.
[0106] The material description file of the original three-dimensional model contains description information for multiple original textures. After merging and conversion, the embodiment of the present invention uses a compressed texture file to replace the original texture, so it is necessary to synchronize the change to the material description file and generate a new material description file (i.e., the zeroth description file) to ensure that the zeroth-level model can be loaded normally in the future according to the zeroth description file.
[0107] In order to illustrate the process of generating the first-level model, Figure 6 As shown, the step 20 includes:
[0108] Step 201: Scale the height and width of the zero-level texture to half of the original size to obtain an initial first-level texture.
[0109] Step 202: Initialize the initial model, add the initial first-level texture, the mesh of the zero-th-level texture, and the zero-th description file of the zero-th-level model to the initialized initial model to generate the initial model.
[0110] Adding the initial first-level texture, the mesh of the zero-level texture, and the zero-th description file to the initialized initial model to generate the initial model refers to: constructing an initial model including the initial first-level texture, the mesh of the zero-level texture, and the zero-th description file; in one embodiment, the initial model can be constructed in the manner of step 104.
[0111] Step 203: Determine the textures in the initial first-level textures in the initial model that are smaller than the second minimum texture threshold as textures to be merged; merge multiple textures to be merged into a merged texture; and determine a first texture coordinate value of the merged texture.
[0112] The second minimum texture threshold is used to define the maximum size of the textures to be merged, and is selected by those skilled in the art based on specific usage scenarios. The specific method for merging multiple textures to be merged into a merged texture is selected by those skilled in the art based on specific usage scenarios and is not limited here.
[0113] Step 204: Use the first texture coordinate value to update the zeroth description file in the initial model to obtain a first description file.
[0114] The method for determining the first texture coordinate value is the same as the method for determining the target texture coordinate value, and the method for generating the zeroth description file is the same as the method for generating the first description file, which will not be repeated here.
[0115] Step 205: replacing the multiple textures to be merged in the initial model with the merged texture, and replacing the zeroth description file of the initial model with the first description file to generate a first-level model.
[0116] The embodiment of the present invention generates a zero-level model and a first-level model with a higher degree of detail by merging small textures. The following describes the process of generating other level models based on textures. Figure 7 As shown, the step 30 includes:
[0117] Step 301: Set the zoom factor of the nth level to 2 -n ; where n is greater than or equal to 2.
[0118] For example, the second level has a zoom factor of one quarter.
[0119] Step 302: Scale the height and width of the zero-level texture according to the scaling factor of the n-th level to obtain the n-th level texture.
[0120] For example, the height and width of the zero-level texture are scaled by one quarter respectively to obtain the second-level texture.
[0121] The method of performing sampling scaling according to the scaling factor in the embodiment of the present invention is the same as that in step 201 , which is equivalent to generating the first-level model with a scaling factor of one-half.
[0122] Step 303: Combine the n-th level texture, the mesh of the zero-th level texture, and the zero-th description file of the zero-th level model to obtain the n-th level model.
[0123] Combining the nth level texture, the mesh of the zeroth level texture and the zeroth description file means: constructing the nth level model including the nth level texture, the mesh of the zeroth level texture and the zeroth description file; in one embodiment, the combination can be performed in the manner of step 104.
[0124] Step 304: When the zero-level texture cannot be sampled and scaled according to the corresponding scaling factor, stop generating the at least one level model.
[0125] When the scaling factor is greater than the scalable level of the zero-level texture, the zero-level texture cannot be sampled and scaled according to the corresponding scaling factor; the expression of the scalable level is: Log(s) / Log(2); where s is the minimum height or minimum width of the texture in the zero-level model, and Log(·) is used to calculate the logarithmic value with a constant e as the base.
[0126] After using the method for constructing a multi-level-of-detail model of an embodiment of the present invention to generate a multi-level-of-detail model of the original three-dimensional model, the computer terminal uses the mesh of the generated multi-level-of-detail model when displaying and loading the original three-dimensional model, and can load model data of different levels according to different perspectives, so as to improve loading efficiency while ensuring the consistency of the appearance of the original three-dimensional model at different levels.
[0127] The more triangular facets a model mesh has, the finer the details of the model it expresses. Existing technologies directly reduce the number of vertices and facets in the mesh of the original 3D model, which reduces the fineness of the original 3D model, thus causing the morphology of the 3D model to change. A certain amount of fineness change will cause the appearance to deform, such as Figure 9 The figure shows the degree of detail that a cow can express with different numbers of noodles. Figure 9 In the figure, the number of facets from left to right are 5804, 994, 532, 248 and 64 respectively. It can be seen that when the number of facets decreases from 5804 to 994 and from 994 to 532, the deformation of the cow's appearance is small; when the number of facets decreases from 532 to 248, the edge clarity of the cow's appearance decreases, resulting in a certain deformation; when the number of facets decreases from 248 to 64, the edge clarity of the cow's appearance decreases significantly, and the horns on the cow's head even disappear directly. The degree of deformation of the appearance is too large, and the inconsistency between the appearance of the 3D model before simplification and the simplification is too high, and the practicality is poor.
[0128] During 3D rendering, the model mesh is loaded first, followed by the model texture. Once loaded, the texture is applied to the corresponding facets in the mesh based on the texture coordinates. This embodiment of the present invention merges multiple small textures (i.e., original textures), effectively optimizing the loading process of multiple small textures into a single large texture (i.e., target texture), thereby improving the loading performance of model textures when used.
[0129] Because sampling and scaling a texture image results in the loss of certain pixels, further scaling will result in the loss of even more detail. However, the original texture image in the zero-level model retains more pixel detail, and scaling it ensures the quality of each subsequent level of texture scaling. Therefore, the textures in the first-level and other-level models of the present invention are all obtained by sampling and scaling the zero-level texture. After scaling the texture, the number of pixels in the textures in the other-level models is significantly reduced, which reduces the texture loading and rendering pressure on the graphics card during rendering, thereby improving the model's rendering performance.
[0130] Example 2:
[0131] like Figure 10FIG. 1 is a schematic diagram of the architecture of a device for constructing a multi-level-of-detail model according to an embodiment of the present invention. The device for constructing a multi-level-of-detail model according to this embodiment includes one or more processors 21 and a memory 22. Figure 10 A processor 21 is taken as an example.
[0132] The processor 21 and the memory 22 may be connected via a bus or other means. Figure 10 The bus connection is taken as an example.
[0133] Memory 22, as a nonvolatile computer-readable storage medium, can be used to store nonvolatile software programs and nonvolatile computer-executable programs, such as the method for constructing a multi-level-of-detail model in this embodiment. Processor 21 executes the method for constructing a multi-level-of-detail model by running the nonvolatile software programs and instructions stored in memory 22.
[0134] The memory 22 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some embodiments, the memory 22 may optionally include a memory remotely located relative to the processor 21, and such remote memory may be connected to the processor 21 via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0135] The program instructions / modules are stored in the memory 22, and when executed by the one or more processors 21, the method for constructing a multi-level-of-details model in the above-mentioned embodiment is executed, for example, each step of the method for constructing a multi-level-of-details model in the embodiment of the present invention described above is executed.
[0136] An embodiment of the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are executed by one or more processors, for example Figure 10 A processor 21 can enable the above one or more processors to execute the method for constructing a multi-level-of-detail model in a specific embodiment of the present invention, for example, to execute the various steps of the method for constructing a multi-level-of-detail model in the embodiment of the present invention described above; it can also realize Figure 10 The various modules and units described above; or executing the method for constructing a multi-level detail model in a specific embodiment of the present invention, for example, executing the various steps of the method for constructing a multi-level detail model in the embodiment of the present invention described above; or Figure 10 The various modules and units described.
[0137] It is worth noting that the information interaction, execution process, etc. between the modules and units within the above-mentioned devices and systems are based on the same concept as the processing method embodiment of the present invention. The specific content can be found in the description of the method embodiment of the present invention and will not be repeated here.
[0138] Those skilled in the art will understand that all or part of the steps in the various methods of the embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a disk or an optical disk, etc.
[0139] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for constructing a multi-level-of-detail model, characterized in that: include: Performing texture merging on multiple original textures in the original three-dimensional model to generate a zero-level model; Obtaining an initial first-level texture based on the zero-level model to generate an initial model; Performing texture merging on a plurality of initial first-level textures in the initial model to generate a first-level model; Starting from the second level, sampling and scaling the zero-level texture of the zero-level model according to the scaling factors of different levels until the zero-level texture cannot be sampled and scaled according to the corresponding scaling factors, so as to generate at least one level model; All generated hierarchical models are combined to obtain a multi-level detail model of the original three-dimensional model.
2. The method for constructing a multi-level-of-detail model according to claim 1, wherein: The step of merging the multiple original textures in the original three-dimensional model to generate a zero-level model includes: Determining textures in the original three-dimensional model whose sizes are smaller than a first small texture threshold as original textures; merging multiple original textures into a target texture; Determine target texture coordinate values of the target texture; updating the material description file of the original three-dimensional model according to the target texture and the target texture coordinate value to obtain a zeroth description file; All the target textures are merged into a zero-level texture; a zero-level model is initialized, and the zero-level texture, the mesh of the original three-dimensional model and the zero-th description file are added to the initialized zero-level model to generate a zero-level model.
3. The method for constructing a multi-level detail model according to claim 2, characterized in that: Determining the target texture coordinate value of the target texture includes: Obtaining the offset position (x, y) of each original texture on the target texture, the size (w, h) of the original texture, and the size (W, H) of the target texture; Obtain all associated texture coordinates (u, v) associated with the original texture from the material description file; and obtain corresponding original texture pixel coordinates (u*w, v*h) based on the associated texture coordinates (u, v); Based on the size (w, h) of the original texture, obtaining the target pixel coordinates (x+u*w, y+v*h) of the associated texture coordinates (u, v) on the target texture; Based on the size (W, H) of the target texture and the target pixel coordinates (x+u*w, y+v*h), a target texture coordinate value ((x+u*w) / W, (y+v*h) / H) of the associated texture coordinate (u, v) on the target texture is obtained.
4. The method for constructing a multi-level-of-detail model according to claim 2, wherein: The updating of the material description file of the original three-dimensional model according to the target texture and the target texture coordinate value to obtain the zeroth description file comprises: Converting the target texture into a compressed texture file; Using the compressed texture file and the target texture coordinate value, the description information of the multiple original textures in the material description file is updated to the description information of the target texture to obtain a zeroth description file.
5. The method for constructing a multi-level-of-detail model according to claim 2, wherein: The number of empty pixels in the target texture is less than a preset value.
6. The method for constructing a multi-level-of-detail model according to claim 1, wherein: The initial first-level texture is obtained based on the zero-level model to generate an initial model; Performing texture merging on a plurality of initial first-level textures in the initial model to generate a first-level model includes: Scaling the height and width of the zero-level texture to half of the original size to obtain an initial first-level texture; Initializing an initial model, adding the initial first-level texture, the mesh of the zero-level texture, and the zero-th description file of the zero-level model to the initialized initial model to generate an initial model; Determining textures whose sizes are smaller than a second minimum texture threshold in the initial first-level textures in the initial model as textures to be merged; merging multiple textures to be merged into a merged texture; and determining a first texture coordinate value of the merged texture; Using the first texture coordinate value to update the zeroth description file in the initial model to obtain a first description file; The multiple textures to be merged in the initial model are replaced with the merged textures, and the zeroth description file of the initial model is replaced with the first description file to generate a first-level model.
7. The method for constructing a multi-level-of-detail model according to any one of claims 1 to 6, characterized in that: Starting from the second level, sampling and scaling the zero-level texture of the zero-level model according to the scaling factors of different levels until the zero-level texture cannot be sampled and scaled according to the corresponding scaling factors to generate at least one level model includes: Set the zoom factor of the nth level to 2 -n ; Wherein, n is greater than or equal to 2; According to the scaling factor of the nth level, the height and width of the zeroth level texture are scaled respectively to obtain the nth level texture; combining the nth level texture, the mesh of the zeroth level texture, and the zeroth description file of the zeroth level model to obtain the nth level model; When the zero-th level texture cannot be sampled and scaled according to the corresponding scaling factor, the generation of the at least one level model is stopped.
8. The method for constructing a multi-level-of-detail model according to any one of claims 1 to 6, characterized in that: When the scaling factor is greater than the scalable level of the zero-th level texture, the zero-th level texture cannot be sampled and scaled according to the corresponding scaling factor; The expression of the scalability level is: Log(s) / Log(2); Where s is the minimum height or minimum width of the texture in the zero-level model, and Log(·) is used to calculate the logarithmic value with a constant e as the base.
9. A device for constructing a multi-level-of-detail model, characterized in that: The device for constructing a multi-level-of-details model includes at least one processor and a memory, and the at least one processor and the memory are connected via a data bus. The memory stores instructions that can be executed by the at least one processor. After being executed by the processor, the instructions are used to implement the method for constructing a multi-level-of-details model described in any one of claims 1-8.
10. A non-volatile computer storage medium, characterized in that The computer storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors to complete the method for constructing a multi-level-of-detail model according to any one of claims 1 to 8.
Citation Information
Cited By
Sampling precision calculation method, chip and electronic equipment
CN121458849A