Model Loading Method, Device, Electronic Device and Computer Readable Storage Medium

By separating and compressing the model and appearance maps separately, using the Basis Universal and gltf-pipeline tools, the problem of too long loading of the model is solved, and rapid loading and reduced data storage pressure is achieved.

CN114491352BActive Publication Date: 2025-07-11ASIAINFO TECH CHINA INC
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011255011.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-11
Publication Date
2025-07-11
Estimated Expiration
2040-11-11

AI Technical Summary

Technical Problem

When presenting high-definition models, the large amount of model file data leads to low loading efficiency, too long loading time, and poor user experience.

Method used

Separate and export the model and appearance map, compress the model and texture using the Basis Universal compression tool and the gltf-pipeline tool, replace it with low-resolution preset maps, and load and parse compressed data on the front end to load the high-definition appearance maps.

Benefits of technology

It realizes rapid loading of large model files, reduces the data storage pressure on the server, and improves loading speed and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114491352B_ABST
    Figure CN114491352B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a model loading method, device, electronic device, and computer-readable storage medium, which relate to the field of three-dimensional visualization technology. The method includes: separately exporting a model and an appearance texture map, replacing the appearance texture map with a preset texture map of low resolution, separately compressing the appearance texture map and the model containing the preset texture map, and then replacing the preset texture map with the appearance texture map before rendering, thereby achieving fast loading of large model files and effectively solving the problem of too long model file loading time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of three-dimensional visualization technology. Specifically, this application relates to a model loading method, apparatus, electronic device, and computer-readable storage medium. Background Art

[0002] A three-dimensional model is a polygonal representation of an object, usually displayed using a computer or other video device. Nowadays, three-dimensional models have been used in various different fields, such as applications in intelligent healthcare, movie entertainment, and smart cities.

[0003] Currently, when displaying a high-definition model, usually at the modeling step, a high-definition picture is directly attached to the model as a texture map, and the high-definition texture map and the model are exported together. When rendering, the model containing the high-definition texture map is loaded. Although the final display effect is achieved in this way, the model file often has a large amount of data, resulting in too low model loading efficiency and slow data loading. Summary of the Invention

[0004] The purpose of this application aims to solve at least one of the above technical defects, especially the technical defect of slow model data loading.

[0005] In a first aspect, a model loading method is provided. The method includes:

[0006] Obtain a first model to be loaded; an appearance texture map is attached to the surface of the first model;

[0007] Separate and export the first model to obtain a second model in a loadable data format and the appearance texture map;

[0008] Compress the appearance texture map to obtain a texture map compressed file, and compress a preset texture map and the second model to obtain a model compressed file;

[0009] Parse the texture map compressed file to obtain the appearance texture map, and load the model compressed file to obtain a third model with the preset texture map attached to its surface. Replace the preset texture map with the appearance texture map to load the first model.

[0010] In an optional embodiment of the first aspect, obtaining the first model to be loaded includes:

[0011] Construct a second model according to the model appearance diagram, model structure diagram, and model size diagram;

[0012] Attach the model appearance diagram to the surface of the second model as the appearance texture map to obtain the first model.

[0013] In an optional embodiment of the first aspect, compressing the appearance texture map to obtain a texture map compressed file includes:

[0014] Compress the appearance texture map using the Basis Universal compression tool to obtain a texture map compression file.

[0015] In an optional embodiment of the first aspect, before compressing the preset texture map and the second model to obtain a model compression file, it further includes:

[0016] Filter out target pictures in the preset picture library whose resolution is less than a preset value and whose format is the preset format, and use the target pictures as the preset texture map.

[0017] In an optional embodiment of the first aspect, compressing the preset texture map and the second model to obtain a model compression file includes:

[0018] Use the gltf-pipeline tool to compress the preset texture map and the second model to obtain a model compression file.

[0019] In an optional embodiment of the first aspect, the appearance texture map includes a compressed texture file corresponding to the appearance texture map; parsing the texture map compression file to obtain the appearance texture map includes:

[0020] Load the texture map compression file, and the texture map compression file includes a basis file corresponding to the appearance texture map;

[0021] Convert the basis file into a compressed texture file corresponding to the appearance texture map through a basis transcoder.

[0022] In an optional embodiment of the first aspect, replacing the preset texture map attached to the surface of the third model with the appearance texture map includes:

[0023] Obtain the texture file corresponding to the preset texture map;

