A three-dimensional engine-based texture loading method, electronic device and storage medium

By constructing a multi-level texture feature index structure in the 3D engine, dynamic recognition and content reuse before texture loading are achieved, solving the problem of cross-model texture recognition and deduplication, and improving rendering performance and video memory utilization.

CN120580333BActive Publication Date: 2025-11-04YANTAI JIERUI NETWORK TRADING
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511079597.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-04
Publication Date
2025-11-04
Estimated Expiration
2045-08-04

AI Technical Summary

Technical Problem

Existing 3D engines lack efficient, scalable, and accurate methods for cross-model texture content recognition and deduplication in texture management, resulting in wasted video memory, low loading efficiency, and limited rendering performance.

Method used

By extracting texture features before texture loading and constructing a multi-level index structure, dynamic recognition and content reuse of textures before loading are achieved. The hierarchical index structure is used to quickly locate existing texture resources and avoid repeated loading.

Benefits of technology

It significantly improves the rendering efficiency of the 3D engine, reduces the pressure on video memory usage, enhances the overall user experience, and is compatible with existing virtual textures and dynamic scheduling mechanisms, making it suitable for mobile devices and low-end hardware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120580333B_ABST
    Figure CN120580333B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of computer graphics, and mainly relates to a texture loading method based on a three-dimensional engine, an electronic device and a storage medium; wherein the present application provides a texture loading method based on a three-dimensional engine, which improves the efficiency of the three-dimensional engine during texture loading through intelligent texture loading and deduplication mechanism, and reduces the memory occupation. The core idea of the method is to automatically identify the repeated part with the loaded texture during the three-dimensional model loading process, and skip the repeated texture loading, and directly use the loaded texture data. This technical innovation helps to significantly improve the rendering efficiency of the three-dimensional engine, reduce the use pressure of the memory, and thus improve the rendering performance and overall user experience.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the field of computer graphics, and particularly relates to a texture loading method based on a three-dimensional engine, an electronic device and a storage medium. BACKGROUND

[0002] In modern computer graphics and three-dimensional engine technology, texture resources are a key component for constituting visual details and material realism, and the loading and management manner thereof directly affects the rendering performance and resource utilization efficiency of the engine. With the wide rise of virtual reality (VR), augmented reality (AR), digital twin, open world game and other application scenarios, the number and resolution of texture data in a three-dimensional scene are rapidly increasing, and the volume of a texture file usually reaches hundreds of megabytes or even hundreds of megabytes, further intensifying the pressure on the system in terms of loading and video memory management. The existing mainstream three-dimensional engines (such as Unity, Unreal Engine, etc.) usually adopt the following texture loading process: when a model is loaded, the texture file referenced by the model is read from the disk, decoded and uploaded to the GPU video memory, and then used by the rendering module. In terms of resource management, these engines usually maintain a texture resource table to identify and track the loading state and video memory occupation of the texture, and are supplemented by texture compression (such as ASTC, BCn, ETC) technology to reduce video memory usage and bandwidth consumption.

[0003] To adapt to the requirements of large scene loading and multi-detail rendering, the existing engines also adopt dynamic scheduling strategies such as virtual texture (Virtual Texturing), sparse texture (Sparse Textures) or megatexture (Megatexture), which realize a partial breakthrough of the video memory capacity bottleneck by splitting a large size texture into tiles (tile / page) and loading them on demand within the screen space range. Although the above texture compression and virtual texture technology has made certain progress in single texture resource compression rate and local dynamic scheduling, there are still significant deficiencies in texture redundancy identification and cross-model reuse. At present, there is still a lack of a cross-model texture content identification and deduplication method with high efficiency, scalability and accuracy, especially a method for realizing pre-judgment and resource reuse before the texture is decoded, which causes waste of video memory, low loading efficiency and limited rendering performance. SUMMARY

[0004] The present application aims at: in view of the deficiencies of the prior art, a cross-model texture content identification and deduplication method with high efficiency, scalability and accuracy is provided.

[0005] In order to achieve the above-mentioned purpose, the following technical solutions are implemented in the present application:

[0006] A texture loading method based on a three-dimensional engine, comprising the following steps:

[0007] S101, before loading the texture resource, the three-dimensional engine extracts the undecoded texture part information from the texture resource, and calculates and constructs a first texture feature based on the texture part information;

[0008] S201, the three-dimensional engine queries whether there is a texture matching the first texture feature in the texture resource; when there is not, step S701 is executed; when there is, step S301 is executed;

[0009] S301, before loading the texture resource, the three-dimensional engine extracts undecoded texture information from a specified window area of the texture resource, and calculates and constructs a second texture feature based on the texture information;

