Shielding data generation method and device and electronic equipment

By using an automated method to generate occlusion data, and leveraging navigation mesh data and collision detection, the high cost and error issues of occlusion marking in game scenes are resolved, achieving efficient and accurate occlusion data generation and game performance optimization.

CN120960762APending Publication Date: 2025-11-18NETEASE (SHANGHAI) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511094056.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-05
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

In existing technologies, marking occlusions in game scenes requires a lot of manual intervention, resulting in high costs and high error rates. Furthermore, it is difficult to generate occlusion data efficiently and accurately, which affects game performance.

Method used

By acquiring navigation mesh data, determining scan points, performing collision detection and ray scanning, generating an occlusion database, automatically generating rough models of occluded objects, setting labels in the offline stage, baking to generate occlusion data, and removing occluded objects in the virtual scene.

Benefits of technology

It achieves efficient and accurate generation of occlusion data, reduces the cost and error of manual labeling, avoids real-time performance overhead, and improves game running efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120960762A_ABST
    Figure CN120960762A_ABST
Patent Text Reader

Abstract

The invention provides a method and a device for generating occlusion data and electronic equipment. The method comprises the following steps of: determining a scanning point from navigation grid data for indicating an area which a virtual character can enter in a virtual scene; determining a collision detection range based on the position of the scanning point, emitting a ray in the collision detection range, and recording collision information of collision between a scene object in the collision detection range and the ray; generating a shielding object coarse model based on a shielding database determined by the collision information; importing the shielding object rough model into the virtual scene, and hiding a plurality of scene objects contained in the virtual scene; and setting a first label for indicating that the scene object is a shelter for the shelter coarse model in the virtual scene, and baking the shelter coarse model provided with the first label to obtain shelter data. According to the method, the shielding object rough model is generated through completely offline automatic scanning and collision information processing, and then the shielding data is generated through baking the shielding object rough model, so that the manufacturing efficiency and accuracy of the shielding data in the offline stage are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data processing technology, and in particular to a method, apparatus and electronic device for generating occluded data. Background Technology

[0002] The virtual environment in a game is crucial to the gaming experience. To make a game scene realistic and believable, many details need to be added, such as scattered trash on the ground, grass at the base of walls, and pebbles by the roadside. These details put pressure on performance. To optimize this performance, scene objects that are not visible from the player's perspective need to be hidden from rendering, thus reducing performance overhead.

[0003] In related technologies, scene objects in the game scene need to be manually classified and labeled, distinguishing them into "occluders" and "occluded objects." When a scene object is labeled as an "occluder," it will block objects behind it after occlusion culling and baking. When a scene object is labeled as an "occluded object," it will be blocked by occluders in front of it. However, manual labeling not only consumes a lot of manpower but is also prone to labeling errors or omissions. Summary of the Invention

[0004] The purpose of this disclosure is to provide a method, apparatus, and electronic device for generating occlusion data, so as to automatically set labels for occlusion objects in a virtual scene and improve the efficiency and accuracy of occlusion data production in the offline stage.

[0005] In a first aspect, this disclosure provides a method for generating occlusion data. The method includes: acquiring navigation mesh data and determining multiple scanning points from the navigation mesh data; wherein the navigation mesh data is used to indicate scene areas that a virtual character can enter in a virtual scene, and the virtual scene includes multiple scene objects; for each of the multiple scanning points, determining a collision detection range based on the location of the scanning point, emitting a ray within the collision detection range, and recording collision information when scene objects within the collision detection range collide with the ray; generating an occlusion database based on the collision information, and generating a rough model of an occluder based on the occlusion database; wherein the rough model of the occluder is used to indicate the outer contour of a scene object that acts as an occluder in the virtual scene; importing the rough model of the occluder into the virtual scene and hiding multiple scene objects contained in the virtual scene; setting a first label for the currently retained rough model of the occluder in the virtual scene, and baking the rough model of the occluder with the first label to obtain occlusion data, so as to remove occluded scene objects in the virtual scene based on the occlusion data during the scene running phase; wherein the first label is used to indicate that the scene object corresponding to the rough model of the occluder is an occluder.

[0006] Secondly, this disclosure provides an apparatus for generating occlusion data, comprising: a scan point determination module, configured to acquire navigation mesh data and determine multiple scan points from the navigation mesh data; wherein the navigation mesh data is used to indicate scene areas that a virtual character can enter in a virtual scene, and the virtual scene includes multiple scene objects; a collision information determination module, configured to determine a collision detection range for each of the multiple scan points based on the location of the scan point, and emit a ray within the collision detection range, recording collision information of scene objects within the collision detection range colliding with the ray; and a rough model generation module, configured to generate a rough model based on the collision information. An occlusion database is created, and a rough model of the occluding object is generated based on the occlusion database. The rough model of the occluding object is used to indicate the outer contour of the scene object that acts as an occlusion in the virtual scene. The rough model import module is used to import the rough model of the occluding object into the virtual scene and hide multiple scene objects contained in the virtual scene. The data generation module is used to set a first label for the currently retained rough model of the occluding object in the virtual scene and bake the rough model of the occluding object with the first label to obtain occlusion data, so as to remove the occluded scene objects in the virtual scene based on the occlusion data during the scene running stage. The first label is used to indicate that the scene object corresponding to the rough model of the occluding object is an occluding object.

[0007] Thirdly, this disclosure provides an electronic device including a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the above-described method for generating occlusion data.

[0008] Fourthly, this disclosure provides a computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the aforementioned method for generating occlusion data.

[0009] The embodiments disclosed herein bring the following beneficial effects:

[0010] This disclosure provides a method, apparatus, and electronic device for generating occlusion data. First, navigation mesh data is acquired, and multiple scanning points are determined from the navigation mesh data. The navigation mesh data indicates the scene areas accessible to virtual characters in a virtual scene, which includes multiple scene objects. For each scanning point, a collision detection range is determined based on its location, and a ray is emitted within the collision detection range. Collision information is recorded when scene objects within the collision detection range collide with the ray. An occlusion database is generated based on the collision information, and a rough model of the occluded object is generated according to the occlusion database. The rough model of the occluded object is then imported into the virtual scene, hiding multiple scene objects contained in the virtual scene. A first label is set for the currently retained rough models of the occluded object in the virtual scene, and the rough models of the occluded object with the first label are baked to obtain occlusion data. During scene execution, occluded scene objects in the virtual scene are removed based on the occlusion data. The first label indicates that the scene object corresponding to the rough model of the occluded object is an occluder. This method generates a rough model of occlusion objects through fully offline automated scanning and collision information processing. Occlusion data is then generated by baking the rough model. This approach avoids the high labor costs and error rates of traditional manual occlusion marking methods, improving the efficiency and accuracy of offline occlusion data creation. Furthermore, this method is independent of real-time occlusion culling or collision detection during game runtime, thus avoiding real-time performance overhead.

[0011] Other features and advantages of this disclosure will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the techniques described above.

[0012] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0013] To more clearly illustrate the technical solutions in the specific embodiments of this disclosure or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0014] Figure 1 A flowchart illustrating a method for generating occlusion data provided in this embodiment of the disclosure;

[0015] Figure 2 A schematic diagram of a minimum bounding box divided into multiple cells provided in an embodiment of this disclosure;

[0016] Figure 3 This is a schematic diagram illustrating the determination of a target point according to an embodiment of the present disclosure;

[0017] Figure 4 A schematic diagram of a scanner provided in an embodiment of this disclosure;

[0018] Figure 5 This is a schematic diagram illustrating how collision information is stored in a temporary database, as provided in an embodiment of this disclosure.

[0019] Figure 6 This is a schematic diagram of the structure of an occlusion data generation device provided in an embodiment of the present disclosure;

[0020] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0022] Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely to illustrate selected embodiments of the disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0023] The existing solution, based on the Unity engine's occlusion data creation process, requires the following steps:

[0024] Step 1 involves manually classifying and labeling scene objects, categorizing them into "occluders" and "occluded objects." When a scene object is labeled "occluder," it will block objects behind it after occlusion culling baking. When a scene object is labeled "occluded," it will be blocked by occluders in front of it. From different player perspectives, a scene object can be either an occluder or an occluded object.

[0025] Step 2: To conserve data, Unity provides a feature to set a fine-grained occlusion range. The level of detail in the occlusion data within this range is determined by the art developers. Higher detail results in better occlusion, but the data volume increases exponentially, placing a burden on memory and CPU. Therefore, art developers need to balance occlusion effects and performance overhead, repeatedly adjusting the range and detail of the fine-grained occlusion.

[0026] Step 3, bake masking data.

[0027] Step 4: Verify the occlusion effect. This step requires art developers to verify the occlusion culling effect through the Unity Debug interface and correct any omissions in tagging that may have occurred in Step 1.

[0028] The main drawback of the existing technical solution lies in step 1 above. That is, the complexity of game scenes varies greatly. When a game scene is larger than 500m x 500m and has a realistic art style, the number of scene objects can exceed 10,000, sometimes even exceeding 40,000. For scenes of this size, manually completing step 1 is extremely time-consuming and error-prone. For example, in a 500m x 500m game scene containing 10,000 scene objects, labeling the scene objects takes 2-3 days, and almost inevitably results in omissions. Due to Unity's occlusion culling mechanism, the "occluded object" label can be ignored, because even if not labeled as an "occluded object," it can still be blocked by "occluders" in front. Therefore, the main effort for these 2-3 days is to select suitable scene objects as occluders in the game scene and label them as "occluders." Furthermore, due to the complex placement of scene objects, it is very common for scene objects of various sizes to interweave and nest with each other. Therefore, omissions in labeling are inevitable. Moreover, after the initial setup is completed, there will be thousands of objects that are missed being tagged.

[0029] When making corrections in step 4 above, the Unity debug interface is used to visually check for any omissions and identify which models were missed. This process often takes another 2-3 days. Regarding step 2 above, the basis for planning the fine occlusion area is whether the player character will pass through it. If the player character will pass through a certain area, it is included in the fine occlusion area. Because scene structures are often complex, developers cannot intuitively distinguish which areas the player will pass through. In some cave scenes, due to the obstruction of large external rock models, developers cannot even directly observe the area where the player character will walk, let alone plan the fine occlusion area.

[0030] To address the aforementioned issues, this disclosure provides a method, apparatus, and electronic device for generating occlusion data, which can be applied to scenarios involving the generation of occlusion data during offline phases.

[0031] To facilitate understanding of the embodiments of this disclosure, a method for generating occlusion data disclosed in this disclosure will first be described in detail, such as... Figure 1 As shown, the method includes the following specific steps:

[0032] Step S102: Obtain navigation grid data and determine multiple scan points from the navigation grid data; wherein, the navigation grid data is used to indicate the scene area that the virtual character can enter in the virtual scene, and the virtual scene includes multiple scene objects.

[0033] The aforementioned navigation grid data is a data structure used for virtual characters to navigate within a virtual scene. It describes the areas where the virtual character can move freely within the virtual scene. The virtual character can be a game character controlled by the user or a non-player character (NPC) within the virtual scene. For example, importing the navigation grid data into the corresponding script of an NPC in the virtual scene tells the NPC which areas within the virtual scene are accessible.

[0034] In practical applications, navigation mesh data can be generated automatically programmatically or manually through Unity's relevant interfaces. The program can directly call the generated navigation mesh data via Unity's provided interfaces. After obtaining the navigation mesh data, a certain number of point information is randomly and evenly generated within it, and then scan points are determined from this generated point information. For example, all points in the navigation mesh data can be determined as scan points, or points in the navigation mesh data that meet preset conditions can be determined according to development needs; no specific limitations are made here.

[0035] Step S104: For each of the multiple scanning points, determine the collision detection range based on the location of the scanning point, emit a ray within the collision detection range, and record the collision information of scene objects within the collision detection range colliding with the ray.

[0036] After identifying multiple scan points, scanning processing needs to be performed during the offline phase of game development to generate occlusion data in an offline state. This method does not involve any performance overhead during real-time game operation. During scanning processing, a collision detection range needs to be determined based on the location of the scan points. Multiple rays are then emitted within the collision detection range for ray scanning to detect and record collision information when the rays collide with scene objects within the collision detection range. This collision information includes, but is not limited to, the position information of the collision point on the scene object and the normal information of the collision surface when the scene object collides with the ray. The collision surface is the surface on the scene object where the collision point is located, and the normal information corresponding to the collision point is consistent with the normal information of the surface on the scene object where the collision point is located.

[0037] Step S106: Generate an occlusion database based on collision information, and generate a rough model of the occlusion object based on the occlusion database; wherein, the rough model of the occlusion object is used to indicate the outer contour of the scene object that acts as an occlusion object in the virtual scene.

[0038] In the actual implementation, since each scanning point needs to be processed by ray scanning within the corresponding collision detection range, and the number of emitted rays corresponding to each scanning point is multiple, when storing the collision information of all scene objects colliding with rays into the occlusion database, it is necessary to remove duplicate data or remove information where the collision positions indicated by the collision information are close to each other, so as to reduce the amount of calculation when generating the rough model of the occluded object later.

[0039] Because the occlusion database records the position and normal information of multiple collision points, a simplified model can be generated based on the data stored in the database. This simplified model, also known as the occlusion coarse model, is used to replace the complex models corresponding to scene objects in the virtual scene, thereby reducing the complexity of subsequent data baking. Specifically, the occlusion coarse model indicates the outer contour of scene objects in the virtual scene that should be set as occluders.

[0040] Step S108: Import the rough model of the occluding object into the virtual scene to hide multiple scene objects contained in the virtual scene.

[0041] After obtaining the rough model of the occluder, the occluder model is automatically loaded into the virtual scene, and the scene objects originally set in the virtual scene are hidden. Only the rough model based on the occluder is retained in the virtual scene.

[0042] Step S110: Set a first label for the coarse model of the occluder currently retained in the virtual scene, and bake the coarse model of the occluder with the first label to obtain occlusion data, so as to remove the occluded scene objects in the virtual scene during the scene running stage according to the occlusion data; wherein, the first label is used to indicate that the scene object corresponding to the coarse model of the occluder is an occluder.

[0043] After setting the first label for the coarse model of the occluded objects currently retained in the virtual scene, occlusion data needs to be generated using baking technology. That is, during the offline phase of game development, the first labels set for the scene objects corresponding to the coarse models of the occluded objects and the corresponding scene objects are pre-calculated and saved to obtain occlusion data. During game runtime, the occlusion data can be directly used to determine the occlusion relationships between scene objects in the virtual scene, thereby removing occluded scene objects from the virtual scene. This avoids real-time calculations, reduces unnecessary rendering work, and improves game performance.

[0044] After baking the coarse model of the occluder with the first label and obtaining the occlusion data, the imported coarse model of the occluder is deleted from the virtual scene, and multiple scene objects are restored and displayed in the virtual scene. That is, after baking, the coarse model of the occluder in the virtual scene is automatically deleted, and all the original scene objects in the virtual scene are restored, thus completing the entire occlusion removal baking process.

[0045] This invention provides a method for generating occlusion data. It generates a rough model of occlusion objects through fully offline automated scanning and collision information processing, and then generates occlusion data by baking the rough model. This method avoids the high labor costs and error rates of traditional manual occlusion marking methods, improving the efficiency and accuracy of offline occlusion data generation. Furthermore, this method is independent of real-time occlusion culling or collision detection during game runtime, thus avoiding real-time performance overhead.

[0046] In one specific implementation, the process of determining multiple scan points from navigation mesh data described above can be achieved through the following steps 10-13:

[0047] Step 10: Generate points with a preset amount of data on the navigation grid data.

[0048] After obtaining the navigation grid data, a preset number of points can be randomly generated on the navigation grid, or a preset number of points can be generated by evenly scattering points on the navigation grid. The preset number can be 1000 or 10000, etc., and there is no specific limitation here.