[0024] Replace the texture file corresponding to the preset texture map with the compressed texture file corresponding to the appearance texture map.

[0025] In a second aspect, there is provided a device for model loading, and the device includes:

[0026] A model acquisition module, configured to acquire a first model to be loaded; an appearance texture map is attached to the surface of the first model; separate and export the first model to obtain a second model and an appearance texture map;

[0027] A texture map compression module, configured to compress the appearance texture map to obtain a texture map compression file, and compress the preset texture map and the second model to obtain a model compression file;

[0028] A model loading module, configured to parse the texture map compression file to obtain the appearance texture map, and load the model compression file to obtain a third model with a preset texture map attached to its surface, and replace the preset texture map with the appearance texture map to load the first model.

[0029] In an alternative embodiment of the second aspect, when the model acquisition module acquires the first model to be loaded, it specifically is used for:

[0030] Construct a second model according to the model appearance diagram, the model structure diagram, and the model size diagram;

[0031] Attach the model appearance diagram as an appearance texture map to the surface of the second model to obtain the first model.

[0032] In an alternative embodiment of the second aspect, when the texture map compression module compresses the appearance texture map to obtain a texture map compression file, it specifically is used for:

[0033] Use the Basis Universal compression tool to compress the appearance texture map to obtain a texture map compression file.

[0034] In an alternative embodiment of the second aspect, it further includes a texture map acquisition module, which specifically is used for:

[0035] Screen out target pictures in the preset picture library whose resolution is less than a preset value and whose format is a preset format, and use the target pictures as preset texture maps.

[0036] In an alternative embodiment of the second aspect, when the texture map compression module compresses the preset texture map and the second model to obtain a model compression file, it specifically is used for:

[0037] Use the gltf-pipeline tool to compress the preset texture map and the second model to obtain a model compression file.

[0038] In an alternative embodiment of the second aspect, the appearance texture map includes a compressed texture file corresponding to the appearance texture map; when the model loading module parses the texture map compression file to obtain the appearance texture map, it specifically is used for:

[0039] Load the texture map compression file to obtain the basis file corresponding to the appearance texture map;

[0040] Use a basis transcoder to transcode the basis file into a compressed texture file corresponding to the appearance texture map.

[0041] In an alternative embodiment of the second aspect, when the model loading module replaces the preset texture map attached to the surface of the third model with the appearance texture map, it specifically is used for:

[0042] Acquire the texture file corresponding to the preset texture map;

[0043] Replace the texture file corresponding to the preset texture map with the compressed texture file corresponding to the appearance texture map.

[0044] In a third aspect, an electronic device is provided, and the electronic device includes:

[0045] A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, the model loading method of any of the above embodiments is implemented.

[0046] In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the model loading method of any of the above embodiments is implemented.

[0047] For the above model loading method, by separating and exporting the model and the appearance texture map, replacing the appearance texture map with a preset texture map of low resolution, then compressing the appearance texture map using the basis-universal compression tool, and at the same time compressing the model and the preset texture map using the gltf-pipeline model compression tool, the size of the model file is greatly reduced by separately compressing the appearance texture map and the model. Before rendering at the front end, the compressed appearance texture map is loaded and parsed, the model containing the preset texture map is loaded, and then the preset texture map is replaced with the appearance texture map, that is, the two compressed data are combined to achieve the purpose of loading a model with a high-definition appearance texture map, thereby realizing the rapid loading of large model files, effectively solving the problem of too long model file loading time, and reducing the data storage pressure on the server side. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for description in the embodiments of the present application.

[0049] Figure 1 It is a schematic flowchart of a model loading method provided by an embodiment of the present application;

[0050] Figure 2 It is a schematic flowchart of the model loading method in the example provided by an embodiment of the present application;

[0051] Figure 3 It is a schematic flowchart of the model loading method in the example provided by an embodiment of the present application;

[0052] Figure 4 It is a schematic structural diagram of a model loading device provided by an embodiment of the present application;

[0053] Figure 5 It is a schematic structural diagram of an electronic device for model loading provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0054] Embodiments of the present application will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where like or similar reference numerals denote like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the accompanying drawings are exemplary only for explaining the present application and should not be construed as limiting the present invention.

[0055] Those skilled in the art of the present technology can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present application means the presence of the stated features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups. It should be understood that when we say that an element is "connected" or "coupled" to another element, it can be directly connected or coupled to other elements, or there may also be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The phrase "and / or" used herein includes all or any unit and all combinations of one or more of the associated listed items.