[0010] S401, the three-dimensional engine queries whether there is a texture matching the second texture feature in the texture matching the first texture feature; when there is not, step S701 is executed; when there is, step S501 is executed;

[0011] S501, the three-dimensional engine completely reads the texture data in the texture resource, and queries whether there is a texture identical to the texture matching the second texture feature; when there is not, step S701 is executed; when there is, step S601 is executed;

[0012] S601, the texture identical to the texture matching the second texture feature is directly loaded as the texture to be loaded, and the process ends;

[0013] S701, the texture in the texture resource is decoded, and the decoded texture is loaded to the three-dimensional engine, and at least one of the first texture feature or the second texture feature is loaded to the three-dimensional engine.

[0014] The above technical solution produces the following technical effects:

[0015] The application proposes a texture loading method based on a three-dimensional engine, which realizes dynamic identification, content reuse and decoding optimization of the texture before loading by constructing a multi-level texture feature mechanism. In the model loading process, it is judged in real time whether the texture already exists in the video memory, and the texture resource is selectively reused accurately to avoid repeated loading and waste of video memory, while being compatible with the virtual texture and dynamic scheduling mechanism of the modern three-dimensional engine. This technical innovation helps to significantly improve the rendering efficiency of the three-dimensional engine, reduce the use pressure of the video memory, and thus improve the rendering performance and overall user experience. In addition, the technical solution of the application also has the following technical effects:

[0016] 1. Extremely low running overhead, the first texture feature only depends on metadata such as resolution, picture type and sampling method, and can be calculated completely without reading texture data, which almost does not consume additional time on modern devices; the calculation of the second texture feature only needs to sequentially read a part (≤ 256 bytes) of the texture data after the file header, without the need to completely read the texture, without the need to decode the pixels of the texture or upload the GPU, the memory usage is very small, and the calculation is extremely fast. Therefore, the additional burden on CPU, I / O and graphics card bandwidth can be ignored, which is suitable for mobile terminals and low-end hardware.

[0017] 2. Online, cross-model deduplication and reuse, unlike traditional "single model internal map merging" or offline batch processing, the method completes cross-model texture deduplication in real time during the loading stage; when multiple buildings or characters share basic maps such as brick walls and metals, the system directly reuses the loaded textures, saving redundant uploading and video memory allocation; in open world, digital twin and VR scenarios (the number of models can reach thousands), the startup time and window switching delay can be significantly shortened.

[0018] 3. Greatly improved video memory utilization, by removing duplicate textures, a large amount of video memory can be freed up without reducing resolution; when used with texture compression technology and on-demand tile scheduling technology such as virtual texture, GPU memory and bus bandwidth are further saved.

[0019] 4. Multi-threaded access support, using a hierarchical index structure of "first texture feature → second texture feature → associated data set"; the overall data structure can be placed in a thread-safe hash table, supporting multi-threaded pipeline (I / O thread, decoding thread, rendering thread) parallel access without performance bottleneck.

[0020] 5. High discrimination and low misjudgment rate, since the second texture feature directly samples valid data without file header, misjudgment caused by file header can be greatly reduced, different textures can be more accurately identified, and for textures with the same first and second texture features, accurate matching is performed to avoid misjudgment caused by fuzzy or similarity matching algorithms.

[0021] 6. No special hardware or distributed architecture dependence, easy integration, the whole process only involves regular file reading and writing and hash calculation, without any special hardware or distributed asset pipeline; it can be directly embedded in existing three-dimensional engines or self-developed rendering frameworks, and remains compatible with existing resources and virtual texture subsystems.

[0022] As a further improvement of the texture loading method based on a three-dimensional engine, a hierarchical index structure is maintained in the three-dimensional engine, and the hierarchical index structure comprises:

[0023] The first mapping relationship is used for mapping the first texture feature to a secondary index structure corresponding to the first texture feature.

[0024] The second mapping relationship is stored in the secondary index structure and is used for mapping the second texture feature to an associated data set.

[0025] As a further improvement of the three-dimensional engine-based texture loading method, the associated data set is used for storing texture data entries matched with the first texture feature and / or the second texture feature, and each texture data entry includes texture data in a texture resource and a loaded texture.

[0026] As a further improvement of the three-dimensional engine-based texture loading method, in step S101, the method for calculating and constructing the first texture feature based on the texture part information includes the following steps.

[0027] Extracting a resolution of the texture in the texture part information, the resolution including a width and a height;

[0028] Extracting a picture type of the texture in the texture part information, the picture type being a jpeg type or a png type;