[0049] Step 11: Generate the minimum bounding box that encloses the navigation mesh data.

[0050] In practical implementation, a minimum bounding box that can surround the navigation mesh data can be generated based on the range of the navigation mesh data. This minimum bounding box is a three-dimensional cube.

[0051] Step 12: Divide the smallest bounding box into multiple cells on average.

[0052] Based on a preset point density, the minimum bounding box is divided into individual cells. This preset point density can be determined by the user's settings. Figure 2 The diagram shown is a schematic representation of a minimum bounding box divided into multiple cells according to an embodiment of the present invention. Figure 2 The large cube in the diagram is the smallest bounding box, which is divided into several smaller pieces, which are the cells mentioned above.

[0053] Step 13: Determine the center position of each cell, and based on the center position, determine the target point from the points contained in the navigation grid data, and set the target point as the scan point.

[0054] Iterate through all cells in the smallest bounding box to obtain the position coordinates corresponding to the center position of each cell. Then, based on the distance between the center position of each cell and the points contained in the navigation grid data, determine the target point from the points contained in the navigation grid data. This target point is also the scan point.

[0055] In an optional embodiment, the specific process of determining the target point from the points contained in the navigation grid data based on the center position and determining the target point as the scan point may include: performing the following operation for each cell: determining whether the distance between the center position of the current cell and the navigation grid data is less than or equal to a preset distance threshold; if so, determining the target point closest to the center position of the current cell from the points contained in the navigation grid data.

[0056] In practical implementation, each cell within the minimum bounding box needs to be treated as the current cell to determine the distance between the center of the current cell and the navigation grid data. When this distance is less than or equal to a preset distance threshold, the point in the navigation grid data closest to the center of the current cell is determined as the target point. The preset distance threshold can be determined according to development needs; for example, it could be half the side length of the cell or half the diagonal of the cell.

[0057] like Figure 3 The diagram shown is a schematic diagram of determining a target point according to an embodiment of the present invention. Figure 3 The cube in the diagram represents a cell within the smallest bounding box, and P0 is the center position of that cell. Figure 3 The gray cuboid in the diagram represents a portion of the navigation grid data, and point P is the target point closest to P0 in the navigation grid data. Specifically, if no navigation grid data is detected within a spherical area of ​​radius R around P0, the cell is discarded, where R is equal to half the length of the cell's diagonal, which is also the aforementioned preset distance threshold.

[0058] The above method can output a set of multiple target points (scan points) so that the virtual scene can be scanned using the target points later.

[0059] In one specific display method, the above-mentioned process of determining the collision detection range based on the location of the scanning point may include: creating a scanner at the location of the scanning point; wherein the scanner includes a root node and a scanning node, the root node is located at the location of the scanning point, and the scanning node is located at a preset height above the root node; determining a spherical range with the scanning node as the center and a preset length as the radius as the collision detection range; wherein the collision detection range is used to indicate the possible location of the virtual camera capturing the virtual scene.

[0060] The aforementioned scanner is used to scan a virtual scene. It consists of two parts: a root node and scanning nodes. The root node is responsible for the scanner's location, while the scanning nodes, located as children of the root node, move with the root node's position. The scanning nodes are responsible for scanning the virtual scene. The children of the root node are the sets containing the scanning points.

[0061] like Figure 4 The diagram shown is a schematic diagram of a scanner provided in an embodiment of the present invention. Figure 4 The root node is located at the very bottom of the scanner, and the scanning nodes are positioned at a preset height above the root node. Simultaneously, the scanning node includes a spherical collision detection range with a preset radius. The scanning node simulates the height of the virtual character's head, meaning the preset height matches the virtual character's height. Therefore, the preset height can be set and adjusted according to the virtual character's body size; for example, it could be 1.8 meters or 1.6 meters. The spherical collision detection range simulates the possible locations of the virtual camera. The preset length corresponding to the radius of this collision detection range can be determined based on the game type; for example, the preset length could be 1 meter or 2 meters.

[0062] In an optional embodiment, the specific process of emitting rays within the collision detection range and recording collision information when scene objects within the collision detection range collide with the rays may include: controlling the scanner to emit a specified number of rays within the corresponding collision detection range; generating collision information corresponding to the collision point when the rays collide with scene objects within the collision detection range; wherein the collision information includes position information and normal information corresponding to the collision point; and storing the collision information corresponding to the collision point in a temporary database.

[0063] In the actual implementation, each scan point needs to be traversed sequentially. The root node of the scanner is placed at the location of the scan point, and a specified number of rays are emitted in all directions from the scan node. This specified number is determined by the developers. The more rays specified, the denser the generated collision information, the longer the processing time, but the more accurate the final coarse model of the occlusion. When a ray hits a scene object, a collision point data structure is generated. This data structure is the collision information, which includes the position information of the collision point and the normal information of the collision surface. Then, the generated collision information is stored in a temporary database.

[0064] In one optional embodiment, the starting point and direction of the rays emitted by the scanner are random within the corresponding collision detection range; this ray direction can also be understood as random along a spherical direction. This approach makes the collision information generated based on rays more accurate and comprehensive.

[0065] Optionally, the specific process of storing the collision information corresponding to the collision point into the temporary database may include: determining whether the distance between the location of the collision point and the location of the collision point in the temporary database is greater than a minimum distance threshold based on the location information corresponding to the collision point; if it is greater than the minimum distance threshold, storing the collision information corresponding to the collision point into the temporary database; if the distance between the location of the collision point and the location of the collision point in the temporary database is not greater than the minimum distance threshold, discarding the collision information corresponding to the collision point.

[0066] The minimum distance threshold is set by the user. The smaller the minimum distance threshold, the higher the density of collision points stored in the temporary database. By filtering the locations corresponding to collision points using the minimum distance threshold, the collision points stored in the temporary database are prevented from being too dense or overlapping.

[0067] like Figure 5 The diagram shown is a schematic representation of storing collision information in a temporary database according to an embodiment of the present invention. First, a temporary database is established (equivalent to...). Figure 5 The temporary database (used in the context of the scene) stores and processes collision information for the current scan point. This collision information includes the position and normal information corresponding to the collision point. When a ray collides with an object in the scene, the position information of the collision point is compared with the position information in the temporary database. If the distance between the current collision point and any position in the temporary database is greater than the minimum distance threshold, the position and normal information of the current collision point are added to the temporary database; otherwise, the collision information of the current collision point is discarded.

[0068] After completing the ray detection for all scan points, a temporary database corresponding to the current scan point can be obtained. Specifically, each scan point is configured with a corresponding temporary database, which is used to store the collision information determined based on the corresponding scan point.

[0069] Based on the above description, the specific process of generating an occlusion database based on collision information may include: filtering the positions of collision points in a temporary database corresponding to multiple scan points using a minimum distance threshold to obtain an occlusion database that only contains collision information corresponding to collision points whose distances between collision points are greater than the minimum distance threshold.

[0070] In practical implementation, the data in the temporary database corresponding to each scan point and the data currently stored in the occlusion database need to be filtered again using the minimum distance threshold. That is, for the temporary database corresponding to each scan point, the following operations are performed in sequence: For each collision point in the temporary database corresponding to the current scan point, based on the position information corresponding to the current collision point, it is determined whether the distance between the position of the current collision point and the position of the collision point in the occlusion database is greater than the minimum distance threshold; if it is greater than the minimum distance threshold, the collision information corresponding to the current collision point is stored in the occlusion database.

[0071] Specifically, if the position of the current collision point in the temporary database and the position of the collision point currently stored in the occlusion database are both less than the minimum distance threshold, the collision information of the current collision point is moved from the temporary database to the occlusion database; if the position of the current collision point in the temporary database and the position of the collision point currently stored in the occlusion database are both less than or equal to the minimum distance threshold, the collision information of the current collision point is discarded.

[0072] As the scanning process progresses, the amount of data in the occlusion database increases, and the comparison time for collision information to be migrated into the occlusion database becomes increasingly longer, affecting scanning efficiency. To improve efficiency in this process, multiple preset cache databases can be established and processed in parallel, and then integrated to obtain the occlusion data path after the scan is completed.