[0056] To make the objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0057] A three-dimensional model, that is, a 3D (three-dimensional) model, refers to a three-dimensional and solid model. In the computer field, it refers to a solid model built by 3D software, including various buildings, characters, vegetation, machinery, and so on.

[0058] Today, the applications of three-dimensional models are already very extensive. In the medical industry, they are used to create accurate models of organs; in the film industry, they are used to create vivid characters and objects; the video game industry uses them as resources in computer and video games; the construction industry uses them to display wonderful and delicate buildings; in the past few decades, the earth science field has also started to construct three-dimensional geological models. And for people who are not technical personnel, the applications of three-dimensional models are not far away. With the continuous progress of 3D technology, there will be more Internet applications presented to users in 3D form, including web video, e-reading, distance education, and so on. For example, in the tourism industry, some scenic spots and historical relics can be presented to users in the form of three-dimensional models, which can bring users a more real feeling.

[0059] To display a 3D model on the Internet, it is usually necessary to load the 3D model at the front end of the Web (World Wide Web). Common 3D model loading solutions include: first constructing a 3D model in modeling software based on graphics and data, then attaching a high-definition appearance image of the model as a texture to the surface of the 3D model, and then exporting the model as a data format that can be loaded by a browser through the modeling software. Finally, when rendering at the front end, load the model file, parse the model file, and complete the rendering. In this existing solution, when there is a need for high-definition textures for model display, the high-definition image is directly attached to the model as a texture during modeling. Although the effect of displaying the 3D model is achieved, due to the large volume of high-definition images, the data volume of the 3D model file is often extremely large, resulting in a very long data loading time. Moreover, it is necessary to specifically adjust the configuration of the server data request timeout, resulting in a long waiting time for users to load and a poor experience.

[0060] The model loading method, device, electronic device, and computer-readable storage medium provided by this application aim to solve the above technical problems in the prior art.

[0061] The following uses specific embodiments to elaborate in detail on the technical solution of this application and how the technical solution of this application solves the above technical problems. These several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The following will describe the embodiments of this application in conjunction with the accompanying drawings.

[0062] The model loading method provided in the embodiments of this application can be applied to a server or a terminal.

[0063] Those skilled in the art of this technology can understand that the "terminal" used here can be a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a MID (Mobile Internet Device), etc.; the "server" can be implemented by an independent server or a server cluster composed of multiple servers.

[0064] The embodiments of this application provide a model loading method that can be applied to a server or a terminal, as Figure 1 shown, this method may include:

[0065] Step S100, obtain a first model to be loaded; an appearance texture is attached to the surface of the first model.

[0066] Among them, the model to be loaded can be a model file stored in a local library or a model with 3D data constructed in a virtual 3D space using 3D production software.

[0067] In the embodiment of the present application, in step S100, obtaining the first model to be loaded may specifically include:

[0068] (1) Constructing a second model according to the model appearance diagram, the model structure diagram, and the model dimension diagram;

[0069] (2) Attaching the model appearance diagram as an appearance texture map to the surface of the second model to obtain the first model.

[0070] Among them, the second model is an initial model that does not include texture maps and only has the shape of the target object, and the first model is obtained by applying the appearance texture map to the second model.

[0071] 3D modeling can be generally divided into two types: NURBS (Non-Uniform Rational B-Splines) and polygon meshes. Among them, NURBS is a very excellent modeling method that can better control the curvature of the object surface than the traditional mesh modeling method, so more realistic and vivid shapes can be created. The polygon mesh modeling is by the way of pulling noodles and is suitable for making effect diagrams and complex scene animations. The present application does not limit which modeling method is used to obtain the 3D model.

[0072] In addition to different modeling methods and modeling software making the 3D model more flexible and vivid, the application of textures is also very important. Textures include both the textures on the object surface in the general sense, that is, the uneven grooves presented on the object surface, and also the color patterns on the smooth surface. Mapping the textures to the object surface in a specific way can make the object look more real. Among them, the texture mapping method can be completed by using UV coordinates. For 3D models, in addition to the (X, Y, Z) coordinate system being important, the UV coordinates should also be concerned because the UV coordinates are the basis for mapping the texture map to the model surface. The UV coordinates are the UVW coordinates. U and V are the coordinates of the picture in the horizontal and vertical directions of the display respectively, and the direction of W is perpendicular to the surface of the display. For the NURBS (Non-Uniform Rational B-Splines) modeling method, the surface of NURBS itself has UV parameters, and it is easier to correspond the points on the surface to the pixels on the plane. For polygon models, in order to map textures, UV coordinates can be additionally introduced to facilitate the correspondence between the vertices of the polygon and the pixels of the image.