[0029] Extracting a sampling mode of the texture in the texture part information, the sampling mode being at least one of a texture enlargement filter, a texture reduction filter, a horizontal padding of texture coordinates, and a vertical padding of texture coordinates;

[0030] Calculating the first texture feature according to the extracted resolution, picture type, and sampling mode.

[0031] As a further improvement of the three-dimensional engine-based texture loading method, the method for calculating and constructing the first texture feature based on the texture part information further includes the following steps.

[0032] Extracting a color space of the texture in the texture part information;

[0033] Extracting a file size of the texture in the texture part information;

[0034] Calculating the first texture feature according to the extracted resolution, picture type, sampling mode, color space, and file size.

[0035] As a further improvement of the three-dimensional engine-based texture loading method, in step S301, the method for calculating and constructing the second texture feature based on the texture information includes the following steps.

[0036] S302, skipping a picture file header of the texture, and the skipping length is adaptively adjusted according to the file size of the texture and the format of the texture;

[0037] S303, reading a small amount of data backwardly;

[0038] S304, calculating a second texture feature of a fixed size from the small amount of data.

[0039] As a further improvement of the texture loading method based on a three-dimensional engine of the present application, the step of calculating a second texture feature of a fixed size from the small amount of data in step S303 is: using a hash algorithm to calculate the hash value of the small amount of data, and the hash value is the second texture feature.

[0040] The hash algorithm is CRC cyclic redundancy check or xxHash.

[0041] As a further improvement of the texture loading method based on a three-dimensional engine of the present application, the step of calculating a second texture feature of a fixed size from the small amount of data is: dividing the small amount of data into blocks according to the fixed size, and performing XOR operation on each data bit by bit, and the XOR operation result is the second texture feature.

[0042] An electronic device comprising:

[0043] A memory for storing a computer program;

[0044] A processor for executing the computer program to implement the steps of any of the above texture loading methods based on a three-dimensional engine.

[0045] A computer readable storage medium, the computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the steps of any of the above texture loading methods based on a three-dimensional engine. BRIEF DESCRIPTION OF DRAWINGS

[0046] The drawings described herein are intended to provide further understanding of the present application, and form a part of the present application. The illustrative embodiments of the present application and their description serve to explain the present application. They do not constitute an inappropriate limitation on the present application. In the drawings:

[0047] Figure 1 A texture loading method based on a three-dimensional engine provided by the present application is shown in the figure;

[0048] Figure 2 A hierarchical index structure for efficiently storing and retrieving texture resources of the present application is shown in the figure;

[0049] Figure 3 A first texture feature extraction method for calculating texture information in embodiment 2 of the present application is shown in the figure;

[0050] Figure 4 A first texture feature extraction method for calculating texture information in embodiment 3 of the present application is shown in the figure;

[0051] Figure 5 A second texture feature calculation method of the present application is shown in the figure. DETAILED DESCRIPTION

[0052] The present application will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0053] The following detailed description is exemplary and is intended to provide further details of the present application. Unless otherwise indicated, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the present application is only for the purpose of describing specific embodiments in accordance with the exemplary embodiments of the present application, and is not intended to limit the present application.

[0054] In order to facilitate the understanding of the schemes provided by the following embodiments of the present application, before describing the technical schemes provided by the present application, the terms related to the present application are first explained as follows:

[0055] Texture refers to an image resource attached to the surface of a model in two-dimensional or three-dimensional graphics rendering, used to give the model visual details, colors, lighting changes, concave and convex information, etc. Texture is usually stored in the form of an image file (such as PNG, DDS, KTX, etc.), containing pixel data (texels) and possibly containing metadata (such as resolution, compression method, mipmap level, etc.).

[0056] Three-dimensional engine refers to a software system that integrates rendering pipeline, physical simulation, resource management, animation playback, and interactive control modules, used to load, manage, and render three-dimensional scenes and their contents in real time. Typical engines include Unity, UnrealEngine, Godot, etc.

[0057] Texture feature refers to a data digest information extracted from a texture resource that can be used to uniquely identify or distinguish the content of the texture, commonly used for texture similarity judgment, deduplication optimization, and resource reuse.

[0058] Video memory, as a dedicated high-speed storage space for GPU, is mainly used to cache and render related data, including textures, geometry information, and frame buffers, etc. Its capacity is usually much smaller than that of the main memory, and cannot be expanded at will, especially in mobile devices, game consoles, or low-end hardware environments, the video memory limitation problem is particularly prominent. Therefore, how to efficiently manage and reuse texture resources in video memory has become the key to optimizing rendering performance.

[0059] Hierarchical index structure refers to an index mechanism that organizes texture features into a hierarchical structure according to different granularities (such as format level, content level) to speed up feature matching and texture lookup. It usually contains two levels of primary index (coarse features) and secondary index (fine features).