[0073] Specifically, before scanning based on the current scan point, a target cache library needs to be determined from multiple preset cache libraries. The preset cache libraries store collision information corresponding to a specified number of collision points. The target cache library is an occlusion database containing the collision information of the collision points stored in the temporary database corresponding to the current scan point. Then, for each collision point in the temporary database corresponding to the current scan point, based on the position information of the current collision point, it is determined whether the distance between the position of the current collision point and the position of the collision point in the target cache library is greater than a minimum distance threshold. If it is greater than the minimum distance threshold, the collision information corresponding to the current collision point is stored in the target cache library.

[0074] In practical implementation, a corresponding preset cache library can be established in advance based on the number of CPU threads before the scan begins. For example, if the current computer's CPU has 16 cores and 32 threads, 32 preset cache libraries can be established. The target database mentioned above can be any of the currently available preset cache libraries, or it can be the preset cache library with the least amount of data in the currently available preset cache library.

[0075] Each time collision information from the temporary database needs to be moved into the preset cache, an idle preset cache is first located, and the preset cache with the least amount of data is selected for comparison. When the number of collision information in a preset cache exceeds a specified number (e.g., 60,000 or 80,000), that preset cache is saved separately, and a new empty cache is created. These measures are taken to ensure the smoothness and efficiency of the entire scanning process.

[0076] After the full-scene scan is completed, multiple preset cache libraries will be obtained. These preset cache libraries need to be integrated into a complete occlusion database. That is, the positions of collision points in the multiple preset cache libraries need to be filtered by a minimum distance threshold to obtain an occlusion database that only contains collision information corresponding to collision points whose distance is not greater than the minimum distance threshold.

[0077] In practical implementation, the final occlusion database can be obtained by comparing collision information from multiple rounds of preset cache libraries. First, preset cache libraries are paired in pairs, forming combinations AB, AB, AB. Any missing preset cache library automatically proceeds to the next round. Within each pair, the position information of collision points in A is compared one by one with the position information of collision points in B using a minimum distance threshold filter. If the position of a collision point in A and the position of a collision point in B are both greater than the minimum distance threshold, the collision information of the collision point in A is moved to B. If the position of a collision point in A and the position of a collision point in B are less than or equal to the minimum distance threshold, the collision information of that collision point in A is discarded. After one round of comparison, preset cache libraries B, B, B are obtained, and there may still be a missing preset cache library A from the previous round. The pairing is then repeated for the next round of comparison. Finally, a complete occlusion database is obtained, in which the distance between collision points is greater than the minimum distance threshold and is basically evenly distributed. The above processing of preset cache libraries is performed simultaneously by multiple threads to improve processing efficiency.

[0078] In one specific embodiment, the process of generating a rough model of an occluded object based on an occlusion database may include: performing three-dimensional reconstruction based on the occlusion information stored in the occlusion database to obtain a rough model of the occluded object.

[0079] In practical implementation, since the occlusion database contains position and normal information for multiple collision points, and these collision points are located on scene objects in the virtual scene, a simplified model of the scene object, i.e., a rough model of the occlusion object, can be obtained based on the position and normal information of multiple collision points. This process is completed during the offline phase of game development. The final generated rough model of the occlusion object is used for baking offline occlusion data. During game runtime, the pre-baked occlusion data is used directly without any real-time calculations.

[0080] In one specific embodiment, the collision information in the occlusion database can be organized into the format required for a .xyz file. Specifically, the xyz coordinates of the position information from the collision information in the occlusion database are arranged at the beginning of a line, and the xyz coordinates of the normal information are arranged in the latter half of the line, separated by spaces, resulting in the following format: XYZ NX NY NZ. Here, X, Y, and Z in the first three elements represent the coordinates corresponding to the X, Y, and Z axes in the position information, respectively, while NX, NY, and NZ represent the coordinates corresponding to the X, Y, and Z axes in the discovery information, respectively. The collision information is organized line by line in this format and output directly as text, with the filename ending in .xyz.

[0081] Then, the interface of an open-source software called MeshLab was directly invoked to read the output xyz file. The algorithm in MeshLab was used to generate a rough model of the occluded object based on the collision information. This rough model of the occluded object represents the outer contour of the scene objects in the virtual scene.

[0082] In an optional embodiment, after generating a rough model of the occluder based on the occlusion database, the points, lines, and surfaces of the rough model can be converted into voxel format to obtain a rough model of the occluder containing multiple voxel blocks; the multiple voxel blocks are scaled down according to a preset ratio to obtain scaled-down voxel blocks; the scaled-down voxel blocks are restored to a model in the form of points, lines, and surfaces to obtain an updated rough model of the occluder.

[0083] In practical implementation, after the rough model of the occluded object is generated, it is automatically imported into the engine. The engine needs to use Houdini's interface to perform simple processing on the rough model of the occluded object. First, the rough model of the occluded object is converted into voxel format, that is, the points, lines and surfaces of the rough model of the occluded object are expressed in the form of voxel blocks. Then, these voxel blocks are scaled down according to a preset ratio and restored to the traditional model in the form of points, lines and surfaces to obtain the updated rough model of the occluded object.

[0084] The above method can be understood as pushing the surface of the occluding object's rough model back a certain distance along its normal direction. This method serves two purposes. First, it eliminates some small scene objects, such as streetlights, building pillars, and roadside trash cans. These small scene objects do not block the scene objects behind them and would instead increase the final occlusion data. The second purpose is to create a gap between the surface of the occluding object's rough model and the actual scene object's surface, preventing the engine from mistakenly believing the virtual camera is behind the wall and removing all scene objects in front of it due to accuracy issues during the virtual camera's contact with the wall.

[0085] After obtaining the updated rough model of the occlusion, it can be automatically loaded into the virtual scene, hiding multiple scene objects that were originally included in the scene. This facilitates the next step of setting up a more refined occlusion area.

[0086] Specifically, after importing the coarse model of the occlusion into the virtual scene and hiding multiple scene objects contained in the virtual scene, it is necessary to determine the fine occlusion area in the virtual scene based on the coarse model of the occlusion currently retained in the virtual scene.

[0087] In an optional embodiment, the user can outline some cubes in the virtual scene, defining these cubes as refined occlusion areas. This tells the engine that the space within these cubes requires refined occlusion data baking, while the space outside the cubes can be simply baked. The purpose of this step is to distribute the limited data as much as possible within the area reachable by the virtual character. Since this invention hides the original scene objects in the virtual scene and only displays the rough outlines of the occlusion objects, the entire process is visually very clear and easy to understand. It allows for a more intuitive view of the areas requiring refined occlusion; that is, simply outlining the rough outlines of the occlusion objects is sufficient, significantly improving the efficiency of refined occlusion area layout.

[0088] Based on the above description, the specific process of setting a first label for the coarse model of the occluder currently retained in the virtual scene and baking the coarse model of the occluder with the first label to obtain occlusion data may include: in response to the baking instruction for the fine occlusion area, setting a first label for the coarse model of the occluder in the fine occlusion area and baking the coarse model of the occluder with the first label to obtain occlusion data.

[0089] Since the refined occlusion area is the same as the area where the rough model of the occluding object is located in the virtual scene, the "occluding object" label (equivalent to the first label mentioned above) can be set for the rough model of the occluding object using the baking command on the preset operation panel, and the rough model of the occluding object with the first label is baked to obtain the occlusion data. After baking, the rough model of the occluding object in the virtual scene is automatically deleted, restoring all the original scene objects in the virtual scene.

[0090] It should be clearly stated that the generated occlusion data is static data and is not subject to real-time ray detection or point cloud scanning during the game's operation. Therefore, this invention does not involve real-time occlusion judgment or real-time collision detection technology, but focuses on optimizing the automated generation process of offline occlusion data.

