Shielding object removing method and device, electronic equipment and storage medium

By building the building group structure in the game scene and using cone cutting technology, the problem of long-term occlusion of blocked objects in the prior art is solved, and efficient rendering efficiency is achieved.

CN119488716APending Publication Date: 2025-02-21BEIJING PIXEL SOFTWARE TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411924358.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

The soft raster method used for occluding object culling in game scene rendering requires a large number of CPU calculations, resulting in a long time for occluding object culling and affecting rendering efficiency.

Method used

By pre-constructing the building structure of the virtual scene, including the room, the connecting entrance and the occlusion, and using the view cone cropping method to calculate the clipped view cone at the player's current position, thereby quickly eliminating invisible objects.

Benefits of technology

By prefabricating the occlusion body and the entrance in advance, this method can quickly determine whether the object is blocked during operation, effectively eliminate a large number of invisible objects, and improve rendering efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119488716A_ABST
    Figure CN119488716A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an occluded object removing method and device, electronic equipment and a storage medium, and relates to the technical field of three-dimensional images. The method comprises the steps that a building group structure of a virtual scene is established according to the virtual scene to be rendered, the building group structure comprises a room, a connection entrance and a shielding body, and the shielding body represents an object which may be invisible during image rendering; performing view cone cutting according to the current position of the player in the virtual scene and the connection entrance, and calculating a cut view cone body of the current position; and calculating a shielding body which is not intersected with the cutting view cone in each room as a target shielding body, and removing each target shielding body. Therefore, through the constructed room, the connection entrance and the shielding body, whether the object is shielded or not can be rapidly calculated during operation, and a large number of invisible objects can be rapidly removed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of three-dimensional image technology, and in particular to a method, device, electronic device and storage medium for removing occluded objects. Background Art

[0002] In image rendering technology, for example, when rendering a game scene, in order to improve the performance of the game, objects in the game scene that are invisible to the player's perspective due to occlusion are often eliminated, and only objects that are currently visible to the player's perspective are rendered.

[0003] In the related technology, for example, a soft raster method is used to remove occluded objects. The purpose of detecting visibility is achieved by rasterizing the objects once on the central processing unit (CPU). However, a large amount of CPU calculation is required, which results in a long time for removing occluded objects, affecting rendering efficiency. Summary of the invention

[0004] In view of this, an object of embodiments of the present invention is to provide a method, device, electronic device and storage medium for removing occluded objects to at least partially improve the above-mentioned problem.

[0005] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:

[0006] In a first aspect, an embodiment of the present invention provides a method for removing occluded objects, the method comprising:

[0007] According to the virtual scene to be rendered, a building group structure of the virtual scene is established; the building group structure includes rooms, connecting entrances and occluding bodies; the occluding bodies represent objects that may not be visible when the image is rendered;

[0008] Perform visual cone clipping according to the current position of the player in the virtual scene and the connection entrance, and calculate the clipping visual cone of the current position;

[0009] The occluders in each of the rooms that do not intersect with the clipping frustum are calculated as target occluders, and each of the target occluders is eliminated.

[0010] Optionally, establishing a building group structure of the virtual scene according to the virtual scene to be rendered includes:

[0011] According to the virtual scene to be rendered, establishing a building group structure of the virtual scene; the building group structure includes at least one room;

[0012] Marking connection entrances on each of the rooms, and establishing connection relationships between each of the connection entrances and each of the rooms; the connection entrances indicate that the player or the player's line of sight is allowed to move from one room to another;

[0013] Each object in the room is marked as an occluder.

[0014] Optionally, the connection entrance includes a unidirectional connection entrance and a bidirectional connection entrance, and the frustum clipping is performed according to the current position of the player in the virtual scene and the connection entrance to calculate the clipped frustum of the current position, including:

[0015] When the player is outside the building group structure, find the one-way connection entrance within the field of vision of the player, and recursively calculate the clipping frustum of the current position;

[0016] When the player is in any of the rooms, the one-way connection entrance and the two-way connection entrance within the field of view of the player are found, and the clipping frustum of the current position is calculated.

[0017] Optionally, the step of finding the one-way connection entrance within the field of view of the player and recursively calculating the clipping frustum of the current position includes:

[0018] Find the one-way connection entrance within the field of vision of the player;