[0060] Further, it is known to those skilled in the art that in the field of modern computer graphics, texture loading and management has always been one of the core bottlenecks of the rendering performance of three-dimensional engines. With the rapid development of applications such as virtual reality, digital twin, open-world games, the complexity of three-dimensional scenes has increased dramatically, and the resolution and data volume of textures have also increased significantly. This makes the contradiction between limited video memory resources and increasingly large texture data increasingly prominent, becoming a key factor affecting rendering performance.

[0061] The data organization method of a three-dimensional model is usually to package model data together with the required texture resources. In particular, in a scene where multiple independent models share the same base texture material library, different model files often contain textures that are completely identical in content. Current mainstream three-dimensional engines generally use the process of first reading the texture file, decoding it, and then uploading it to the video memory when loading textures. To alleviate the pressure on video memory and improve loading efficiency, a variety of optimization techniques have been applied in the industry.

[0062] Texture compression techniques (such as ASTC, BCn, ETC, etc.) have been widely used to reduce the storage space and bandwidth consumption of individual texture files, and the best compression format can be dynamically selected according to hardware support. However, compression techniques can only improve the storage efficiency of individual textures and cannot automatically identify and remove redundant storage of textures that are completely identical across models. When multiple models reference the same base map (such as brick walls, metals, etc.), each will occupy independent space in the video memory, causing resource waste. Virtual texture (Virtual Texturing), sparse texture (Sparse Textures), or megatexture (Megatextures) techniques break through the limitation of video memory capacity on large-scale textures by dividing large textures into blocks and loading only the texture pages visible or about to be visible in the current viewport to the video memory. For example, patent CN113269882A proposes a terrain rendering scheme based on virtual textures, which can dynamically schedule texture pages through screen space sampling, thereby significantly reducing video memory usage. Although virtual texture technology has significant advantages in handling large-scale scenes, its optimization focus is on the dynamic loading of texture blocks rather than identifying and removing whole texture redundancies across models. Therefore, when different models carry the same map, these textures are still managed and loaded independently by the engine, and resource reuse cannot be achieved.

[0063] Some current texture deduplication techniques mainly focus on texture merging optimization within a single model, or rely on complex offline processing and runtime content comparison (such as full traversal and comparison). This approach brings great computational and I / O (input / output) pressure when facing large three-dimensional scenes with hundreds or even thousands of models and textures, making it difficult to achieve real-time and efficient cross-model texture content identification and reuse. There are also some general picture comparison methods that use similarity algorithms, such as pHash (Perceptual hashing). This method not only requires complete texture image reading and decoding, but also can cause some content with different texture images to be misjudged as repeated. In three-dimensional engine rendering, texture differences that cannot be seen will become seams, spots, and flicker during rendering. Therefore, similarity matching cannot be used in three-dimensional engines, and accurate matching is required.

[0064] Especially in large open-world games and high-precision virtual reality scenes, the content repetition rate of textures is extremely high. This repetition not only leads to a great waste of video memory, but also increases the overhead of texture loading, decoding, and I / O operations, thereby affecting the overall rendering efficiency and application startup speed of the system. Currently, the mainstream technology system lacks a lightweight and efficient online deduplication and reuse mechanism during multiple model loading stages, making it difficult to maximize the use of limited video memory resources.

[0065] In summary, current three-dimensional engines in texture management, although through texture compression and virtual texture, etc. have made progress in single texture compression rate, dynamic scheduling ability, etc., there are still significant technical shortcomings in cross-model identification and reuse of content consistent texture resources. There is an urgent need for a new method that can efficiently and dynamically complete texture deduplication and resource reuse during model loading to significantly improve video memory utilization and rendering performance.

[0066] The present application will be further described in detail below in conjunction with specific embodiments, but the embodiments of the present application are not limited thereto.

[0067] Embodiment 1

[0068] The present application finds that the existing three-dimensional engine lacks a cross-model texture content identification and deduplication method with high efficiency, scalability and accuracy in texture management technical solutions, especially cannot realize pre-judgment and resource reuse before the texture is decoded, causing waste of video memory, low loading efficiency and limited rendering performance. In order to solve the above problems, the present application provides a texture loading method based on a three-dimensional engine, which improves the efficiency of the three-dimensional engine during texture loading through intelligent texture loading and deduplication mechanism, and reduces the video memory occupation. The core idea of the method is to automatically identify the repeated part of the loaded texture during the three-dimensional model loading process, and skip the repeated texture loading, and directly use the loaded texture data. This technical innovation helps to significantly improve the rendering efficiency of the three-dimensional engine, reduce the use pressure of the video memory, and thus improve the rendering performance and overall user experience.