[0091] Furthermore, this method reduces the cost of maintaining occlusion data later. If developers modify the virtual scene, for example, by adding a street, the newly added model needs to re-mark occluders and occluded objects. This part of the virtual scene also needs to have its occlusion effect rechecked. If the modifications are not synchronized, it's possible that the modified parts haven't been re-created with occlusion removal, leading to ineffective or incorrect occlusion in this part of the scene. This invention can be integrated with automation tools to automatically scan scene modification dates, thereby automatically refreshing the occlusion data after scene modifications.

[0092] Corresponding to the above method embodiments, this disclosure provides an apparatus for generating occlusion data, such as... Figure 6 As shown, the device includes:

[0093] The scan point determination module 60 is used to acquire navigation grid data and determine multiple scan points from the navigation grid data; wherein, the navigation grid data is used to indicate the scene area that the virtual character can enter in the virtual scene, and the virtual scene includes multiple scene objects.

[0094] The collision information determination module 61 is used to determine the collision detection range based on the location of each of the multiple scanning points, emit rays within the collision detection range, and record the collision information of scene objects within the collision detection range colliding with the rays.

[0095] The rough model generation module 62 is used to generate an occlusion database based on collision information and generate a rough model of the occlusion object based on the occlusion database; wherein, the rough model of the occlusion object is used to indicate the outer contour of the scene object that acts as an occlusion object in the virtual scene.

[0096] The rough model import module 63 is used to import the rough model of the occluding object into the virtual scene, thereby hiding multiple scene objects contained in the virtual scene.

[0097] The data generation module 64 is used to set a first label for the coarse model of the occluder currently retained in the virtual scene, and bake the coarse model of the occluder with the first label to obtain occlusion data, so as to remove the occluded scene objects in the virtual scene according to the occlusion data during the scene running stage; wherein, the first label is used to indicate that the scene object corresponding to the coarse model of the occluder is an occluder.

[0098] The aforementioned occlusion data generation device generates a rough model of the occlusion object through fully offline automated scanning and collision information processing. Then, it generates occlusion data by baking the rough model. This method avoids the high labor costs and error rates of traditional manual occlusion marking methods, improving the efficiency and accuracy of offline occlusion data generation. Furthermore, this method is independent of real-time occlusion culling or collision detection during game runtime, thus avoiding real-time performance overhead.

[0099] Furthermore, the aforementioned device also includes an object restoration module, used to: after baking a rough model of an occluder with a first label and obtaining occlusion data, delete the rough model of the occluder imported into the virtual scene, and restore and display multiple scene objects in the virtual scene.

[0100] Furthermore, the aforementioned scan point determination module 60 is used to: generate points with a preset amount of data on the navigation grid data; generate a minimum bounding box that surrounds the navigation grid data; divide the minimum bounding box into multiple cells on an average basis; determine the center position of each cell; and determine the target point from the points contained in the navigation grid data based on the center position, and determine the target point as the scan point.

[0101] Furthermore, the aforementioned scanning point determination module 60 is also used to: perform the following operation for each cell: determine whether the distance between the center position of the current cell and the navigation grid data is less than or equal to a preset distance threshold; if so, determine the target point closest to the center position of the current cell from the points contained in the navigation grid data.

[0102] Furthermore, the collision information determination module 61 described above is used to: create a scanner at the location of the scanning point; wherein the scanner includes a root node and a scanning node, the root node is located at the location of the scanning point, and the scanning node is located at a preset height above the root node; and determine a spherical range with the scanning node as the center and a preset length as the radius as the collision detection range; wherein the collision detection range is used to indicate the possible location of the virtual camera capturing the virtual scene.

[0103] Furthermore, the collision information determination module 61 is also used to: control the scanner to emit a specified number of rays within the corresponding collision detection range; generate collision information corresponding to the collision point when the ray collides with a scene object within the collision detection range; wherein the collision information includes the position information and normal information corresponding to the collision point; and store the collision information corresponding to the collision point in a temporary database.

[0104] Furthermore, the starting point and direction of the rays emitted by the aforementioned scanner are random within the corresponding collision detection range.

[0105] Furthermore, the aforementioned scanning point determination module 60 is also used to: determine whether the distance between the location of the collision point and the location of the collision point in the temporary database is greater than a minimum distance threshold based on the location information corresponding to the collision point; if it is greater than the minimum distance threshold, store the collision information corresponding to the collision point in the temporary database.

[0106] Furthermore, the above-mentioned device also includes an information discarding module, used to discard the collision information corresponding to the collision point if the distance between the location of the collision point and the location of the collision point in the temporary database is not greater than a minimum distance threshold.

[0107] Furthermore, each scan point is configured with a corresponding temporary database, which is used to store collision information determined based on the corresponding scan point; based on this, the coarse model generation module 62 is used to: filter the positions of collision points in the temporary databases corresponding to multiple scan points by a minimum distance threshold, and obtain an occlusion database that only contains collision information corresponding to collision points whose distance between collision points is greater than the minimum distance threshold.

[0108] Furthermore, the aforementioned coarse model generation module 62 is also used to: for each temporary database corresponding to a scan point, perform the following operations in sequence: for each collision point in the temporary database corresponding to the current scan point, based on the position information corresponding to the current collision point, determine whether the distance between the position of the current collision point and the position of the collision point in the occlusion database is greater than the minimum distance threshold; if it is greater than the minimum distance threshold, store the collision information corresponding to the current collision point in the occlusion database.

[0109] Furthermore, the aforementioned device also includes a database determination module, configured to: for each collision point in the temporary database corresponding to the current scan point, determine, based on the position information corresponding to the current collision point, whether the distance between the position of the current collision point and the position of the collision point in the occlusion database is greater than a minimum distance threshold; if it is greater than the minimum distance threshold, determine a target cache database from multiple preset cache databases before storing the collision information corresponding to the current collision point in the occlusion database; wherein, the preset cache database is used to store the collision information corresponding to a specified number of collision points; the target cache database is the occlusion database containing the collision information corresponding to the collision points in the temporary database corresponding to the current scan point.

[0110] Based on the above description, the device further includes a data filtering module, configured to: for each collision point in the temporary database corresponding to the current scanning point, determine whether the distance between the position of the current collision point and the position of the collision point in the occlusion database is greater than a minimum distance threshold based on the position information corresponding to the current collision point; if it is greater than the minimum distance threshold, after storing the collision information corresponding to the current collision point in the occlusion database, filter the positions of the collision points in multiple preset cache databases using the minimum distance threshold to obtain an occlusion database that only contains the collision information corresponding to collision points whose distance is greater than the minimum distance threshold.

[0111] Furthermore, the aforementioned rough model generation module 62 is also used to: perform three-dimensional reconstruction based on the occlusion information stored in the occlusion database to obtain a rough model of the occluded object.

[0112] Furthermore, the above-mentioned device also includes a rough model update module, which is used to: after generating a rough model of the occluder based on the occlusion database, convert the points, lines and surfaces of the rough model of the occluder into voxel format to obtain a rough model of the occluder containing multiple voxel blocks; reduce the multiple voxel blocks according to a preset ratio to obtain reduced voxel blocks; and restore the reduced voxel blocks to a model in the form of points, lines and surfaces to obtain an updated rough model of the occluder.

[0113] Furthermore, the aforementioned device also includes a region determination module, used to: after importing the coarse model of the occlusion into the virtual scene and hiding multiple scene objects contained in the virtual scene, determine a refined occlusion region in the virtual scene based on the currently retained coarse model of the occlusion in the virtual scene.

[0114] Furthermore, the aforementioned data generation module 64 is used to: in response to a baking instruction for a refined occlusion area, set a first label for a rough model of an occluder within the refined occlusion area, and bake the rough model of the occluder with the first label set to obtain occlusion data.

[0115] The occlusion data generation apparatus provided in this disclosure has the same implementation principle and technical effect as the aforementioned method embodiments. For the sake of brevity, any parts not mentioned in the apparatus embodiments can be referred to the corresponding content in the aforementioned method embodiments.

[0116] This disclosure also provides an electronic device, such as... Figure 7 As shown, the electronic device includes a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor. The processor executes the machine-executable instructions to implement the above-described method for generating occlusion data.

