Method, device, storage medium and program product for generating a visibility information file

By calculating the Hamming distance between virtual models, adjusting the order of model visibility vectors in the visibility matrix, and performing binary compression, the problem of excessive storage space requirements for visibility information in large-scale rendering scenes is solved, achieving higher compression ratios and faster rendering performance.

CN116775585BActive Publication Date: 2026-05-08TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2022-03-10
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

As the scale of the rendering scene and the number of models increase, the storage space requirement for visibility information in existing occlusion culling methods increases dramatically, leading to a decrease in the usability of occlusion culling in large worlds.

Method used

By calculating the Hamming distance between virtual models, adjusting the order of model visibility vectors in the visibility matrix, generating the target visibility matrix, and performing binary compression on it to reduce information entropy and improve the compression rate.

Benefits of technology

While ensuring information accuracy, the size of the visibility information file is significantly reduced, thereby improving the loading performance of scene rendering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116775585B_ABST
    Figure CN116775585B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a kind of generation method, equipment, storage medium and program product of visibility information file, belong to image processing technical field.The method comprises: generating initial visibility matrix based on virtual scene;Based on the hamming distance between model visibility vector in initial visibility matrix, the arrangement order of model visibility vector is adjusted, and target visibility matrix is obtained;The target visibility matrix is compressed in binary, and the visibility information file is generated.The application improves the compression rate of visibility information, reduces the size of visibility information file, thereby improves the loading performance of scene rendering under the premise of guaranteeing information accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a method, device, storage medium, and program product for generating visibility information files. Background Technology

[0002] Occlusion culling refers to the method of calculating the occlusion information of the scene in advance before the graphics rendering occurs, removing the occluded parts, interrupting the rendering process of that part of the model, and saving resources.

[0003] In related technologies, computer equipment inputs a virtual scene into an occlusion culling system, generates visibility information in binary form, compresses and packages it, and sends it to the terminal. This visibility information indicates whether the model is visible in various areas of the scene. The terminal queries the visibility information based on the area of ​​view to determine the model that needs to be rendered.

[0004] However, visibility information needs to be stored in a file in binary form. Each model in the scene has two states, visible and invisible, within each region, requiring one bit for storage. Therefore, the total amount of information is directly proportional to the number of models and regions. As the size of the rendered scene and the number of models increase, the amount of information used for occlusion culling also increases, requiring more storage space and reducing the usability of occlusion culling in large-scale scenarios. Summary of the Invention

[0005] This application provides a method, device, storage medium, and program product for generating visibility information files, which can improve the compression rate of visibility information, reduce the size of visibility information files, and improve the loading performance of scene rendering. The technical solution is as follows:

[0006] On one hand, embodiments of this application provide a method for generating a visibility information file, the method comprising:

[0007] An initial visibility matrix is ​​generated based on a virtual scene, wherein the virtual scene contains a virtual model, and the matrix elements in the initial visibility matrix are used to indicate whether the virtual model is visible in the scene area;

[0008] Based on the Hamming distance between the model visibility vectors in the initial visibility matrix, the arrangement order of the model visibility vectors is adjusted to obtain the target visibility matrix. The total Hamming distance of the target visibility matrix is ​​less than the total Hamming distance of the initial visibility matrix. The model visibility vectors are used to indicate the visibility of the same virtual model in the scene area. The total Hamming distance is the sum of the Hamming distances of adjacent model visibility vectors.

[0009] The target visibility matrix is ​​binary compressed to generate a visibility information file, which is used to guide the rendering of visible virtual models in the virtual scene.

[0010] On the other hand, embodiments of this application provide an apparatus for generating visibility information files, the apparatus comprising:

[0011] A matrix generation module is used to generate an initial visibility matrix based on a virtual scene, wherein the virtual scene contains a virtual model, and the matrix elements in the initial visibility matrix are used to indicate whether the virtual model is visible in the scene area;

[0012] The matrix adjustment module is used to adjust the arrangement order of the model visibility vectors based on the Hamming distance between the model visibility vectors in the initial visibility matrix to obtain a target visibility matrix. The total Hamming distance of the target visibility matrix is ​​less than the total Hamming distance of the initial visibility matrix. The model visibility vectors are used to indicate the visibility of the same virtual model in the scene area. The total Hamming distance is the sum of the Hamming distances of adjacent model visibility vectors.

[0013] The file generation module is used to perform binary compression on the target visibility matrix to generate a visibility information file, which is used to guide the rendering of visible virtual models in the virtual scene.

[0014] On the other hand, embodiments of this application provide a computer device, the computer device including a processor and a memory; the memory stores at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the method for generating a visibility information file as described above.

[0015] On the other hand, embodiments of this application provide a computer-readable storage medium storing at least one computer program, which is loaded and executed by a processor to implement the method for generating a visibility information file as described above.

[0016] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the visibility information file generation method provided in various alternative implementations of the above aspect.

[0017] The technical solutions provided in this application have at least the following beneficial effects:

[0018] In this embodiment, by calculating the Hamming distance of visibility information between virtual models, the order of model visibility vectors in the visibility matrix is ​​adjusted according to the minimum Hamming distance, reducing the information entropy of the visibility matrix and making the information in the matrix more continuous, thereby improving the data compression ratio. While ensuring information accuracy, preprocessing the visibility matrix improves the compression ratio of visibility information and reduces the size of the visibility information file, thus enhancing the loading performance of scene rendering. Attached Figure Description

[0019] Figure 1 This is a flowchart illustrating a method for generating a visibility information file, as shown in an exemplary embodiment of this application;

[0020] Figure 2 This is a schematic diagram illustrating the process of generating a visibility information file, as shown in an exemplary embodiment of this application.