[0019] Calculating a first clipping frustum according to the one-way connection entrance and the current position;

[0020] In the case that there is no connection entrance in the first clipping frustum, using the first clipping frustum as the clipping frustum of the current position;

[0021] When the connection entrance exists in the first clipping frustum, the intersection of the connection entrance and the first clipping frustum is recursively calculated to obtain a first visible connection entrance, and the Nth clipping frustum is calculated based on the first visible connection entrance, until the connection entrance does not exist in the Nth clipping frustum, and the first clipping frustum to the Nth clipping frustum are merged to obtain the clipping frustum at the current position.

[0022] Optionally, the finding the one-way connection entrance and the two-way connection entrance within the field of view of the player and calculating the clipping frustum of the current position includes:

[0023] Find the one-way connection entrance within the field of view of the player, and calculate the outdoor clipping frustum;

[0024] Find the bidirectional connection entrance within the field of view of the player and calculate the second clipping frustum;

[0025] In the case where the connection entrance is not present in the second clipping frustum, using the second clipping frustum as the indoor clipping frustum of the current position;

[0026] In the case where the connection entrance exists in the second clipping frustum, recursively calculate the intersection of the connection entrance and the second clipping frustum to obtain a second visible connection entrance, and calculate an M-th clipping frustum according to the second visible connection entrance, until there is no connection entrance in the M-th clipping frustum, and merge the second clipping frustum to the M-th clipping frustum to obtain the indoor clipping frustum of the current position;

[0027] The indoor clipping frustum and the indoor clipping frustum are combined to obtain the clipping frustum of the current position.

[0028] Optionally, the process of frustum clipping includes:

[0029] Obtaining a first bounding box of the connection entrance in the world space and a current position of the player in the virtual scene;

[0030] Projecting the first bounding box of the connection entrance to the screen space of the current position to obtain the size of the first bounding box in the screen space;

[0031] Calculating positions and depth information of eight points of the first bounding box in the screen space according to the size of the first bounding box in the screen space;

[0032] Projecting the positions of the 8 points back to the world space to obtain the positions of the 8 points after the clipping frustum;

[0033] The clipping frustum is constructed according to the positions of the 8 points after the clipping frustum.

[0034] Optionally, calculating the occluders in each of the rooms that do not intersect with the clipping frustum as target occluders and removing each of the target occluders includes:

[0035] Calculating six clipping planes of the clipping frustum;

[0036] Obtaining a second bounding box of each of the occluding bodies;

[0037] Performing an intersection test on each of the second bounding boxes and each of the clipping planes to determine whether the second bounding box is completely on one side of any of the clipping planes and not within the clipping frustum;

[0038] If yes, the occluder corresponding to the second bounding box is used as the target occluder, and the target occluder is eliminated.

[0039] In a second aspect, an embodiment of the present invention provides a device for removing occluded objects, the device comprising:

[0040] A building group structure construction unit, used to establish a building group structure of the virtual scene according to the virtual scene to be rendered; the building group structure includes a room, a connecting entrance and an occluding body; the occluding body represents an object that may not be visible when the image is rendered;

[0041] A visual cone clipping unit, used for performing visual cone clipping according to the current position of the player in the virtual scene and the connection entrance, and calculating a clipping visual cone at the current position;

[0042] The occluder culling unit is used to calculate the occluders in each of the rooms that do not intersect with the clipping frustum as target occluders, and cull each of the target occluders.

[0043] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements any of the above-described methods when executing the program.

[0044] In a fourth aspect, an embodiment of the present invention provides a storage medium having a computer program stored thereon, wherein the computer program implements any of the above-described methods when executed by a processor.

[0045] An embodiment of the present invention provides a method, device, electronic device and storage medium for removing obstructing objects. A building group structure is pre-constructed, and the building group structure includes rooms, connecting entrances and obstructing bodies. Invisible objects are then removed by clipping the viewing cone. The obstructing bodies and entrances are pre-fabricated in advance, so that whether an object is obstructed can be quickly calculated during runtime, thereby quickly removing a large number of invisible objects.

[0046] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 A schematic structural block diagram of an electronic device provided by an embodiment of the present invention;

[0049] Figure 2 A schematic flow chart of a method for removing occluded objects is provided for an embodiment of the present invention;

[0050] Figure 3 A schematic structural block diagram of a building group structure is provided for an embodiment of the present invention;