[0069] Specifically, as shown in Figure 1 The present application discloses a texture loading method based on a three-dimensional engine, comprising the following steps:

[0070] S101, before loading the texture resource, the three-dimensional engine extracts the undecoded texture part information from the texture resource, and calculates and constructs the first texture feature based on the texture part information;

[0071] S201, the three-dimensional engine queries whether there is a texture matching the first texture feature in the texture resource; when there is not, step S701 is executed; when there is, step S301 is executed;

[0072] S301, before loading the texture resource, the three-dimensional engine extracts the undecoded texture information from the specified window area of the texture resource, and calculates and constructs the second texture feature based on the texture information;

[0073] S401, the three-dimensional engine queries whether there is a texture matching the second texture feature in the texture matching the first texture feature; when there is not, step S701 is executed; when there is, step S501 is executed;

[0074] S501, the three-dimensional engine completely reads the texture data in the texture resource, and queries whether there is a texture identical to the texture matching the second texture feature; when there is not, step S701 is executed; when there is, step S601 is executed;

[0075] S601, the texture identical to the texture matching the second texture feature is directly loaded as the texture to be loaded, and the process ends;

[0076] S701, decode the texture in the texture resource, load the decoded texture to the three-dimensional engine, and load at least one of the first texture feature or the second texture feature to the three-dimensional engine.

[0077] Specifically, in the present embodiment, a three-dimensional engine is used to load and render a three-dimensional scene of a city, the scene containing a large number of buildings, each of which is a three-dimensional model, and all the models together have about 2000 textures. When the view angle moves, the three-dimensional models of the buildings and the textures therein are loaded according to the range visible in the viewport.

[0078] As shown in Figure 2 , a hierarchical index structure is maintained in the three-dimensional engine, and the hierarchical index structure includes:

[0079] a first mapping relationship for mapping the first texture feature to a secondary index structure corresponding to the first texture feature;

[0080] a second mapping relationship stored in the secondary index structure for mapping the second texture feature to a set of associated data. The set of associated data is used to store texture data entries matched with the first texture feature and / or the second texture feature, and each texture data entry includes texture data in a texture resource and a loaded texture. Thus,

[0081] The three-dimensional engine can quickly locate an existing texture data entry matched with the current loaded texture feature through the hierarchical index structure. When the three-dimensional engine receives a texture loading request, it first extracts the first texture feature of the texture, and uses the first mapping relationship to search the hierarchical index structure for a secondary index structure matched with the first texture feature. If a matched secondary index structure is found, the second mapping relationship is further used to search the secondary index structure for a texture data entry matched with the second texture feature. If a matched texture data entry is found, the texture data corresponding to the entry is directly used as the loaded texture, without the need for texture decoding and video memory uploading operations, thereby greatly saving video memory space and loading time. If a matched texture feature or texture data entry is not found in the first mapping relationship or the second mapping relationship, the texture is decoded and loaded into the video memory according to the traditional texture loading process, and the newly loaded texture feature and texture data entry are added to the hierarchical index structure for subsequent reuse. In this way, the present application realizes efficient and dynamic texture deduplication and resource reuse during three-dimensional model loading, significantly improving video memory utilization and rendering performance.

[0082] Embodiment 2

[0083] As shown in Figure 3 , in step S101, the method for calculating and constructing the first texture feature based on the texture partial information includes:

[0084] extracting the resolution of the texture in the texture partial information, the resolution including width and height;

[0085] extracting a picture type of the texture in the texture part information, the picture type being a jpeg type or a png type;

[0086] extracting a color space of the texture in the texture part information;

[0087] extracting a file size of the texture in the texture part information;

[0088] extracting a sampling mode of the texture in the texture part information, the sampling mode being at least one of a texture magnification filter, a texture minification filter, a texture coordinate horizontal padding, a texture coordinate vertical padding;

[0089] calculating a first texture feature according to the extracted resolution, the picture type, the sampling mode, the color space and the file size.

[0090] Further, in the specific implementation process, the specific steps of calculating the first texture feature are:

[0091] 1. extracting a width and a height of the texture as 16-bit unsigned integers, and if there is a value that exceeds the value that can be represented by the 16-bit unsigned integer, taking the maximum value that can be represented by the 16-bit unsigned integer;

[0092] 2. extracting a picture type of the texture, taking the jpeg type as 1, the png type as 2, the webp type as 3, the dds type as 4, the tga type as 5, the tiff type as 6, the exr type as 7, the ASTC type as 8, the BCn type as 9, the ETC type as 10, and other types as 0, as 8-bit unsigned integers;