[0021] Figure 3 This is a flowchart illustrating a method for generating a visibility information file, as shown in another exemplary embodiment of this application;

[0022] Figure 4 This is a schematic diagram illustrating the process of adjusting the model number in an exemplary embodiment of this application;

[0023] Figure 5 This is a flowchart illustrating a method for generating a visibility information file, as shown in another exemplary embodiment of this application;

[0024] Figure 6 This is a schematic diagram illustrating the interface of the occlusion culling plugin in an exemplary embodiment of this application;

[0025] Figure 7 This is a schematic diagram illustrating a scene editing interface in an exemplary embodiment of this application;

[0026] Figure 8 This is a schematic diagram illustrating a visibility information display interface in an exemplary embodiment of this application;

[0027] Figure 9 This is a schematic diagram illustrating the process of generating a visibility information file, as shown in another exemplary embodiment of this application;

[0028] Figure 10 This is a schematic diagram illustrating a virtual scene in an exemplary embodiment of this application;

[0029] Figure 11 This is a structural block diagram of a visibility information file generation apparatus illustrated in an exemplary embodiment of this application;

[0030] Figure 12 This is a structural block diagram of a computer device illustrated in an exemplary embodiment of this application. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0032] In this article, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0033] First, let's introduce the terms used in the embodiments of this application:

[0034] Rendering optimization: Many performance bottlenecks exist in the field of graphics rendering. Identifying these bottlenecks and performing targeted optimizations to improve program efficiency is called rendering optimization. Common optimization methods include model optimization, culling, multithreading, and caching.

[0035] Occlusion culling: A technique that calculates the occlusion information of the scene in advance before graphics rendering, removes the occluded parts of the model, and interrupts the subsequent rendering process of the model in order to save rendering resources.

[0036] Hamming distance: a measure of the difference between two objects. It is 0 when the elements of the objects are the same and 1 when they are different. The final value represents the number of different elements.

[0037] Hamiltonian problem: In a weighted graph, given a starting point and an ending point, find a path that minimizes the weight of the path.

[0038] In the field of graphics rendering research and industry applications, pre-computed occlusion culling systems are one of the more commonly used rendering optimization methods. By pre-compiling and storing the potential visible sets of different regions in a virtual scene, it achieves the goal of fast occlusion culling during rendering runtime. The pre-computed information needs to be stored in binary form in a file. Each model within a region has both visible and invisible states, requiring one bit for storage. Therefore, the total amount of information in the file is directly proportional to the number of models and regions in the scene. As the scene size and the number of scene models increase, the amount of information in the file also increases, causing the usability of pre-computed occlusion culling to decrease in large-scale scenarios.

[0039] Since visibility information is stored in bits, computer devices serialize it sequentially into a file based on the visibility of each model in each region. Therefore, consecutive bits may be either 0 or 1. The industry has proposed compression schemes for visibility information, such as the commonly used Lempel-Ziv-Markov chain-Algorithm (LZMA compression algorithm), which can achieve a compression rate of around 30%, thereby reducing the amount of information stored.

[0040] However, the order of visibility vectors corresponding to models within the matrix in the aforementioned files is usually related to the model's position in the scene, which is an empirical approach and cannot achieve stable compression ratio gains. There are two main reasons for this problem: First, position information is usually three-dimensional or higher-dimensional, while the storage structure of visibility information requires model numbers to be stored in one-dimensional order, making it difficult to truly arrange objects with similar positions more closely together. Second, in a three-dimensional scene, the visibility between geometric models is information with infinitely high frequency and has no positive correlation with three-dimensional spatial position information; even objects placed consecutively in space may have significantly different visibility.

[0041] This application provides a method for generating visibility information files. From the perspective of information entropy, it calculates the Hamming distance between visibility information between virtual models and adjusts the order of model visibility vectors in the visibility matrix according to the minimum Hamming distance. This reduces the information entropy of the visibility matrix, resulting in higher continuity of information within the matrix and improving data compression efficiency. This method is executed by a computer device with image processing capabilities. This computer device can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0042] Please refer to Figure 1 This document illustrates a flowchart of a method for generating a visibility information file according to an exemplary embodiment of this application. This embodiment describes the method as being executed by a computer device, and the method includes the following steps:

[0043] Step 101: Generate an initial visibility matrix based on the virtual scene.

[0044] The virtual scene contains virtual models, and the matrix elements in the initial visibility matrix are used to indicate whether the virtual models are visible in the scene area.

[0045] In one possible implementation, the virtual scene consists of virtual models, and the virtual scene is relatively large. When the terminal displays the virtual scene, some models are visible, while others are not. To facilitate guiding the terminal to determine the visible models based on the viewpoint, the virtual scene can be obtained simply by drawing the visible models. The computer device inputs the virtual scene into an occlusion culling system to obtain an initial visibility matrix. The order of the model visibility vectors in the initial visibility matrix (i.e., the order of the models along the row direction) is related to the positional relationship of the models in the scene or the model rendering order.

[0046] Indicatively, a virtual scene contains n models that need occlusion culling, denoted as O1, O2, O3...On. The pre-computation occlusion culling system divides the scene into k regions, denoted as C1, C2, C3...Ck. After pre-computation, the visibility V of each region for each model is represented by a Boolean value, with two cases: 0 and 1, representing invisible and visible, respectively. For example, when the viewpoint is in the i-th region, the visibility of the j-th model is represented as Vij, where 1≤i≤k, 1≤j≤n, and i, j, k, and n are all positive integers. The entire visibility information is represented as an n×k two-dimensional array, i.e., the initial visibility matrix. For example, the virtual scene is divided into 4 scene regions, containing 3 virtual models that need occlusion culling. The computer device generates a 3×4 matrix. The elements in the first column represent the visibility of the first virtual model in the first to fourth scene regions, and the elements in the first row represent the visibility of the first to third virtual models in the first scene region. The order of the models can be determined by their positional relationship or the order in which they are rendered. For example, computer devices can number the models starting from the origin of the scene, in the order of left to right, front to back, and top to bottom.

