A method and system for memory optimization with alterable texture
By filtering and compressing the texture display products in the web 3D program, the problem of page crashes caused by insufficient memory on low-end devices was solved, achieving efficient memory optimization and stable operation.
Patent Information
- Application Number
- CN202511212675.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-08-28
AI Technical Summary
In web-based 3D applications, low-end devices have limited memory. When modifying textures during runtime, excessive memory usage can easily lead to page crashes. Existing pixel replacement and texture copying methods are insufficient in terms of performance and memory usage.
By selecting and optimizing target textures to display products, the PVRTexTool is used to convert JPG or PNG image files into compressed textures supported by the target platform. The texture parameters are then combined and compressed to generate PVR files. Texture instances are then decoded and created during program execution for modification and rendering.
It optimizes memory usage, improves processing efficiency, is suitable for a wide range of hardware and platforms, and ensures stable operation on low-end devices.
Smart Images

Figure CN120725856B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of image processing, and particularly relates to a memory optimization method and system capable of changing textures. BACKGROUND
[0002] In a web 3D program, 2D textures of images need to be used to display scenes customized by users, for example, in a kitchen scene, users can customize the style design, furniture arrangement, furniture model, etc. in the kitchen scene. However, it is found in the project development process that when the textures are changed in runtime, the web page often crashes due to too large memory occupation because the memory of some low-end devices is small.
[0003] To solve the above technical problems, the prior art often uses a pixel replacement method or a texture replication method to change the textures. However, the above technical solutions have the following technical problems:
[0004] When the pixel replacement method is used to modify the textures, all operations are performed on the CPU. When high-resolution textures are processed, the performance is low, compressed textures cannot be used, the memory occupation is high, and the overall processing efficiency is low. In mobile devices, the GPU does not have a dedicated display memory, and shares the memory with the CPU. Therefore, a texture will occupy double memory. Taking a 512*512 png image as an example, if the modification problem is not considered, the size of the image in the memory (display memory) without compression is about 1MB (512*512*4). The size of the image in the compressed format (taking the DXT5 format under the Windows platform as an example) is about 44.9KB, which is only about 4.4% of the former. A large number of textures are used in the project to display products. It can be seen that the low-end mobile devices with small memory are not friendly, and all textures in the project are created in runtime. The compressed format supported by the target platform cannot be set by the import setting of the engine, and the textures cannot be compressed in the program in runtime.
[0005] When the texture replication method is used to modify the textures, the processing performance is high. However, the textures need to meet the requirements according to the situation, the texture type of the texture modification target must be the RenderTexture type (a texture type for GPU rendering in the Unity engine), which will bring additional memory occupation, and the texture replication process needs to be supported by the device. For mobile web, the use is often not supported.
[0006] To solve the above technical problems, the application provides a memory optimization method and system capable of changing textures. SUMMARY
[0007] To achieve the object of the application, the application adopts the following technical solutions:
[0008] Specifically, the application provides a memory optimization method for changing texture, specifically comprising the following steps:
[0009] S1, based on the image file of the texture display product data in different scenes, the optimization target of the texture display product is screened, the image file of the optimization target is compressed to obtain original texture data, the original texture data and the texture parameters are combined according to a preset rule to obtain an original file, and whether compression processing is needed is determined according to the texture display product data in the scene corresponding to the original file, so as to obtain a texture file;
[0010] S3, when the texture is modified, the texture instance of the texture modification target is obtained, the pixel block of the original texture data of the original texture instance is modified based on the original texture data of the texture modification target, the texture file of the texture modification target and the modified original texture data are written into a data container pointing to the memory, and the data in the data container is read by the processor to perform rendering processing of the modified texture target.
[0011] The application has the advantages that:
[0012] The application mainly optimizes the problem of high memory occupation, and has better processing efficiency compared with the pixel-by-pixel modification of the prior art.
[0013] The method is implemented by pure code and does not depend on any hardware and platform, and has very wide application scenarios.
[0014] Further, the optimization target of the texture display product in different scenes is screened, specifically comprising the following steps:
[0015] All the texture display products in the scene are taken as optimization targets.
[0016] Further, the original texture data is obtained, specifically comprising the following steps:
[0017] The image file in jpg or png format is converted into a compressed texture supported by the target platform by using a PVRTexTool tool to obtain the original texture data.
[0018] Specifically, the PVRTexTool tool is a batch texture compression tool.
[0019] Further, it is determined whether compression processing is needed, specifically comprising the following steps:
[0020] The texture display product data in the scene corresponding to the original file of the optimization target is determined to perform the optimization target data in the scene, and the texture display product not belonging to the optimization target in the scene is determined based on the optimization target data.
[0021] determining the similarity of the pixel blocks of the original texture data corresponding to the original file of the optimization target with the pixel blocks of the original texture data corresponding to other optimization targets in the scene based on the pixel blocks of the original texture data corresponding to the original file of the optimization target, and determining the same number of pixel blocks between the optimization target and other optimization targets based on the similarity;
[0022] determining whether the original file needs to be compressed based on the texture display product data in the scene that does not belong to the optimization target and the same number of pixel blocks between the optimization target and other optimization targets.
[0023] It can be understood that when the number of texture display products in the scene that do not belong to the optimization target does not meet the requirement, that is, the memory processing pressure in the scene is large at this time, and therefore the original files of all optimization targets need to be compressed, in a possible embodiment, when the number of texture display products in the scene that do not belong to the optimization target is more than 15, it is determined that the number of texture display products in the scene that do not belong to the optimization target does not meet the requirement.
[0024] In addition, it should be noted that when the number of texture display products in the scene that do not belong to the optimization target meets the requirement, at this time the memory processing pressure in the scene is not large, and therefore if the same number of pixel blocks between the optimization target and other optimization targets all meet the requirement, that is, the proportion of the same number in the pixel blocks of the original texture data corresponding to the original file of the optimization target is more than 0.3, at this time the other optimization targets are converted to the optimization target, the original file of the optimization target is not compressed, and the same number of pixel blocks between the optimization target and other optimization targets does not meet the requirement, at this time the original file of the optimization target is compressed.
[0025] Further, the specific steps of constructing the texture file are as follows:
[0026] The original texture data is obtained pvr file, according to the encoding rule of pvr file, the compressed texture data is intercepted, and the texture parameters are combined according to the self-defined encoding rule, if the compression tool is used for further compression, the compression information needs to be written additionally for decompression, and then the final texture file data is obtained, written into the file and saved, that is, the final texture file is obtained.
[0027] It should be noted that the pvr file is the file converted by the PVRTexTool tool.
[0028] Further, if no further compression is performed using the compression tool, then the pvr file combined with the texture parameters according to the custom encoding rule is directly used as the texture file.
[0029] Further, the texture file includes the width of the texture, the height of the texture, whether the texture has a transparent channel, and original texture data.
[0030] Specifically, the specific steps of constructing the texture instance of the texture modification target are as follows:
[0031] During the running of the program, after obtaining the texture file of the texture modification target, the texture data is obtained by decompression using the compression tool, and the texture parameters are decoded to create a texture instance.
[0032] Further, the rendering processing of the modified texture target is performed, and specifically includes:
[0033] The business interface is called to load the original texture data and the texture parameters after the modification processing and to apply them, so that the texture available in the program is obtained, and the rendering processing of the modified texture target is implemented.
[0034] In a second aspect, the application provides a memory optimization system capable of changing textures, which is applied to the memory optimization method capable of changing textures, and specifically includes:
[0035] The scene screening module is responsible for determining the texture display product data based on the texture display product in the scene, and determining the memory optimization scene in the scene based on the memory occupation data of the texture display product.
[0036] The target identification module is responsible for determining the basic screening target in the memory optimization scene based on the similarity of the pixel blocks of the original texture data of the texture display product in the memory optimization scene.
[0037] The target screening module is responsible for determining the optimization target in the basic screening target based on the common data of the basic screening target in different scenes and the constituent data of the basic screening target.
[0038] The optimization target determination module is responsible for determining the screening optimization target in the texture display product in the scene based on the constituent data of the optimization target in the scene and the use data of the texture display product in the scene except the memory optimization scene, and taking the screening optimization target and the optimization target as the optimization target in the scene.
[0039] Further, the memory occupation data of the texture display product is determined according to the memory occupation amount when the image of the texture display product is modified.
[0040] Further, the method for determining the optimization target in the basic screening target is:
[0041] With the universal data of the basic screening target in different scenes, the scene where the basic screening target exists is determined and taken as a target matching scene;
[0042] Based on the constituent data of the basic screening target in the target matching scene, the texture display product in the target matching scene except the basic screening target is determined and taken as a remaining display product;
[0043] According to the constituent data of the remaining display product in each target matching scene, the scene in the target matching scene which does not need to be optimized is determined, and whether the basic screening target is an optimization target is determined based on the distribution of the scene which does not need to be optimized in the target matching scene.
[0044] Other features and advantages will be set forth in the following description of the application, and in part will be apparent from the description and the accompanying drawings, or can be learned by practice of the application as claimed in the claims.
[0045] In order to make the above-mentioned objects, features and advantages of the present application more apparent, the following preferred embodiments are specifically described with reference to the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0046] The above and other features and advantages of the present application will become more apparent by describing in detail exemplary embodiments thereof with reference to the attached drawings in which:
[0047] Figure 1 It is a flow chart of a memory optimization method which can change texture;
[0048] Figure 2 It is a flow chart of image preprocessing;
[0049] Figure 3 It is a flow chart of reading image to create texture;
[0050] Figure 4 It is a flow chart of modifying texture;
[0051] Figure 5 It is an original pixel distribution map;
[0052] Figure 6 It is a flow chart of determining whether compression processing is needed;
[0053] Figure 7 It is a structure diagram of a memory optimization system which can change texture. DETAILED DESCRIPTION
[0054] In order for those skilled in the art to better understand the technical solutions in the specification, the technical solutions in the specification will be clearly and completely described below in combination with the drawings in the specification. Obviously, the described embodiments are only part of the embodiments of the specification, not all. Based on the embodiments of the specification, all other embodiments obtained by those of ordinary skill in the art without creative labor should be within the scope of protection of the specification.
[0055] In the web 3D program, it is necessary to use 2D texture to display the user-defined scene, for example, in the kitchen scene, the user can customize the style design, furniture placement, furniture model, etc.
[0056] Technical background: In the process of project development, it is found that some low-end devices have small memory, and when operating the changeable texture, the webpage page often crashes due to large memory occupation. Taking iPhoneX as an example, the device has a memory of 2GB, which generally cannot meet the running requirements, but after optimization using the technology, it can run smoothly. The coverage of the program running device is effectively improved, and more potential economic benefits are explored.
[0057] The most similar existing implementation scheme (prior art) to the present application is:
[0058] Technical solution 1: modify the texture using the pixel replacement method
[0059] Taking the Unity engine used in the project development as an example, after importing images such as JPG and PNG into texture resources, select the compression format as uncompressed in the related setting window, and open the Read / Write setting option, then you can use the API provided by the Unity engine: Texture2D.GetPixel or Texture2D.GetPixel32 method to obtain the pixel data of the texture, after customizing the pixel data, use the Texture2D.SetPixel or Texture2D.SetPixel32 method to set the pixel data of the texture, thus achieving the purpose of modifying the texture.
[0060] Technical solution 2: use texture replication technology
[0061] Taking the Unity engine used in project development as an example, the API: Graphic.Blit or Graphic.CopyTexture method provided by the Unity engine can be used to perform the texture copying operation at runtime, copy the A texture into the B texture, and the Shader can be used for custom operation in the Blit process. The Shader is written to realize the function of pixel replacement for the copying process, so as to achieve the purpose of modifying the texture.
[0062] When the method in technical solution 1 is used to modify the texture, all operations are performed on the CPU, and when a high-resolution texture is processed, the performance is low, compressed textures cannot be used, the memory occupation is high, and the overall processing efficiency is low.
[0063] In a mobile device, the GPU does not have a dedicated display memory, and shares the memory with the CPU, so a texture will occupy double the memory.
[0064] Taking a 512 × 512 png image as an example, if the modification problem is not considered, its size in memory (video memory) without compression is about 1MB (512 × 512 × 4), and the size of the compressed format (taking the DXT5 format under the Windows platform as an example) is about 44.9KB, which is only about 4.4% of the former. A large number of textures are used in the project to display products, which is very unfriendly to low-end mobile devices with small memory, and all textures in the project are created at runtime, and cannot be set to the compressed format supported by the target platform using the import settings of the engine. The program cannot compress the texture during running.
[0065] When the method in technical solution 2 is used to modify the texture, the processing performance is high, but the texture needs to meet its requirements according to the situation, the Blit target texture must be of the RenderTexture type, which will bring additional memory occupation, and the CopyTexture needs to be supported by the device (the platform of the project is a mobile terminal webpage, which does not support the use)
[0066] The present application mainly optimizes the high memory occupation problem, and has certain advantages in performance compared with the pixel-by-pixel modification of technical solution 1.
[0067] Embodiment 1
[0068] As shown in Figure 1 The present application provides a memory optimization method for changing texture, specifically including:
[0069] S1 is based on the image file of the texture display product data in different scenes of the texture display product optimization target screening, the image file of the optimization target is compressed to obtain the original texture data, and the original texture data and the texture parameters are combined according to the preset rule to obtain the original file, and the texture display product data in the scene corresponding to the original file is used to determine whether compression processing is needed, so as to obtain the texture file;
[0070] S3, when the texture is modified, the texture instance of the texture modification target is obtained, the pixel block of the original texture data of the original texture instance is modified based on the original texture data of the texture modification target, the texture file of the texture modification target and the modified original texture data are written into the data container pointing to the memory, and the data in the data container is read by the processor to perform rendering processing of the modified texture target.
[0071] In one possible embodiment:
[0072] As Figure 2 shown, a flowchart for image preprocessing, the image file in jpg or png format is converted into a compressed texture supported by the target platform using the PVRTexTool tool, taking a development project as an example, the main target platform is a mobile terminal webpage, which can be converted into an ETC_2 texture. The tool will generate a pvr file, according to the encoding rule of the pvr file, the compressed texture data is intercepted, and the texture parameters are combined according to the self-defined encoding rule, if LZ4 is used for further compression (this step can be selected according to the actual situation, and omitted to improve the loading performance of the texture), additional compression information is written for decompression, and then the final texture file data is obtained, written into a file and saved, that is, the final texture file is obtained.
[0073] Taking a development project as an example, the final texture file, the first 4 bytes (int32) represent the data length after LZ4 compression, and the remaining data is compressed data. After decompression, 0-3 bytes (uint32) represent the width of the texture, 4-7 bytes (uint32) represent the height of the texture, 8-11 bytes (uint32) represent whether the texture has a transparent channel, and the remaining data is the texture data.
[0074] As Figure 3 shown, a flowchart for reading image to create texture, after obtaining the texture file in the above steps (network download, local loading, etc.), the texture data is obtained by using LZ4 decompression (according to the above selection), the texture parameters are decoded to create a texture instance, the API is called to load and apply the decoded texture data, and the texture available in the program is obtained.
[0075] As Figure 4As shown in the flow chart for modifying the texture, the API is called to replace the pixel block data in the target texture and apply it, that is, the modification of the texture is completed. Taking ETC_2 used in the project as an example, the pixel block data layout is as follows Figure 5 As shown in the original pixel distribution diagram, each block is 4x4 pixels, and different formats differ. Continue to adjust the relevant pixels to be replaced according to the actual situation.
[0076] Specifically, the selection of the optimization target of the texture display product in different scenes is performed, specifically including:
[0077] All texture display products in the scene are taken as optimization targets.
[0078] Optionally, the selection of the optimization target of the texture display product in different scenes is performed, specifically including:
[0079] When the number of texture display products in the scene meets the requirement, all texture display products in the scene are not taken as optimization targets.
[0080] When the number of texture display products in the scene does not meet the requirement, the memory data of the image file of the texture display product is used as the basis to determine the optimization target in the scene.
[0081] It can be understood that the memory data of the image file of the texture display product in the scene is sorted from large to small, and the top preset number of texture display products in the sorting result are selected as the optimization target in the scene.
[0082] Optionally, the selection of the optimization target of the texture display product in different scenes is performed, specifically including:
[0083] The number of texture display products in the scene is determined based on the texture display product data in the scene.
[0084] Based on the similarity of the original texture data between the texture display products, the same number of pixel blocks of the original texture data of the texture display product and other texture display products is determined.
[0085] Based on the same number of pixel blocks of the original texture data of the texture display product and other texture display products and the number of texture display products, it is determined whether the texture display product is an optimization target.
[0086] It can be understood that based on the same number of pixel blocks of the original texture data of the texture display product and other texture display products and the number of texture display products, it is determined whether the texture display product is an optimization target, specifically including:
[0087] When the number of the texture display products in the scene meets the requirement, all the texture display products in the scene are not the optimization target;
[0088] When the number of the texture display products in the scene does not meet the requirement, the texture display products are divided into different combinations based on the same number of pixel blocks of the principle texture data of the texture display products, and the optimization target in the scene is determined based on the same number of pixel blocks of the principle texture data of the texture display products between different combinations.
[0089] In one possible embodiment, when the number of the texture display products in the scene is less than 20, it is determined that the number of the texture display products in the scene meets the requirement.
[0090] In addition, it is to be noted that when the number of the texture display products in the combination meets the requirement, i.e. more than 3, the texture display products in the combination are determined as the optimization target, and when the number of the texture display products in the combination does not meet the requirement, the texture display products in the combination are determined as the optimization target when the number of similar combinations in which the number of the texture display products in the combination meets the requirement is more than 2.
[0091] Further, the original texture data is obtained, and specifically includes:
[0092] The image file in jpg or png format is converted into compressed texture supported by the target platform by using the PVRTexTool tool to obtain the original texture data.
[0093] Specifically, the PVRTexTool tool is a batch processing texture compression tool.
[0094] Specifically, as shown in Figure 6 whether compression processing is required is determined, and specifically includes:
[0095] The texture display product data in the scene corresponding to the original file of the optimization target is determined to be the optimization target data in the scene, and the texture display products in the scene that do not belong to the optimization target are determined based on the optimization target data;
[0096] Based on the pixel blocks of the original texture data corresponding to the original file of the optimization target, the similarity of the pixel blocks of the original texture data corresponding to other optimization targets in the corresponding scene is determined, and the same number of pixel blocks between the other optimization targets is determined based on the similarity.
[0097] determining whether the original file needs to be compressed based on the number of texture display products in the scene that do not belong to the optimization target and the same number of pixel blocks between the other optimization targets.
[0098] It can be understood that when the number of texture display products in the scene that do not belong to the optimization target does not meet the requirement, that is, the memory processing pressure in the scene is large at this time, and therefore the original files of all optimization targets need to be compressed, in a possible embodiment, when the number of texture display products in the scene that do not belong to the optimization target is more than 15, it is determined that the number of texture display products in the scene that do not belong to the optimization target does not meet the requirement.
[0099] In addition, it should be noted that when the number of texture display products in the scene that do not belong to the optimization target meets the requirement, at this time the memory processing pressure in the scene is not large, and therefore if the same number of pixel blocks between the other optimization targets all meet the requirement, that is, the proportion of the same number in the pixel blocks of the original texture data corresponding to the original file is more than 0.3, at this time the other optimization targets are converted to the smaller modification range of the pixel blocks of the original texture data corresponding to the original file, which makes it necessary to maintain the details as much as possible, and therefore the original file of the optimization target is not compressed, and when the same number of pixel blocks between the other optimization targets does not meet the requirement, at this time the original file of the optimization target is compressed.
[0100] Further, the specific steps of constructing the texture file are:
[0101] The original texture data is obtained to obtain a pvr file, according to the encoding rule of the pvr file, the compressed texture data therein is intercepted, and the texture parameters are combined according to the self-defined encoding rule, if a compression tool is used for further compression, additional compression information needs to be written for decompression, and then the final texture file data is obtained, written into a file and saved, and the final texture file is obtained.
[0102] It should be noted that the pvr file is a file converted by the PVRTexTool tool.
[0103] Further, if the compression tool is not used for further compression, the pvr file combined with the texture parameters according to the self-defined encoding rule is directly used as the texture file.
[0104] Further, the texture file includes the width of the texture, the height of the texture, whether the texture has a transparent channel, and the original texture data.
[0105] Specifically, the specific steps of constructing the texture instance of the texture modification target are:
[0106] During program execution, after obtaining the texture file of the texture modification target, a compression tool is used to decompress and obtain the texture data, and the texture parameters are decoded to create a texture instance.
[0107] Further, the rendering process of modifying the texture target is performed, specifically including:
[0108] The business interface is called to load the decoded and modified original texture data and texture parameters, which are then sent to the graphics card and applied. This yields a usable texture for the program, enabling the rendering of the modified texture target.
[0109] Example 2
[0110] Secondly, such as Figure 7 As shown, this application provides a memory optimization system with modifiable textures, applied to the aforementioned memory optimization method with modifiable textures, specifically including:
[0111] The scene filtering module is responsible for determining the texture display product data based on the texture display products in the scene, and determining the memory optimization scene in the scene based on the memory usage data of the texture display products.
[0112] The target recognition module is responsible for determining the similarity of pixel blocks in the original texture data of the product in the memory optimization scenario, and identifying the basic screening targets in the memory optimization scenario.
[0113] The target filtering module is responsible for determining the optimized targets among the basic filtering targets based on the general data of the basic filtering targets in different scenarios and the constituent data of the basic filtering targets;
[0114] The optimization target determination module is responsible for determining the selection optimization targets in the texture display product of the scene based on the composition data of the optimization targets in the scene and the usage data of the texture display product in the scene excluding the memory optimization scene, and using the selection optimization targets and the optimization targets as the optimization targets in the scene.
[0115] Specifically, the memory usage data of the texture display product is determined based on the memory usage when the image of the texture display product is modified.
[0116] Furthermore, the method for determining the memory optimization scenario in the aforementioned scenario is as follows:
[0117] Based on the memory usage data of the texture display product, determine the memory usage of the texture display product in the scene during the process of texture modification;
[0118] determine whether the scene is a memory-optimized scene based on the texture display product whose memory usage does not meet the requirement.
[0119] determine whether the scene is a memory-optimized scene based on the texture display product whose memory usage does not meet the requirement.
[0120] It can be understood that when the memory usage is too large, it is determined that the memory usage of the texture display product does not meet the requirement. In one possible embodiment, the texture display product whose memory usage is greater than 100 MB is regarded as the texture display product whose memory usage does not meet the requirement.
[0121] It should be noted that when the number of the texture display products whose memory usage does not meet the requirement in the scene is too large, the modification process of the texture features of the texture display products in the scene will cause the memory usage to be too large. Therefore, the scene is regarded as a memory-optimized scene. Specifically, when the number of the texture display products whose memory usage does not meet the requirement in the scene is not less than 10, it is determined that the modification process of the texture features of the texture display products in the scene will cause the memory usage to be too large. Therefore, the scene is regarded as a memory-optimized scene.
[0122] Further, the method for determining the basic screening target in the memory-optimized scene comprises:
[0123] determining the same number of pixel blocks of the original texture data of the texture display product in the memory-optimized scene based on the similarity of the pixel blocks of the original texture data of the texture display product in the memory-optimized scene.
[0124] determining whether the texture display product is a basic screening target based on the same number of pixel blocks of the original texture data of the other texture display products.
[0125] It should be noted that determining whether the texture display product is a basic screening target based on the same number of pixel blocks of the original texture data of the other texture display products specifically comprises:
[0126] regarding the other texture display products whose same number of pixel blocks of the original texture data meets the requirement as similar products.
[0127] determining whether the texture display product is a basic screening target based on the number of the similar products.
[0128] It can be understood that the similar product is another texture product whose proportion of the number of pixel blocks in the texture display exhibit to the same number of pixel blocks of the original texture data of the texture display product is greater than 0.2, and when the number of similar products is not less than 3, it is determined that the texture display product is a basic screening target.
[0129] It should be noted that the general data is determined according to the scene in which the basic screening target exists.
[0130] Further, the method for determining the optimization target in the basic screening target is:
[0131] With the general data of the basic screening target in different scenes, the scene in which the basic screening target exists is determined as a target matching scene.
[0132] Based on the constituent data of the basic screening target in the target matching scene, the texture display product in the target matching scene except the basic screening target is determined as a remaining display product.
[0133] According to the constituent data of the remaining display product in each target matching scene, it is determined whether the basic screening target is an optimization target.
[0134] It can be understood that according to the constituent data of the remaining display product in each target matching scene, it is determined whether the basic screening target is an optimization target, which specifically includes:
[0135] With the constituent data of the remaining display product in each target matching scene, the number of the remaining display product in each target matching scene is determined.
[0136] With the memory occupation data and the number of the remaining display product in each target matching scene, the scene in the target matching scene that does not need to be optimized is determined.
[0137] Based on the scene data that does not need to be optimized, it is determined whether the basic screening target is an optimization target.
[0138] It can be understood that the scene that does not need to be optimized is a scene in which the sum of the memory occupation of each remaining display product in the process of changing the texture is less than 300MB. At this time, in order to ensure the level of detail of the texture features, the basic screening target does not need to be optimized in the scene with small memory occupation.
[0139] It should be noted that when there are no scenarios for the basic screening target that do not require optimization, the basic screening target is determined to be an optimization target. However, when there are scenarios for the basic screening target that do not require optimization, and the number of scenarios that do not require optimization does not meet the requirement (i.e., more than 4), then in order to retain more detailed features, it is determined that the basic screening target does not need to be optimized.
[0140] Furthermore, if the number of scenarios that do not require optimization meets the requirements, then the number of scenarios that do not require optimization corresponding to the basic screening targets in each scenario that does not require optimization is determined, and the ranking results in each scenario that does not require optimization are determined. Basic screening targets whose ranking results do not meet the requirements are regarded as basic screening targets that do not require optimization, that is, they are not optimization targets.
[0141] It should be noted that the sorting results are sorted from smallest to largest based on the number of scenarios that do not require optimization processing corresponding to the basic screening targets in each scenario that does not require optimization processing. If the number of scenarios that do not require optimization processing in the top three of the sorting results is not less than 2, then these scenarios are regarded as basic screening targets that do not require optimization processing, i.e., they are not optimization targets.
[0142] It is understandable that the basic screening objectives, excluding those that are not optimization objectives, are considered optimization objectives.
[0143] Optionally, the method for determining the optimization objective in the basic screening objectives is as follows:
[0144] Using general data on basic filtering targets in different scenarios, determine the scenarios in which the basic filtering targets exist, and use them as target matching scenarios;
[0145] Based on the composition data of the basic filtering targets in the target matching scenario, the texture display products other than the basic filtering targets in the target matching scenario are determined and used as the remaining display products.
[0146] Based on the composition data of the remaining displayed products in each target matching scenario, the scenarios that do not require optimization are identified. Based on the distribution of the scenarios that do not require optimization in the target matching scenarios, it is determined whether the basic filtering target is an optimization target.
[0147] It should be noted that when the proportion of the scene that does not need to be optimized in the target matching scene is greater than 70%, it is determined that the basic screening target does not belong to the optimization target, and when the proportion of the scene that does not need to be optimized in the target matching scene is not greater than 70%, the number of target matching scenes is determined in the scene that does not need to be optimized, and when the number of target matching scenes is greater than the preset matching scene number threshold, it is determined that the basic screening target is an optimization target.
[0148] In addition, it can be understood that when the number of target matching scenes is not greater than the preset matching scene number threshold, the number of scenes that do not need to be optimized in each scene is determined, and the sorting result in each scene that does not need to be optimized is determined. The basic screening target that does not meet the requirement is determined as the basic screening target that does not need to be optimized, that is, it does not belong to the optimization target.
[0149] Further, the method for determining the screening optimization target of the texture display product in the scene is:
[0150] Based on the composition data of the optimization target in the scene, the texture display product in the scene excluding the optimization target is determined, and is used as an unoptimized product;
[0151] According to the use data of the unoptimized product in the scene excluding the memory optimization scene, the scene of the unoptimized product is determined, and is used as another matching scene;
[0152] Using the memory occupation data of the unoptimized product in the scene and the other matching scene data of the unoptimized product, it is determined whether the unoptimized product is a screening optimization target of the texture display product in the scene.
[0153] It should be noted that when the memory occupation data of the unoptimized product in the scene meets the requirement, that is, it belongs to the scene in which the sum of the memory occupation of each unoptimized product in the texture change process is less than 300MB, the memory occupation in the scene can meet the requirement at this time, so it is not necessary to determine the screening optimization target, that is, all unoptimized products do not belong to the screening optimization target.
[0154] In addition, it can be understood that if the memory occupation data of the unoptimized product in the scene does not meet the requirement, it is further necessary to determine the number of other matching scenes of the unoptimized product, and if the number of other matching scenes of the unoptimized product meets the requirement, that is, it is not less than 2, it is determined that the unoptimized product belongs to the screening optimization target.
[0155] Further, if the number of other adaptation scenarios of the non-optimized product does not meet the requirement, it is further needed to determine the number of scenarios of the non-optimized product which do not need to be optimized, wherein if the number of scenarios of the non-optimized product which do not need to be optimized is less than the number of other adaptation scenarios or the difference between the number of scenarios of the non-optimized product which do not need to be optimized and the number of other adaptation scenarios meets the requirement, i.e. is not greater than 1, it is determined that the non-optimized product belongs to the screening optimization target.
[0156] In other cases, according to the sum of the memory occupation amounts of the non-optimized products other than the screening optimization target and the optimization target in the process of texture variation, when the sum is not less than 300MB, the non-optimized products other than the screening optimization target and the optimization target are removed, and the screening optimization target is determined from small to large based on the difference between the number of scenarios of the non-optimized product which do not need to be optimized and the number of other adaptation scenarios until the sum of the memory occupation amounts of the non-optimized products other than the screening optimization target and the optimization target in the process of texture variation is less than 300MB.
[0157] Each of the embodiments in the specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other. Each embodiment mainly explains the difference from other embodiments. Especially, for the device, equipment and non-volatile computer storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiments.
[0158] The above describes specific embodiments of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different than the order in which the actions or steps are recited in the embodiments, and still achieve the desired result. In addition, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous.
[0159] The above only describes one or more embodiments of the specification, and is not used to limit the specification. One or more embodiments of the specification can have various changes and variations for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of one or more embodiments of the specification shall be included in the scope of claims of the specification.
Claims
1. A memory optimization method with modifiable textures, characterized in that, Specifically, it includes: Based on the image files of texture display product data, the optimization targets of texture display products in different scenarios are screened. The image files of the optimization targets are compressed to obtain the original texture data. The original texture data and texture parameters are combined according to preset rules to obtain the original file. The texture display product data in the scene corresponding to the original file is used to determine whether compression is required, thereby obtaining the texture file. When modifying a texture, the texture instance of the target texture is obtained. Based on the original texture data of the target texture, the pixel blocks of the original texture data of the original texture instance are modified. The texture file of the target texture and the modified original texture data are written to a data container pointing to memory. The processor reads the data in the data container and performs the rendering process of the modified texture target. Determining whether compression is necessary includes: Based on the texture display product data in the scene corresponding to the original file of the optimization target, determine the optimization target data in the scene, and based on the optimization target data, determine the texture display products in the scene that do not belong to the optimization target; Based on the pixel blocks of the original texture data corresponding to the original file of the optimization target, determine the similarity of pixel blocks with the original texture data corresponding to other optimization targets in the corresponding scene, and determine the same number of pixel blocks with other optimization targets based on the similarity. Based on the texture display product data that does not belong to the optimization target in the scenario and the same number of pixel blocks as other optimization targets, it is determined whether the original file needs to be compressed.
2. The memory optimization method with changeable texture as described in claim 1, characterized in that, Optimization targets for texture display products in different scenarios are selected, specifically including: All texture display products in the scenario are considered as optimization targets.
3. The memory optimization method with changeable texture as described in claim 1, characterized in that, The original texture data is obtained, specifically including: Use the PVRTexTool to convert JPG or PNG image files into compressed textures supported by the target platform to obtain the original texture data.
4. The memory optimization method with changeable texture as described in claim 3, characterized in that, The PVRTexTool is a batch texture compression tool.
5. The memory optimization method with changeable texture as described in claim 1, characterized in that, If the number of texture display products that do not belong to the optimization target in the scenario does not meet the requirements, then it is determined that the number of texture display products that do not belong to the optimization target in the scenario does not meet the requirements.
6. The memory optimization method with changeable texture as described in claim 1, characterized in that, The specific steps for constructing the texture file are as follows: The original texture data is converted into a PVR file. According to the encoding rules of the PVR file, the compressed texture data is extracted and combined with the texture parameters according to the custom encoding rules. If a compression tool is used for further compression, additional compression information needs to be written for decompression. Then the final texture file data can be obtained, written to a file and saved, thus obtaining the final texture file.
7. The memory optimization method with changeable texture as described in claim 6, characterized in that, The pvr file mentioned above is the file converted by the PVRTexTool.
8. The memory optimization method with changeable texture as described in claim 1, characterized in that, The texture file includes the texture width, texture height, whether the texture has an alpha channel, and the original texture data.
9. A memory optimization system with modifiable texture, applied to the memory optimization method with modifiable texture as described in any one of claims 1-8, specifically comprising: The scene filtering module is responsible for determining the texture display product data based on the texture display products in the scene, and determining the memory optimization scene in the scene based on the memory usage data of the texture display products. The target recognition module is responsible for determining the similarity of pixel blocks in the original texture data of the product in the memory optimization scenario, and identifying the basic screening targets in the memory optimization scenario. The target filtering module is responsible for determining the optimized targets among the basic filtering targets based on the general data of the basic filtering targets in different scenarios and the constituent data of the basic filtering targets; The optimization target determination module is responsible for determining the selection optimization targets in the texture display product of the scene based on the composition data of the optimization targets in the scene and the usage data of the texture display product in the scene excluding the memory optimization scene, and using the selection optimization targets and the optimization targets as the optimization targets in the scene.
Citation Information
Patent Citations
Picture processing method and device and picture rendering method and device
CN116128983A
Interactive three-dimensional model texture editing method and system and electronic equipment
CN118379470A