Search

CN-116775585-B - Method, apparatus, storage medium, and program product for generating visibility information file

CN116775585BCN 116775585 BCN116775585 BCN 116775585BCN-116775585-B

Abstract

The embodiment of the application discloses a method, equipment, a storage medium and a program product for generating a visibility information file, and belongs to the technical field of image processing. The method comprises the steps of generating an initial visibility matrix based on a virtual scene, adjusting the arrangement sequence of model visibility vectors based on hamming distances among the model visibility vectors in the initial visibility matrix to obtain a target visibility matrix, and binary compressing the target visibility matrix to generate a visibility information file. According to the method, on the premise of ensuring the information accuracy, the visibility matrix is preprocessed, so that the compression rate of the visibility information is improved, the size of the visibility information file is reduced, and the loading performance of scene rendering is improved.

Inventors

  • WANG QINJIA
  • YANG HUANG

Assignees

  • 腾讯科技(深圳)有限公司

Dates

Publication Date
20260508
Application Date
20220310

Claims (14)

  1. 1. A method for generating a visibility information file, the method comprising: generating an initial visibility matrix based on a virtual scene, wherein the virtual scene comprises a virtual model, and matrix elements in the initial visibility matrix are used for indicating whether the virtual model is visible in a scene area; Generating a hamming distance matrix corresponding to the initial visibility matrix based on hamming distances among model visibility vectors in the initial visibility matrix, wherein the hamming distance matrix comprises hamming distances among the model visibility vectors corresponding to the pairwise virtual models; adjusting the arrangement sequence of the model visibility vectors based on the hamming distance matrix to obtain a target visibility matrix, wherein the total hamming distance of the target visibility matrix is smaller than the total hamming distance of the initial visibility matrix, the model visibility vector is used for indicating the visibility of the same virtual model in the scene area, and the total hamming distance is the sum of hamming distances of adjacent model visibility vectors; binary compression is carried out on the target visibility matrix, and a visibility information file is generated, wherein the visibility information file is used for guiding rendering of a visible virtual model in the virtual scene.
  2. 2. The method of claim 1, wherein the generating a hamming distance matrix corresponding to the initial visibility matrix based on hamming distances between model visibility vectors in the initial visibility matrix comprises: Extracting the model visibility vector corresponding to the virtual model from the initial visibility matrix; generating the hamming distance matrix based on the arrangement sequence of the model visibility vectors in the initial visibility matrix, wherein matrix elements of an ith row and a jth column in the hamming distance matrix are used for indicating hamming distances between the ith model visibility vector and the jth model visibility vector in the initial visibility matrix.
  3. 3. The method of claim 1, wherein the adjusting the order of the model visibility vectors based on the hamming distance matrix to obtain a target visibility matrix comprises: creating n chains by using model identification as nodes, wherein n is the number of the virtual models in the virtual scene, and n is a positive integer; under the condition that the number of the chains is larger than 1, splicing the chains based on the Hamming distance matrix according to the principle that the sum of Hamming distances of adjacent model identification corresponding to the model visibility vector is minimum; and under the condition that the number of the chains is 1, adjusting the arrangement sequence of the model visibility vectors according to the sequence of the model identifications in the chains to obtain the target visibility matrix.
  4. 4. A method according to claim 3, wherein said stitching the chains based on the hamming distance matrix according to the principle that the sum of hamming distances of neighboring model identities corresponding to the model visibility vectors is minimal, comprises: determining the hamming distance between every two of the rest chains based on the hamming distance matrix, wherein the hamming distance between the chains is the hamming distance between the model visibility vector corresponding to the chain head and the model visibility vector corresponding to the chain tail; and splicing the chains with the minimum Hamming distance.
  5. 5. A method according to claim 3, wherein the model visibility vector is a column vector, and the elements of the same row in the initial visibility matrix are used to indicate whether the virtual model is visible when the field of view is within the same virtual area; The step of adjusting the arrangement sequence of the model visibility vectors according to the sequence of the model identifications in the chain to obtain the target visibility matrix comprises the following steps: And adjusting the sequence of column vectors in the initial visibility matrix according to the sequence of the model identifications in the chain to obtain the target visibility matrix, wherein the sequence of the model identifications corresponding to the column vectors in the target visibility matrix is consistent with the sequence of the model identifications in the chain.
  6. 6. A method according to claim 3, wherein the model visibility vector is a row vector, and the elements of the same column in the initial visibility matrix are used to indicate whether the virtual model is visible when the field of view is within the same virtual area; The step of adjusting the arrangement sequence of the model visibility vectors according to the sequence of the model identifications in the chain to obtain the target visibility matrix comprises the following steps: And adjusting the sequence of the row vectors in the initial visibility matrix according to the sequence of the model identifications in the chain to obtain the target visibility matrix, wherein the sequence of the model identifications corresponding to the row vectors in the target visibility matrix is consistent with the sequence of the model identifications in the chain.
  7. 7. The method according to any one of claims 1 to 6, wherein prior to generating the initial visibility matrix based on the virtual scene, the method comprises: Acquiring scene area information in response to an area density setting operation, wherein the scene area information is used for indicating the size of the scene area; The generating an initial visibility matrix based on the virtual scene includes: Dividing the virtual scene based on the scene area information, and determining the position information of the scene area; And determining the visibility of the virtual model when the view angle is in the scene area based on an occlusion elimination algorithm, and generating the initial visibility matrix.
  8. 8. The method according to any one of claims 1 to 6, further comprising: and responding to the selection operation of the target virtual model, and displaying a sequence number corresponding to the target virtual model through a visibility information display interface, wherein the sequence number is used for indicating the position of the model visibility vector corresponding to the virtual model in the target visibility matrix.
  9. 9. The method according to any one of claims 1 to 6, wherein the virtual scene is a virtual scene in an application program; The binary compression is carried out on the target visibility matrix, and after the visibility information file is generated, the method further comprises the following steps: packaging the visibility information file into an installation package of the application program; And responding to an application program acquisition request sent by a terminal, sending the installation package to the terminal, wherein the terminal is used for decompressing the visibility information file to obtain the target visibility matrix when the virtual scene is rendered, and determining a model to be rendered from the target visibility matrix based on a scene area where the view angle is located.
  10. 10. A visibility information file generation apparatus, characterized in that the apparatus comprises: a matrix generation module, configured to generate an initial visibility matrix based on a virtual scene, where the virtual scene includes a virtual model, and matrix elements in the initial visibility matrix are used to indicate whether the virtual model is visible in a scene area; The matrix adjustment module is used for generating a hamming distance matrix corresponding to the initial visibility matrix based on hamming distances among the model visibility vectors in the initial visibility matrix, wherein the hamming distance matrix comprises hamming distances among the model visibility vectors corresponding to the two-by-two virtual models; adjusting the arrangement sequence of the model visibility vectors based on the hamming distance matrix to obtain a target visibility matrix, wherein the total hamming distance of the target visibility matrix is smaller than the total hamming distance of the initial visibility matrix, the model visibility vector is used for indicating the visibility of the same virtual model in the scene area, and the total hamming distance is the sum of hamming distances of adjacent model visibility vectors; The file generation module is used for binary compressing the target visibility matrix to generate a visibility information file, wherein the visibility information file is used for guiding the rendering of a visible virtual model in the virtual scene.
  11. 11. The apparatus of claim 10, wherein the matrix adjustment module is further configured to: Extracting the model visibility vector corresponding to the virtual model from the initial visibility matrix; generating the hamming distance matrix based on the arrangement sequence of the model visibility vectors in the initial visibility matrix, wherein matrix elements of an ith row and a jth column in the hamming distance matrix are used for indicating hamming distances between the ith model visibility vector and the jth model visibility vector in the initial visibility matrix.
  12. 12. Computer device, characterized in that it comprises a processor and a memory, in which at least one instruction, at least one program, a set of codes or a set of instructions is stored, which is loaded and executed by the processor to implement the method of generating a visibility information file according to any one of claims 1 to 9.
  13. 13. A computer-readable storage medium, in which at least one computer program is stored, the computer program being loaded and executed by a processor to implement the method of generating a visibility information file according to any one of claims 1 to 9.
  14. 14. A computer program product, characterized in that the computer program product comprises computer instructions stored in a computer-readable storage medium, from which computer-readable storage medium a processor of a computer device reads the computer instructions, which processor executes the computer instructions, causing the computer device to perform the method of generating a visibility information file according to any one of claims 1 to 9.