[0047] It's worth noting that visibility information is not stored directly as a two-dimensional array, but rather linearly according to the major order of the regions. That is, the visibility information of the n virtual models in the first region is written first, then the visibility information of the n virtual models in the second region is written, and so on. Therefore, the initial visibility matrix occupies n×k÷8 bytes of storage space.

[0048] Step 102: Based on the Hamming distance between the model visibility vectors in the initial visibility matrix, adjust the order of the model visibility vectors to obtain the target visibility matrix.

[0049] The total Hamming distance of the target visibility matrix is ​​less than the total Hamming distance of the initial visibility matrix. The model visibility vector is used to indicate the visibility of the same virtual model in the scene area. The total Hamming distance is the sum of the Hamming distances of the visibility vectors of adjacent models.

[0050] Because the data storage structure is one-dimensional, the order of models in the initial visibility matrix is ​​not the order corresponding to the optimal compression ratio. However, there exists an order that minimizes the total Hamming distance, which is the sum of the Hamming distances between all adjacent model visibility vectors. For example, in the example in step 101, there are 3 models, so the total Hamming distance is the sum of the Hamming distances between the first and second model visibility vectors and the second and third model visibility vectors. The computer device adjusts the order of the model visibility vectors to minimize the total Hamming distance of the matrix.

[0051] The above embodiments store visibility information in a one-dimensional manner with regions as the primary order. Therefore, the order of the model visibility vectors is adjusted to reduce the information density in the visibility information corresponding to each region (i.e., to make 0s adjacent to 0s and 1s adjacent to 1s as much as possible). In another possible implementation, if linear storage is performed according to the model primary order, the computer device adjusts the visibility information in units of region visibility vectors to obtain the target visibility matrix.

[0052] Step 103: Perform binary compression on the target visibility matrix to generate a visibility information file, which is used to guide the rendering of visible virtual models in the virtual scene.

[0053] After adjusting the order of the model visibility vectors, the information density in the model decreases, resulting in more identical values ​​being adjacent. Therefore, compressing the target visibility matrix, compared to directly compressing the initial visibility matrix, can significantly improve the compression ratio.

[0054] In summary, in this embodiment, by calculating the Hamming distance of visibility information between virtual models and adjusting the order of model visibility vectors in the visibility matrix according to the minimum Hamming distance, the information entropy of the visibility matrix is ​​reduced, resulting in higher continuity of information in the matrix and thus improving the data compression ratio. While ensuring information accuracy, preprocessing the visibility matrix improves the compression ratio of visibility information and reduces the size of the visibility information file, thereby enhancing the loading performance of scene rendering.

[0055] like Figure 2 As shown, it illustrates the generation process of the visibility information file provided in the above embodiments:

[0056] Step 201: Enter visibility information.

[0057] Step 202: Calculate the Hamming distance matrix of visibility information.

[0058] Step 203: Solve for the optimal arrangement order of the models.

[0059] Step 204: Output the sorted model order.

[0060] Regarding the adjustment process of the model visibility vector, the computer device can determine the model numbering order based on the solution method of the Hamiltonian path problem. Please refer to [reference needed]. Figure 3 This illustration shows a flowchart of a method for generating a visibility information file provided in another exemplary embodiment of this application. This embodiment describes the method as being executed by a computer device, and the method includes the following steps:

[0061] Step 301: Generate an initial visibility matrix based on the virtual scene.

[0062] The specific implementation of step 301 can be referred to step 101 above, and will not be repeated here in the embodiments of this application.

[0063] Step 302: Based on the Hamming distance between the model visibility vectors in the initial visibility matrix, generate the Hamming distance matrix corresponding to the initial visibility matrix.

[0064] The Hamming distance matrix contains the Hamming distance between the model visibility vectors corresponding to each pair of virtual models.

[0065] In one possible implementation, matrix adjustment is not completed in a single adjustment but requires multiple iterative loops to find the order corresponding to the minimum Hamming distance. Since each adjustment requires obtaining the Hamming distance between model visibility vectors, to avoid redundant calculations, the computer device first generates a Hamming distance matrix corresponding to the initial visibility matrix, which contains the Hamming distance between any two model visibility vectors. Therefore, the computer device only needs to query the Hamming distance matrix to perform vector adjustment. Step 302 specifically includes the following steps:

[0066] Step 302a: Extract the model visibility vector corresponding to the virtual model from the initial visibility matrix.

[0067] Step 302b: Generate the Hamming distance matrix based on the order of the model visibility vectors in the initial visibility matrix.

[0068] The matrix element in the i-th row and j-th column of the Hamming distance matrix is ​​used to indicate the Hamming distance between the i-th model visibility vector and the j-th model visibility vector in the initial visibility matrix.

[0069] Hamming distance represents the bit correlation between two binary pieces of information. A value of 0 indicates that the two binary pieces of information are identical, while a larger distance indicates a greater difference between the information and a higher information density. The visibility information of each virtual model for all k regions is extracted; for example, the visibility vector of the i-th model is [V1i, V2i, ..., Vki]. The Hamming distance between pairwise model visibility vectors is calculated as follows:

[0070]

[0071] Among them, V xi V represents the model visibility vector corresponding to the i-th virtual model. xj This represents the model visibility vector corresponding to the j-th virtual model, where n is the total number of virtual models. It's worth noting that j here is not the j in the initial visibility matrix; i and j in the Hamming distance matrix are used to indicate the model number.