[0073] There are many ways to obtain textures. You can use PS (Adobe Photoshop, image processing software) to make them, or you can use high-polygon topology in 3D software. The size of the texture can be square and should be as small as possible. The type of texture can be a diffuse texture, a bump texture, or a normal texture. Among them, it is found that the texture can calculate the surface details of the model based on light and shadow. Although it is a two-dimensional effect, it can reflect three-dimensional details, and realize the effect of simulating a high-polygon model with a low-polygon model, increase the sense of hierarchy, and reduce the number of faces of the model.

[0074] In an embodiment of the present application, the first model may be a three-dimensional model after mapping is completed, that is, the appearance map has been converted into a texture and mapped to the model surface. When the model is displayed, lines and patterns can be seen on the model surface. Therefore, the data of the first model may contain the UV coordinate information of the map.

[0075] Step S200, separating and exporting the first model to obtain a second model and an appearance map in a loadable data format.

[0076] In the embodiment of the present application, the second model means the model file after the texture of the first model is removed, and the file format of the second model can be exported in GLTF (Graphics Language Transmission Format) format, which is convenient for the application to perform real-time rendering. When the three-dimensional model has a Web application requirement, it is more appropriate to save the model in GLTF format, which can have a faster model loading speed.

[0077] Specifically, GLTF is a 3D model file format that minimizes the size of 3D model files, optimizes the efficiency of transmitting, loading, and parsing 3D model files, and is scalable and interactive. GLTF model files contain description information such as node hierarchy, cameras, meshes, materials, and animations in the scene.

[0078] Appearance maps can be exported to png (Portable Network Graphics) format. png format is a bitmap format that uses a lossless compression algorithm and has many advantages: small size while maintaining a certain degree of clarity; lossless compression, can be saved repeatedly without reducing image quality; more optimized network transmission display, streaming browsing can be used on the browser, allowing continuous reading and writing of image data, this feature is very suitable for displaying and generating images during the communication process.

[0079] In the example of the present application, the second model and the appearance map are exported separately, and the model and the map can be compressed separately in the next step, thereby further reducing the size of the model file.

[0080] Step S300: Compress the appearance texture map to obtain a texture map compression file, and compress the preset texture map and the second model to obtain a model compression file.

[0081] Among them, the preset texture map can be a texture map whose resolution or format meets specific requirements. For example, the resolution is less than a preset value and the texture map format is the png format. The preset texture map can also be the grayscale image and binary image corresponding to the appearance texture map after processing. When there is a need to preview the general profile of the model, the model with the grayscale image or binary image as the texture map can be displayed first, and then it can be selected whether to perform further loading.

[0082] In the embodiment of the present application, before step S300 compresses the preset texture map and the second model to obtain a model compression file, it may further include:

[0083] Screen out target pictures in the preset picture library whose resolution is less than a preset value and whose format is a preset format, and use the target pictures as the preset texture map.

[0084] Among them, the preset picture library can be a local picture library, a network picture library, or a picture library synthesized by a crawler. Target pictures with a resolution less than a preset value and a format of the png format can be screened out in the preset picture library, and the target pictures are used as the preset texture map. In one embodiment, the preset texture map can be a solid-color picture, such as pure black or pure white, or a binary image or grayscale image corresponding to a high-definition texture map, which is used for some specific display requirements.

[0085] In the embodiment of the present application, the appearance texture map may be a high-definition appearance picture. At this time, the size of the appearance texture map may be larger than that of the model file, and the model and the texture map can be processed separately.

[0086] For the processing of the texture map file, it can be to compress a png-format picture, or to convert the png format to the jpg (i.e., JPEG, Joint Photographic Experts Group, JPEG format) format to reduce the texture size. These two methods optimize the picture loading speed. However, after the texture map is loaded, the texture map file in the png or jpg format needs to be converted into a texture to start rendering. Usually, when the texture map sizes are the same, the amount of GPU memory occupied is also the same. Therefore, no optimization is performed during the rendering process.

