Data Compression Method, Apparatus and Electronic Device
The neural network is used to compress the spherical ambient light data in blocks, which solves the problem of excessive data volume of dynamic global lighting changes in the mobile game scene, and realizes efficient data compression and decompression, supporting fast rendering of mobile devices.
Patent Information
- Application Number
- CN202310875904.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-17
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2043-07-17
AI Technical Summary
The prior art is difficult to achieve the dynamic global lighting change effect of game scenes on the mobile terminal, mainly due to the large amount of pre-baked spherical ambient light data, which makes it difficult for mobile devices to carry.
The spherical harmonic ambient light data is compressed by using neural networks. By decomposing the data blocks into small neural networks for training, the target neural network and potential encoding are obtained. The compressed data amount is less than the second-order spherical harmonic coefficient, and it is integrated into compressed data.
It realizes rapid decompression on both the mobile and computers, ensuring the global lighting change effect of the game scene, achieving a compression ratio of up to 44.42:1, and reducing the size of the game scene.
Smart Images

Figure CN117172292B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular, to a data compression method, apparatus, and electronic device. Background Art
[0002] In the related art, in order to achieve the global illumination change effect of a game scene at different time points, it is necessary to pre-bake multiple sets of spherical harmonic ambient light data of the game scene at different time points, and then use the corresponding spherical harmonic ambient light data for rendering in real time. However, as the volume of the game scene increases, the amount of data of the pre-baked spherical harmonic ambient light data also increases, resulting in difficulty for mobile devices to carry a large amount of spherical harmonic ambient light data and inability to achieve the global illumination change effect of the game scene.
[0003] In order to achieve the global illumination change effect of a game scene on a mobile device, it is necessary to compress the pre-baked spherical harmonic ambient light data. In the related art, a method for compressing a single set of spherical harmonic ambient light data at a fixed time point is provided, but when multiple sets of spherical harmonic ambient light data need to be used to transition to achieve the dynamic global illumination effect, the implementation effect of this method is poor. Summary of the Invention
[0004] The purpose of the present invention is to provide a data compression method, apparatus, and electronic device, so as to compress multiple sets of spherical harmonic ambient light data that change over time through a neural network and achieve a better global illumination effect.
[0005] In a first aspect, the present invention provides a data compression method, which includes: obtaining spherical harmonic ambient light data corresponding to a target game scene; wherein, the spherical harmonic ambient light data is obtained by pre-baking the target game scene under the global illumination at a specified time point; the spherical harmonic ambient light data includes multiple data blocks, and each data block includes multiple lighting probes, and each lighting probe stores the corresponding second-order spherical harmonic coefficient; training an initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the lighting probes in the data block; wherein, the target neural network is used to: decompress the compressed data according to the latent encoding corresponding to the lighting probe to obtain the second-order spherical harmonic coefficient of the lighting probe; the amount of data of the latent encoding is less than the amount of data of the second-order spherical harmonic coefficient; determining the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the lighting probes in the data block as the compressed data of the data block; integrating the compressed data of the data blocks to obtain a compression result corresponding to the spherical harmonic ambient light data.
[0006] Second aspect, the present invention provides a data compression device, which includes: a data acquisition module, configured to acquire spherical harmonic ambient light data corresponding to a target game scene; wherein, the spherical harmonic ambient light data is obtained by pre-baking the target game scene under global illumination at a specified time point; the spherical harmonic ambient light data includes a plurality of data blocks, each data block includes a plurality of lighting probes, and each lighting probe stores corresponding second-order spherical harmonic coefficients; a data compression module, configured to train an initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent code corresponding to the lighting probe in the data block; wherein, the target neural network is used to: decompress the compressed data according to the latent code corresponding to the lighting probe to obtain the second-order spherical harmonic coefficients of the lighting probe; the amount of data of the latent code is smaller than the amount of data of the second-order spherical harmonic coefficients; a data integration module, configured to determine the network parameters of the target neural network corresponding to the data block and the latent code corresponding to the lighting probe in the data block as the compressed data of the data block; integrate the compressed data of the data blocks to obtain a compression result corresponding to the spherical harmonic ambient light data.
[0007] Third aspect, the present invention provides an electronic device, which includes a processor and a memory, the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above data compression method.
[0008] Fourth aspect, the present invention provides a computer-readable storage medium, which stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the above data compression method.
[0009] The embodiments of the present invention bring the following beneficial effects:
[0010] A data compression method, apparatus, and electronic device provided by the present invention first obtain spherical harmonic ambient light data corresponding to a target game scene, which is pre-baked for the target game scene under global illumination at a specified time point; the spherical harmonic ambient light data includes multiple data blocks, and each data block includes multiple light probes storing second-order spherical harmonic coefficients; then, based on the data blocks, an initial neural network is trained to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block, where the target neural network is used to: decompress compressed data according to the latent encoding corresponding to the light probe to obtain the second-order spherical harmonic coefficients of the light probe; the amount of data of the latent encoding is less than the amount of data of the second-order spherical harmonic coefficients; then, the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probes in the data block are determined as the compressed data of the data block; the compressed data of the data blocks is integrated to obtain a compression result corresponding to the spherical harmonic ambient light data. This method compresses the data blocks included in the spherical harmonic ambient light data of the entire game scene by a large number of small neural networks, can limit the size of a single neural network within a controllable range, and ensure that data can be decompressed at a fast enough speed in real time, so that the global illumination change effect of the game scene can be better realized on both mobile devices and computers.
[0011] Other features and advantages of the present invention will be described in the subsequent description, or some features and advantages can be inferred from the description or determined without doubt, or can be known by implementing the above technologies of the present invention.
[0012] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0014] Figure 1 It is a flowchart of a data compression method provided by an embodiment of the present invention;
[0015] Figure 2 It is a flowchart of another data compression method provided by an embodiment of the present invention;
[0016] Figure 3 It is a schematic diagram of data block compression provided by an embodiment of the present invention;
[0017] Figure 4A flowchart of another data compression method provided by an embodiment of the present invention;
[0018] Figure 5 A schematic diagram of data block splicing provided by an embodiment of the present invention;
[0019] Figure 6 A schematic structural diagram of a data compression device provided by an embodiment of the present invention;
[0020] Figure 7 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.
[0022] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.
[0023] In related technologies, to achieve global illumination changes in a game scene at different time points, it is necessary to pre-bake multiple sets of spherical harmonic ambient light data for the game scene at different time points, and then use the corresponding spherical harmonic ambient light data for rendering in real time. Spherical harmonic ambient light data is the data obtained by baking the game scene at a specific time point using spherical harmonic lighting. This spherical harmonic lighting decomposes the illumination field using spherical harmonics as basis functions and uses these spherical harmonic coefficients to represent the illumination. These coefficients are multiplied by the spherical harmonic weights to form a spherical harmonic lighting function, which can be used to approximate any illumination field.
[0024] However, as the size of the game scene increases, for example, the game scene is a super large world, the amount of pre-baked spherical harmonic ambient light data also increases. For example, in a test in a 16km*16km game scene, the spherical harmonic ambient light data of a single time frame is as high as 1-2GB. If you want to bake 13 time frames, the spherical harmonic ambient light data will occupy a maximum of 26GB of package. The PC game may barely be able to run, but the mobile terminal will find it difficult to carry it, and thus the global lighting change effect of the game scene cannot be achieved.
[0025] In order to achieve the global illumination change effect of the game scene on the mobile device, it is necessary to compress the pre-baked spherical harmonic ambient light data. In the related art, a Moving Basis Decomposition (MBD) compression method is provided. This MBD compression method decomposes the high-dimensional spherical harmonic ambient light data into the product of a set of bases and a set of coefficients. The key to its seamless decompression lies in the ability to interpolate the bases and coefficients with different distributions separately in 3D space. In 3D space, a grid where a coefficient is located contains i^3 original data, and a grid where a base is located contains j^3 coefficients. Both i and j can be adjusted according to the required compression ratio. Generally speaking, the larger their values, the better the reconstruction effect, but the lower the compression ratio. Although the MBD compression method can achieve a good compression ratio for a single set of spherical harmonic ambient light data at a fixed time point, when it is necessary to use multiple sets of spherical harmonic ambient light data to transition to achieve the dynamic global illumination effect, the implementation effect of this method is poor.
[0026] Based on the above problems, the embodiments of the present invention provide a data compression method, device and electronic device. This technology can be applied to the scene of realizing the global illumination effect of the game scene, especially in the compression and decompression scenes of the pre-baked spherical harmonic ambient light data.
[0027] To facilitate the understanding of the embodiments of the present invention, first, a data method provided by the embodiments of the present invention will be introduced in detail, as Figure 1 shown, the data compression method includes the following specific steps:
[0028] Step S102, obtain the spherical harmonic ambient light data corresponding to the target game scene; wherein, the spherical harmonic ambient light data is obtained by pre-baking the target game scene under the global illumination at a specified time point; the spherical harmonic ambient light data includes multiple data blocks, and each data block includes multiple light probes, and each light probe stores the corresponding second-order spherical harmonic coefficient.
[0029] In specific implementation, the global illumination irradiating the target game scene is spherical harmonic illumination, and the target game scene under the spherical harmonic illumination at the specified time point is baked to obtain the spherical harmonic ambient light data corresponding to the target game scene. Among them, the spherical harmonic illumination is to decompose the illumination field using spherical harmonic functions as basis functions and use these spherical harmonic function coefficients to represent the illumination. The above-mentioned specified time point can be any one or more time points. If there are multiple time points, each time point will correspond to a set of spherical harmonic ambient light data. Each set of spherical harmonic ambient light data includes multiple data blocks, each data block includes multiple light probes, and the number of light probes included in each data block can be the same or different. Specifically, the scene ranges in the target game scene covered by each data block are different.
[0030] The above-mentioned light probe refers to a sampling point placed in space for capturing indirect light in all directions, which can provide ambient light illumination for characters or models in the game scene. Each light probe stores corresponding second-order spherical harmonic coefficients. By multiplying these second-order spherical harmonic coefficients by the weights of the spherical harmonic functions, a spherical harmonic lighting function can be formed, which is used to approximate any lighting field. The amount of data of these second-order spherical harmonic coefficients is usually relatively large, usually represented by 12 floating-point numbers, resulting in a relatively large amount of data for each data block, and thus an even larger amount of data for the entire spherical harmonic ambient light data. Therefore, it is necessary to compress the spherical harmonic ambient light data.
[0031] Step S104: Based on the data block, train the initial neural network to obtain the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block. Among them, the target neural network is used to: decompress the compressed data according to the latent encoding corresponding to the light probe to obtain the second-order spherical harmonic coefficients of the light probe; the amount of data of this latent encoding is smaller than the amount of data of the second-order spherical harmonic coefficients.
[0032] The above-mentioned initial neural network can be set according to R & D requirements or any neural network can be selected. In practical applications, a large neural network can be used to compress the spherical harmonic ambient light data corresponding to the entire target game scene. However, the larger the neural network, the greater the real-time calculation overhead, making it difficult to be applied to mobile terminals. Therefore, the present invention uses the divide-and-conquer idea, splits the compression task into units according to data blocks, and independently uses a small neural network to compress each data block, so as to obtain better real-time decompression performance and effects. By compressing the data blocks corresponding to the entire target game scene with a large number of small neural networks, the size of a single neural network can be limited within a controllable range, and the amount of data decompressed per frame can be flexibly adjusted to ensure that the data can be decompressed in real time at a fast enough speed, thus being applicable to mobile terminals.
[0033] For each data block, a corresponding target neural network needs to be trained. The process of training the neural network is also the process of compressing the data in the data block. When training the neural network, the position encoding, initial latent encoding, and time encoding corresponding to each light probe in the data block are used as the input of the initial neural network. The initial neural network will output the second-order spherical harmonic coefficients corresponding to each light probe, and compare the output second-order spherical harmonic coefficients with the real second-order spherical harmonic coefficients corresponding to the data block to obtain a loss value. According to the loss value, adjust the network parameters and initial latent encoding of the initial neural network, and iterate multiple times to obtain the initial neural network corresponding to the data block and the final latent encoding corresponding to each light probe.
[0034] Step S106: Determine the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block as the compressed data of the data block; integrate the compressed data of the data block to obtain the compression result corresponding to the spherical harmonic ambient light data.
[0035] In specific implementation, the compressed data of each data block includes: the network parameters of the target neural network corresponding to the data block and the latent encoding stored in each light probe in the data block. Since the amount of data of the latent encoding is much smaller than that of the second-order spherical harmonic coefficients, this method can compress each data block. Obtaining the compressed data of each data block in the spherical harmonic ambient light data means obtaining the compression result corresponding to the spherical harmonic ambient light data. It can also be understood that the compression result corresponding to the spherical harmonic ambient light data includes the compressed data of each data block in the spherical harmonic ambient light data. According to the network parameters of the target neural network in the compressed data of the data block, the target neural network corresponding to the data block can be obtained. Through this target neural network, during game operation, according to the latent encoding corresponding to the light probe, the compressed data can be decompressed to obtain the second-order spherical harmonic coefficients of the light probe, thereby restoring the data in the data block.
[0036] A data compression method provided by an embodiment of the present invention first obtains the spherical harmonic ambient light data corresponding to the target game scene, which is pre-baked for the target game scene under global illumination at a specified time point; the spherical harmonic ambient light data includes multiple data blocks, and the data block includes multiple light probes storing second-order spherical harmonic coefficients; then, based on the data block, an initial neural network is trained to obtain the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block. The target neural network is used to: decompress the compressed data according to the latent encoding corresponding to the light probe to obtain the second-order spherical harmonic coefficients of the light probe; the amount of data of the latent encoding is smaller than that of the second-order spherical harmonic coefficients; then, determine the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block as the compressed data of the data block; integrate the compressed data of the data block to obtain the compression result corresponding to the spherical harmonic ambient light data. This method compresses the data blocks included in the spherical harmonic ambient light data of the entire game scene by a large number of small neural networks, can limit the size of a single neural network within a controllable range, and ensure that the data can be decompressed at a fast enough speed in real time, so that the global illumination change effect of the game scene can be better realized on both mobile devices and computer devices.
[0037] Another data compression method is also provided by an embodiment of the present invention. This method is implemented on the basis of the above embodiment. This method focuses on describing the specific process of training an initial neural network based on data blocks to obtain the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block (specifically implemented through the following steps S204 - S206); as Figure 2As shown in the figure, the method includes the following specific steps:
[0038] Step S202: Obtain the spherical harmonic ambient light data corresponding to the target game scene. Among them, the spherical harmonic ambient light data is pre-baked for the target game scene under global illumination at a specified time point. The spherical harmonic ambient light data includes multiple data blocks, and each data block includes multiple light probes, and each light probe stores the corresponding second-order spherical harmonic coefficients.
[0039] Step S204: Determine the position encoding of the light probes in the data block and the time encoding corresponding to the data block.
[0040] To train the initial neural network, it is necessary to determine the position encoding and time encoding of the light probes in the data block. In specific implementation, the position encoding and time encoding can be obtained through a preset position encoding function and time encoding function according to the relative position of each light probe and the specified time point of baking. It should be noted that the time encoding part is optional. If only compressing static scenes rather than multiple sets of spherical harmonic ambient light data that change over time, time encoding may not be required for compression.
[0041] In practical applications, the above step S204 can be implemented through the following steps 10-11:
[0042] Step 10: For each light probe in the data block, obtain the position encoding of the current light probe according to the preset encoding function and the position coordinates of the current light probe in the target game scene.
[0043] The above preset encoding function can be determined according to R & D requirements. When determining the position encoding of the light probe, first, the position coordinates of the light probe in the target game scene need to be converted into the normalized relative position vector of the light probe in its corresponding data block. Then, for each component in the relative position vector (the relative position vector includes X-axis component, Y-axis component, or Z-axis component), the preset encoding function is used for calculation respectively, and the encoding results of each component are concatenated to finally obtain the position encoding of the light probe. For example, the preset encoding function can adopt the following formula:
[0044] γ(p)=(sin(2 0 πp),cos(2 0 πp),…,sin(2 L-1 πp),cos(2 L-1 πp))
[0045] Among them, for any scalar p, this scalar p is also a component in the relative position vector of the light probe; γ(p) represents the preset encoding function for p; L is a constant obtained through experiments. For example, L = 10, L = 3, etc.
[0046] Step 11: Obtain the time encoding corresponding to the data block according to the preset encoding function and the time value corresponding to the specified time point.
[0047] The above preset encoding function can be determined according to R & D requirements. When determining the time encoding corresponding to the data block, it is necessary to convert the specified time point corresponding to baking the data block into a normalized floating-point number, and then use the preset encoding function to encode the floating-point number to obtain the time encoding. For example, the floating-point number can be used as p in the above formula, and the above formula can be used for encoding to obtain the time encoding.
[0048] In practical applications, after multiple tests, when performing position encoding, L = 2 can achieve good results; while for time encoding, using L = 5 has better effects.
[0049] Step S206: Train the initial neural network according to the time encoding corresponding to the data block, as well as the position encoding and second-order spherical harmonic coefficients corresponding to the light probes in the data block, to obtain the target neural network corresponding to the data block and the latent encoding corresponding to the light probes in the data block.
[0050] In specific implementation, the above step S206 can be implemented through the following steps 20 - 23:
[0051] Step 20: For each light probe in the data block, connect the latent encoding, position encoding, and time encoding corresponding to the current light probe to obtain the connection vector of the current light probe.
[0052] Connecting the latent encoding, position encoding, and time encoding of each light probe in the data block can obtain the connection vector of each light probe; among them, connecting can be understood as adding the position encoding after the latent encoding, and then adding the time encoding after the position encoding to obtain the connection vector. When first obtaining the connection vector, the latent encoding of each light probe is zero, and the latent encoding of this light probe will be adjusted as the neural network is trained. It can also be understood that the latent encoding is a trainable parameter.
[0053] Step 21: Input the connection vector of each light probe in the data block into the initial neural network to obtain an output result, and determine the loss value based on the output result and the second-order spherical harmonic coefficients corresponding to each light probe in the data block.
[0054] Input the connection vector of each light probe in the current data block into the initial neural network to obtain an output result. The output result includes the second-order spherical harmonic coefficients corresponding to each light probe calculated by the initial neural network. Comparing the second-order spherical harmonic coefficients corresponding to each light probe in the output result with the real second-order spherical harmonic coefficients stored in each light probe in the data block can obtain the loss value.
[0055] Step 22, if the above loss value is greater than the preset loss threshold, adjust the network parameters of the initial neural network and the latent encoding of each lighting probe to obtain an intermediate neural network and the adjusted latent encoding.
[0056] If the above loss value is greater than the preset loss threshold, it is necessary to adjust the network parameters of the initial neural network and the latent encoding of each lighting probe to obtain the adjusted initial neural network (i.e., the intermediate neural network) and the adjusted latent encoding corresponding to each lighting probe. The above preset loss threshold can be determined according to R & D requirements. For example, the preset loss threshold can be set to 5e-6 or 0.001, etc.
[0057] In practical applications, the above initial neural network is designed to adopt different data scales for different data blocks. Specifically, the initial neural network includes an input layer and an output layer. It can also be understood that the initial neural network is a decompressor composed of a two-layer neural network; the input layer includes an activation function, and the output layer can connect a Sigmoid as the activation function; the output layer includes multiple neurons; among them, the number M of neurons included in the output layer is dynamically adjusted according to the size of the preset loss threshold, so as to achieve the purpose of reducing errors or increasing the compression ratio. Generally, the more the number M of neurons, the better the compression effect.
[0058] After testing, if compressing a single set of spherical harmonic ambient light data of a pure static scene, M = 5 is sufficient, and at this time, a compression ratio of 7.37:1 can be achieved. When compressing multiple sets of spherical harmonic ambient light data corresponding to different specified time points, using M = 12 has a better effect, and at this time, a compression ratio of 44.42:1 can be achieved. It should be noted that generally, as long as the preset loss threshold reaches about 1e-5, there is almost no obvious difference in visual effects. In many places where the outdoor ambient light changes gently, using the above M value can usually obtain an error level of 1e-6 or even 1e-7. If a higher compression ratio is pursued, a lower M value can be used for different data blocks to reduce the data volume of the neural network. As long as the error is controlled below 5e-6, it is usually no problem.
[0059] Step 23, update the latent encoding in the connection vector of each lighting probe in the data block to the adjusted latent encoding, and update the initial neural network to the intermediate neural network; continue to execute the step of inputting the connection vector of each lighting probe in the data block into the initial neural network until the loss value is not greater than the preset loss threshold, and obtain the target neural network and the final latent encoding of each lighting probe in the data block.
[0060] After obtaining the intermediate neural network and the adjusted latent encoding, it is also necessary to update the connection vector of each lighting probe according to the adjusted latent encoding, and then input the updated connection vector corresponding to each lighting probe into the intermediate neural network to obtain an output result. Based on the difference between the output result and the true second-order spherical harmonic coefficients stored in each lighting probe in the data block, a loss value is obtained. If the loss value is still greater than the preset loss threshold, it is also necessary to adjust the network parameters of the intermediate neural network and the connection vectors of each lighting probe, and update the connection vectors again to perform iteration of the connection vectors until the loss value is less than or equal to the preset loss threshold, so as to obtain the target neural network corresponding to the data block and the final latent encoding of each lighting probe in the data block.
[0061] Step S208: Determine the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the lighting probe in the data block as the compressed data of the data block; integrate the compressed data of the data block to obtain the compressed result corresponding to the spherical harmonic ambient light data.
[0062] In specific implementation, the present invention compresses multiple sets of spherical harmonic ambient light data in the above-mentioned manner of steps S204 - S208, and the baking time corresponding to each set of spherical harmonic ambient light data is different.
[0063] In practical applications, the present invention is based on the SparseLightProbeVolume of the NeoX engine and has three layers of LOD (Level Of Details). Each set of spherical harmonic ambient light data contains multiple data blocks, and each data block is an array of 5*5*5 lighting probes. The entire SparseLightProbeVolume is composed of these data blocks. Under different LODs, the scene ranges covered by each data block are also different. As Figure 3 shown in the schematic diagram of data block compression provided by the embodiment of the present invention, Figure 3 the leftmost cube in it is used to represent a data block in the spherical harmonic ambient light data, and the circles on the data block represent lighting probes. The goal of the present invention is to determine to use independent and as small as possible neural networks to compress each 5*5*5 lighting probe array.
[0064] Figure 3The "1-byte feature" in it represents the potential encoding of one byte, "position encoding" represents the position encoding, "time encoding" represents the time encoding, and the decoder represents the target neural network. Connect the potential encoding, position encoding, and time encoding of a certain lighting probe to obtain a connection vector, and input this connection vector into the target neural network to obtain the second-order spherical harmonic coefficients of this lighting probe. In specific implementation, each lighting probe in the data block before compression stores the second-order spherical harmonic lighting coefficients, while each lighting probe in the data block after compression only stores the potential encoding of one byte, so the amount of data after compression is much smaller than that before compression.
[0065] When each data block includes 5*5*5 lighting probes, each compressed data block stores the potential encoding of one byte, and the amount of this part of data is 125 bytes. The number of units in the input layer of the target neural network: 1 feature + (position_encoding_L * 3 + time_encoding_L) * 2; where, position_encoding_L represents the L value corresponding to the preset position encoding function in the above formula, time_encoding_L represents the L value corresponding to the preset time encoding function in the above formula, and feature identifies the number of bytes of the potential encoding; when position_encoding_L = 2 and time_encoding_L = 5, the number of units in the input layer is 23. The number of units in the output layer of the target neural network is M, that is, the number of neurons. Each neuron outputs the second-order spherical harmonic coefficients of 12 floating-point numbers, and each floating-point number stored in the neural network uses half precision. Therefore, the amount of data in the input layer is (23 * M + M) * 2 bytes; the amount of data in the output layer is (M * 12 + 12) * 2 bytes. When M = 12, the total amount of data of the target neural network part is 888 bytes. So, adding the amount of data of the potential encoding of the data block to the neural network, the total amount of compressed data corresponding to the data block is 1013 bytes.
[0066] The size of the original data: The amount of data of each data block in a single set of spherical harmonic ambient light data is 5*5*5*12*2 = 3000 bytes; for a total of 15 sets of spherical harmonic ambient light data, the amount of data is 3000 * 15 = 45000 bytes; therefore, the compression ratio of this method is 45000:1013 = 44.42:1. If there is a total of 1 set of spherical harmonic ambient light data, the compression ratio is 3000:1013.
[0067] The above data compression method uses a neural network to compress multiple sets of spherical harmonic ambient light data that changes over time, achieving a dynamic global illumination effect. It can achieve a compression ratio of up to 44.42:1, effectively reducing the package size of extremely large game scenes. At the same time, the amount of data required by the neural network compression method is also small. Moreover, this method can be used to compress a single set of spherical harmonic ambient light data at a fixed time and has achieved very good results. In addition, this method has high performance and can support efficient operation on devices such as PCs and mobile terminals.
[0068] An embodiment of the present invention also provides another data compression method, which is implemented on the basis of the above embodiment. This method focuses on describing the specific process of decompressing the compression result of spherical harmonic ambient light data during game operation; as Figure 4 shown, this method includes the following specific steps:
[0069] Step S402, during game operation, obtain the compression results of spherical harmonic ambient light data corresponding to multiple specified time points; wherein, the compression result of spherical harmonic ambient light data at each specified time point includes the compressed data corresponding to multiple data blocks; the compressed data includes the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block.
[0070] In specific implementation, which specific time point each specified time point is determined according to R & D requirements and baking time.
[0071] Step S404, use the target neural network corresponding to the data block in the first compression result corresponding to the first specified time point to decompress the first compression result to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, the first specified time point is the smallest time point among the multiple specified time points.
[0072] In specific implementation, the above step S404 can be implemented through the following steps 30-31:
[0073] Step 30, for the compressed data of each data block included in the first compression result corresponding to the first specified time point, input the connection vector of the light probe included in the current compressed data into the target neural network corresponding to the current compressed data, and output the decompressed data of the current compressed data; wherein, the decompressed data includes: the second-order spherical harmonic coefficients corresponding to the light probe included in the compressed data.
[0074] The above connection vector of the light probe is also the result of connecting the latent encoding, position encoding, and time encoding corresponding to the light probe. Inputting the connection vector of each light probe into its corresponding target neural network can obtain the second-order spherical harmonic coefficients of each light probe, thereby realizing data decompression.
[0075] Step 31: Concatenate the decompressed data of each compressed data included in the first compression result to obtain the spherical harmonic ambient light data corresponding to the first specified time point. When concatenating the decompressed data, copy the target light probe adjacent to the data block corresponding to the current decompressed data from the data block corresponding to the decompressed data adjacent to the data block corresponding to the current decompressed data, and combine the target light probe with the data block corresponding to the current decompressed data.
[0076] After real-time decompression, the present invention uses the seam processing algorithm of ComputeShader to perform high-performance filling on the seams between different data blocks, so that the light probes between adjacent data blocks can provide continuous and smooth spherical harmonic ambient lighting.
[0077] As Figure 5 shown in the schematic diagram of data block concatenation provided by the embodiment of the present invention, Figure 5 each data block in is a 5*5*5 light probe array, but there is a unit gap between data blocks in the GPU. To ensure good connection when sampling this unit, the data blocks in the GPU are 6*6*6 light probe arrays, and the data of the extra row of light probes is copied from adjacent data blocks.
[0078] Since the data blocks in the present invention are compressed independently, the neural network cannot ensure that the overlapping parts of the data blocks can restore exactly the same values. Therefore, the neural network still only compresses the 5*5*5 part, and for the extra part, after decompression, a ComputeShader is used to copy data from adjacent data blocks to eliminate the seams. Figure 5 The light-colored dots in represent the compressed data blocks, and the dark-colored dots represent the light probes copied from adjacent data blocks. Figure 5 only shows the case of two data blocks with the same LOD. In actual projects, the situation is more complex. Not only do we need to consider adjacent data blocks with the same LOD, but also adjacent data blocks with different LODs, and the processing of seam problems is more complex.
[0079] Step S406: If the current time is after the first specified time point and before the second specified time point, decompress the second compression result through the target neural network corresponding to the data block in the second compression result corresponding to the second specified time point to obtain the spherical harmonic ambient light data corresponding to the second specified time point. The second specified time point is the next specified time point after the first specified time point.
[0080] For the decompression method of the second compressed data corresponding to the second specified time, reference can be made to the above steps 30-31, which will not be elaborated here.
[0081] Step S408: Interpolate the spherical harmonic ambient light data corresponding to the first specified time point and the spherical harmonic ambient light data corresponding to the second specified time point to obtain the spherical harmonic ambient light data corresponding to the current time.
[0082] Real-time decompression does not mean decompressing at the current time for each frame into the target neural network, nor does it require decompression for each frame. Instead, the value after the nearest specified time point following the current time t is passed in for decompression. After decompressing the spherical harmonic ambient light data corresponding to the subsequent specified time points all at once, for each frame, only the spherical harmonic ambient light data in the current video memory needs to be interpolated with the spherical harmonic ambient light data decompressed at the next specified time point to obtain the spherical harmonic ambient light data corresponding to the current time.
[0083] In practical applications, the process of real-time decompression is implemented in the ComputeShader. Each thread is responsible for the decompression process of a data block. After running the calculations of the entire neural network, all data blocks are integrated into one decompressed data to obtain the spherical harmonic ambient light data.
[0084] Step S410: When the current time is after the second specified time point, determine whether the second specified time point is the last specified time point among multiple specified time points; if so, execute Step S412.
[0085] Step S412: Stop decompression.
[0086] Step S414: Decompress the third compression result through the target neural network corresponding to the data block in the third compression result corresponding to the next specified time point after the second specified time point to obtain the spherical harmonic ambient light data corresponding to the third specified time point; execute Step S416.
[0087] Step S416: Determine the next specified time point after the second specified time point as the new second specified time point, and continue to execute Step S410.
[0088] When the current time is after the second specified time point, if there is no un-decompressed compression result, stop decompression. If there is an un-decompressed compression result after the second specified time point, it is necessary to continue decompressing the compression result of the spherical harmonic ambient light data corresponding to the specified time point after the current time, so as to interpolate the currently existing spherical harmonic ambient light data and the spherical harmonic ambient light data obtained from this decompression to obtain the spherical harmonic ambient light data corresponding to the current time.
[0089] For the above data compression method, it only needs to provide the next specified time point closest to the current time for the neural network in the decompression frame, and the neural network decompresses the spherical harmonic ambient light data at the next specified time point at one time. In other rendering frames, it only needs to use the current spherical harmonic ambient light data and the decompressed spherical harmonic ambient light data to perform a simple linear interpolation to obtain the spherical harmonic ambient light data at the current time. Through this method, the overhead of real-time decompression is effectively reduced, and the need to decompress every frame is converted into decompressing the data at specific time points only when needed, while also obtaining a good dynamic global illumination effect.
[0090] Corresponding to the above method embodiments, the embodiments of the present invention also provide a data compression device, as Figure 6 shown. The device includes:
[0091] A data acquisition module 60, configured to acquire the spherical harmonic ambient light data corresponding to the target game scene; wherein, the spherical harmonic ambient light data is pre-baked for the target game scene under the global illumination at a specified time point; the spherical harmonic ambient light data includes a plurality of data blocks, and each data block includes a plurality of light probes, and each light probe stores the corresponding second-order spherical harmonic coefficient.
[0092] A data compression module 61, configured to train an initial neural network based on the data blocks to obtain a target neural network corresponding to the data blocks and a latent encoding corresponding to the light probes in the data blocks; wherein, the target neural network is used to: decompress the compressed data according to the latent encoding corresponding to the light probe to obtain the second-order spherical harmonic coefficient of the light probe; the amount of data of the latent encoding is less than the amount of data of the second-order spherical harmonic coefficient.
[0093] A data integration module 62, configured to determine the network parameters of the target neural network corresponding to the data blocks and the latent encoding corresponding to the light probes in the data blocks as the compressed data of the data blocks; integrate the compressed data of the data blocks to obtain the compression result corresponding to the spherical harmonic ambient light data.
[0094] The above data compression device first obtains the spherical harmonic ambient light data corresponding to the target game scene, which is pre-baked for the target game scene under global illumination at a specified time point; the spherical harmonic ambient light data includes multiple data blocks, and each data block includes multiple light probes storing second-order spherical harmonic coefficients; then, based on the data blocks, an initial neural network is trained to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block. The target neural network is used to: decompress the compressed data according to the latent encoding corresponding to the light probe to obtain the second-order spherical harmonic coefficients of the light probe; the amount of data of the latent encoding is smaller than the amount of data of the second-order spherical harmonic coefficients; then, the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probes in the data block are determined as the compressed data of the data block; the compressed data of the data blocks is integrated to obtain the compression result corresponding to the spherical harmonic ambient light data. This method compresses the data blocks included in the spherical harmonic ambient light data of the entire game scene by a large number of small neural networks, which can limit the size of a single neural network within a controllable range and ensure that the data can be decompressed in real time at a sufficiently fast speed, so that the global illumination change effect of the game scene can be better achieved on both mobile devices and desktop computers.
[0095] Specifically, the above data compression module 61 includes: an encoding determination unit, configured to determine the position encoding of the light probes in the data block and the time encoding corresponding to the data block; a network training unit, configured to train an initial neural network according to the time encoding corresponding to the data block, the position encoding corresponding to the light probes in the data block, and the second-order spherical harmonic coefficients, to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block.
[0096] In a specific implementation, the above encoding unit is configured to: for each light probe in the data block, obtain the position encoding of the current light probe according to a preset encoding function and the position coordinates of the current light probe in the target game scene; and obtain the time encoding corresponding to the data block according to a preset encoding function and the time value corresponding to the specified time point.
[0097] In specific implementation, the above-mentioned network training unit is used to: for each light probe in the data block, connect the latent encoding, position encoding, and time encoding corresponding to the current light probe to obtain the connection vector of the current light probe; input the connection vectors of each light probe in the data block into the initial neural network to obtain an output result, and determine a loss value based on the output result and the second-order spherical harmonic coefficients corresponding to each light probe in the data block; if the loss value is greater than a preset loss threshold, adjust the network parameters of the initial neural network and the latent encoding of each light probe to obtain an intermediate neural network and the adjusted latent encoding; update the latent encoding in the connection vector of each light probe in the data block to the adjusted latent encoding, and update the initial neural network to the intermediate neural network; continue to execute the step of inputting the connection vectors of each light probe in the data block into the initial neural network until the loss value is not greater than the preset loss threshold, to obtain the target neural network and the final latent encoding of each light probe in the data block.
[0098] In practical applications, the above-mentioned initial neural network includes an input layer and an output layer; the input layer includes an activation function, and the output layer includes multiple neural units; among them, the number of neural units included in the output layer is dynamically adjusted according to the size of the preset loss threshold.
[0099] Further, the above specified time points include multiple ones; the compression results of the spherical harmonic ambient light data at each specified time point each include the compressed data corresponding to multiple data blocks; the compressed data includes the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block; the above device further includes a decompression module, configured to: during the game running, decompress the first compression result through the target neural network corresponding to the data block in the first compression result corresponding to the first specified time point to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, the first specified time point is the smallest time point among the multiple specified time points; if the current time is after the first specified time point and before the second specified time point, decompress the second compression result through the target neural network corresponding to the data block in the second compression result corresponding to the second specified time point to obtain the spherical harmonic ambient light data corresponding to the second specified time point; wherein, the second specified time point is the next specified time point after the first specified time point; interpolate the spherical harmonic ambient light data corresponding to the first specified time point and the spherical harmonic ambient light data corresponding to the second specified time point to obtain the spherical harmonic ambient light data corresponding to the current time; when the current time is after the second specified time point, determine whether the second specified time point is the last specified time point among the multiple specified time points; if so, stop decompressing; if not, decompress the third compression result through the target neural network corresponding to the data block in the third compression result corresponding to the next specified time point after the second specified time point to obtain the spherical harmonic ambient light data corresponding to the next specified time point after the second specified time point; determine the next specified time point after the second specified time point as the new second specified time point, and continue to execute the step of determining whether the second specified time point is the last specified time point among the multiple specified time points when the current time is after the second specified time point until the second specified time point is the last specified time point among the multiple specified time points.
[0100] In practical applications, the above decompression unit is further configured to: for the compressed data of each data block included in the first compression result corresponding to the first specified time point, input the connection vector of the light probe included in the current compressed data into the target neural network corresponding to the current compressed data, and output the decompressed data of the current compressed data; wherein, the decompressed data includes: the second-order spherical harmonic coefficients corresponding to the light probe included in the compressed data; splice the decompressed data of each compressed data included in the first compression result to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, when splicing the decompressed data, copy the target light probe adjacent to the data block corresponding to the current decompressed data from the data block corresponding to the decompressed data adjacent to the data block corresponding to the current decompressed data, and combine the target light probe with the data block corresponding to the current decompressed data.
[0101] The data compression device provided by the embodiments of the present invention has the same implementation principle and technical effects as those of the foregoing method embodiments. For the sake of brief description, for the parts not mentioned in the device embodiments, reference may be made to the corresponding content in the foregoing method embodiments.
[0102] The embodiments of the present invention also provide an electronic device, as Figure 7 shown. The electronic device includes a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the above data compression method.
[0103] Specifically, the above data compression method includes: obtaining spherical harmonic ambient light data corresponding to a target game scene; wherein, the spherical harmonic ambient light data is pre-baked for the target game scene under global illumination at a specified time point; the spherical harmonic ambient light data includes a plurality of data blocks, and each data block includes a plurality of light probes, and each light probe stores corresponding second-order spherical harmonic coefficients; training an initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block; wherein, the target neural network is used to: decompress the compressed data according to the latent encoding corresponding to the light probe to obtain the second-order spherical harmonic coefficients of the light probe; the amount of data of the latent encoding is smaller than the amount of data of the second-order spherical harmonic coefficients; determining the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probes in the data block as the compressed data of the data block; integrating the compressed data of the data blocks to obtain a compression result corresponding to the spherical harmonic ambient light data.
[0104] The above data compression method compresses the data blocks included in the spherical harmonic ambient light data of the entire game scene by a large number of small neural networks, which can limit the size of a single neural network within a controllable range and ensure that the data can be decompressed at a fast enough speed in real time, so that the global illumination change effect of the game scene can be better realized on both mobile devices and computer devices.
[0105] In an alternative embodiment, the step of training the initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block includes: determining a position encoding of the light probes in the data block and a time encoding corresponding to the data block; training the initial neural network according to the time encoding corresponding to the data block, the position encoding corresponding to the light probes in the data block, and the second-order spherical harmonic coefficients to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block.
[0106] In an alternative embodiment, the steps of determining the position encoding of the light probes in the data block and the time encoding corresponding to the data block include: for each light probe in the data block, obtaining the position encoding of the current light probe according to a preset encoding function and the position coordinates of the current light probe in the target game scene; and obtaining the time encoding corresponding to the data block according to the preset encoding function and the time value corresponding to the specified time point.
[0107] In an alternative embodiment, the steps of training the initial neural network according to the time encoding corresponding to the data block, the position encoding corresponding to the light probes in the data block, and the second-order spherical harmonic coefficients, to obtain the target neural network corresponding to the data block and the latent encoding corresponding to the light probes in the data block include: for each light probe in the data block, concatenating the latent encoding, the position encoding, and the time encoding corresponding to the current light probe to obtain a connection vector of the current light probe; inputting the connection vectors of each light probe in the data block into the initial neural network to obtain an output result, and determining a loss value based on the output result and the second-order spherical harmonic coefficients corresponding to each light probe in the data block; if the loss value is greater than a preset loss threshold, adjusting the network parameters of the initial neural network and the latent encoding of each light probe to obtain an intermediate neural network and an adjusted latent encoding; updating the latent encoding in the connection vector of each light probe in the data block to the adjusted latent encoding, and updating the initial neural network to the intermediate neural network; continuing to execute the step of inputting the connection vectors of each light probe in the data block into the initial neural network until the loss value is not greater than the preset loss threshold, to obtain the target neural network and the final latent encoding of each light probe in the data block.
[0108] In an alternative embodiment, the initial neural network includes an input layer and an output layer; the input layer includes an activation function, and the output layer includes a plurality of neurons; wherein, the number of neurons included in the output layer is dynamically adjusted according to the magnitude of the preset loss threshold.
[0109] In an alternative embodiment, the above-mentioned specified time points include multiple ones; the compression results of the spherical harmonic ambient light data at each specified time point each include the compressed data corresponding to multiple data blocks; the compressed data includes the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block; the above method further includes: during the game operation, by using the target neural network corresponding to the data block in the first compression result corresponding to the first specified time point, decompressing the first compression result to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, the first specified time point is the smallest time point among the multiple specified time points; if the current time is after the first specified time point and before the second specified time point, by using the target neural network corresponding to the data block in the second compression result corresponding to the second specified time point, decompressing the second compression result to obtain the spherical harmonic ambient light data corresponding to the second specified time point; wherein, the second specified time point is the next specified time point after the first specified time point; interpolating the spherical harmonic ambient light data corresponding to the first specified time point and the spherical harmonic ambient light data corresponding to the second specified time point to obtain the spherical harmonic ambient light data corresponding to the current time; when the current time is after the second specified time point, determining whether the second specified time point is the last specified time point among the multiple specified time points; if so, stopping decompression; if not, by using the target neural network corresponding to the data block in the third compression result corresponding to the next specified time point after the second specified time point, decompressing the third compression result to obtain the spherical harmonic ambient light data corresponding to the next specified time point after the second specified time point; determining the next specified time point after the second specified time point as the new second specified time point, and continuing to execute the step of determining whether the second specified time point is the last specified time point among the multiple specified time points when the current time is after the second specified time point until the second specified time point is the last specified time point among the multiple specified time points..
[0110] In an alternative embodiment, the step of decompressing the first compression result by using the target neural network corresponding to the data block in the first compression result corresponding to the first specified time point to obtain the spherical harmonic ambient light data corresponding to the first specified time point includes: for the compressed data of each data block included in the first compression result corresponding to the first specified time point, inputting the connection vector of the light probe included in the current compressed data into the target neural network corresponding to the current compressed data, and outputting the decompressed data of the current compressed data; wherein, the decompressed data includes: the second-order spherical harmonic coefficients corresponding to the light probe included in the compressed data; splicing the decompressed data of each compressed data included in the first compression result to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, when splicing the decompressed data, copying the target light probe adjacent to the data block corresponding to the current decompressed data from the data block corresponding to the decompressed data adjacent to the data block corresponding to the current decompressed data, and combining the target light probe with the data block corresponding to the current decompressed data.
[0111] Further, Figure 7 the electronic device shown further includes a bus 102 and a communication interface 103, and the processor 101, the communication interface 103, and the memory 100 are connected through the bus 102.
[0112] Among them, the memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between this system network element and at least one other network element is realized through at least one communication interface 103 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 102 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of simplicity of representation, Figure 7 only a bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0113] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the above method can be completed by the integrated logic circuit in the hardware of the processor 101 or the instructions in the form of software. The above-mentioned processor 101 may be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it may also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of the hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and combines its hardware to complete the steps of the method in the foregoing embodiments.
[0114] An embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the above data compression method. For specific implementation, refer to the method embodiment and details are not described herein again.
[0115] Specifically, the above data compression method includes: obtaining spherical harmonic ambient light data corresponding to a target game scene; wherein, the spherical harmonic ambient light data is pre-baked for the target game scene under global illumination at a specified time point; the spherical harmonic ambient light data includes a plurality of data blocks, each data block includes a plurality of light probes, and each light probe stores corresponding second-order spherical harmonic coefficients; training an initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block; wherein, the target neural network is used to: decompress the compressed data according to the latent encoding corresponding to the light probe to obtain the second-order spherical harmonic coefficients of the light probe; the data amount of the latent encoding is less than the data amount of the second-order spherical harmonic coefficients; determining the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probes in the data block as the compressed data of the data block; integrating the compressed data of the data blocks to obtain a compression result corresponding to the spherical harmonic ambient light data.
[0116] The above data compression method compresses the data blocks included in the spherical harmonic ambient light data of the entire game scene by a large number of small neural networks, which can limit the size of a single neural network within a controllable range and ensure that the data can be decompressed in real time at a fast enough speed, so that the global illumination change effect of the game scene can be better realized on both mobile devices and computer devices.
[0117] In an alternative embodiment, the step of training the initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block includes: determining a position encoding of the light probes in the data block and a time encoding corresponding to the data block; training the initial neural network according to the time encoding corresponding to the data block, the position encoding corresponding to the light probes in the data block, and the second-order spherical harmonic coefficients to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block.
[0118] In an alternative embodiment, the step of determining a position encoding of the light probes in the data block and a time encoding corresponding to the data block includes: for each light probe in the data block, obtaining the position encoding of the current light probe according to a preset encoding function and the position coordinates of the current light probe in the target game scene; obtaining the time encoding corresponding to the data block according to the preset encoding function and the time value corresponding to the specified time point.
[0119] In an alternative embodiment, the step of training the initial neural network according to the time encoding corresponding to the data block, the position encoding corresponding to the light probe in the data block, and the second-order spherical harmonic coefficient, to obtain the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block, includes: for each light probe in the data block, concatenating the latent encoding, the position encoding, and the time encoding corresponding to the current light probe to obtain a connection vector of the current light probe; inputting the connection vectors of each light probe in the data block into the initial neural network to obtain an output result, and determining a loss value based on the output result and the second-order spherical harmonic coefficient corresponding to each light probe in the data block; if the loss value is greater than a preset loss threshold, adjusting the network parameters of the initial neural network and the latent encoding of each light probe to obtain an intermediate neural network and an adjusted latent encoding; updating the latent encoding in the connection vector of each light probe in the data block to the adjusted latent encoding, and updating the initial neural network to the intermediate neural network; continuing to execute the step of inputting the connection vectors of each light probe in the data block into the initial neural network until the loss value is not greater than the preset loss threshold, to obtain the target neural network and the final latent encoding of each light probe in the data block.
[0120] In an alternative embodiment, the above initial neural network includes an input layer and an output layer; the input layer includes an activation function, and the output layer includes a plurality of neurons; wherein, the number of neurons included in the output layer is dynamically adjusted according to the size of the preset loss threshold.
[0121] In an alternative embodiment, the above-mentioned specified time points include multiple ones; the compression results of the spherical harmonic ambient light data at each specified time point each include compressed data corresponding to multiple data blocks; the compressed data includes the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probe in the data block; the above method further includes: during the game runtime, by using the target neural network corresponding to the data block in the first compression result corresponding to the first specified time point, decompressing the first compression result to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, the first specified time point is the smallest time point among the multiple specified time points; if the current time is after the first specified time point and before the second specified time point, by using the target neural network corresponding to the data block in the second compression result corresponding to the second specified time point, decompressing the second compression result to obtain the spherical harmonic ambient light data corresponding to the second specified time point; wherein, the second specified time point is the next specified time point after the first specified time point; interpolating the spherical harmonic ambient light data corresponding to the first specified time point and the spherical harmonic ambient light data corresponding to the second specified time point to obtain the spherical harmonic ambient light data corresponding to the current time; when the current time is after the second specified time point, determining whether the second specified time point is the last specified time point among the multiple specified time points; if so, stopping decompression; if not, by using the target neural network corresponding to the data block in the third compression result corresponding to the next specified time point after the second specified time point, decompressing the third compression result to obtain the spherical harmonic ambient light data corresponding to the next specified time point after the second specified time point; determining the next specified time point after the second specified time point as the new second specified time point, and continuing to execute the step of determining whether the second specified time point is the last specified time point among the multiple specified time points when the current time is after the second specified time point until the second specified time point is the last specified time point among the multiple specified time points..
[0122] In an alternative embodiment, the step of decompressing the first compression result by using the target neural network corresponding to the data block in the first compression result corresponding to the first specified time point to obtain the spherical harmonic ambient light data corresponding to the first specified time point includes: for the compressed data of each data block included in the first compression result corresponding to the first specified time point, inputting the connection vector of the light probe included in the current compressed data into the target neural network corresponding to the current compressed data, and outputting the decompressed data of the current compressed data; wherein, the decompressed data includes: the second-order spherical harmonic coefficients corresponding to the light probe included in the compressed data; splicing the decompressed data of each compressed data included in the first compression result to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, when splicing the decompressed data, copying the target light probe adjacent to the data block corresponding to the current decompressed data from the data block corresponding to the decompressed data adjacent to the data block corresponding to the current decompressed data, and combining the target light probe with the data block corresponding to the current decompressed data.
[0123] When the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a terminal device, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.
[0124] In the description of the present invention, it should be noted that the orientation or positional relationship indicated by the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation to the present invention. In addition, the terms "first", "second", "third" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance.
[0125] Finally, it should be noted that the above-mentioned embodiments are only specific embodiments of the present invention, used to illustrate the technical solutions of the present invention, rather than limiting them. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that any person skilled in the art within the technical scope disclosed by the present invention can still modify the technical solutions recorded in the foregoing embodiments, or can easily think of changes, or make equivalent replacements for some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims
1. A data compression method, characterized in that, The method includes: Obtaining spherical harmonic ambient light data corresponding to a target game scene; wherein, the spherical harmonic ambient light data is pre-baked for the target game scene under global illumination at a specified time point; the spherical harmonic ambient light data includes a plurality of data blocks, the data blocks include a plurality of light probes, and the light probes store corresponding second-order spherical harmonic coefficients; Training an initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block; wherein, the target neural network is used to: decompress compressed data according to the latent encoding corresponding to the light probe to obtain the second-order spherical harmonic coefficient of the light probe; the data volume of the latent encoding is smaller than the data volume of the second-order spherical harmonic coefficient; Determining the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the light probes in the data block as the compressed data of the data block; integrating the compressed data of the data block to obtain a compression result corresponding to the spherical harmonic ambient light data.
2. The method according to claim 1, wherein The step of training an initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block includes: Determining a position encoding of the light probes in the data block and a time encoding corresponding to the data block; Training the initial neural network according to the time encoding corresponding to the data block, the position encoding and the second-order spherical harmonic coefficient corresponding to the light probes in the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block.
3. The method according to claim 2, characterized in that, The step of determining a position encoding of the light probes in the data block and a time encoding corresponding to the data block includes: For each light probe in the data block, obtaining the position encoding of the current light probe according to a preset encoding function and the position coordinates of the current light probe in the target game scene; Obtaining the time encoding corresponding to the data block according to a preset encoding function and the time value corresponding to the specified time point.
4. The method according to claim 2, wherein The step of training the initial neural network according to the time encoding corresponding to the data block, the position encoding and the second-order spherical harmonic coefficient corresponding to the light probes in the data block to obtain a target neural network corresponding to the data block and a latent encoding corresponding to the light probes in the data block includes: For each light probe in the data block, connecting the latent encoding, the position encoding and the time encoding corresponding to the current light probe to obtain a connection vector of the current light probe; Inputting the connection vectors of each light probe in the data block into the initial neural network to obtain an output result, and determining a loss value based on the output result and the second-order spherical harmonic coefficient corresponding to each light probe in the data block; If the loss value is greater than a preset loss threshold, adjusting the network parameters of the initial neural network and the latent encoding of each light probe to obtain an intermediate neural network and an adjusted latent encoding; Update the latent encoding in the connection vector of each lighting probe in the data block to the adjusted latent encoding, and update the initial neural network to the intermediate neural network; continue to execute the step of inputting the connection vector of each lighting probe in the data block into the initial neural network until the loss value is not greater than the preset loss threshold, and obtain the target neural network and the final latent encoding of each lighting probe in the data block.
5. The method according to claim 4, characterized in that The initial neural network includes an input layer and an output layer; the input layer includes an activation function, and the output layer includes multiple neurons; wherein, the number of neurons included in the output layer is dynamically adjusted according to the size of the preset loss threshold.
6. The method according to claim 1, wherein The specified time points include multiple; the compression result of the spherical harmonic ambient light data at each specified time point includes the compressed data corresponding to multiple data blocks; the compressed data includes the network parameters of the target neural network corresponding to the data block and the latent encoding corresponding to the lighting probe in the data block; The method further includes: During the game runtime, decompress the first compression result through the target neural network corresponding to the data block in the first compression result corresponding to the first specified time point to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, the first specified time point is the smallest time point among the multiple specified time points; If the current time is after the first specified time point and before the second specified time point, decompress the second compression result through the target neural network corresponding to the data block in the second compression result corresponding to the second specified time point to obtain the spherical harmonic ambient light data corresponding to the second specified time point; wherein, the second specified time point is the next specified time point after the first specified time point; Interpolate the spherical harmonic ambient light data corresponding to the first specified time point and the spherical harmonic ambient light data corresponding to the second specified time point to obtain the spherical harmonic ambient light data corresponding to the current time; When the current time is after the second specified time point, determine whether the second specified time point is the last specified time point among the multiple specified time points; if so, stop decompressing; If not, decompress the third compression result through the target neural network corresponding to the data block in the third compression result corresponding to the next specified time point after the second specified time point to obtain the spherical harmonic ambient light data corresponding to the next specified time point after the second specified time point; determine the next specified time point after the second specified time point as the new second specified time point, and continue to execute the step of determining whether the second specified time point is the last specified time point among the multiple specified time points when the current time is after the second specified time point until the second specified time point is the last specified time point among the multiple specified time points.
7. The method according to claim 6, wherein The step of decompressing the first compression result through the target neural network corresponding to the data block in the first compression result corresponding to the first specified time point to obtain the spherical harmonic ambient light data corresponding to the first specified time point includes: For the compressed data of each data block included in the first compression result corresponding to the first specified time point, input the connection vector of the light probe included in the current compressed data into the target neural network corresponding to the current compressed data, and output the decompressed data of the current compressed data; wherein, the decompressed data includes: the second-order spherical harmonic coefficients corresponding to the light probes included in the compressed data. Concatenate the decompressed data of each compressed data included in the first compression result to obtain the spherical harmonic ambient light data corresponding to the first specified time point; wherein, when concatenating the decompressed data, copy the target light probe adjacent to the data block corresponding to the current decompressed data from the data block corresponding to the decompressed data adjacent to the data block corresponding to the current decompressed data, and combine the target light probe with the data block corresponding to the current decompressed data.
8. A data compression device, characterized in that, The device includes: A data acquisition module, configured to acquire spherical harmonic ambient light data corresponding to a target game scene; wherein, the spherical harmonic ambient light data is pre-baked for the target game scene under global illumination at a specified time point; the spherical harmonic ambient light data includes multiple data blocks, each data block includes multiple light probes, and each light probe stores corresponding second-order spherical harmonic coefficients. A data compression module, configured to train an initial neural network based on the data block to obtain a target neural network corresponding to the data block and a latent code corresponding to the light probe in the data block; wherein, the target neural network is used to: decompress the compressed data according to the latent code corresponding to the light probe to obtain the second-order spherical harmonic coefficients of the light probe; the data volume of the latent code is smaller than the data volume of the second-order spherical harmonic coefficients. A data integration module, configured to determine the network parameters of the target neural network corresponding to the data block and the latent code corresponding to the light probe in the data block as the compressed data of the data block; integrate the compressed data of the data block to obtain a compression result corresponding to the spherical harmonic ambient light data.
9. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the data compression method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the data compression method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method for dynamically estimating illumination parameters of location in augmented reality scene using neural network
CN111723902A
Illumination map data generation method, device and equipment, medium and program product
CN114299220A