[0072] The computer device calculates the Hamming distance between pairwise model visibility vectors based on the above formula, obtaining the Hamming distance matrix. It can be seen that the Hamming distance matrix is ​​a symmetric matrix, and all values ​​on the main diagonal are 0. To minimize the total Hamming distance, the vector order is adjusted so that the sum of the values ​​on the diagonals adjacent to the main diagonal in the Hamming distance matrix corresponding to the adjusted visibility matrix is ​​minimized.

[0073] Step 303: Adjust the order of the model visibility vectors based on the Hamming distance matrix to obtain the target visibility matrix.

[0074] The Hamming distance matrix represents the similarity between each pair of information, and the total Hamming distance HamDis(i, i+1) accurately measures the density of the stored information. Therefore, the computer needs to find an optimal permutation of 1, 2, 3...n that minimizes the total Hamming distance.

[0075] The above problem can be categorized as a graph problem in computer algorithms. Let 1, 2, 3...n be n nodes in a graph, forming a weighted undirected fully connected graph. The weight between any two nodes is their Hamming distance. The computer needs to find a path in the graph such that the sum of the weights of the paths is minimized. This problem belongs to the Hamiltonian path problem of graph solving, similar to the Traveling Salesman Problem (TSP). However, because there is no explicit start and end point in this problem, its complexity is higher than that of the TSP.

[0076] Since the optimal solution to the Traveling Salesman Problem has a time complexity of n... 2 ×2 nThe visibility compression problem is highly complex. Therefore, in one possible implementation, the computer device replaces the optimal solution to the Traveling Salesman Problem with a suboptimal solution of the best permutation, i.e., it uses an iterative greedy algorithm to solve it. Step 303 specifically includes the following steps:

[0077] Step 303a: Create n chains with model identifiers as nodes, where n is the number of virtual models in the virtual scene and is a positive integer.

[0078] The computer device first treats each node as a separate chain. By continuously exploring the minimum Hamming distance between adjacent nodes, the chains are spliced ​​together, thereby gradually reducing the number of chains until a chain containing n nodes is generated, thus obtaining the order of the models in the target visibility matrix.

[0079] To illustrate, there are four virtual models to be occluded and culled in the virtual scene, so the initial visibility matrix contains four model visibility vectors, and the computer device creates four chains.

[0080] Step 303b: When the number of chains is greater than 1, the chains are spliced ​​based on the Hamming distance matrix according to the principle of minimizing the sum of the Hamming distances of the visibility vectors of adjacent model identifiers.

[0081] Treating n visibility information pieces as n chains, in each iteration, the computer determines the minimum Hamming distance between any two chains based on the Hamming distance matrix. Chains with a minimum Hamming distance are then connected end-to-end (i.e., there are two ways to join the same two chains, and their corresponding Hamming distances may be different). After multiple iterations, the number of chains gradually decreases until they are all connected to a single complete chain, which is the final permutation.

[0082] The iterative greedy solution considers the optimization of the starting and ending points of the permutation, while simplifying the complexity of the solution. In the worst case, its complexity will not exceed n to the power of 3, which can be solved in a short time for problems with a scale of thousands.

[0083] Specifically, step 303b includes the following steps:

[0084] Step 1: Determine the pairwise Hamming distances between the remaining chains based on the Hamming distance matrix. The Hamming distance between chains is the Hamming distance between the model visibility vector corresponding to the head of the chain and the model visibility vector corresponding to the tail of the chain.

[0085] Step two: Connect the chains with the smallest Hamming distance.

[0086] As an illustration, an initial visibility matrix is ​​as follows:

[0087]

[0088] The column vectors are the model visibility vectors. Their corresponding Hamming distance matrices are as follows:

[0089]

[0090] In the first round of concatenation, consulting the Hamming distance matrix reveals that the smallest existing Hamming distance is 1, corresponding to the first and third models. Therefore, the first and third models are concatenated, resulting in 3 chains. In the second round, the Hamming distance matrix shows that the smallest existing chain-to-chain distance is 2, corresponding to the second and fourth models. Therefore, the second and fourth models are concatenated, resulting in 2 chains. In the third round, the Hamming distance matrix shows that the smallest existing chain-to-chain distance is either 3, corresponding to the first and fourth models, or 3, corresponding to the first and second models. Therefore, nodes corresponding to the first and second models can be concatenated, or nodes corresponding to the first and fourth models can be concatenated, to obtain the final chain.

[0091] Step 303c: When the number of chains is 1, adjust the order of the model visibility vectors according to the order of the model identifiers in the chains to obtain the target visibility matrix.

[0092] The computer organizes the obtained chain into an array S[i] from beginning to end, obtaining the optimal arrangement order of the models. The indices of the models in the scene are changed from i to S[i]. At the same time, the visibility order is rearranged so that T[i] = T[S[i]], and submitted to the compression algorithm for subsequent compression.

[0093] In one possible implementation, the model visibility vector is a column vector, and the elements in the same row of the initial visibility matrix are used to indicate whether the virtual model is visible when the field of view is within the same virtual region. Step 303c includes the following steps:

[0094] The column vectors in the initial visibility matrix are ordered according to the order of the model identifiers in the chain to obtain the target visibility matrix. The order of the model identifiers corresponding to the column vectors in the target visibility matrix is ​​consistent with the order of the model identifiers in the chain.

[0095] In another possible implementation, the model visibility vector is a row vector, and the elements in the same column of the initial visibility matrix are used to indicate whether the virtual model is visible when the field of view is within the same virtual region. Step 303c includes the following steps:

[0096] The order of the row vectors in the initial visibility matrix is ​​adjusted according to the order of the model identifiers described in the chain to obtain the target visibility matrix. The order of the model identifiers corresponding to the row vectors in the target visibility matrix is ​​consistent with the order of the model identifiers in the chain.