[0087] In one embodiment, the appearance map can be compressed using the Basis Universal compression tool. This solution uses the open-source Basis Universal GPU texture codec, which not only maintains GPU performance efficiency but also improves the performance of image transmission in web, desktop, and mobile applications. This is because the Basis Universal texture format will remain compressed throughout the application process, occupying 6-8 times less resources on the GPU than the traditional JPEG format, while the file storage space required is similar to that of JPEG. The compressed files it creates are suitable for various common application scenarios.

[0088] In step S200, the model can be exported in the GLTF format. A GLTF file is not actually a single file and can include:

[0089] (1) A model file that contains description information such as the node hierarchy, camera, mesh, material, and animation in the scene.

[0090] (2) A binary file that contains geometry, animation data, and other buffer-based data, usually with a.bin suffix. This file can be directly loaded into the GPU buffer without additional parsing, enabling efficient transmission and fast loading.

[0091] (3) A material map file, which is the file used for bump mapping or normal mapping of 3D models.

[0092] Among these three parts, files other than the model file can be applied through a relative URL (uniform resource locator).

[0093] In one embodiment, a CDN (Content Delivery Network) may be used instead of its own web server. In this case, it may not be possible to control the relative URL, resulting in problems. We can convert the GLTF format to a binary format called GLB, a single file that contains all resources, with a further reduced volume, and the GLB file can be directly referenced when placed on the CDN.

[0094] Among them, before further compressing the GLTF format file into a GLB format file, high-definition appearance maps can be replaced with preset maps, and the preset maps can be low-resolution images. The GLB file can be directly exported from a 3D modeling program or a tool can be used to convert the GLTF file to GLB. The conversion tool can be a web-based converter: MakeGLB. Drag the folder containing the FLTF file to the page, and this converter will generate and download the GLB file.

[0095] Specifically, the conversion tool can also be gltf - pipeline. Gltf - pipeline is a command - line tool developed based on a tool library for 3D model compression and decompression launched by Google. It can further compress GLTF - format model files into GLB format. When using it, the model file, binary file, and material texture file in the GLTF file need to be placed together and the command - line is executed for conversion. Since the appearance texture and the second model were exported separately before, the preset texture can be used to replace the original appearance texture, and the preset texture and the second model are compressed into a GLB - format file together.

[0096] In one embodiment, the Basis Universal compression tool can be used to compress the texture to obtain the basis file corresponding to the appearance texture. At the same time, use gltf - pipeline to further compress the model file into GLB format. In this step, a low - resolution preset texture can be used as the material texture file required for compression, and the problem that GLTF and GLB formats do not currently support using the basis file as the material texture file is solved by substitution.

[0097] Step S400: Parse the texture compression file to obtain the appearance texture, and load the model compression file to obtain a third model with a preset texture attached to its surface. Replace the preset texture with the appearance texture to load the first model.

[0098] In the embodiment of the present application, the appearance texture and the model file can be compressed separately, and when loading, they can be loaded separately. Loading the texture compression file to obtain the appearance texture, and loading the model compression file to obtain a third model containing the preset texture.

[0099] Among them, the third model refers to the model with a preset texture attached to its surface, and the display requirement is for the first model containing the appearance texture. Therefore, after loading the model compression file to obtain the third model, the preset texture on the surface of the third model can be replaced with the appearance texture to obtain the first model. The first model refers to the model with the appearance texture attached to its surface. By combining the two compressed data, the purpose of displaying the first model containing the appearance texture is achieved.

[0100] In the embodiment of the present application, step S400 of parsing the texture compression file to obtain the appearance texture may include:

[0101] (1) Load the texture compression file, and the texture compression file includes the basis file corresponding to the appearance texture;

[0102] (2) Use a basis transcoder to transcode the basis file into a compressed texture file corresponding to the appearance texture.

[0103] Among them, the appearance texture map may include a compressed texture file corresponding to the appearance texture map.

[0104] Among them, in the previous step S300, the texture map can be compressed using the Basis Universal compression tool. Basis Universal supports a variety of common compressed texture formats and can convert a texture map in png format into a basis file, whose size is similar to that of the jpg format, but its size on the GPU is 6-8 times smaller than that of the png / jpg format. When parsing the compressed texture file of the texture map, first load the compressed texture file, that is, load the basis file corresponding to the appearance texture map, and then quickly convert it into a compressed texture format suitable for the device through the basis transcoder. For general texture maps in jpg and png formats, the images still need to be transcoded into texture format after being loaded before starting to render, while the compressed texture format obtained after transcoding through the basis transcoder does not require further texture transcoding, and the compressed texture will remain compressed throughout the process, and its size can be reduced by more than 5 times compared to the texture transcoded from a png format image, which can greatly reduce the texture memory.