[0051] Figure 4 A schematic structural block diagram of a connection entry is provided for an embodiment of the present invention;

[0052] Figure 5 A schematic diagram of a player's field of view outdoors is provided for an embodiment of the present invention;

[0053] Figure 6 A schematic diagram of a player's field of view in a room is provided for an embodiment of the present invention;

[0054] Figure 7 A schematic diagram of a field of view of multiple recursive connection entrances is provided for an embodiment of the present invention;

[0055] Figure 8 Another schematic flow chart of a method for removing occluded objects is provided for an embodiment of the present invention;

[0056] Fig. 9 A schematic structural block diagram of a device for removing occluded objects is provided for an embodiment of the present invention.

[0057] Icons: 100 - electronic device; 101 - memory; 102 - communication interface; 103 - processor; 104 - bus; 300 - occluding object culling device; 310 - building group structure construction unit; 320 - frustum clipping unit; 330 - occluding body culling unit. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0059] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0060] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0061] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0062] As described in the background technology, existing mainstream invisible object culling solutions, such as soft rasterization, achieve the purpose of detecting visibility by rasterizing the object on the CPU side, such as portal culling, which divides the virtual scene into areas and then calculates whether the object is visible through the connectivity between the areas, such as Hzb, which renders the image of the previous frame on the graphics processing unit (GPU) and then uses the depth map of the previous frame to calculate the visibility of this frame. However, their disadvantages are that they are relatively time-consuming.

[0063] Based on the above situation, an embodiment of the present invention provides a method, device, electronic device and storage medium for removing obstructed objects. The rooms, connecting entrances and obstructions of a building structure are pre-constructed, and invisible objects are removed by clipping the viewing cone. The obstructions and entrances are pre-fabricated in advance, so that whether an object is obstructed can be quickly calculated during runtime, thereby quickly removing a large number of invisible objects.

[0064] To implement the process steps and functions of each example of the present invention, please refer to Figure 1 , Figure 1A schematic structural block diagram of an electronic device provided by an embodiment of the present invention. The electronic device 100 includes a memory 101 and a processor 103, and the memory 101 and the processor 103 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses 104 or signal lines. The memory 101 can be used to store software programs and modules, and the processor 103 executes the software programs and modules stored in the memory 101 to perform various functional applications and data processing.

[0065] The electronic device 100 may be, but is not limited to, a personal computer (PC), a server, a distributed computer, etc. It is understandable that the electronic device 100 is not limited to a physical server, but may also be a virtual machine on a physical server, a virtual machine built on a cloud platform, etc., which can provide the same functions as the server or virtual machine. The operating system of the electronic device 100 may be, but is not limited to, a Windows system, a Linux system, etc.

[0066] Among them, the memory 101 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc.

[0067] The communication connection between the electronic device 100 and an external device is achieved through at least one communication interface 102 (which can be wired or wireless).

[0068] The processor 103 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the embodiment of the present invention can be completed by the hardware integrated logic circuit in the processor 103 or the instructions in the form of software. The processor 103 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 gates or transistor logic devices, discrete hardware components.

[0069] Understandably, Figure 1 The structure shown is for illustration only. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0070] The following is an exemplary description of the method for removing occluded objects provided by the present invention. Specifically, Figure 2 A flowchart of a method for removing occluded objects is provided for an embodiment of the present invention. Figure 2 , the execution subject of this method can be the above Figure 1 The electronic device 100 shown in FIG. 1 includes: Figure 2 The following steps are described:

[0071] S210: Establishing a building group structure of the virtual scene according to the virtual scene to be rendered, wherein the building group structure includes rooms, connecting entrances and occluders; the occluders represent objects that may not be visible during image rendering.

[0072] Building group structure refers to a group of buildings with specific functions or logical relationships and their layout and relationship with each other. Figure 3 For example, a room has a connecting entrance. The relationship between the connecting entrances refers to how the connection points (entrances) between the rooms are related and organized. The connecting entrances can be windows and doors, etc. For example, players can pass through the connecting entrances from one room to another. The occluders can be objects in the room, such as furniture, home appliances, decorations, etc. When rendering, if the player's line of sight cannot see the object through the connecting entrance, it can be not rendered.