[0097] In conjunction with the above embodiments, Figure 4 The following flowchart illustrates a process for determining the order of model numbers: Step 401, input the Hamming distance matrix; Step 402, create n chains with model numbers as nodes; Step 403, determine if the number of chains is greater than 1; if yes, proceed to step 404, otherwise proceed to step 406; Step 404, determine the Hamming distance between the first and last nodes of each pair of chains; Step 405, determine the minimum Hamming distance; Step 406, connect the first and last nodes of the chain corresponding to the minimum Hamming distance; after step 406, return to step 403; Step 407, output the order of model numbers in the chains.

[0098] Step 304: Perform binary compression on the target visibility matrix to generate a visibility information file, which is used to guide the rendering of visible virtual models in the virtual scene.

[0099] The specific implementation of step 304 can be referred to step 103 above, and will not be repeated here in the embodiments of this application.

[0100] In this embodiment, the computer device solves the arrangement order of the model visibility vectors based on a greedy algorithm, and uses the suboptimal solution of the best arrangement to replace the optimal solution of the traveling salesman problem. This reduces computational complexity while improving file compression rate and increases the generation efficiency of visibility files, making it suitable for rendering large-scale virtual scenes.

[0101] In one possible implementation, developers can obtain the initial visibility matrix and generate the target visibility matrix by writing script files or using tool plugins. Please refer to [link / reference]. Figure 5 This illustration shows a flowchart of a method for generating a visibility information file provided in another exemplary embodiment of this application. This embodiment describes the method as being executed by a computer device, and the method includes the following steps:

[0102] Step 501: In response to the region density setting operation, obtain scene region information, which is used to indicate the size of the scene region.

[0103] In one possible implementation, the pre-computed occlusion culling system supports the graphics rendering development process as a plugin. For example, for rendering virtual scenes in game applications, visibility information can be generated using Unreal Engine or Unity Engine.

[0104] Taking the Unity engine as an example, after the developer opens the plugin, as follows: Figure 6As shown in the image. The first control is used to initialize the scene's visibility data system, the second control is used to unload the system, and the third control expands the settings window. The interface of the settings window is shown below. Figure 7 As shown. Developers can set the location where the visible set needs to be calculated, i.e., the coordinates of the virtual scene, and set the region size and calculation density. Click the build control at the bottom to start generating the visible set.

[0105] Developers can also write scripts to call plugins for flexible rendering and obtain the visible set, and then perform subsequent processing as needed.

[0106] Step 502: Divide the virtual scene based on the scene area information and determine the location information of the scene area.

[0107] The computer equipment divides the virtual scene according to the scene location, area, and height information input by the developers, and determines the location information of each scene area.

[0108] Step 503: Determine the visibility of the virtual model when the viewpoint is within the scene area based on the occlusion culling algorithm, and generate an initial visibility matrix.

[0109] In this application embodiment, the algorithm code is inserted into the existing pre-computation occlusion culling system. After the developers deploy the code according to the method provided in the embodiment, they can use the pre-computation occlusion culling system in the previous way to perform occlusion culling calculation with lower storage space overhead.

[0110] Step 504: Based on the Hamming distance between the model visibility vectors in the initial visibility matrix, adjust the order of the model visibility vectors to obtain the target visibility matrix.

[0111] The specific implementation of step 504 can be referred to step 102 above, and will not be repeated here in the embodiments of this application.

[0112] Step 505: In response to the selection operation of the target model, the serial number corresponding to the target virtual model is displayed through the visibility information display interface.

[0113] The index indicates the position of the virtual model's visibility vector within the target visibility matrix. For example, if the model visibility vector is a column vector, then the virtual model corresponding to the first column of the model visibility vector has an index of 1.

[0114] The plugin provides a method for debugging and viewing the numbering information of objects to be culled. After initializing the scene, developers can select a model in the scene display area (i.e., perform a selection operation on the target model) and then see the relevant script information in the details of the visibility information display interface, recording the model's sequence number in the visibility set. For example... Figure 8As shown, after the target visibility matrix is ​​obtained through compression preprocessing, the model number may change, and developers can also view the changed number through the visibility information display interface.

[0115] Step 506: Perform binary compression on the target visibility matrix to generate a visibility information file, which is used to guide the rendering of visible virtual models in the virtual scene.

[0116] The specific implementation of step 506 can be referred to step 103 above, and will not be repeated here in the embodiments of this application.

[0117] Step 507: Package the visibility information file into the application's installation package.

[0118] In one possible implementation, the virtual scene described above is a virtual scene within an application. The application's server generates a visibility information file during the application development phase and packages it into the installation package.

[0119] Step 508: In response to the application acquisition request sent by the terminal, the installation package is sent to the terminal.

[0120] The terminal is used to decompress the visibility information file to obtain the target visibility matrix when rendering a virtual scene, and to determine the model to be rendered from the target visibility matrix based on the scene region where the viewpoint is located. The target visibility matrix is ​​stored in a one-dimensional form in the file.

[0121] When a user downloads an application via a terminal, the computer device (server) sends an installation package containing visibility information files to the terminal. After the terminal receives and installs the application, it decompresses the visibility information files to obtain the visibility information. Then, during the application's execution, based on the scene area where the current viewpoint is located, it determines the visible models from the visibility information and renders the visible models.

[0122] In this embodiment, the computer device provides support for the graphics rendering development process in the form of a plug-in, making the process of scene occlusion culling and model number adjustment visible, which makes it convenient for developers to set scene parameters and region division parameters according to their needs, and to view the changes in model number through the interface.

[0123] In combination with the above embodiments, Figure 9 This illustrates a pre-computed process for occlusion culling:

[0124] Step 901: Input the rendering scene.

[0125] Step 902: Divide the scene area.

[0126] Step 903: Generate the initial visibility matrix.