[0117] Specifically, the method for generating the aforementioned occlusion data includes: acquiring navigation mesh data and determining multiple scanning points from the navigation mesh data; wherein the navigation mesh data is used to indicate the scene area that a virtual character can enter in the virtual scene, and the virtual scene includes multiple scene objects; for each of the multiple scanning points, determining a collision detection range based on the location of the scanning point, emitting a ray within the collision detection range, and recording the collision information of scene objects within the collision detection range colliding with the ray; generating an occlusion database based on the collision information, and generating a rough model of the occluder based on the occlusion database; wherein the rough model of the occluder is used to indicate the outer contour of the scene object that acts as an occluder in the virtual scene; importing the rough model of the occluder into the virtual scene, hiding the multiple scene objects contained in the virtual scene; setting a first label for the currently retained rough model of the occluder in the virtual scene, and baking the rough model of the occluder with the first label to obtain occlusion data, so as to remove the occluded scene objects in the virtual scene based on the occlusion data during the scene running stage; wherein the first label is used to indicate that the scene object corresponding to the rough model of the occluder is an occluder.

[0118] The aforementioned method for generating occlusion culling data generates a rough model of occlusions through fully offline automated scanning and collision information processing. Occlusion data is then generated by baking this rough model. This approach avoids the high labor costs and error rates of traditional manual occlusion marking methods, improving the efficiency and accuracy of offline occlusion data generation. Furthermore, this method is independent of real-time occlusion culling or collision detection during game runtime, thus avoiding real-time performance overhead.

[0119] In an optional embodiment, after the step of baking the rough model of the occluder with the first label to obtain the occlusion data, the above method further includes: deleting the rough model of the occluder imported into the virtual scene and restoring the display of multiple scene objects in the virtual scene.

[0120] In an optional embodiment, the step of determining multiple scan points from navigation grid data includes: generating points with a preset amount of data on the navigation grid data; generating a minimum bounding box that surrounds the navigation grid data; dividing the minimum bounding box into multiple cells on an average basis; determining the center position of each cell; and determining a target point from the points contained in the navigation grid data based on the center position, and determining the target point as a scan point.

[0121] In an optional embodiment, the step of determining the target point from the points contained in the navigation grid data based on the center position and determining the target point as the scanning point includes: performing the following operation for each cell: determining whether the distance between the center position of the current cell and the navigation grid data is less than or equal to a preset distance threshold; if so, determining the target point closest to the center position of the current cell from the points contained in the navigation grid data.

[0122] In an optional embodiment, the step of determining the collision detection range based on the location of the scanning point includes: creating a scanner at the location of the scanning point; wherein the scanner includes a root node and a scanning node, the root node is located at the location of the scanning point, and the scanning node is located at a preset height above the root node; determining a spherical range with the scanning node as the center and a preset length as the radius as the collision detection range; wherein the collision detection range is used to indicate the possible location of the virtual camera capturing the virtual scene.

[0123] In an optional embodiment, the steps of emitting rays within the collision detection range and recording collision information when scene objects within the collision detection range collide with the rays include: controlling the scanner to emit a specified number of rays within the corresponding collision detection range; generating collision information corresponding to the collision point when the rays collide with scene objects within the collision detection range; wherein the collision information includes position information and normal information corresponding to the collision point; and storing the collision information corresponding to the collision point in a temporary database.

[0124] In an optional embodiment, the starting point and direction of the rays emitted by the scanner are random within the corresponding collision detection range.

[0125] In an optional embodiment, the step of storing the collision information corresponding to the collision point into a temporary database includes: determining whether the distance between the location of the collision point and the location of the collision point in the temporary database is greater than a minimum distance threshold based on the location information corresponding to the collision point; if it is greater than the minimum distance threshold, storing the collision information corresponding to the collision point into the temporary database.

[0126] In an optional embodiment, the method further includes: if the distance between the location of the collision point and the location of the collision point in the temporary database is not greater than the minimum distance threshold, discard the collision information corresponding to the collision point.

[0127] In an optional embodiment, each scanning point is configured with a corresponding temporary database, which is used to store collision information determined based on the corresponding scanning point. Based on this, the step of generating an occlusion database based on collision information includes: filtering the positions of collision points in the temporary databases corresponding to multiple scanning points using a minimum distance threshold to obtain an occlusion database that only contains collision information corresponding to collision points whose distance between collision points is greater than the minimum distance threshold.

[0128] In an optional embodiment, the step of filtering the positions of collision points in the temporary database corresponding to multiple scan points using a minimum distance threshold to obtain an occlusion database containing only collision information corresponding to collision points whose distances are greater than the minimum distance threshold includes: for each temporary database corresponding to a scan point, performing the following operations in sequence: for each collision point in the temporary database corresponding to the current scan point, based on the position information corresponding to the current collision point, determining whether the distance between the position of the current collision point and the position of the collision point in the occlusion database is greater than the minimum distance threshold; if it is greater than the minimum distance threshold, storing the collision information corresponding to the current collision point in the occlusion database.

[0129] In an optional embodiment, for each collision point in the temporary database corresponding to the current scan point, based on the location information corresponding to the current collision point, it is determined whether the distance between the location of the current collision point and the location of the collision point in the occlusion database is greater than a minimum distance threshold; if it is greater than the minimum distance threshold, before the step of storing the collision information corresponding to the current collision point into the occlusion database, the above method further includes: determining a target cache library from multiple preset cache libraries; wherein, the preset cache libraries are used to store the collision information corresponding to a specified number of collision points; the target cache library is the occlusion database that stores the collision information corresponding to the collision points in the temporary database corresponding to the current scan point.

[0130] In an optional embodiment, for each collision point in the temporary database corresponding to the current scanning point, based on the location information corresponding to the current collision point, it is determined whether the distance between the location of the current collision point and the location of the collision point in the occlusion database is greater than a minimum distance threshold; if it is greater than the minimum distance threshold, after the step of storing the collision information corresponding to the current collision point into the occlusion database, the above method further includes: filtering the locations of collision points in multiple preset cache databases by the minimum distance threshold to obtain an occlusion database that only contains collision information corresponding to collision points whose distance is greater than the minimum distance threshold.

[0131] In an optional embodiment, the step of generating a rough model of an occluder based on an occlusion database includes: performing three-dimensional reconstruction based on the occlusion information stored in the occlusion database to obtain a rough model of the occluder.

[0132] In an optional embodiment, after generating a rough model of the occluder based on the occlusion database, the method further includes: converting the points, lines, and surfaces of the rough model of the occluder into a voxel format to obtain a rough model of the occluder containing multiple voxel blocks; reducing the multiple voxel blocks by a preset ratio to obtain a reduced voxel block; and restoring the reduced voxel block to a model in the form of points, lines, and surfaces to obtain an updated rough model of the occluder.

[0133] In an optional embodiment, after importing the coarse model of the occluder into the virtual scene and hiding the multiple scene objects contained in the virtual scene, the method further includes: determining a refined occlusion area in the virtual scene based on the currently retained coarse model of the occluder in the virtual scene.

[0134] In an optional embodiment, the steps of setting a first label for the coarse model of the occluder currently retained in the virtual scene and baking the coarse model of the occluder with the first label to obtain occlusion data include: in response to a baking instruction for a refined occlusion area, setting a first label for the coarse model of the occluder in the refined occlusion area and baking the coarse model of the occluder with the first label to obtain occlusion data.

[0135] Furthermore, Figure 7 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 101, the communication interface 103 and the memory 100 connected via the bus 102.

[0136] The memory 100 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 7 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0137] Processor 101 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 101 or by instructions in software form. The processor 101 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 100, and processor 101 reads information from memory 100 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0138] This disclosure also provides a computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the above-described method for generating occlusion data.