[0073] S220: Perform visual cone clipping according to the player's current position in the virtual scene and the connection entrance, and calculate the clipping visual cone of the current position.

[0074] Through the current position of the player in the virtual scene, and the position and size of the connection entrance, a clipped clipping frustum can be obtained, and the clipping frustum can include six planes.

[0075] S230: Calculate the occluders in each room that do not intersect with the clipping frustum as target occluders, and remove each target occluder.

[0076] The view frustum is a pyramid shape in three-dimensional space, defined by the field of view. It determines the area that the camera can "see", that is, the area that the player's virtual character can see. By calculating the view frustum, we can determine which objects are in the camera's field of view and which are not. Objects that are not in the field of view do not need to be rendered, which can save computing resources and improve performance.

[0077] For each object, check whether its bounding box or bounding sphere is completely outside the clipping frustum. If the object's bounding box or bounding sphere intersects with or is inside any plane, the object is inside the clipping frustum and needs to be rendered. If the object's bounding box or bounding sphere is completely outside the frustum, the object does not need to be rendered.

[0078] This method constructs rooms, connecting entrances and occluding bodies, and calculates the clipping frustum according to the connecting entrances and the current position of the player. Based on the clipping frustum, it is possible to quickly calculate whether an object is blocked, and thus quickly eliminate a large number of invisible objects.

[0079] In a possible implementation, the building group structure may be constructed by marking each room and object after all buildings and objects are constructed. The above step S210 may include the following steps:

[0080] S211: According to the virtual scene to be rendered, a building group structure of the virtual scene is established, wherein the building group structure includes at least one room.

[0081] The building group structure is established according to the designed virtual scene, for example, the assets provided by the artist, and different rooms in the virtual scene are divided out, including some doors and windows, etc., and some objects in the room.

[0082] S212: Marking connection entrances on each room, and establishing connection relationships between each connection entrance and each room, wherein the connection entrance indicates that the player or the player's line of sight is allowed to move from one room to another.

[0083] Connection entrances can be marked on rooms according to preset rules. For example, if the rules indicate that doors and windows are connection entrances, the doors and windows of the room are marked as connection entrances, and the rooms connected to each connection entrance are recorded to form a connection relationship diagram. For example, there is a door between the living room and the bedroom. This door is the connection entrance. The connection relationship is established that the door of the living room is connected to the bedroom, and the door of the bedroom is connected to the living room. This connection entrance, i.e., the connection relationship, can indicate that the player can move from the living room to the bedroom, or from the bedroom to the living room, and the same is true for the player's line of sight.

[0084] S213: Mark each object in each room as an occluding body.

[0085] Identify all objects in each room, such as furniture, home appliances, decorations, etc., and mark them as occluders. After calculating the clipping frustum, you can directly calculate whether each occluder is visible, and then remove the invisible occluders to reduce rendering time.

[0086] There are two types of connecting entrances: one is a connecting entrance from one room to another, and the other is a connecting entrance from the outside to the room. Figure 4 , that is, the connection entry may include a unidirectional connection entry and a bidirectional connection entry, and the above step S220 may include the following steps:

[0087] S221: When the player is outside the building group structure, find the one-way connection entrance within the player's field of view, and recursively calculate the clipping frustum of the current position.

[0088] See also Figure 5 , when the player is outside the building group structure, it only needs to find the one-way connection entrance, and then calculate the clipping frustum of the player's current position through the one-way connection entrance.

[0089] S222: When the player is in any room, find the one-way connection entrance and the two-way connection entrance within the player's field of view, and calculate the clipping frustum of the current position.

[0090] When the player is in a room, the room may have one-way connection entrances and two-way connection entrances, so it is necessary to process both connection entrances and calculate the clipping frustum of the player's current position. Figure 6 , one possible situation is that there are both one-way connection entrances and two-way connection entrances within the player's field of view, then it is necessary to calculate the clipping frustum of the player's field of view through the two-way connection entrance and the one-way connection entrance.

[0091] When the player is outside the building group structure, in a possible implementation, the above step S221 may include the following steps:

[0092] S2211: Find the one-way connection entrance within the player's field of vision.

[0093] It can traverse all objects within the player's field of view and identify which ones are one-way connection entrances.

[0094] S2212: Calculate the first clipping frustum according to the one-way connection entrance and the current position.