[0127] Step 904, data compression preprocessing. The preprocessing process adopts the visibility file generation method provided in the above embodiments.

[0128] Step 905, data compression.

[0129] Step 906: Output the visible set compressed file.

[0130] By employing the aforementioned visibility information compression preprocessing technique, the visibility information density is reduced through model arrangement without incurring additional overhead for real-time rendering, thereby improving the compression ratio of the compression algorithm. Compared to geolocation-based arrangement methods, the method provided in this application is more unbiased and stable, providing reliable spatial benefits to the pre-computed occlusion culling system and improving its usability. Furthermore, it is compatible with graphics rendering engines that have pre-computed occlusion culling systems and can be applied to various large-scale rendering products.

[0131] The developers used the classic CrytekSponza open-source library as the test scene, which contained 381 model objects. The computer first divided the scene into 1824 scene regions, resulting in a total visibility count of 694944 boolean values, of which 193024 were visible. The uncompressed source file size was 87552 bytes. The scene is as follows... Figure 10 As shown.

[0132] Using the default sorting, the total Hamming distance is 69302, and the compressed size is 19748 bytes. In contrast, the computer device randomly shuffles the default sorting, resulting in a total Hamming distance of 142168, and the compressed size is 29198 bytes. This demonstrates the correlation between the total Hamming distance and the compressed size. The computer device preprocesses the default visibility matrix using the method provided in the above embodiments, obtaining an optimal arrangement with a total Hamming distance of 33712, which, after compression, is 17479 bytes. This represents an 11.48% reduction in file size compared to the information from the default sorting (i.e., the initial visibility matrix), and a 40.13% reduction compared to the worst random sorting. Since the default sorting depends on the output during modeling and has significant uncertainty, while the optimal sorting ensures the model is adjusted to the best sorting state, the pre-computation process is completed within seconds and its proportion in the pre-computation occlusion culling process is negligible.

[0133] Figure 11 This is a structural block diagram of a visibility information file generation apparatus provided in an exemplary embodiment of this application. The apparatus includes the following structure.

[0134] The matrix generation module 1101 is used to generate an initial visibility matrix based on a virtual scene, wherein the virtual scene contains a virtual model, and the matrix elements in the initial visibility matrix are used to indicate whether the virtual model is visible in the scene area;

[0135] The matrix adjustment module 1102 is used to adjust the arrangement order of the model visibility vectors based on the Hamming distance between the model visibility vectors in the initial visibility matrix to obtain a target visibility matrix. The total Hamming distance of the target visibility matrix is ​​less than the total Hamming distance of the initial visibility matrix. The model visibility vectors are used to indicate the visibility of the same virtual model in the scene area. The total Hamming distance is the sum of the Hamming distances of adjacent model visibility vectors.

[0136] The file generation module 1103 is used to perform binary compression on the target visibility matrix to generate a visibility information file, which is used to guide the rendering of visible virtual models in the virtual scene.

[0137] Optionally, the matrix adjustment module 1102 is further configured to:

[0138] Based on the Hamming distance between the model visibility vectors in the initial visibility matrix, a Hamming distance matrix corresponding to the initial visibility matrix is ​​generated, wherein the Hamming distance matrix contains the Hamming distance between the model visibility vectors corresponding to each pair of virtual models;

[0139] The target visibility matrix is ​​obtained by adjusting the arrangement order of the model visibility vectors based on the Hamming distance matrix.

[0140] Optionally, the matrix adjustment module 1102 is further configured to:

[0141] Extract the model visibility vector corresponding to the virtual model from the initial visibility matrix;

[0142] Based on the arrangement order of the model visibility vectors in the initial visibility matrix, the Hamming distance matrix is ​​generated. The matrix element in the i-th row and j-th column of the Hamming distance matrix is ​​used to indicate the Hamming distance between the i-th model visibility vector and the j-th model visibility vector in the initial visibility matrix.

[0143] Optionally, the matrix adjustment module 1102 is further configured to:

[0144] Create n chains with model identifiers as nodes, where n is the number of virtual models in the virtual scene and is a positive integer;

[0145] When the number of chains is greater than 1, the chains are spliced ​​together based on the Hamming distance matrix according to the principle of minimizing the sum of the Hamming distances of the visibility vectors of adjacent model identifiers;

[0146] When the number of chains is 1, the arrangement order of the model visibility vectors is adjusted according to the order of the model identifiers in the chains to obtain the target visibility matrix.

[0147] Optionally, the matrix adjustment module 1102 is further configured to:

[0148] The Hamming distance between each pair of remaining chains is determined based on the Hamming distance matrix. The Hamming distance between chains is the Hamming distance between the model visibility vector corresponding to the head of the chain and the model visibility vector corresponding to the tail of the chain.

[0149] The chains with the smallest Hamming distance are spliced ​​together.

[0150] Optionally, the model visibility vector is a column vector, and the elements in the same row of the initial visibility matrix are used to indicate whether the virtual model is visible when the field of view is within the same virtual region;

[0151] The matrix adjustment module 1102 is also used for:

[0152] The order of the column vectors in the initial visibility matrix is ​​adjusted according to the order of the model identifiers in the chain to obtain the target visibility matrix, wherein the order of the model identifiers corresponding to the column vectors in the target visibility matrix is ​​consistent with the order of the model identifiers in the chain.

[0153] Optionally, the model visibility vector is a row vector, and the elements in the same column of the initial visibility matrix are used to indicate whether the virtual model is visible when the field of view is within the same virtual region;

[0154] The matrix adjustment module 1102 is also used for:

[0155] The order of the row vectors in the initial visibility matrix is ​​adjusted according to the order of the model identifiers in the chain to obtain the target visibility matrix, wherein the order of the model identifiers corresponding to the row vectors in the target visibility matrix is ​​consistent with the order of the model identifiers in the chain.