[0093] 3. extracting a sampling mode of the texture, the sampling mode including any one of the following 3.1-3.5:

[0094] 3.1. extracting a texture magnification filter, the value taking mode being shown in Table 1 below, as 8-bit unsigned integers;

[0095] 3.2. extracting a texture minification filter, the value taking mode being shown in Table 1 below, as 8-bit unsigned integers;

[0096] 3.3. extracting a texture coordinate horizontal padding, taking repetition as 1, clamping to the edge of the texture as 2, mirroring repetition as 3, and other as 0, as 4-bit unsigned integers;

[0097] 3.4. extracting a texture coordinate vertical padding, the value taking mode being the same as 3.3, as 4-bit unsigned integers;

[0098] 3.5. concatenating the extracted texture magnification filter, the texture minification filter, the texture coordinate horizontal padding and the texture coordinate vertical padding in binary, which is the sampling mode;

[0099] 4. The extracted resolution, picture type, and sampling method are combined in binary form to form a 64-bit unsigned integer, which is the first texture feature, as shown in Table 2.

[0100] Table 1: Value mode of texture magnification filter and texture reduction filter

[0101] Types of texture magnification and minification filters Values Corresponding OpenGL enumeration Nearest neighbor interpolation, take the nearest pixel when magnifying a texture 1 GL_NEAREST Linear interpolation, take the average of surrounding pixels when magnifying a texture 2 GL_LINEAR Select MIP level using nearest neighbor interpolation and select 3 GL_NEAREST_MIPMAP_NEAREST Select MIP level using linear interpolation and nearest neighbor MIP mapping 4 GL_LINEAR_MIPMAP_NEAREST Select MIP level using nearest neighbor interpolation and apply MIP mapping with linear interpolation 5 GL_NEAREST_MIPMAP_LINEAR Select MIP level using linear interpolation and linear interpolation MIP mapping 6 GL_LINEAR_MIPMAP_LINEAR Other 0 Other

[0102] Table 2: Binary arrangement of the first texture feature

[0103] Bits 0~15 16~31 32~39 40~47 48~55 56~59 60~63 Contents Width of the texture Height of the texture Picture type Texture magnification filter Texture minification filter Horizontal fill mode for texture coordinates Vertical fill mode for texture coordinates

[0104] Further, in step S201, it is checked whether there is a texture matching the first texture feature in the three-dimensional engine. If not, jump to the specific steps of step S701:

[0105] 1. Find the secondary index structure matching the first texture in the first-level mapping of the hierarchical index structure.

[0106] 2. If there is no matching secondary index structure, jump to step S701. Further, the first-level mapping of the hierarchical index structure is implemented using a thread-safe hash table. Further, in step S301, the method for constructing the second texture feature based on texture information in step S301 includes the following steps:

[0107] S302, skip the picture file header of the texture, and the skip length can be adaptively adjusted according to the file size of the texture and the format of the texture; wherein, in the specific implementation process, if the picture file size of the texture is greater than 128 bytes, the first 128 bytes of data of the picture file of the texture are skipped, otherwise, no skipping is performed. If the remaining size of the picture file of the texture after skipping the picture file header of the texture is greater than 256 bytes, read 256 bytes of data backward, otherwise, read all data of the picture file of the texture.

[0108] S303, read a small amount of data backward.

[0109] S304, calculate a fixed-size second texture feature from the small amount of data.

[0110] As a further improvement to the three-dimensional engine-based texture loading method of the present application, in step S303, the step of calculating a fixed-size second texture feature from a small amount of data is: using a hash algorithm to calculate the hash value of the small amount of data, and the hash value is the second texture feature; in the specific implementation process, the xxHash algorithm with a bit width of 64 bits is used to calculate the hash value of the read 256 bytes of data, and the obtained result is a 64-bit unsigned integer, which is the second texture feature.

[0111] The hash algorithm is CRC (Cyclic Redundancy Check) or xxHash.

[0112] As a further improvement of the texture loading method based on a three-dimensional engine, the step of calculating a second texture feature of a fixed size from a small amount of data is: block processing the small amount of data according to a fixed size, and performing an XOR operation on each data bit by bit, and the XOR operation result is the second texture feature.

[0113] Further, in the step S401, the three-dimensional engine is used to query whether there is a texture matching the second texture feature in the texture matching the first texture feature, and if not, jump to the specific step S701:

[0114] 1. Find a matching associated data set in the second level mapping of the secondary index structure;

[0115] 2. If there is no matching associated data set, jump to step S701.

[0116] Among them, the second level mapping of the secondary index structure is implemented using a thread-safe hash table.