[0105] In the embodiment of the present application, step S400 replacing the preset texture map with the appearance texture map may include:

[0106] (1) Obtain a texture file corresponding to the preset texture map;

[0107] (2) Replace the texture file corresponding to the preset texture map with the compressed texture file corresponding to the appearance texture map.

[0108] As mentioned in the description of the previous step, for texture maps in jpg and png formats, they need to be transcoded into texture format after being loaded before starting to render. Therefore, a low-resolution preset texture map can be transcoded into a file in texture format. While a high-definition appearance texture map can be compressed using Basis Universal to convert the high-definition appearance texture map into a corresponding basis file. After loading the basis file, then use the basis transcoder to transcode the basis file into a compressed texture format to obtain a compressed texture file. This compressed texture file does not require further texture transcoding and decompression, and the texture file corresponding to the preset texture map can be replaced with the compressed texture file corresponding to the high-definition appearance texture map, achieving the effect of attaching the high-definition appearance texture map to the model. Through the super-compression process of the high-definition appearance texture map using the Basis Universal compression tool, the size of the picture can be extremely compressed without damaging the picture quality. While maintaining the GPU performance efficiency, it optimizes the performance of picture transmission and also reduces the data storage pressure on the server side.

[0109] To more clearly illustrate the model loading method of this application, the following will further explain the model loading method in combination with specific examples.

[0110] In one example, this application provides a model loading method, such as Figure 2 , including the following steps:

[0111] Step S201, construct a second model according to the model appearance diagram, model structure diagram, and model size diagram;

[0112] Step S202, attach the model appearance diagram as an appearance texture to the surface of the second model to obtain a first model;

[0113] Step S203, separate and export the first model to obtain a second model in a loadable data format and an appearance texture;

[0114] Step S204, use the Basis Universal compression tool to compress the appearance texture to obtain a texture compression file;

[0115] Step S205, screen out target pictures in a preset picture library with a resolution less than a preset value and a format of a preset format, and use the target pictures as preset textures;

[0116] Step S206, use the gltf-pipeline tool to compress the preset texture and the second model to obtain a model compression file;

[0117] Step S207, load the texture compression file to obtain a basis file corresponding to the appearance texture;

[0118] Step S208, use a basis transcoder to transcode the basis file into a compressed texture file corresponding to the appearance texture;

[0119] Step S209, obtain a texture file corresponding to the preset texture;

[0120] Step S210, replace the texture file corresponding to the preset texture with the compressed texture file corresponding to the appearance texture.

[0121] Taking the loaded model used in a client browser as an example, the model loading method will be further explained in combination with specific examples.

[0122] In one example, this application provides a model loading method, such as Figure 3 , including the following steps:

[0123] (1) Collect picture materials of the modeling object, such as model appearance pictures, model structure pictures, and model size diagrams;

[0124] (2) Construct a 3D model in modeling software based on the picture materials of the modeling object, and attach the high-definition appearance texture as a texture to the surface of the 3D model to obtain a 3D model with an appearance texture;

[0125] (3) Separate and export the 3D model with an appearance texture into a model file and a high-definition appearance texture, where the model file is in GLTF format and the high-definition appearance texture is in png format;

[0126] (4) Compress the exported high-definition appearance texture with the Basis Universal compression tool, and output the basis texture compression file corresponding to the high-definition appearance texture after compression;

[0127] (5) The high-definition appearance texture can be replaced with a pure black and png-format replacement texture. Use the gltf-pipeline model compression tool to compress the model file and the pure black replacement texture, and output a model compression file in GLB format; Figure 1 Start using the gltf-pipeline model compression tool for compression, and output a model compression file in GLB format;

[0128] (6) Before model rendering on the web page, first load the basis texture compression file corresponding to the high-definition appearance texture, and at the same time use a basis transcoder to transcode the basis texture compression file into a compressed texture file (i.e., the high-definition texture map in the figure). This compressed texture file does not need to be transcoded or decompressed again;

[0129] (7) Load the model compression file in GLB format. At this time, the pure black replacement texture can be transcoded into a corresponding texture file. Replace the texture file corresponding to the pure black replacement map with the compressed texture file corresponding to the high-definition texture map to combine into a model with a high-definition appearance texture attached;

[0130] (8) Render the model with a high-definition appearance texture to achieve the purpose of displaying the model in the client browser.