[0095] The first clipping frustum is calculated by combining the player's position and view direction, as well as the position and direction of the one-way connection entrance found.

[0096] S2213: When there is no connected entrance in the first clipping frustum, the first clipping frustum is used as the clipping frustum of the current position.

[0097] After obtaining the first clipping frustum, if there is no connection entrance in the first clipping frustum, the first clipping frustum is used as the final clipping frustum.

[0098] S2214: When there is a connection entrance in the first clipping frustum, recursively calculate the intersection of the connection entrance and the first clipping frustum to obtain the first visible connection entrance, and calculate the Nth clipping frustum based on the first visible connection entrance, until there is no connection entrance in the Nth clipping frustum, merge the first clipping frustum to the Nth clipping frustum to obtain the clipping frustum at the current position.

[0099] After obtaining the first clipping frustum, if there is a connection entrance in the first clipping frustum, it is necessary to continue calculating the clipping frustum of the next connection entrance until there is no connection entrance in the clipping frustum. Figure 7 , calculate the intersection of these connection entrances and the first clipping frustum to obtain new visible connection entrances, such as Figure 7 In the example, if one connection entrance is completely within the first clipping frustum, the entire connection entrance is used as a visible connection entrance. If part of another connection entrance is within the first clipping frustum, the visible part of the connection entrance is used as another visible connection entrance. Based on the new visible connection entrance, the next clipping frustum (Nth clipping frustum) is calculated. Repeat the above steps until there is no connection entrance within the Nth clipping frustum. Merge all generated clipping frustums to obtain the final clipping frustum.

[0100] Optionally, the final clipping frustum may not be merged, that is, when the invisible objects are subsequently culled, each clipping frustum culls the invisible objects within its own clipping frustum.

[0101] When the player is in any room, in a possible implementation, the above step S222 may include the following steps:

[0102] S2221: Find the one-way connection entrance within the player's field of view and calculate the outdoor clipping frustum.

[0103] Since the player is indoors, the player sees outdoor objects through the one-way connection portal, so the clipping frustum calculated through the one-way connection portal is an outdoor clipping frustum facing outdoors.

[0104] S2222: Find the bidirectional connection entrance within the player's field of view and calculate the second clipping frustum.

[0105] S2223: When there is no connected entrance in the second clipping frustum, the second clipping frustum is used as the indoor clipping frustum of the current position.

[0106] S2224: When there is a connection entrance in the second clipping frustum, recursively calculate the intersection of the connection entrance and the second clipping frustum to obtain the second visible connection entrance, and calculate the Mth clipping frustum based on the second visible connection entrance, until there is no connection entrance in the Mth clipping frustum, merge the second clipping frustum to the Mth clipping frustum to obtain the indoor clipping frustum of the current position.

[0107] S2225: Merge the indoor clipping frustum and the indoor clipping frustum to obtain the clipping frustum of the current position.

[0108] For players indoors, the processing of the two-way connection entrance is the same as the processing logic of the player outdoors, so I will not repeat it here. For ease of understanding, we remove the room where the player is, then the player is outdoors, and the two-way connection entrance becomes a one-way connection entrance. Therefore, the indoor clipping frustum of the current position can be obtained in the same way as the processing logic of the player outdoors.

[0109] The indoor clipping frustum and outdoor clipping frustum calculated previously are combined to form a complete clipping frustum, which is used to determine all visible areas within the player's current field of view.

[0110] In a possible implementation, the above-mentioned process of clipping the view frustum may include the following steps:

[0111] S1: Get the first bounding box of the connection entrance in the world space and the current position of the player in the virtual scene.

[0112] S2: Project the first bounding box connected to the entrance to the screen space of the current position to obtain the size of the first bounding box in the screen space.

[0113] S3: Calculate the positions and depth information of eight points of the first bounding box in the screen space according to the size of the first bounding box in the screen space.

[0114] S4: Project the positions of the 8 points back to the world space to obtain the positions of the 8 points after the clipping frustum.

[0115] S5: Construct a clipping frustum according to the positions of the 8 points after the clipping frustum.