[0156] Optionally, the device further includes:

[0157] The acquisition module is used to acquire scene area information in response to the area density setting operation, wherein the scene area information is used to indicate the size of the scene area;

[0158] The matrix generation module 1101 is further used for:

[0159] The virtual scene is divided based on the scene area information to determine the location information of the scene area;

[0160] The initial visibility matrix is ​​generated by determining the visibility of the virtual model within the scene area based on the occlusion culling algorithm.

[0161] Optionally, the device further includes:

[0162] The display module is used to respond to the selection operation of the target model and display the serial number corresponding to the target virtual model through the visibility information display interface. The serial number is used to indicate the position of the model visibility vector corresponding to the virtual model in the target visibility matrix.

[0163] Optionally, the virtual scene is a virtual scene within an application;

[0164] The device further includes:

[0165] The file packaging module is used to package the visibility information file into the application's installation package;

[0166] The sending module is used to send the installation package to the terminal in response to an application acquisition request sent by the terminal. The terminal is used to decompress the visibility information file to obtain the target visibility matrix when rendering the virtual scene, and to determine the model to be rendered from the target visibility matrix based on the scene area where the viewpoint is located.

[0167] In summary, in this embodiment, by calculating the Hamming distance of visibility information between virtual models and adjusting the order of model visibility vectors in the visibility matrix according to the minimum Hamming distance, the information entropy of the visibility matrix is ​​reduced, resulting in higher continuity of information in the matrix and thus improving the data compression ratio. While ensuring information accuracy, preprocessing the visibility matrix improves the compression ratio of visibility information and reduces the size of the visibility information file, thereby enhancing the loading performance of scene rendering.

[0168] Please refer to Figure 12 The diagram illustrates the structure of a computer device provided in one embodiment of this application.

[0169] The server 1200 includes a central processing unit (CPU) 1201, a system memory 1204 including random access memory (RAM) 1202 and read-only memory (ROM) 1203, and a system bus 1205 connecting the system memory 1204 and the CPU 1201. The server 1200 also includes a basic input / output (I / O) controller 1206 that facilitates information transfer between various devices within the computer, and a mass storage device 1207 for storing the operating system 1213, application programs 1214, and other program modules 1215.

[0170] The basic input / output system 1206 includes a display 1208 for displaying information and an input device 1209 for user input, such as a mouse or keyboard. Both the display 1208 and the input device 1209 are connected to the central processing unit 1201 via an input / output controller 1210 connected to the system bus 1205. The basic input / output system 1206 may also include the input / output controller 1210 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1210 also provides output to a display screen, printer, or other types of output devices.

[0171] The mass storage device 1207 is connected to the central processing unit 1201 via a mass storage controller (not shown) connected to the system bus 1205. The mass storage device 1207 and its associated computer-readable media provide non-volatile storage for the server 1200. That is, the mass storage device 1207 may include computer-readable media (not shown) such as a hard disk or a compact disc read-only memory (CD-ROM) drive.

[0172] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, erasable programmable read-only memory (EPROM), flash memory or other solid-state storage technologies, CD-ROM, digital video disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer storage media are not limited to the above-mentioned types. The system memory 1204 and mass storage device 1207 described above can be collectively referred to as memory.

[0173] According to various embodiments of this application, the server 1200 can also be connected to a remote computer on a network, such as the Internet. That is, the server 1200 can be connected to the network 1212 via the network interface unit 1211 connected to the system bus 1205, or the network interface unit 1211 can be used to connect to other types of networks or remote computer systems (not shown).

[0174] This application also provides a computer-readable storage medium storing at least one instruction, which is loaded and executed by a processor to implement the method for generating a visibility information file as described in the above embodiments.

[0175] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the visibility information file generation method provided in various alternative implementations of the above aspect.

[0176] Those skilled in the art will recognize that the functions described in the embodiments of this application in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable storage medium or transmitted as one or more instructions or code on a computer-readable storage medium. Computer-readable storage media include computer storage media and communication media, wherein communication media include any medium that facilitates the transmission of a computer program from one place to another. Storage media can be any available medium accessible to a general-purpose or special-purpose computer.

[0177] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, data stored, data displayed, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0178] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for generating a visibility information file, characterized in that, The method includes: An initial visibility matrix is ​​generated based on a virtual scene, wherein the virtual scene contains a virtual model, and the matrix elements in the initial visibility matrix are used to indicate whether the virtual model is visible in the scene area; Based on the Hamming distance between the model visibility vectors in the initial visibility matrix, a Hamming distance matrix corresponding to the initial visibility matrix is ​​generated. The Hamming distance matrix contains the Hamming distance between the model visibility vectors corresponding to each pair of virtual models. Based on the Hamming distance matrix, the arrangement order of the model visibility vectors is adjusted to obtain the target visibility matrix. The total Hamming distance of the target visibility matrix is ​​less than the total Hamming distance of the initial visibility matrix. The model visibility vectors are used to indicate the visibility of the same virtual model in the scene area. The total Hamming distance is the sum of the Hamming distances of adjacent model visibility vectors. The target visibility matrix is ​​binary compressed to generate a visibility information file, which is used to guide the rendering of visible virtual models in the virtual scene.

2. The method according to claim 1, characterized in that, The step of generating the Hamming distance matrix corresponding to the initial visibility matrix based on the Hamming distance between the model visibility vectors in the initial visibility matrix includes: Extract the model visibility vector corresponding to the virtual model from the initial visibility matrix; Based on the arrangement order of the model visibility vectors in the initial visibility matrix, the Hamming distance matrix is ​​generated. The matrix element in the i-th row and j-th column of the Hamming distance matrix is ​​used to indicate the Hamming distance between the i-th model visibility vector and the j-th model visibility vector in the initial visibility matrix.