[0131] In the above example, by separating and exporting the model and the appearance texture, replacing the appearance texture with a low-resolution preset texture, using the Basis Universal compression tool to compress the appearance texture, and using the gltf-pipeline model compression tool to compress the model and the preset texture, the size of the model file is greatly reduced by compressing the appearance texture and the model separately. Before rendering on the front end, load and parse the compressed appearance texture, load the model with the preset texture, and then replace the preset texture with the appearance texture, that is, combine the two compressed data to achieve the purpose of loading a model with a high-definition appearance texture, thus realizing the fast loading of large model files, effectively solving the problem of too long model file loading time, and reducing the data storage pressure on the server side.

[0132] An embodiment of the present application provides an image processing device, such as Figure 4 shown. The image processing device 400 may include: a model acquisition module 4001, a texture map compression module 4002, and a model loading module 4003. Among them,

[0133] The model acquisition module 4001 is configured to acquire a first model to be loaded; an appearance texture map is attached to the surface of the first model; the first model is separated and exported to obtain a second model and an appearance texture map;

[0134] The texture map compression module 4002 is configured to compress the appearance texture map to obtain a texture map compression file, and compress a preset texture map and the second model to obtain a model compression file;

[0135] The model loading module 4003 is configured to parse the texture map compression file to obtain the appearance texture map, and load the model compression file to obtain a third model with a preset texture map attached to the surface, and replace the preset texture map with the appearance texture map to load the first model.

[0136] In an embodiment of the present application, when the model acquisition module 4001 acquires the first model to be loaded, it is specifically configured to:

[0137] Construct a second model according to the model appearance diagram, the model structure diagram, and the model size diagram;

[0138] Attach the model appearance diagram as the appearance texture map to the surface of the second model to obtain the first model.

[0139] In one embodiment, when the texture map compression module 4002 compresses the appearance texture map to obtain a texture map compression file, it is specifically configured to:

[0140] Use the Basis Universal compression tool to compress the appearance texture map to obtain a texture map compression file.

[0141] In one embodiment, it further includes a texture map acquisition module, which is specifically configured to:

[0142] Screen out target pictures with a resolution less than a preset value and a format of a preset format in a preset picture library, and use the target pictures as the preset texture map.

[0143] In one embodiment, the appearance texture map includes a compressed texture file corresponding to the appearance texture map; when the model loading module 4003 parses the texture map compression file to obtain the appearance texture map, it is specifically configured to:

[0144] Load the texture map compression file to obtain the basis file corresponding to the appearance texture map;

[0145] Transcode the basis file into a compressed texture file corresponding to the appearance texture map through a basis transcoder.

[0146] In one embodiment, when the model loading module 4003 replaces the preset texture map attached to the third model surface with an appearance texture map, it is specifically configured to:

[0147] Obtain a texture file corresponding to the preset texture map;

[0148] Replace the texture file corresponding to the preset texture map with a compressed texture file corresponding to the appearance texture map.

[0149] In the above model loading device, by separating and exporting the model and the appearance texture map, replacing the appearance texture map with a preset texture map of low resolution, then compressing the appearance texture map using the basis-universal compression tool, and simultaneously compressing the model and the preset texture map using the gltf-pipeline model compression tool, the size of the model file is greatly reduced by compressing the appearance texture map and the model separately. Before rendering at the front end, the compressed appearance texture map is loaded and parsed, the model containing the preset texture map is loaded, and then the preset texture map is replaced with the appearance texture map, that is, the two compressed data are combined to achieve the purpose of loading a model with a high-definition appearance texture map, thereby realizing the fast loading of large model files, effectively solving the problem of too long model file loading time, and reducing the data storage pressure on the server side.

[0150] In the embodiment of the present application, an electronic device is provided. The electronic device includes: a memory and a processor; at least one program stored in the memory, which when executed by the processor, compared with the prior art, can achieve: greatly reducing the size of the model file by compressing the appearance texture map and the model separately, before rendering at the front end, loading and parsing the compressed appearance texture map, loading the model containing the preset texture map, and then replacing the preset texture map with the appearance texture map, that is, combining the two compressed data to achieve the purpose of loading a model with a high-definition appearance texture map, thereby realizing the fast loading of large model files, effectively solving the problem of too long model file loading time, and reducing the data storage pressure on the server side.