[0116] Determine the position and size of the connection entrance, which is represented by a bounding box. At the same time, the current position of the player in the virtual scene is also obtained. Use the camera's projection matrix and view matrix to transform the vertices of the first bounding box from world space to screen space. Calculate the size of the transformed first bounding box in screen space. Calculate the positions (x, y coordinates) of the 8 vertices of the first bounding box in screen space, and calculate the depth value (z coordinate) of each vertex, which can be obtained using the camera's depth buffer or projection matrix. Use the camera's inverse projection matrix and inverse view matrix to transform the 8 vertices in screen space back to world space to obtain the positions of these 8 vertices in world space. Use these 8 vertices to construct a hexahedron, the clipping frustum. This hexahedron defines the objects that the player can see within the current field of view.

[0117] In a possible implementation, the above step S230 may include the following steps:

[0118] S231: Calculate six clipping planes of the clipping frustum.

[0119] S232: Obtain a second bounding box for each occluding body.

[0120] S233: performing an intersection test on each second bounding box and each clipping plane to determine whether the second bounding box is completely on one side of any clipping plane and not within the clipping frustum;

[0121] S234: If yes, take the occluder corresponding to the second bounding box as the target occluder and remove the target occluder.

[0122] The clipping frustum is defined by six planes, namely the near plane, far plane, left plane, right plane, top plane and bottom plane. Use the camera's projection matrix and view matrix to calculate the equations of these six planes. Get the second bounding box of each occluder in world space. For each second bounding box, perform intersection tests with the six clipping planes to determine whether the second bounding box is completely on one side of a clipping plane. The specific method can be: calculate the relative position of each vertex of the bounding box relative to the clipping plane. If all vertices are in the same half-space, the second bounding box is completely on one side of the plane. If the second bounding box is on one side of all clipping planes and is not in the clipping frustum, it means that the player cannot see the second bounding box, then the corresponding occluder is used as the target occluder, the target occluder is culled, and when rendering, the occluder is no longer rendered.

[0123] The following is a possible implementation of the occluded object culling method. Figure 8 First, determine the player's location. If the player is outdoors, find the visible building group structure, process the one-way connection entrance of the visible building group structure, obtain the clipping frustum, and use the clipped clipping frustum to process the objects of the building group accordingly. If there are still connection entrances in the clipping frustum, recursive processing is performed. If the player is indoors, find a one-way connection entrance, clip the frustum through the entrance, obtain the clipping frustum, and use the clipping frustum to process objects outside the building group; find a two-way connection entrance, clip the frustum through the entrance, obtain the clipping frustum, and use the clipping frustum to process objects in the building. If there are still visible connection entrances, recursive processing is performed.

[0124] Furthermore, the embodiment of the present invention also provides a device for removing blocked objects, see Fig. 9 , the blocking object removal device 300 comprises:

[0125] The building group structure construction unit 310 is used to establish a building group structure of a virtual scene according to the virtual scene to be rendered; the building group structure includes rooms, connecting entrances and occluders; the occluders represent objects that may not be visible when rendering an image.

[0126] The view cone clipping unit 320 is used to perform view cone clipping according to the current position of the player in the virtual scene and the connection entrance, and calculate the clipping view cone at the current position.

[0127] The occluder culling unit 330 is used to calculate the occluders in each room that do not intersect with the clipping frustum as target occluders, and cull each target occluder.

[0128] In summary, the embodiments of the present invention provide an efficient method, device, electronic device and storage medium for removing occluded objects. The method pre-constructs a building group structure, which includes rooms, connecting entrances and occluders. During operation, invisible objects are removed by clipping the view cone. Since the occluders and entrances have been prefabricated in the early stage, the system can quickly determine whether the object is blocked and efficiently remove a large number of invisible objects.

[0129] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a module, a program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0130] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0131] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a computer-readable storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0132] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0133] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.

Claims

1. A method for removing occluded objects, characterized in that: The method comprises: According to the virtual scene to be rendered, a building group structure of the virtual scene is established; the building group structure includes rooms, connecting entrances and occluding bodies; the occluding bodies represent objects that may not be visible when the image is rendered; Perform visual cone clipping according to the current position of the player in the virtual scene and the connection entrance, and calculate the clipping visual cone of the current position; The occluders in each of the rooms that do not intersect with the clipping frustum are calculated as target occluders, and each of the target occluders is eliminated.