[0117] Further, the texture data is completely read and compared with the texture matching the second texture feature to check whether there is a texture with the same texture data in the texture matching the second texture feature, and if not, jump to the specific step S701:

[0118] 1. Read the texture data in binary form;

[0119] 2. In the matching associated data set found in step S401, find an entry that exactly matches the texture data read;

[0120] 3. If not, jump to step S701.

[0121] Further, in the step S701, the texture data is decoded, and the decoded texture, the first texture feature, and the second texture feature are loaded into the three-dimensional engine. The specific steps are:

[0122] 1. Decode the texture data to obtain the decoded texture;

[0123] 2. Load the decoded texture into the three-dimensional engine to obtain the loaded texture;

[0124] 3. Find a secondary index structure matching the first texture in the first level mapping of the hierarchical index structure;

[0125] 4. If there is no matching secondary index structure, create a secondary index structure containing second-level mappings and add it to the hierarchical index structure, associated with the first texture feature;

[0126] 5. Look up a matching associated data set in the second-level mappings of the secondary index structure;

[0127] 6. If there is no matching associated data set, create an empty associated data set and add it to the second-level mapping, associated with the second texture feature;

[0128] 7. Add the texture data and the loaded texture to the matching associated data set.

[0129] Other than the same as Embodiment 1, this embodiment will not be repeated.

[0130] Embodiment 3

[0131] Different from Embodiment 1: In this embodiment, a three-dimensional engine is used to load and render an industrial park scene, which contains a large number of devices, each of which is a three-dimensional model, and the device contains a large number of parts, and the textures used by the parts are mostly derived from a basic texture material library, and there are about 3000 textures in all models, but most of them are repeated textures. When the view angle moves, the three-dimensional model of the device and the texture in it are loaded according to the range visible in the viewport.

[0132] Specifically, the device three-dimensional model uses the glb format. The size of the textures in the basic texture material library used is mostly 512x512 or 1024x1024, and more texture information needs to be extracted to increase the discrimination of the first texture feature.

[0133] Further, as shown in Figure 4 , in step S101, the specific steps of calculating the first texture feature are:

[0134] 1. Extract the width and height of the texture as a 32-bit unsigned integer;

[0135] 2. Extract the picture type of the texture, the specific method is to extract the extension name of the texture file, for file formats with multiple extension names, such as jpeg, take the shortest extension name, for example,.jpeg ->.jpg;

[0136] 3. Extract the sampling method of the texture

[0137] 3.1. Extract the texture magnification filter, take the original value in the model as a 16-bit unsigned integer;

[0138] 3.2. Extract the texture minification filter, take the original value in the model as a 16-bit unsigned integer;

[0139] 3.3. Extract the texture coordinate horizontal padding, take the original value in the model as a 16-bit unsigned integer;

[0140] 3.4. Extract the texture coordinate vertical padding, take the original value in the model as a 16-bit unsigned integer;

[0141] 3.5. The extracted texture magnification filter, texture minification filter, texture coordinate horizontal padding, and texture coordinate vertical padding are the sampling mode;

[0142] 4. Extract the color space of the texture, linearly recorded as 1, sRGB recorded as 2, and others recorded as 0, as an 8-bit unsigned integer;

[0143] 5. Extract the file size of the texture, recorded by the number of bytes, as a 64-bit unsigned integer;

[0144] 6. Convert the extracted resolution, picture type, sampling mode, color space, and file size into a string, where the integer is converted to decimal, and the converted string is connected at the beginning and end with a half-width colon “:” as a separator to obtain a connected string;

[0145] 7. Convert the connected string into binary data according to UTF-8 encoding, calculate the hash value of the binary data using the xxHash algorithm with a bit width of 128 bits, and the result is a 128-bit (16-byte) feature value, which is the first texture feature.

[0146] Further, in step S301, the specific steps for calculating the second texture feature are:

[0147] 1. If the picture file size of the texture is greater than 256 bytes, skip the first 256 bytes of data of the picture file of the texture, otherwise, if the picture file size of the texture is greater than 128 bytes, skip the first 128 bytes of data of the picture file of the texture, otherwise, do not skip;

[0148] 2. If the remaining size of the picture file of the texture after skipping the picture file header is greater than 256 bytes, read 256 bytes of data backward, otherwise, read all data of the picture file of the texture;

[0149] 3. Divide the read 256 bytes of data into 8 blocks of 32 bytes, and perform XOR operation on the 8 blocks in turn, and the obtained 32 bytes of data are the second texture feature.

[0150] Other than the same as in Embodiment 1, this embodiment will not be described again.

[0151] Those skilled in the art will appreciate that embodiments of the application can be readily used as a method, a system or a computer program product. Accordingly, the application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) embodying computer readable program code thereon.