[0151] In an alternative embodiment, an electronic device is provided, as Figure 5 shown, Figure 5 The electronic device 5000 shown includes: a processor 5001 and a memory 5003. Among them, the processor 5001 and the memory 5003 are connected, such as connected through a bus 5002. Optionally, the electronic device 5000 may further include a transceiver 5004. It should be noted that in actual applications, the transceiver 5004 is not limited to one, and the structure of the electronic device 5000 does not constitute a limitation to the embodiment of the present application.

[0152] The processor 5001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logical blocks, modules, and circuits described in connection with the disclosure of this application. The processor 5001 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0153] The bus 5002 may include a path for transmitting information between the above components. The bus 5002 can be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 5002 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 only a thick line is used to represent it in the figure, but it does not mean that there is only one bus or one type of bus.

[0154] The memory 5003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or it can also be an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.

[0155] The memory 5003 is used to store the application program code for implementing the solution of this application, and is controlled by the processor 5001 for execution. The processor 5001 is used to execute the application program code stored in the memory 5003 to implement the content shown in the foregoing method embodiments.

[0156] Among them, the electronic device includes but is not limited to mobile terminals such as mobile phones, laptop computers, PADs, etc. and fixed terminals such as digital TVs, desktop computers, etc.

[0157] The embodiment of this application provides a computer-readable storage medium, on which a computer program is stored. When it runs on a computer, it enables the computer to execute the corresponding content in the foregoing method embodiments.

[0158] It should be understood that although each step in the flowchart of the accompanying drawings is shown in sequence according to the indication of the arrows, these steps do not necessarily have to be executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages. These sub-steps or stages do not necessarily have to be executed at the same moment, but can be executed at different moments. Their execution order does not necessarily have to be sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.

[0159] The above is only part of the implementation manners of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.

Claims

1. A method for model loading, characterized in that, Including: Obtain a first model to be loaded; Appearance maps are attached to the surface of the first model; Separate and export the first model to obtain a second model in a loadable data format and the appearance maps; Compress the appearance maps to obtain a map compression file, and compress a preset map and the second model to obtain a model compression file; The preset map includes a grayscale image or a binary image corresponding to the processed appearance map; Parse the map compression file to obtain the appearance maps, load the model compression file to obtain a third model with the preset map attached to its surface, and replace the preset map with the appearance maps to load the first model.

2. The model loading method according to claim 1, wherein Obtaining a first model to be loaded includes: Construct the second model according to the model appearance diagram, the model structure diagram, and the model size diagram; Attach the model appearance diagram as the appearance maps to the surface of the second model to obtain the first model.

3. The model loading method according to claim 1, wherein The step of compressing the appearance maps to obtain a map compression file includes: Use the Basis Universal compression tool to compress the appearance maps to obtain a map compression file.

4. The model loading method according to claim 1, wherein Before compressing the preset map and the second model to obtain a model compression file, it further includes: Screen out target images with a resolution less than a preset value and in a preset format from a preset image library, and use the target images as the preset map.

5. The model loading method according to claim 1, characterized in that The step of compressing the preset map and the second model to obtain a model compression file includes: Use the gltf-pipeline tool to compress the preset map and the second model to obtain a model compression file.

6. The model loading method according to claim 3, wherein The appearance maps include the compressed texture files corresponding to the appearance maps; the step of parsing the map compression file to obtain the appearance maps includes: Load the map compression file, where the map compression file includes the basis file corresponding to the appearance maps; Use a basis transcoder to transcode the basis file into the compressed texture file corresponding to the appearance maps.

7. The model loading method according to claim 6, wherein Replacing the preset map attached to the surface of the third model with the appearance maps includes: Obtain the texture file corresponding to the preset map; Replace the texture file corresponding to the preset map with the compressed texture file corresponding to the appearance maps.

8. A model loading device, characterized in that, Including: A model acquisition module for obtaining a first model to be loaded; Appearance maps are attached to the surface of the first model; Separate and export the first model to obtain a second model and the appearance maps; A map compression module for compressing the appearance maps to obtain a map compression file, and compressing a preset map and the second model to obtain a model compression file; The preset map includes a grayscale image or a binary image corresponding to the processed appearance map; A model loading module for parsing the map compression file to obtain the appearance maps, loading the model compression file to obtain a third model with the preset map attached to its surface, and replacing the preset map with the appearance maps to load the first model.

9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the model loading method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the program is executed by a processor, the model loading method according to any one of claims 1-7 is implemented.

Citation Information

Patent Citations

  • Three-dimensional model image generating method and apparatus

    CN101364310A