[0139] Specifically, the method for generating the aforementioned occlusion data includes: acquiring navigation mesh data and determining multiple scanning points from the navigation mesh data; wherein the navigation mesh data is used to indicate the scene area that a virtual character can enter in the virtual scene, and the virtual scene includes multiple scene objects; for each of the multiple scanning points, determining a collision detection range based on the location of the scanning point, emitting a ray within the collision detection range, and recording the collision information of scene objects within the collision detection range colliding with the ray; generating an occlusion database based on the collision information, and generating a rough model of the occluder based on the occlusion database; wherein the rough model of the occluder is used to indicate the outer contour of the scene object that acts as an occluder in the virtual scene; importing the rough model of the occluder into the virtual scene, hiding the multiple scene objects contained in the virtual scene; setting a first label for the currently retained rough model of the occluder in the virtual scene, and baking the rough model of the occluder with the first label to obtain occlusion data, so as to remove the occluded scene objects in the virtual scene based on the occlusion data during the scene running stage; wherein the first label is used to indicate that the scene object corresponding to the rough model of the occluder is an occluder.

[0140] The aforementioned method for generating occlusion culling data generates a rough model of occlusions through fully offline automated scanning and collision information processing. Occlusion data is then generated by baking this rough model. This approach avoids the high labor costs and error rates of traditional manual occlusion marking methods, improving the efficiency and accuracy of offline occlusion data generation. Furthermore, this method is independent of real-time occlusion culling or collision detection during game runtime, thus avoiding real-time performance overhead.

[0141] In an optional embodiment, after the step of baking the rough model of the occluder with the first label to obtain the occlusion data, the above method further includes: deleting the rough model of the occluder imported into the virtual scene and restoring the display of multiple scene objects in the virtual scene.

[0142] In an optional embodiment, the step of determining multiple scan points from navigation grid data includes: generating points with a preset amount of data on the navigation grid data; generating a minimum bounding box that surrounds the navigation grid data; dividing the minimum bounding box into multiple cells on an average basis; determining the center position of each cell; and determining a target point from the points contained in the navigation grid data based on the center position, and determining the target point as a scan point.

[0143] In an optional embodiment, the step of determining the target point from the points contained in the navigation grid data based on the center position and determining the target point as the scanning point includes: performing the following operation for each cell: determining whether the distance between the center position of the current cell and the navigation grid data is less than or equal to a preset distance threshold; if so, determining the target point closest to the center position of the current cell from the points contained in the navigation grid data.

[0144] In an optional embodiment, the step of determining the collision detection range based on the location of the scanning point includes: creating a scanner at the location of the scanning point; wherein the scanner includes a root node and a scanning node, the root node is located at the location of the scanning point, and the scanning node is located at a preset height above the root node; determining a spherical range with the scanning node as the center and a preset length as the radius as the collision detection range; wherein the collision detection range is used to indicate the possible location of the virtual camera capturing the virtual scene.

[0145] In an optional embodiment, the steps of emitting rays within the collision detection range and recording collision information when scene objects within the collision detection range collide with the rays include: controlling the scanner to emit a specified number of rays within the corresponding collision detection range; generating collision information corresponding to the collision point when the rays collide with scene objects within the collision detection range; wherein the collision information includes position information and normal information corresponding to the collision point; and storing the collision information corresponding to the collision point in a temporary database.

[0146] In an optional embodiment, the starting point and direction of the rays emitted by the scanner are random within the corresponding collision detection range.

[0147] In an optional embodiment, the step of storing the collision information corresponding to the collision point into a temporary database includes: determining whether the distance between the location of the collision point and the location of the collision point in the temporary database is greater than a minimum distance threshold based on the location information corresponding to the collision point; if it is greater than the minimum distance threshold, storing the collision information corresponding to the collision point into the temporary database.

[0148] In an optional embodiment, the method further includes: if the distance between the location of the collision point and the location of the collision point in the temporary database is not greater than the minimum distance threshold, discard the collision information corresponding to the collision point.

[0149] In an optional embodiment, each scanning point is configured with a corresponding temporary database, which is used to store collision information determined based on the corresponding scanning point. Based on this, the step of generating an occlusion database based on collision information includes: filtering the positions of collision points in the temporary databases corresponding to multiple scanning points using a minimum distance threshold to obtain an occlusion database that only contains collision information corresponding to collision points whose distance between collision points is greater than the minimum distance threshold.

[0150] In an optional embodiment, the step of filtering the positions of collision points in the temporary database corresponding to multiple scan points using a minimum distance threshold to obtain an occlusion database containing only collision information corresponding to collision points whose distances are greater than the minimum distance threshold includes: for each temporary database corresponding to a scan point, performing the following operations in sequence: for each collision point in the temporary database corresponding to the current scan point, based on the position information corresponding to the current collision point, determining whether the distance between the position of the current collision point and the position of the collision point in the occlusion database is greater than the minimum distance threshold; if it is greater than the minimum distance threshold, storing the collision information corresponding to the current collision point in the occlusion database.

[0151] In an optional embodiment, for each collision point in the temporary database corresponding to the current scan point, based on the location information corresponding to the current collision point, it is determined whether the distance between the location of the current collision point and the location of the collision point in the occlusion database is greater than a minimum distance threshold; if it is greater than the minimum distance threshold, before the step of storing the collision information corresponding to the current collision point into the occlusion database, the above method further includes: determining a target cache library from multiple preset cache libraries; wherein, the preset cache libraries are used to store the collision information corresponding to a specified number of collision points; the target cache library is the occlusion database that stores the collision information corresponding to the collision points in the temporary database corresponding to the current scan point.

[0152] In an optional embodiment, for each collision point in the temporary database corresponding to the current scanning point, based on the location information corresponding to the current collision point, it is determined whether the distance between the location of the current collision point and the location of the collision point in the occlusion database is greater than a minimum distance threshold; if it is greater than the minimum distance threshold, after the step of storing the collision information corresponding to the current collision point into the occlusion database, the above method further includes: filtering the locations of collision points in multiple preset cache databases by the minimum distance threshold to obtain an occlusion database that only contains collision information corresponding to collision points whose distance is greater than the minimum distance threshold.

[0153] In an optional embodiment, the step of generating a rough model of an occluder based on an occlusion database includes: performing three-dimensional reconstruction based on the occlusion information stored in the occlusion database to obtain a rough model of the occluder.

[0154] In an optional embodiment, after generating a rough model of the occluder based on the occlusion database, the method further includes: converting the points, lines, and surfaces of the rough model of the occluder into a voxel format to obtain a rough model of the occluder containing multiple voxel blocks; reducing the multiple voxel blocks by a preset ratio to obtain a reduced voxel block; and restoring the reduced voxel block to a model in the form of points, lines, and surfaces to obtain an updated rough model of the occluder.

[0155] In an optional embodiment, after importing the coarse model of the occluder into the virtual scene and hiding the multiple scene objects contained in the virtual scene, the method further includes: determining a refined occlusion area in the virtual scene based on the currently retained coarse model of the occluder in the virtual scene.

[0156] In an optional embodiment, the steps of setting a first label for the coarse model of the occluder currently retained in the virtual scene and baking the coarse model of the occluder with the first label to obtain occlusion data include: in response to a baking instruction for a refined occlusion area, setting a first label for the coarse model of the occluder in the refined occlusion area and baking the coarse model of the occluder with the first label to obtain occlusion data.

[0157] If the aforementioned functions are implemented as 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 this disclosure, in essence, or the part that contributes to the prior art, or a portion of the 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 to cause 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 the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0158] In the description of this disclosure, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, and are only for the convenience of describing this disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this disclosure. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0159] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.

Claims

1. A method for generating occlusion data, characterized in that, The method includes: Acquire navigation grid data and determine multiple scan points from the navigation grid data; wherein the navigation grid data is used to indicate the scene area that a virtual character can enter in the virtual scene, and the virtual scene includes multiple scene objects; For each of the plurality of scanning points, a collision detection range is determined based on the location of the scanning point, and a ray is emitted within the collision detection range to record the collision information of scene objects within the collision detection range colliding with the ray. An occlusion database is generated based on the collision information, and a rough model of the occlusion object is generated based on the occlusion database; wherein, the rough model of the occlusion object is used to indicate the outer contour of the scene object that acts as an occlusion object in the virtual scene. Import the rough model of the occluding object into the virtual scene to hide the multiple scene objects contained in the virtual scene; A first label is set for the coarse model of the occluder currently retained in the virtual scene, and the coarse model of the occluder with the first label is baked to obtain occlusion data. In order to remove the occluded scene objects in the virtual scene according to the occlusion data during the scene running stage, wherein the first label is used to indicate that the scene object corresponding to the coarse model of the occluder is an occluder.