[0152] The application is described in relation to flowcharts and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It is to be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as combinations of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of an apparatus, such as a general purpose computer, special purpose computer, embedded processor, or Figure 1 one or more flows and / or blocks Figure 1 means for performing the function specified by one or more blocks

[0153] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flow Figure 1 one or more flows and / or blocks Figure 1 means for performing the function specified by one or more blocks

[0154] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow Figure 1 one or more flows and / or blocks Figure 1 means for performing the function specified by one or more blocks

[0155] Finally, it should be noted that the above-mentioned embodiments illustrate rather than limit the application, since the scope of the application is given by the appended claims.

Claims

1. A method for texture loading based on a three-dimensional engine, characterized in that, The method comprises the following steps: S101, before loading a texture resource, a three-dimensional engine extracts undecoded texture part information from the texture resource, and calculates a first texture feature based on the texture part information; S201, the three-dimensional engine queries whether there is a texture matching the first texture feature in the texture resource; when there is not, step S701 is executed; when there is, step S301 is executed; S301, before loading the texture resource, the three-dimensional engine extracts undecoded texture information from a specified window area of the texture resource, and calculates a second texture feature based on the texture information; S401, the three-dimensional engine queries whether there is a texture matching the second texture feature in the texture matching the first texture feature; when there is not, step S701 is executed; when there is, step S501 is executed; S501, the three-dimensional engine completely reads texture data in the texture resource, queries whether there is a texture identical to the texture matching the second texture feature; when there is not, step S701 is executed; when there is, step S601 is executed; S601, the texture identical to the texture matching the second texture feature is directly loaded as a texture to be loaded, and the process ends; S701, the texture in the texture resource is decoded, and the decoded texture is loaded into the three-dimensional engine, and at least one of the first texture feature or the second texture feature is loaded into the three-dimensional engine; The three-dimensional engine maintains a hierarchical index structure, and the hierarchical index structure comprises: A first mapping relationship, used for mapping the first texture feature to a secondary index structure corresponding to the first texture feature; A second mapping relationship, stored in the secondary index structure, used for mapping the second texture feature to an associated data set; The associated data set is used for storing texture data entries matching the first texture feature and / or the second texture feature, and each texture data entry comprises texture data in a texture resource and a loaded texture.

2. The method of claim 1, wherein, In the step S101, the method for calculating and constructing the first texture feature based on the texture part information comprises: extracting a resolution of the texture in the texture part information, the resolution comprising a width and a height; extracting a picture type of the texture in the texture part information, the picture type being a jpeg type or a png type; extracting a sampling mode of the texture in the texture part information, the sampling mode being at least one of a texture enlargement filter, a texture reduction filter, a horizontal filling of texture coordinates, and a vertical filling of texture coordinates; calculating the first texture feature according to the extracted resolution, picture type, and sampling mode.

3. The method of claim 2, wherein, The method for calculating and constructing the first texture feature based on the texture part information further comprises: extracting a color space of the texture in the texture part information; extracting file size information of the texture in the texture part information; calculating the first texture feature according to the extracted resolution, picture type, sampling mode, color space, and file size.

4. The method of claim 1, wherein, In the step S301, the method for calculating the second texture feature based on the texture information comprises the following steps: S302, skipping the picture file header of the texture, and the skipping length can be adaptively adjusted according to the file size of the texture and the format of the texture; S303, reading a small amount of data backwardly; S304, calculating the second texture feature of a fixed size through the small amount of data.

5. The method of claim 4, wherein, In the step S303, the step of calculating the second texture feature of a fixed size through the small amount of data is: using a hash algorithm to calculate the hash value of the small amount of data, and the hash value is the second texture feature; The hash algorithm is CRC cyclic redundancy check or xxHash.

6. The method of claim 5, wherein, The step of calculating the second texture feature of a fixed size through the small amount of data is: dividing the small amount of data into blocks according to a fixed size, performing XOR operation on each data bit by bit, and the XOR operation result is the second texture feature.

7. An electronic device, comprising: Comprise: a memory for storing a computer program; a processor for executing the computer program to realize the steps of the method for loading a texture based on a three-dimensional engine according to any one of claims 1 to 6.

8. A computer-readable storage medium, characterized in that, The computer program is stored on the computer readable storage medium, and the computer program is executed by the processor to realize the steps of the method for loading a texture based on a three-dimensional engine according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Terrain rendering scheme and system based on virtual texture

    CN113269882A

  • Building group rendering method and device, computer equipment and storage medium

    CN116883575A

  • Simulation scene rendering optimization method

    CN120198562A