3. The method according to claim 1, characterized in that, The step of adjusting the order of the model visibility vectors based on the Hamming distance matrix to obtain the target visibility matrix includes: Create n chains with model identifiers as nodes, where n is the number of virtual models in the virtual scene and is a positive integer; When the number of chains is greater than 1, the chains are spliced ​​together based on the Hamming distance matrix according to the principle of minimizing the sum of the Hamming distances of the visibility vectors of adjacent model identifiers; When the number of chains is 1, the arrangement order of the model visibility vectors is adjusted according to the order of the model identifiers in the chains to obtain the target visibility matrix.

4. The method according to claim 3, characterized in that, The step of concatenating the chains based on the Hamming distance matrix, according to the principle of minimizing the sum of the Hamming distances between the visibility vectors corresponding to adjacent model identifiers, includes: The Hamming distance between each pair of remaining chains is determined based on the Hamming distance matrix. The Hamming distance between chains is the Hamming distance between the model visibility vector corresponding to the head of the chain and the model visibility vector corresponding to the tail of the chain. The chains with the smallest Hamming distance are spliced ​​together.

5. The method according to claim 3, characterized in that, The model visibility vector is a column vector, and the elements in the same row of the initial visibility matrix are used to indicate whether the virtual model is visible when the field of view is within the same virtual region; The step of adjusting the order of the model visibility vectors according to the order of the model identifiers in the chain to obtain the target visibility matrix includes: The order of the column vectors in the initial visibility matrix is ​​adjusted according to the order of the model identifiers in the chain to obtain the target visibility matrix, wherein the order of the model identifiers corresponding to the column vectors in the target visibility matrix is ​​consistent with the order of the model identifiers in the chain.

6. The method according to claim 3, characterized in that, The model visibility vector is a row vector, and the elements in the same column of the initial visibility matrix are used to indicate whether the virtual model is visible when the field of view is within the same virtual region; The step of adjusting the order of the model visibility vectors according to the order of the model identifiers in the chain to obtain the target visibility matrix includes: The order of the row vectors in the initial visibility matrix is ​​adjusted according to the order of the model identifiers in the chain to obtain the target visibility matrix, wherein the order of the model identifiers corresponding to the row vectors in the target visibility matrix is ​​consistent with the order of the model identifiers in the chain.

7. The method according to any one of claims 1 to 6, characterized in that, Before generating the initial visibility matrix based on the virtual scene, the method includes: In response to a region density setting operation, scene region information is acquired, wherein the scene region information is used to indicate the size of the scene region; The generation of the initial visibility matrix based on the virtual scene includes: The virtual scene is divided based on the scene area information to determine the location information of the scene area; The initial visibility matrix is ​​generated by determining the visibility of the virtual model within the scene area based on the occlusion culling algorithm.

8. The method according to any one of claims 1 to 6, characterized in that, The method further includes: In response to the selection operation of the target virtual model, the index corresponding to the target virtual model is displayed through the visibility information display interface. The index is used to indicate the position of the model visibility vector corresponding to the virtual model in the target visibility matrix.

9. The method according to any one of claims 1 to 6, characterized in that, The virtual scene is a virtual scene within the application; After performing binary compression on the target visibility matrix to generate a visibility information file, the method further includes: Package the visibility information file into the application's installation package; In response to an application acquisition request sent by the terminal, the installation package is sent to the terminal. The terminal is used to decompress the visibility information file to obtain the target visibility matrix when rendering the virtual scene, and to determine the model to be rendered from the target visibility matrix based on the scene region where the viewpoint is located.

10. An apparatus for generating visibility information files, characterized in that, The device includes: A matrix generation module is used to generate an initial visibility matrix based on a virtual scene, wherein the virtual scene contains a virtual model, and the matrix elements in the initial visibility matrix are used to indicate whether the virtual model is visible in the scene area; The matrix adjustment module is used to generate a Hamming distance matrix corresponding to the initial visibility matrix based on the Hamming distance between the model visibility vectors in the initial visibility matrix. The Hamming distance matrix contains the Hamming distance between the model visibility vectors corresponding to each pair of virtual models. Based on the Hamming distance matrix, the module adjusts the arrangement order of the model visibility vectors to obtain a target visibility matrix. The total Hamming distance of the target visibility matrix is ​​less than the total Hamming distance of the initial visibility matrix. The model visibility vectors are used to indicate the visibility of the same virtual model in the scene area. The total Hamming distance is the sum of the Hamming distances of adjacent model visibility vectors. The file generation module is used to perform binary compression on the target visibility matrix to generate a visibility information file, which is used to guide the rendering of visible virtual models in the virtual scene.

11. The apparatus according to claim 10, characterized in that, The matrix adjustment module is also used for: Extract the model visibility vector corresponding to the virtual model from the initial visibility matrix; Based on the arrangement order of the model visibility vectors in the initial visibility matrix, the Hamming distance matrix is ​​generated. The matrix element in the i-th row and j-th column of the Hamming distance matrix is ​​used to indicate the Hamming distance between the i-th model visibility vector and the j-th model visibility vector in the initial visibility matrix.

12. A computer device, characterized in that, The computer device includes a processor and a memory; the memory stores at least one instruction, at least one program, code set, or instruction set, the at least one instruction, the at least one program, the code set, or the instruction set being loaded and executed by the processor to implement the method for generating a visibility information file as described in any one of claims 1 to 9.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to implement the method for generating a visibility information file as described in any one of claims 1 to 9.

14. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method for generating a visibility information file as described in any one of claims 1 to 9.

Citation Information

Patent Citations

  • Visibility data compression / decompression method, compression system and decoder

    CN101061514A