2. The method according to claim 1, characterized in that, After the step of baking the rough mold of the obscuring object with the first label and obtaining the obscuring data, the method further includes: Delete the coarse models of the occluding objects imported into the virtual scene, and restore the display of the multiple scene objects in the virtual scene.

3. The method according to claim 1, characterized in that, The step of determining multiple scan points from the navigation mesh data includes: Generate points with a preset amount of data on the navigation grid data; Generate the minimum bounding box that surrounds the navigation mesh data; The minimum bounding box is divided into multiple cells on an average basis; Determine the center position of each cell, and based on the center position, determine the target point from the points contained in the navigation grid data, and determine the target point as the scan point.

4. The method according to claim 3, characterized in that, The step of determining the target point from the points contained in the navigation grid data based on the center position and identifying the target point as the scan point includes: Perform the following operation for each of the cells: Determine whether the distance between the center position of the current cell and the navigation grid data is less than or equal to a preset distance threshold; If so, determine the target point that is closest to the center of the current cell from the points contained in the navigation grid data.

5. The method according to claim 1, characterized in that, The step of determining the collision detection range based on the location of the scan point includes: Create a scanner at the location of the scan point; wherein the scanner includes a root node and a scan node, the root node is located at the location of the scan point, and the scan node is located at a preset height above the root node; A spherical area with the scanning node as the center and a preset length as the radius is defined as the collision detection range; wherein, the collision detection range is used to indicate the possible location of the virtual camera capturing the virtual scene.

6. The method according to claim 5, characterized in that, The step of emitting a ray within the collision detection range and recording collision information of scene objects within the collision detection range colliding with the ray includes: The scanner is controlled to emit a specified number of rays within the corresponding collision detection range; When the ray collides with a scene object within the collision detection range, collision information corresponding to the collision point is generated; wherein, the collision information includes the position information and normal information corresponding to the collision point; The collision information corresponding to the collision point is stored in a temporary database.

7. The method according to claim 6, characterized in that, The starting point and direction of the rays emitted by the scanner are random within the corresponding collision detection range.

8. The method according to claim 6, characterized in that, The step of storing the collision information corresponding to the collision point into a temporary database includes: Based on the location information corresponding to the collision point, determine whether the distance between the location of the collision point and the location of the collision point in the temporary database is greater than the minimum distance threshold. If the distance is greater than the minimum distance threshold, the collision information corresponding to the collision point is stored in the temporary database.

9. The method according to claim 8, characterized in that, The method further includes: If the distance between the location of the collision point and the location of the collision point in the temporary database is not greater than the minimum distance threshold, the collision information corresponding to the collision point is discarded.

10. The method according to claim 6, characterized in that, Each of the scan points is configured with a corresponding temporary database, which is used to store collision information determined based on the corresponding scan point; The step of generating an occlusion database based on the collision information includes: The positions of collision points in the temporary database corresponding to the multiple scan points are filtered by a minimum distance threshold to obtain an occlusion database that only contains collision information corresponding to collision points whose distance between collision points is greater than the minimum distance threshold.

11. The method according to claim 10, characterized in that, The step of filtering the positions of collision points in the temporary database corresponding to the plurality of scan points by a minimum distance threshold to obtain an occlusion database containing only collision information of collision points whose distances are greater than the minimum distance threshold includes: For each of the temporary databases corresponding to the scan points, the following operations are performed sequentially: For each collision point in the temporary database corresponding to the current scan point, based on the location information corresponding to the current collision point, it is determined whether the distance between the location of the current collision point and the location of the collision point in the occlusion database is greater than a minimum distance threshold; if it is greater than the minimum distance threshold, the collision information corresponding to the current collision point is stored in the occlusion database.

12. The method according to claim 11, characterized in that, For each collision point in the temporary database corresponding to the current scan point, based on the location information corresponding to the current collision point, it is determined whether the distance between the location of the current collision point and the location of the collision point in the occlusion database is greater than the minimum distance threshold. Before the step of storing the collision information corresponding to the current collision point into the occlusion database if the distance is greater than the minimum distance threshold, the method further includes: A target cache library is determined from multiple preset cache libraries; wherein, the preset cache libraries are used to store collision information corresponding to a specified number of collision points; and the target cache library is an occlusion database containing collision information corresponding to collision points stored in a temporary database corresponding to the current scan point.

13. The method according to claim 12, characterized in that, For each collision point in the temporary database corresponding to the current scan point, based on the location information corresponding to the current collision point, it is determined whether the distance between the location of the current collision point and the location of the collision point in the occlusion database is greater than the minimum distance threshold. After the step of storing the collision information corresponding to the current collision point in the occlusion database if the distance is greater than the minimum distance threshold, the method further includes: The locations of collision points in the multiple preset cache libraries are filtered by a minimum distance threshold to obtain an occlusion database that contains only collision information corresponding to collision points whose distance is greater than the minimum distance threshold.

14. The method according to claim 1, characterized in that, The step of generating a rough model of the occlusion object based on the occlusion database includes: Three-dimensional reconstruction is performed based on the occlusion information stored in the occlusion database to obtain a rough model of the occluded object.

15. The method according to claim 1, characterized in that, After the step of generating a rough model of the occlusion object based on the occlusion database, the method further includes: Convert the points, lines, and surfaces of the occluder's rough model to voxel format to obtain an occluder's rough model containing multiple voxel blocks; The multiple voxel blocks are reduced in size according to a preset ratio to obtain the reduced voxel blocks; The scaled-down voxel block is restored to a model in the form of points, lines, and surfaces to obtain an updated rough model of the occluder.

16. The method according to claim 1, characterized in that, After the step of importing the rough model of the occluding object into the virtual scene and hiding the multiple scene objects contained in the virtual scene, the method further includes: Based on the coarse model of the occluder currently retained in the virtual scene, a refined occlusion area is determined in the virtual scene.

17. The method according to claim 16, characterized in that, The step of setting a first label for the coarse model of the occluder currently retained in the virtual scene, and baking the coarse model of the occluder with the first label to obtain occlusion data includes: In response to the baking instruction for the refined occlusion area, a first label is set for the rough model of the occlusion object within the refined occlusion area, and the rough model of the occlusion object with the first label is baked to obtain occlusion data.

18. A device for generating occlusion data, characterized in that, The device includes: A scan point determination module is used to acquire navigation grid data and determine multiple scan points from the navigation grid data; wherein, the navigation grid data is used to indicate the scene area that a virtual character can enter in the virtual scene, and the virtual scene includes multiple scene objects; The collision information determination module is used to determine the collision detection range based on the location of each of the plurality of scanning points, emit a ray within the collision detection range, and record the collision information of scene objects within the collision detection range colliding with the ray. The rough model generation module is used to generate an occlusion database based on the collision information, and generate a rough model of the occlusion object according to the occlusion database; wherein, the rough model of the occlusion object is used to indicate the outer contour of the scene object that acts as an occlusion object in the virtual scene; The rough model import module is used to import the rough model of the occluding object into the virtual scene, thereby hiding the multiple scene objects contained in the virtual scene; The data generation module is used to set a first label for the coarse model of the currently retained occluder in the virtual scene, and bake the coarse model of the occluder with the first label to obtain occlusion data, so as to remove the occluded scene objects in the virtual scene according to the occlusion data during the scene running stage; wherein, the first label is used to indicate that the scene object corresponding to the coarse model of the occluder is an occluder.

19. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the method for generating occlusion data according to any one of claims 1 to 17.

20. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the method for generating occlusion data according to any one of claims 1 to 17.