Atlas generation method and system
By analyzing the resource usage information of the game program, the atlas is automatically generated, which solves the problem of large data volume and long time consumption caused by manual analysis in the existing technology, improves the rendering efficiency and the consistency of the optimization results, and achieves efficient atlas generation.
Patent Information
- Application Number
- CN202111232479.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-22
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-10-22
AI Technical Summary
Existing atlas generation methods rely on manual analysis, resulting in a large amount of data, long time consumption, and easy omission, which affects rendering efficiency. In addition, the optimization results of different projects are inconsistent, affecting the actual rendering effect.
By obtaining resource usage information during the running process of the game program, analyzing the resource usage and association times, automatically generating atlases, reducing the number of Draw Calls, improving rendering efficiency, and avoiding the large data volume and long time-consuming problems of manual optimization.
It realizes automatic atlas generation, reduces the number of Draw Calls, improves rendering efficiency, ensures the consistency and efficiency of optimization results, reduces the workload of R&D personnel, and accumulates optimization experience in the tool.
Smart Images

Figure CN113961343B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a method and system for generating an atlas, a computer device, and a computer-readable storage medium. Background Art
[0002] With the development of computer technology, people have put forward higher and higher requirements for gaming experience. Among them, the picture quality and rendering effect of the game directly affect the visual experience. In the rendering implementation process, Draw Call is a rendering instruction submitted by the CPU to the GPU. Too many Draw Calls will cause the CPU occupancy rate to be too high and the frame time to be longer, which will cause problems such as game lag. In order to solve the problem of too many Draw Calls, the images used can be packaged into atlases during the game production stage. Atlases can reduce the number of Draw Calls: some originally continuous Draw Calls with the same texture can be combined into one Draw Call.
[0003] However, existing atlases are packaged through manual analysis, which is not only slow and error-prone, but also affects the actual rendering efficiency. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a method, system, computer device and computer-readable storage medium for generating an atlas to solve the above-mentioned problems.
[0005] One aspect of an embodiment of the present application provides a method for generating an atlas, the method comprising:
[0006] Obtain resource usage information of the game program during operation, wherein the resource usage information includes multiple states, wherein each state is a string of characters, and each string of characters maps resources used when one frame or multiple similar frames are rendered, wherein the multiple similar frames refer to multiple frames whose resource similarity is greater than a preset threshold;
[0007] Analyzing the number of times each resource is used by the game program according to the resources mapped to each state;
[0008] Analyze the number of associations between each resource and its associated resources, and resources in the same state are associated resources; and
[0009] A plurality of atlases are generated according to the number of times each resource is used and the number of times each resource is associated with its associated resources; wherein each atlas includes part of the resources recorded in the resource usage information.
[0010] Optionally, generating multiple atlases according to the number of times each resource is used and the number of times each resource is associated with its associated resources includes:
[0011] Sorting the usage times of each resource, and generating a first resource sorting list according to the sorting result;
[0012] In the first resource sorting table, resources whose usage times and association times in the same frame are both 1 are added to the same atlas;
[0013] Deleting the resources added to the same atlas from the first resource sorting table to obtain a second resource sorting table;
[0014] Traverse the second resource sorting table and perform the following operations: search for multiple target-associated resources associated with the target resource, wherein the target resource is any one of the resources currently traversed in the second resource sorting table; determine whether to add one or more of the multiple target-associated resources to the target atlas where the target resource is located based on the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource itself and its own associated resource; if it is determined to be added, add one or more of the multiple target-associated resources to the target atlas.
[0015] Optionally, determining whether to add one or more of the plurality of target-associated resources to the target atlas where the target resource is located according to the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource itself and its associated resource, includes:
[0016] Obtaining an i-th associated resource list of an i-th target associated resource, where the i-th target associated resource is one of a plurality of target associated resources, and the i-th associated resource list includes the number of associations with each associated resource;
[0017] Get the maximum number of associations in the i-th associated resource list;
[0018] comparing the number of associations between the target resource and the i-th target associated resource with the maximum number of associations; and
[0019] If the number of associations between the target resource and the i-th target-associated resource is greater than the maximum number of associations, then if resources can be added to the target atlas, the i-th target-associated resource is added to the target atlas.
[0020] Optionally, also include:
[0021] Detect the material of each resource and determine several resources with different materials but using the same Shader;
[0022] Generate a universal material through the same Shader, and modify the plurality of resources through the universal material.
[0023] Optionally, also include:
[0024] Detect several resources that use the same Shader; and
[0025] The plurality of resources are merged into an atlas, and the index and reference method of the objects referencing the plurality of resources are modified.
[0026] One aspect of an embodiment of the present application further provides a system for generating an atlas, the system comprising:
[0027] An acquisition module is used to: acquire resource usage information of a game program during operation, wherein the resource usage information corresponds to a plurality of states, wherein each state is a string of characters, and each string of characters maps resources used when a frame or similar multiple frames are rendered, wherein the similar multiple frames refer to a plurality of frames whose resource similarity is greater than a preset threshold;
[0028] The first analysis module is used to: obtain the resources mapped to each state and obtain the usage count of each resource;
[0029] The second analysis module is used to: analyze the number of associations between each resource and its associated resources, and resources in the same state are associated resources; and
[0030] A generation module is used to generate multiple atlases according to the number of times each resource is used and the number of times each resource is associated with its respective associated resource; wherein each atlas includes part of the resources recorded in the resource usage information.
[0031] Optionally, the generating module is further used for:
[0032] Sorting the usage times of each resource, and generating a first resource sorting list according to the sorting result;
[0033] In the first resource sorting table, resources whose usage times and association times in the same frame are both 1 are added to the same atlas;
[0034] Deleting the resources added to the same atlas from the first resource sorting table to obtain a second resource sorting table;
[0035] Traverse the second resource sorting table and perform the following operations: search for multiple target-associated resources associated with the target resource, wherein the target resource is any one of the resources currently traversed in the second resource sorting table; determine whether to add one or more of the multiple target-associated resources to the target atlas where the target resource is located based on the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource itself and its own associated resource; if it is determined to be added, add one or more of the multiple target-associated resources to the target atlas.
[0036] One aspect of an embodiment of the present application further provides a method for generating an atlas, the method comprising:
[0037] Obtain resource usage information of the game program during operation, wherein the resource usage information includes multiple states, wherein each state is a string of characters, and each string of characters maps resources used when one frame or multiple similar frames are rendered, wherein the multiple similar frames refer to multiple frames whose resource similarity is greater than a preset threshold;
[0038] According to the resource usage information, obtaining the association relationship between the various states;
[0039] Generate a state transition tree according to the association relationship between the various states;
[0040] According to the state transition tree, updating the atlas in sequence according to the resources of each state, the atlas updating depends on the resources mapped by the current state and multiple atlases updated based on the previous state of the current state; and
[0041] The multiple atlases obtained based on the last state update are determined as multiple target atlases for the rendering operation.
[0042] One aspect of an embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor is used to implement the steps of the atlas generation method as described above when executing the computer program.
[0043] One aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program can be executed by at least one processor to enable the at least one processor to perform the steps of the above-mentioned atlas generation method.
[0044] The atlas generation method, system, device, and computer-readable storage medium provided in the embodiments of the present application have the following advantages:
[0045] (1) Collect resource usage information and analyze the number of times each resource is used and the number of times it is associated with other resources, so as to obtain the optimal multiple atlases to reduce the number of draw calls generated during rendering and improve rendering efficiency.
[0046] (2) The automatic generation of atlases avoids the problems of large data volumes, long time consumption, and easy omissions in manual analysis and optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A diagram schematically shows an application environment of the atlas generation method according to an embodiment of the present application;
[0048] Figure 2 The flowchart of the atlas generation method according to the first embodiment of the present application is schematically shown;
[0049] Figure 3 A flowchart of newly added steps of the atlas generation method according to the first embodiment of the present application is schematically shown;
[0050] Figure 4 for Figure 2 Flow chart of sub-steps of step S206;
[0051] Figure 5 for Figure 4 Flow chart of sub-steps of step S406;
[0052] Figure 6 A flowchart of newly added steps of the atlas generation method according to the first embodiment of the present application is schematically shown;
[0053] Figure 7 A flowchart of newly added steps of the atlas generation method according to the first embodiment of the present application is schematically shown;
[0054] Figure 8 The flowchart of the atlas generation method according to the second embodiment of the present application is schematically shown;
[0055] Fig. 9 The block diagram of the atlas generation system according to the third embodiment of the present application is schematically shown;
[0056] Fig.10 The schematic diagram shows a hardware architecture of a computer device suitable for implementing the atlas generation method according to the fourth embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0058] It should be noted that the descriptions involving "first", "second", etc. in the embodiments of the present application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0059] In the description of the present application, it should be understood that the numerical labels before the steps do not indicate the order in which the steps are executed, but are only used to facilitate the description of the present application and to distinguish each step, and therefore should not be understood as a limitation on the present application.
[0060] The game's picture quality and rendering effects affect the visual experience. In the rendering process, a Draw Call is a rendering instruction submitted by the CPU to the GPU. Too many Draw Calls will cause the CPU usage to be too high, the frame time to be longer, and thus cause problems such as game lag. In order to solve the problem of too many Draw Calls, you can package the used images into atlases during the game production stage. Atlases can reduce the number of Draw Calls: some originally continuous Draw Calls with the same texture can be combined into one Draw Call.
[0061] The inventors found that existing atlases are all packaged manually and have the following disadvantages:
[0062] First, current development tools provide information about resource usage during game runtime, but do not analyze or process the information;
[0063] Second, manual analysis and optimization faces the problem of large data volumes, long time consumption, and easy omissions;
[0064] Third, similar optimization processes for different projects must be redone or repeated;
[0065] Fourth, people with different project experiences may optimize different results, and sometimes the packaging is unreasonable, affecting the actual rendering efficiency.
[0066] In response to the above-mentioned problems, this application aims to monitor resource usage information through the game engine and perform the following operations:
[0067] First, the data obtained by the detection engine resource usage information is relatively complete, and resource optimization based on the data analysis is also a relatively comprehensive optimization;
[0068] Second, using intelligent resource analysis can allow R&D personnel to focus on logic without spending too much time on resource sorting, thus reducing the workload for R&D;
[0069] Third, experienced optimizers can optimize resource optimization methods and then apply them to their own projects or other projects, so that resource optimization experience can be accumulated in tools for use in more projects;
[0070] Fourth, intelligent optimization methods can be used to detect whether there are optimizable resources within the project.
[0071] The following is an explanation of the terms used in this application:
[0072] Game engine: refers to the core components of some pre-written editable computer game systems or interactive real-time graphics applications. These systems provide game designers with various tools needed to write games, with the aim of allowing game designers to easily and quickly create game programs without starting from scratch. Most of them support multiple operating platforms, such as Linux, Mac OS X, and Microsoft Windows. Game engines include the following systems: rendering engine (also known as "renderer", including 2D graphics engine and 3D graphics engine), physics engine, collision detection system, sound effects, script engine, computer animation, artificial intelligence, network engine, and scene management.
[0073] Draw call: It is the function interface that the CPU calls graphics programming, and is used to implement the transfer of rendering command parameters between the CPU and the GPU. The CPU sends rendering commands to the GPU through Draw Call, and the GPU performs rendering operations according to the rendering commands. Draw Call is used to implement the transfer of rendering command parameters between the CPU and the GPU. In Unity, each time the CPU prepares data and notifies the GPU is called a Draw Call.
[0074] GPU (Graphics Processing Unit): A microprocessor that performs image processing on a terminal. The GPU is used to render images or atlases according to the commands of the CPU.
[0075] Atlas: Multiple images are packaged into one file, and the location information of the original images is recorded. Atlas can reduce the number of draw calls.
[0076] Shader: A code resource in the game that stores image processing logic.
[0077] MD5 (Message-Digest Algorithm) is a cryptographic hash function that can generate a 128-bit (16-byte) hash value to ensure the integrity and consistency of information transmission.
[0078] Figure 1 The following schematically shows the environment architecture diagram of the atlas generation method according to an embodiment of the present application. Figure 1 As shown, the computer device 2 can be connected to multiple electronic devices 6 via a network 4 .
[0079] Computer device 2 may provide resource management services via one or more networks 4 .
[0080] The computer device 2 may be composed of a single or multiple computing devices, such as a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers), etc. The one or more computer devices may include a virtualized computing instance. The computer device may load a virtual machine based on a virtual image and / or other data defining specific software (e.g., an operating system, a dedicated application, a server) for simulation. As the demand for different types of processing services changes, different virtual machines may be loaded and / or terminated on the one or more computer devices.
[0081] The network 4 may include various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices, and / or the like. The network 4 may include physical links, such as coaxial cable links, twisted pair cable links, fiber optic links, combinations thereof, and / or the like. The network 4 may include wireless links, such as cellular links, satellite links, Wi-Fi links, and / or the like.
[0082] The electronic device 6 may be configured to access the computer device 2. The electronic device 6 may include any type of computer device that can be used with a game engine, such as: a smart phone, a tablet device, a laptop computer, a smart device (e.g., a smart watch, smart glasses), virtual reality, a gaming device, a set-top box, a digital streaming device, a vehicle-mounted terminal, a smart TV, a TV box, an MP4 (Moving Picture Experts Group Audio Layer IV) player, etc.
[0083] Electronic device 6, can run Windows system, Android TM ) system or iOS system and other operating systems. In addition, users can also install various applications, program components (such as game engines) as needed. Based on the above programs or program components, various functions can be implemented, such as game functions, or resource monitoring functions. The game engine is a core component for running game applications, which is used to provide various tools required for various operations, such as some pre-written editable computer game systems or some interactive real-time image application programs. The core components. In this application, the game engine can be responsible for providing resource usage information used by the game in different states when the game is running, such as what resources are loaded in the current state, what resources are released, etc.
[0084] Hereinafter, the present application will provide a method, system, computer device and computer-readable storage medium for generating an atlas.
[0085] Embodiment 1
[0086] Figure 2 The flowchart of the atlas generation method according to the first embodiment of the present application is schematically shown. The method can be executed in the computer device 2. Figure 2 As shown, the atlas generation method may include steps S200 to S206, wherein:
[0087] Step S200, obtaining resource usage information of the game program during operation, wherein the resource usage information includes multiple states, wherein each state is a string of characters, and each string of characters maps resources used when one frame or multiple similar frames are rendered, wherein the multiple similar frames refer to several frames whose resource similarity is greater than a preset threshold.
[0088] Step S202: analyzing the number of times each resource is used by the game program according to the resources mapped to each state.
[0089] Step S204, analyzing the number of associations between each resource and its associated resources, and resources in the same state are associated resources with each other.
[0090] Step S206, generating a plurality of atlases according to the number of times each resource is used and the number of times each resource is associated with its associated resources; wherein each atlas includes part of the resources recorded in the resource usage information.
[0091] In actual applications, when developing games using a game engine (such as Unity), monitoring code can be injected into the renderable components provided by the game engine of each electronic device 6. Through the injected monitoring code, the electronic device 6 can collect resource information for rendering each frame of the game program in sequence during the entire running process.
[0092] Taking one of the electronic devices 6 as an example, after the game is finished, a database is automatically generated to store data. The database design is as follows:
[0093] Resource table structure:
[0094] Type: resource type (supported types: mesh, meterial, shader, png);
[0095] Name: resource name;
[0096] Mem: the memory size occupied by the resource;
[0097] Size: actual size of the resource (length and width of png);
[0098] Path: The path where the resource is saved.
[0099] State table structure:
[0100] State: The resource information used in each frame is digitally encoded into a unique state. For example, when rendering a frame A, "resource 1", "resource 2" and "resource 3" are used in sequence. A unique string of characters (such as MD code) can be generated based on the names or other identifiers of "resource 1", "resource 2" and "resource 3". When the computer device reads this string of characters, it can be parsed to obtain that frame A uses "resource 1", "resource 2" and "resource 3" in sequence.
[0101] Parent: the previous state of this state;
[0102] Child: the next state of this state;
[0103] ResList: all resources used by this state;
[0104] Draw call: the drawing batch corresponding to this state;
[0105] Position: the position of the rendered object;
[0106] UseType: Usage type (UI or 3D model).
[0107] The above provides an example of electronic device 6 collecting resource usage information. Computer device 2 integrates the data reported by all electronic devices and obtains the integrated resource usage information (including deduplication and new additions). The "resource usage information" in step S202 is the integrated resource usage information.
[0108] Next, after obtaining the resource usage information in step S202, the resource usage information is analyzed as follows:
[0109] Traverse the resources of each state (such as UI resources), analyze the associated resources of each resource in the same state (such as associated resources rendered at the same time in the same frame), and calculate the number of associations (that is, the number of co-renderings, such as:
[0110] Resources in the first state: 1, 2, 3, 4;
[0111] Resources in the second state: 1, 2, 5, 6;
[0112] Resources in the third state: 1, 7, 8, 9;
[0113] The following analysis data is obtained from the above data:
[0114] 1(3):2(2),3(1),4(1),5(1),6(1),7(1),8(1),9(1);
[0115] 2(2):1(2),3(1),4(1),5(1),6(1);
[0116] 3(1):1(1),2(1),4(1);
[0117] 4(1):1(1),2(1),3(1);
[0118] …
[0119] in:
[0120] Left side: Indicates each resource, and the bracketed data indicates the number of times it has been used. For example, "1(3)" means resource 1 has been used 3 times, "2(2)" means resource 2 has been used 2 times, "3(1)" means resource 3 has been used once, and "4(1)" means resource 4 has been used once.
[0121] Right side: Indicates that the corresponding left resource is used at the same time during the game running process. The number in the bracket on the right side indicates the number of times the resource and the left resource are rendered together. Taking "1(3): 2(2), 3(1), 4(1), 5(1), 6(1), 7(1), 8(1), 9(1)" as an example, "2(2)" means that the number of times resource 2 and the left resource 1 are rendered together is 2, "3(1)" means that the number of times resource 3 and the left resource 1 are rendered together is 1, and so on.
[0122] Based on the usage count of each resource obtained above and the number of associations between each resource and its associated resources, the optimal resource combination can be analyzed and then multiple corresponding atlases can be generated to minimize the number of Draw Calls.
[0123] It should be noted that each atlas includes different parts of resources.
[0124] The atlas generation method provided in the embodiment of the present application may have the following advantages:
[0125] (1) By injecting monitoring code into the renderable components provided by the game engine in each electronic device, the resource usage information of multiple electronic devices is collected, and the number of times each resource is used and the number of times it is associated with other resources are analyzed, so as to obtain the optimal multiple atlases to reduce the number of draw calls generated during rendering.
[0126] (2) The automatic generation of atlases avoids the problems of large data volumes, long time consumption, and easy omissions in manual analysis and optimization.
[0127] (3) The generation of this atlas can be applied to different projects;
[0128] (4) Based on the collected resource usage information, the number of times each resource is used and the number of times it is associated with other resources are analyzed, so that multiple optimal atlases can be obtained, and the optimal effect of consistency can be obtained. The actual rendering efficiency is high and the following situations can be avoided: different people optimize different results and unreasonable packaging.
[0129] (5) Since the monitoring code is injected into the renderable component provided by the game engine, relatively complete resource usage information can be obtained, and data analysis is performed on the resource usage information to optimize the atlas generation, thereby achieving comprehensive optimization.
[0130] (6) Automatic generation of atlases allows R&D personnel to focus on logic rather than on resource organization, thus reducing their workload.
[0131] (7) Experienced optimizers can use the atlas generation method provided in this article and apply it to their own projects or other projects, so that the resource optimization experience can be accumulated in the tool for use in more projects.
[0132] Some optional embodiments are provided below.
[0133] As an optional embodiment, Figure 3 As shown, the atlas generation method may also include: step S300, obtaining a number of frames whose resource similarity is greater than a preset threshold according to the resource usage information; and step S302, merging the several frames into a frame set, generating a state based on the frame set, wherein the state generated based on the frame set maps the common resources and private resources of the several frames. In this embodiment, the number of states can be reduced and the analysis efficiency can be improved.
[0134] The common resources refer to resources used in several frames of a preset threshold.
[0135] Private resources refer to non-general resources, that is, resources used by only a single frame or part of frames among several frames.
[0136] As an optional embodiment, Figure 4 As shown, the step S206 may include the following steps: step S400, sorting the number of times the various resources are used, and generating a first resource sorting list according to the sorting result; step S402, in the first resource sorting table, adding the resources whose number of uses and number of associations in the same frame are both 1 to the same atlas; step S404, deleting the resources added to the same atlas from the first resource sorting table to obtain a second resource sorting table; step S406, traversing the second resource sorting table, performing the following operations: searching for multiple target-associated resources associated with the target resource, wherein the target resource is any one of the resources currently traversed in the second resource sorting table; determining whether to add one or more of the multiple target-associated resources to the target atlas where the target resource is located based on the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource itself and its own associated resource; and if it is determined to be added, adding one or more of the multiple target-associated resources to the target atlas. In this embodiment, the most closely associated resources can be grouped into the same atlas through the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource itself and its own associated resources, thereby greatly reducing the number of Draw Calls during rendering of the game engine.
[0137] It should be noted that the sorting can be performed from large to small according to the number of times used, or from small to large. If the sorting is performed from small to large, the resources that are not frequently used can be separated to achieve a similar effect.
[0138] As an optional embodiment, Figure 5As shown, the step S406 may include the following steps: step S400, obtaining the i-th associated resource list of the i-th target associated resource, the i-th target associated resource being one of a plurality of target associated resources, the i-th associated resource list including the number of associations with each associated resource; step S502, obtaining the maximum number of associations in the i-th associated resource list; step S504, comparing the number of associations between the target resource and the i-th target associated resource and the maximum number of associations; and step S506, if the number of associations between the target resource and the i-th target associated resource is greater than the maximum number of associations, then if resources can be added to the target atlas, then the i-th target associated resource is added to the target atlas. If the number of associations between the target resource and the i-th target associated resource is not greater than the maximum number of associations, or the target atlas is full, then the target atlas is not added.
[0139] For example:
[0140] By default, the maximum number of resources that can be stored in each atlas is MaxCount, the maximum size is MaxSize, and the maximum volume is MaxMem.
[0141] (1) All resources are sorted from largest to smallest according to their usage counts, and a sorted first resource sort list ResList0 is generated.
[0142] (2) Based on the number of times each resource is used and the number of times each resource is associated with its associated resources, the following resources are put into the same atlas: the number of times used is 1 and the number of times associated is 1, and are deleted from ResList0 to generate ResList1. Placing these less used resources in a separate atlas can reduce the impact on other resources.
[0143] (3) Traversing ResList1: When traversing to resource A, find all the associated resources of resource A and sort them from large to small according to the number of associations to generate the associated resource list RefResList ({a1, a2, a3, …, an}) of resource A.
[0144] (3.1) Determine whether resource A is included in the atlas. If so, skip it. If not, add it to the new atlas A1.
[0145] (3.2) Traverse RefResList. When a1 is traversed, if the number of associations between A1 and a1 is greater than the maximum number of associations in a1's own associated resource list, and A1 meets the preset atlas threshold, then a1 is added to A1, otherwise it is not added.
[0146] (3.2) Continue traversing to a2. If the number of associations between A1 and a2 is greater than the maximum number of associations in the associated resource list of a2 itself, and A1 meets the preset atlas threshold, then a2 is added to A1, otherwise it is not added.
[0147] And so on, until an is traversed, then return to step (3) and continue to traverse the next resource of resource A in ResList1.
[0148] After the above traversal is completed, multiple final atlases will be obtained. These multiple atlases can be used in rendering operations.
[0149] As an optional embodiment, Figure 6 As shown, the atlas generation method may also include: step S600, detecting the material of each resource, determining several resources with different materials but using the same Shader; step S602, generating a universal material through the same Shader, and modifying the several resources through the universal material. In this embodiment, the operating pressure of the device, such as rendering pressure, can be reduced by automatically merging materials. For example, when static objects use the same material, the game engine will start static batching to optimize Draw Call to reduce the number of Draw Calls. Dynamic batching technology can also be used when static objects use the same material.
[0150] It should be noted that "material" is used to represent the interaction of an object with light and is a data set read by the renderer. Materials can be used to represent the properties of an object's interaction with light (reflection, refraction, etc.). For example, a game engine can calculate different colors through materials based on the difference in the reflection properties of metal and carpet.
[0151] As an optional embodiment, Figure 7 As shown, the atlas generation method may also include: step S700, detecting a plurality of resources using the same Shader; and step S702, merging the plurality of resources into an atlas, and modifying the index and reference method of the objects that reference the plurality of resources. In this embodiment, the automatic merging of textures (3D resource optimization) can reduce the operating pressure of the device, such as rendering pressure.
[0152] It should be noted that the various optional solutions provided above can be implemented individually or in combination.
[0153] Embodiment 2
[0154] This embodiment provides another atlas generation method, and the specific effects can be referred to above.
[0155] Figure 8The flowchart of the atlas generation method according to the second embodiment of the present application is schematically shown. The method can be executed in the computer device 2. Figure 8 As shown, the atlas generation method may include steps S800 to S808, wherein:
[0156] Step S800, obtaining resource usage information of the game program during operation, wherein the resource usage information includes multiple states, wherein each state is a string of characters, and each string of characters maps resources used when one frame or multiple similar frames are rendered, wherein the multiple similar frames refer to multiple frames whose resource similarity is greater than a preset threshold;
[0157] Step S802, obtaining the association relationship between the various states according to the resource usage information;
[0158] Step S804, generating a state transition tree according to the association relationship between the various states;
[0159] Step S806, according to the state transition tree, updating the atlas in order according to the resources of each state, wherein the atlas updating depends on the resources mapped by the current state and multiple atlases updated based on the previous state of the current state; and
[0160] Step S808 : determining the multiple atlases obtained based on the last state update as multiple target atlases for rendering operations.
[0161] In this embodiment, through longitudinal analysis, all states are traversed in order to obtain multiple target atlases that are optimal overall.
[0162] Compared with the first embodiment, this embodiment takes into account the order of state flow, and continuously updates the iterative atlas content through the flow order of each state, and finally iterates multiple atlases as target atlases. Since adjacent states usually have more common resources, the optimal multiple target atlases are obtained through vertical analysis.
[0163] Among them, the generation rules of the state transition tree are as follows:
[0164] (1) Root state: The state without Parent is the root state.
[0165] (2) State merging: The preset minimum resource similarity is M. When the resource similarity used by two states is greater than or equal to M, the two states are defined as the same state, and the state contains some common resources and private resources.
[0166] (3) Generate a state transition tree based on the merged state and the previous and next state relationships.
[0167] As an optional embodiment, the atlas generation method further includes:
[0168] According to the resource usage information, a number of frames having resource similarity greater than a preset threshold are obtained;
[0169] The plurality of frames are combined into a frame set, and a state is generated based on the frame set, wherein the state generated based on the frame set maps the common resources and private resources of the plurality of frames.
[0170] As an optional embodiment, the atlas generation method further includes:
[0171] Detect the material of each resource and determine several resources with different materials but using the same Shader;
[0172] Generate a universal material through the same Shader, and modify the plurality of resources through the universal material.
[0173] As an optional embodiment, the atlas generation method further includes:
[0174] Detect several resources that use the same Shader; and
[0175] The plurality of resources are merged into an atlas, and the index and reference method of the objects referencing the plurality of resources are modified.
[0176] Embodiment 3
[0177] Fig. 9 The block diagram of the atlas generation system according to the third embodiment of the present application is schematically shown. The atlas generation system can be divided into one or more program modules, one or more program modules are stored in a storage medium, and are executed by one or more processors to complete the embodiment of the present application. The program module referred to in the embodiment of the present application refers to a series of computer program instruction segments that can perform specific functions. The following description will specifically introduce the functions of each program module in this embodiment.
[0178] like Fig. 9 As shown, the atlas generation system 900 may include an acquisition module 910, a first analysis module 920, a second analysis module 930 and a generation module 940, wherein:
[0179] The acquisition module 910 is used to: acquire resource usage information of the game program during operation, wherein the resource usage information corresponds to multiple states, wherein each state is a string of characters, and each string of characters maps resources used when one frame or multiple similar frames are rendered, wherein the multiple similar frames refer to multiple frames whose resource similarity is greater than a preset threshold;
[0180] The first analysis module 920 is used to: obtain the resources mapped to each state, and obtain the number of times each resource is used by the game program;
[0181] The second analysis module 930 is used to: analyze the number of associations between each resource and its associated resources, and resources in the same state are associated resources; and
[0182] The generating module 940 is used to generate a plurality of atlases according to the number of times each resource is used and the number of times each resource is associated with its associated resource; wherein each atlas includes part of the resources recorded in the resource usage information.
[0183] As an optional embodiment, the generating module 940 is further configured to:
[0184] Sorting the usage times of each resource, and generating a first resource sorting list according to the sorting result;
[0185] In the first resource sorting table, resources whose usage times and association times in the same frame are both 1 are added to the same atlas;
[0186] Deleting the resources added to the same atlas from the first resource sorting table to obtain a second resource sorting table;
[0187] Traverse the second resource sorting table and perform the following operations: search for multiple target-associated resources associated with the target resource, wherein the target resource is any one of the resources currently traversed in the second resource sorting table; determine whether to add one or more of the multiple target-associated resources to the target atlas where the target resource is located based on the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource itself and its own associated resource; if it is determined to be added, add one or more of the multiple target-associated resources to the target atlas.
[0188] As an optional embodiment, the generating module 940 is further configured to:
[0189] Obtaining an i-th associated resource list of an i-th target associated resource, where the i-th target associated resource is one of a plurality of target associated resources, and the i-th associated resource list includes the number of associations with each associated resource;
[0190] Get the maximum number of associations in the i-th associated resource list;
[0191] comparing the number of associations between the target resource and the i-th target associated resource with the maximum number of associations; and
[0192] If the number of associations between the target resource and the i-th target-associated resource is greater than the maximum number of associations, then if resources can be added to the target atlas, the i-th target-associated resource is added to the target atlas.
[0193] As an optional embodiment, the system further includes a material modification module (not identified) for:
[0194] Detect the material of each resource and determine several resources with different materials but using the same Shader;
[0195] Generate a universal material through the same Shader, and modify the plurality of resources through the universal material.
[0196] As an optional embodiment, the system further includes a resource merging module (not identified) for:
[0197] Detect several resources that use the same Shader; and
[0198] The plurality of resources are merged into an atlas, and the index and reference method of the objects referencing the plurality of resources are modified.
[0199] Embodiment 4
[0200] Fig.10 The schematic diagram of the hardware architecture of a computer device 2 suitable for implementing the atlas generation method according to the fourth embodiment of the present application is shown. In this embodiment, the computer device 2 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. For example, it can be a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers). Fig.10 As shown, the computer device 2 at least includes but is not limited to: a memory 10010, a processor 10020, and a network interface 10030 that can communicate with each other through a system bus. Among them:
[0201] The memory 10010 includes at least one type of computer-readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 10010 can be an internal storage module of the computer device 2, such as a hard disk or memory of the computer device 2. In other embodiments, the memory 10010 can also be an external storage device of the computer device 2, such as a plug-in hard disk equipped on the computer device 2, a smart memory card (Smart Media Card, referred to as SMC), a secure digital (Secure Digital, referred to as SD) card, a flash card (FlashCard), etc. Of course, the memory 10010 can also include both the internal storage module of the computer device 2 and its external storage device. In this embodiment, the memory 10010 is generally used to store the operating system and various application software installed on the computer device 2, such as the program code of the atlas generation method, etc. In addition, the memory 10010 can also be used to temporarily store various types of data that have been output or are to be output.
[0202] In some embodiments, the processor 10020 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 10020 is generally used to control the overall operation of the computer device 2, such as performing control and processing related to data interaction or communication with the computer device 2. In this embodiment, the processor 10020 is used to run the program code stored in the memory 10010 or process data.
[0203] The network interface 10030 may include a wireless network interface or a wired network interface, and the network interface 10030 is generally used to establish a communication link between the computer device 2 and other computer devices. For example, the network interface 10030 is used to connect the computer device 2 to an external terminal through a network, and to establish a data transmission channel and a communication link between the computer device 2 and the external terminal. The network may be a wireless or wired network such as an intranet, the Internet, the Global System of Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, etc.
[0204] It should be pointed out that Fig.10 Only a computer device having components 10010 - 10030 is shown, but it should be understood that implementation of all of the components shown is not a requirement, and more or fewer components may be implemented instead.
[0205] In this embodiment, the atlas generation method stored in the memory 10010 can also be divided into one or more program modules and executed by one or more processors (processor 10020 in this embodiment) to complete the embodiment of the present application.
[0206] Embodiment 5
[0207] The present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the atlas generation method in the embodiment are implemented.
[0208] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium can also be an external storage device of a computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, referred to as SMC), a secure digital (Secure Digital, referred to as SD) card, a flash card (Flash Card), etc. Of course, the computer-readable storage medium can also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the computer-readable storage medium is generally used to store the operating system and various application software installed on the computer device, such as the program code of the atlas generation method in the embodiment. In addition, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or are to be output.
[0209] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0210] It should be noted that the above are only preferred embodiments of the present application, and the patent protection scope of the present application is not limited thereto. Any equivalent structure or equivalent process transformation made using the contents of the specification and drawings of the present application, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for generating an atlas, characterized in that: The method comprises: Obtain resource usage information of the game program during operation, wherein the resource usage information includes multiple states, wherein each state is a string of characters, and each string of characters maps resources used when one frame or multiple similar frames are rendered, wherein the multiple similar frames refer to multiple frames whose resource similarity is greater than a preset threshold; Analyzing the number of times each resource is used by the game program according to the resources mapped to each state; Analyze the number of associations between each resource and its associated resources, and resources in the same state are associated resources; and Generate multiple atlases according to the number of times each resource is used and the number of times each resource is associated with its associated resources; wherein each atlas includes part of the resources recorded in the resource usage information; The generating of multiple atlases according to the number of times each resource is used and the number of times each resource is associated with its associated resources includes: Sorting the usage times of each resource, and generating a first resource sorting list according to the sorting result; In the first resource sorting table, resources whose usage times and association times in the same frame are both 1 are added to the same atlas; Deleting the resources added to the same atlas from the first resource sorting table to obtain a second resource sorting table; Traverse the second resource sorting table and perform the following operations: search for multiple target-associated resources associated with the target resource, wherein the target resource is any one of the resources currently traversed in the second resource sorting table; determine whether to add one or more of the multiple target-associated resources to the target atlas where the target resource is located based on the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource itself and its own associated resource; if it is determined to be added, add one or more of the multiple target-associated resources to the target atlas.
2. The atlas generation method according to claim 1, characterized in that: The determining, based on the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource and its own associated resource, whether to add one or more of the plurality of target-associated resources to the target atlas where the target resource is located comprises: Obtaining an i-th associated resource list of an i-th target associated resource, where the i-th target associated resource is one of a plurality of target associated resources, and the i-th associated resource list includes the number of associations with each associated resource; Get the maximum number of associations in the i-th associated resource list; comparing the number of associations between the target resource and the i-th target associated resource with the maximum number of associations; and If the number of associations between the target resource and the i-th target-associated resource is greater than the maximum number of associations, then if resources can be added to the target atlas, the i-th target-associated resource is added to the target atlas.
3. The atlas generation method according to any one of claims 1 to 2, characterized in that: Also includes: Detect the material of each resource and determine several resources with different materials but using the same Shader; Generate a universal material through the same Shader, and modify the plurality of resources through the universal material.
4. The atlas generation method according to any one of claims 1 to 2, characterized in that: Also includes: Detect several resources using the same Shader; and The plurality of resources are merged into an atlas, and the index and reference method of the objects referencing the plurality of resources are modified.
5. A system for generating an atlas, characterized in that: The system comprises: An acquisition module is used to: acquire resource usage information of a game program during operation, wherein the resource usage information corresponds to a plurality of states, wherein each state is a string of characters, and each string of characters maps resources used when a frame or similar multiple frames are rendered, wherein the similar multiple frames refer to a plurality of frames whose resource similarity is greater than a preset threshold; The first analysis module is used to: obtain the resources mapped to each state and obtain the usage count of each resource; The second analysis module is used to: analyze the number of associations between each resource and its associated resources, and resources in the same state are associated resources; and A generating module, used to: generate a plurality of atlases according to the number of times each resource is used and the number of times each resource is associated with the respective associated resource; wherein each atlas includes part of the resources recorded in the resource usage information; The generating of multiple atlases according to the number of times each resource is used and the number of times each resource is associated with its associated resources includes: Sorting the usage times of each resource, and generating a first resource sorting list according to the sorting result; In the first resource sorting table, resources whose usage times and association times in the same frame are both 1 are added to the same atlas; Deleting the resources added to the same atlas from the first resource sorting table to obtain a second resource sorting table; Traverse the second resource sorting table and perform the following operations: search for multiple target-associated resources associated with the target resource, wherein the target resource is any one of the resources currently traversed in the second resource sorting table; determine whether to add one or more of the multiple target-associated resources to the target atlas where the target resource is located based on the number of associations between the target resource and each target-associated resource, and the number of associations between each target-associated resource itself and its own associated resource; if it is determined to be added, add one or more of the multiple target-associated resources to the target atlas.
6. A method for generating an atlas, characterized in that: The method comprises: Obtain resource usage information of the game program during operation, wherein the resource usage information includes multiple states, wherein each state is a string of characters, and each string of characters maps resources used when one frame or multiple similar frames are rendered, wherein the multiple similar frames refer to multiple frames whose resource similarity is greater than a preset threshold; According to the resource usage information, obtaining the association relationship between the various states; Generate a state transition tree according to the association relationship between the various states; According to the state transition tree, updating the atlas in sequence according to the resources of each state, the atlas updating depends on the resources mapped by the current state and multiple atlases updated based on the previous state of the current state; and Determine multiple atlases obtained based on the last state update as multiple target atlases for rendering operations; The generation rules of the state transition tree are as follows: (1) Root state: the state without Parent is the root state; (2) State merging: the preset minimum resource similarity is M. When the resource similarity used by two states is greater than or equal to M, the two states are defined as the same state, and the state contains some common resources and private resources; (3) A state transition tree is generated based on the merged state and the relationship between the states.
7. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it is used to implement the steps of the atlas generation method described in any one of claims 1 to 4 and 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program can be executed by at least one processor so that the at least one processor performs the steps of the atlas generation method described in any one of claims 1 to 4 and 6.
Citation Information
Patent Citations
Resource caching method of game front end and storage medium
CN107469352A
Method for searching and optimizing game resource quotation relationship
CN108804688A
Scene rendering method and related device
CN110533755A
Image rendering method and device, and electronic equipment
CN111724293A
Graphics command management tool and methods for analyzing performance for command changes before application modification
US20080141131A1