Description

Method, apparatus, storage medium, and program product for generating visibility information file Technical Field The embodiment of the application relates to the technical field of image processing, in particular to a method, equipment, a storage medium and a program product for generating a visibility information file. Background Occlusion rejection refers to a method for computing the occlusion information of a scene in advance before graphics rendering occurs, rejecting the occluded part, and interrupting the rendering flow of the part model to save resources. In the related art, a computer device inputs a virtual scene into an occlusion and culling system, generates visibility information in a binary form, compresses and packages the visibility information, and sends the visibility information to a terminal, wherein the visibility information is used for indicating whether a model is visible in each area of the scene. And the terminal queries the visibility information based on the area where the view angle is located, so that a model to be rendered is determined. However, the visibility information needs to be stored in a binary form in a file, and each model in the scene has two states, visible and invisible, within each region, and needs to be stored with one bit. The total amount of information is thus proportional to the amount of models and the number of regions. With the increase of the scale of the rendering scene and the increase of the number of models, the information amount for occlusion culling is also increased continuously, and the required storage space is increased, so that the availability of occlusion culling in the world is reduced. Disclosure of Invention The embodiment of the application provides a method, equipment, a storage medium and a program product for generating a visibility information file, which can improve the compression rate of the visibility information, reduce the size of the visibility information file and improve the loading performance of scene rendering. The technical scheme is as follows: In one aspect, an embodiment of the present application provides a method for generating a visibility information file, where the method includes: generating an initial visibility matrix based on a virtual scene, wherein the virtual scene comprises a virtual model, and matrix elements in the initial visibility matrix are used for indicating whether the virtual model is visible in a scene area; based on the hamming distance between model visibility vectors in the initial visibility matrix, adjusting the arrangement sequence of the model visibility vectors to obtain a target visibility matrix, wherein the total hamming distance of the target visibility matrix is smaller than the total hamming distance of the initial visibility matrix, the model visibility vectors are used for indicating the visibility of the same virtual model in the scene area, and the total hamming distance is the sum of the hamming distances of adjacent model visibility vectors; binary compression is carried out on the target visibility matrix, and a visibility information file is generated, wherein the visibility information file is used for guiding rendering of a visible virtual model in the virtual scene. On the other hand, the embodiment of the application provides a generating device of a visibility information file, which comprises the following components: a matrix generation module, configured to generate an initial visibility matrix based on a virtual scene, where the virtual scene includes a virtual model, and matrix elements in the initial visibility matrix are used to indicate whether the virtual model is visible in a scene area; the matrix adjustment module is used for adjusting the arrangement sequence 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, wherein the total hamming distance of the target visibility matrix is smaller than the total hamming distance of the initial visibility matrix, the model visibility vectors are used for indicating the visibility of the same virtual model in the scene area, and the total hamming distance is the sum of the hamming distances of adjacent model visibility vectors; The file generation module is used for binary compressing the target visibility matrix to generate a visibility information file, wherein the visibility information file is used for guiding the rendering of a visible virtual model in the virtual scene. In another aspect, an embodiment of the present application provides a computer device, where the computer device includes a processor and a memory, where the memory stores at least one instruction, at least one section of program, a code set, or an instruction set, and the at least one instruction, the at least one section of program, the code set, or the instruction set is loaded and executed by the processor to implement th