2. The method according to claim 1, characterized in that The step of establishing a building group structure of the virtual scene according to the virtual scene to be rendered includes: According to the virtual scene to be rendered, establishing a building group structure of the virtual scene; the building group structure includes at least one room; Marking connection entrances on each of the rooms, and establishing connection relationships between each of the connection entrances and each of the rooms; the connection entrances indicate that the player or the player's line of sight is allowed to move from one room to another; Each object in the room is marked as an occluder.

3. The method according to claim 1, characterized in that The connection entrance includes a unidirectional connection entrance and a bidirectional connection entrance, and the frustum clipping is performed according to the current position of the player in the virtual scene and the connection entrance to calculate the clipped frustum of the current position, including: When the player is outside the building group structure, find the one-way connection entrance within the field of vision of the player, and recursively calculate the clipping frustum of the current position; When the player is in any of the rooms, the one-way connection entrance and the two-way connection entrance within the field of view of the player are found, and the clipping frustum of the current position is calculated.

4. The method according to claim 3, characterized in that The step of finding the one-way connection entrance within the field of vision of the player and recursively calculating the clipping frustum of the current position includes: Find the one-way connection entrance within the field of vision of the player; Calculating a first clipping frustum according to the one-way connection entrance and the current position; In the case that there is no connection entrance in the first clipping frustum, using the first clipping frustum as the clipping frustum of the current position; When the connection entrance exists in the first clipping frustum, the intersection of the connection entrance and the first clipping frustum is recursively calculated to obtain a first visible connection entrance, and the Nth clipping frustum is calculated based on the first visible connection entrance, until the connection entrance does not exist in the Nth clipping frustum, and the first clipping frustum to the Nth clipping frustum are merged to obtain the clipping frustum at the current position.

5. The method according to claim 3, characterized in that: The step of finding the one-way connection entrance and the two-way connection entrance within the field of view of the player and calculating the clipping frustum of the current position includes: Find the one-way connection entrance within the field of view of the player, and calculate the outdoor clipping frustum; Find the bidirectional connection entrance within the field of view of the player and calculate the second clipping frustum; In the case where the connection entrance is not present in the second clipping frustum, using the second clipping frustum as the indoor clipping frustum of the current position; In the case where the connection entrance exists in the second clipping frustum, recursively calculate the intersection of the connection entrance and the second clipping frustum to obtain a second visible connection entrance, and calculate an M-th clipping frustum according to the second visible connection entrance, until there is no connection entrance in the M-th clipping frustum, and merge the second clipping frustum to the M-th clipping frustum to obtain the indoor clipping frustum of the current position; The indoor clipping frustum and the indoor clipping frustum are combined to obtain the clipping frustum of the current position.

6. The method according to claim 1 or 3 or 4 or 5, characterized in that: The process of frustum clipping includes: Obtaining a first bounding box of the connection entrance in the world space and a current position of the player in the virtual scene; Projecting the first bounding box of the connection entrance to the screen space of the current position to obtain the size of the first bounding box in the screen space; Calculating positions and depth information of eight points of the first bounding box in the screen space according to the size of the first bounding box in the screen space; Projecting the positions of the 8 points back to the world space to obtain the positions of the 8 points after the clipping frustum; The clipping frustum is constructed according to the positions of the 8 points after the clipping frustum.

7. The method according to claim 1, characterized in that The calculating the occluders in each of the rooms that do not intersect with the clipping frustum as target occluders and removing each of the target occluders includes: Calculating six clipping planes of the clipping frustum; Obtaining a second bounding box of each of the occluding bodies; Performing an intersection test on each of the second bounding boxes and each of the clipping planes to determine whether the second bounding box is completely on one side of any of the clipping planes and not within the clipping frustum; If yes, the occluder corresponding to the second bounding box is used as the target occluder, and the target occluder is eliminated.

8. A device for removing obstructing objects, characterized in that: The device comprises: A building group structure construction unit, used to establish a building group structure of the virtual scene according to the virtual scene to be rendered; the building group structure includes a room, a connecting entrance and an occluding body; the occluding body represents an object that may not be visible when the image is rendered; A visual cone clipping unit, used for performing visual cone clipping according to the current position of the player in the virtual scene and the connection entrance, and calculating a clipping visual cone at the current position; The occluder culling unit is used to calculate the occluders in each of the rooms that do not intersect with the clipping frustum as target occluders, and cull each of the target occluders.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Dynamic shielding elimination method and system based on structured sight distance field

    CN120953468A