Object rendering culling method and apparatus, device, medium
By emitting sampling rays in game rendering to obtain the visible proportion and screen ratio of target objects, and making refined culling decisions, the problem of mismatch between visual contribution and rendering cost in traditional rendering culling technology is solved, thus improving game performance and smoothness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU KULUO SHUJIE TECH CO LTD
- Filing Date
- 2026-04-30
- Publication Date
- 2026-05-29
AI Technical Summary
Traditional rendering culling techniques, when dealing with partially occluded or distant small objects, result in a large number of objects that contribute very little to the visual effect of the current frame being rendered, wasting the graphics processor's computing resources and memory bandwidth, and affecting game performance and frame rate.
By emitting multiple sampling rays from the camera position, the set of hit point coordinates of the target object is obtained. The full planar projection area and visible planar projection area of the target object in the screen space are calculated to determine the visible ratio and screen ratio. When the corresponding threshold is met, the target object is removed from the rendering operation.
It refines rendering culling decisions, reduces redundant rendering, lowers the load on the graphics processor, and improves the efficiency of rendering resource utilization and frame rate stability in game scenes.
Smart Images

Figure CN122115690A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of game interaction technology, and in particular to an object rendering culling method, apparatus, device, and medium thereof. Background Technology
[0002] In game development and real-time rendering, rendering culling is one of the core methods for optimizing graphics performance and ensuring smooth visuals. Rendering culling aims to identify objects that are invisible within the current camera's field of view or contribute very little to the final image, and remove them from the rendering pipeline, thereby reducing the computational load on the CPU and GPU. Common rendering culling techniques include frustum culling and occlusion culling. Frustum culling is used to exclude objects outside the camera's field of view, while occlusion culling is used to remove objects that are within the field of view but are completely obscured by other opaque objects.
[0003] Traditional occlusion culling schemes, such as those based on pre-computed visibility sets, typically employ a relatively conservative decision-making strategy. The underlying principle is that, during offline pre-computation or runtime, several sampled rays are emitted from the current camera position towards objects in the scene. The visibility of an object is determined by detecting whether these rays are occluded by other objects in the scene. Specifically, if any sampled ray can reach the target object without occlusion, the object is considered visible and submitted to the rendering pipeline for rendering. Conversely, an object is only culled if all sampled rays are occluded.
[0004] However, this traditional approach reveals its limitations when dealing with partially occluded or distant, tiny objects. Because its decision-making logic is based on the conservative principle of "rendering the whole if any part is visible," many objects that contribute minimally to the visual presentation of the current frame are still submitted for rendering. For example, when a player character is in a complex environment and observes a distant object through a narrow gap (such as a hole in a fence or a crack in a door), most of the object's surface is occluded by foreground objects, with only a tiny portion exposed to the player's view. In this situation, the traditional approach would classify the object as "visible" because at least one ray can pass through the gap to reach it, thus requiring the graphics processor to render the entire object's geometry. However, because the object's projected area in screen space is extremely small, and the visual occlusion percentage is very high, its final rendering contribution to the game visuals is negligible; the player can barely perceive its existence.
[0005] This mismatch between visual contribution and rendering overhead is particularly pronounced in large-scale, highly complex game scenes. When a scene contains a large number of objects that are "theoretically visible but contribute very little to the actual visual experience," the rendering pipeline is forced to handle massive amounts of redundant drawing calls, consuming significant graphics processor computing resources and memory bandwidth without delivering a corresponding improvement in image quality. This has become one of the key technical bottlenecks restricting game performance and causing frame rate drops and stuttering in large-scale scenes. Therefore, providing a more refined culling scheme that can effectively identify and remove objects whose visual contribution to the current frame is below an acceptable threshold, thereby further reducing rendering overhead while maintaining a good visual experience, has become an urgent technical problem to be solved. Summary of the Invention
[0006] The purpose of this application is to solve the above-mentioned problems by providing an object rendering culling method and corresponding apparatus, devices, non-volatile readable storage media, and computer program products.
[0007] According to one aspect of this application, an object rendering culling method is provided, comprising: Multiple sampling rays are emitted from the camera position to determine the target object hit by the sampling rays, and the set of hit point coordinates formed by the sampling rays that hit the target object is obtained. The full-plane projection area and the visible-plane projection area corresponding to the coordinates of the target object and the hit point set in the screen space are determined respectively, so as to determine the visibility ratio of the target object based on the full-plane projection area and the visible-plane projection area; The screen ratio of the target object is determined based on the projected area of the visible plane, the camera distance of the target object, and the near-plane distance. When both the screen ratio and the visible ratio meet their respective culling thresholds, the target object is removed from the rendering operation of the current frame.
[0008] According to another aspect of this application, an object rendering culling apparatus is provided, comprising: The coordinate set acquisition module is used to emit multiple sampling rays from the camera position, determine the target object hit by the sampling rays, and acquire the set of coordinates of the hit points composed of the sampling rays that hit the target object. The visible ratio determination module is used to determine the full plane projection area and the visible plane projection area of the target object and the hit point coordinate set in the screen space, respectively, so as to determine the visible ratio of the target object based on the full plane projection area and the visible plane projection area. The screen ratio determination module is used to determine the screen ratio of the target object based on the projected area of the visible plane, the camera distance of the target object, and the near plane distance. The rendering culling module is used to remove the target object from the rendering operation of the current frame when both the screen ratio and the visible ratio meet their respective culling thresholds.
[0009] According to another aspect of this application, a computer program product is provided, comprising a computer program / instructions that, when executed by a processor, implement the steps of the method.
[0010] As can be seen from the above embodiments, the beneficial effects of this application are mainly reflected in the following aspects: First, this application fundamentally changes the conservative judgment logic of "any visible part is considered as part of the overall rendering" in traditional occlusion culling schemes by using a dual-index quantitative evaluation mechanism of screen ratio and visible ratio. Compared to existing technologies that rely solely on the binary judgment of whether rays are occluded when determining object visibility, the method in this application, after emitting sampling rays from the camera position and obtaining the set of hit point coordinates, does not directly make a rendering or culling conclusion. Instead, it determines the complete planar projection area and the visible plane projection area of the target object in screen space, thereby determining the visible ratio, and then determines the screen ratio based on the visible plane projection area, the camera distance of the target object, and the near-plane distance. The visible ratio reflects the proportion of the unoccluded part of the target object to its overall projection scale, while the screen ratio comprehensively reflects the visible scale of the target object in the image, the spatial distance between it and the camera, and the relationship with the camera imaging parameters. Only when both the screen ratio and the visible ratio meet their respective culling thresholds are the target object removed from the rendering operation of the current frame. This dual-condition joint judgment mechanism effectively avoids the invalid rendering of objects that are only partially visible or are too far away to be recognized in traditional solutions, allowing the rendering pipeline to concentrate computing resources on objects that have a substantial impact on the player's visual experience.
[0011] Secondly, this application improves the fineness and accuracy of rendering culling decisions by transforming the traditional binary judgment of the occlusion state and visual contribution of target objects into a continuous quantitative evaluation. In traditional schemes, as long as a sampling ray can reach the target object without occlusion, regardless of how small the object's projected area on the screen or how high the occlusion ratio is, it will be judged as visible and submitted for rendering, resulting in redundant rendering calls. This application determines the complete planar projected area and the visible planar projected area of the target object, and derives two quantitative indicators, visible ratio and screen ratio, which can distinguish the difference between theoretical visibility and actual perceptible contribution to the image. For example, when a player observes a distant tree through a narrow hole in a wall, although there is a theoretically visible part, its screen ratio and visible ratio are extremely low. This application can identify it as an object that does not substantially contribute to the current frame and cull it. This fine-grained culling logic overcomes the problem of mismatch between visual contribution and rendering overhead caused by the conservative visibility principle in traditional technologies. In large-scale, highly complex game scenes, it can effectively reduce redundant rendering and lower the load on the graphics processor.
[0012] Furthermore, the technical solution of this application fully considers the impact of the spatial distance between the target object and the camera on the visual contribution during execution. By introducing two parameters—the camera distance and the near-plane distance of the target object—when determining the screen ratio, this application can incorporate the spatial distance factor into the comprehensive evaluation of the necessity of rendering the target object. Compared with the existing technology that does not fully consider the distance factor or only performs simple distance culling, this application integrates distance information into the screen ratio determination process, making the culling decision more in line with the visual perception characteristics of the human eye. An object that is large in scale but projects a very small image on the screen due to its distance will have its screen ratio reduced due to the distance factor, and will thus be reasonably culled when facing the culling threshold. This mechanism enables the rendering culling system to automatically adapt to the object rendering needs at different distances in open-world and large-scene games, further improving the utilization efficiency of rendering resources, and providing support for the frame rate stability and smoothness of game operation while ensuring the visual performance. Attached Figure Description
[0013] Figure 1 This is an exemplary network architecture for this application; Figure 2 A schematic flowchart of one embodiment of the object rendering culling method of this application; Figure 3 A schematic diagram of the object rendering culling apparatus of this application; Figure 4 This is a schematic diagram of the structure of an object rendering culling device used in this application. Detailed Implementation
[0014] The technical solution of this application can be widely applied to various network architectures to adapt to different types and scales of game applications. In a network architecture such as... Figure 1 In the typical network architecture shown, the player's terminal device accesses the game service cluster via the network. This cluster consists of multiple game servers 81. A microservice architecture manages and maintains the runtime resources of these game servers 81, providing multiple service instances. Each service instance is responsible for different services. For example, some service instances can be used to maintain the front-end services for the terminal device 80 to access the game, while others can be responsible for the game's dungeon combat gameplay services, providing players with corresponding game combat dungeons to play. The player's terminal device 80 has a computer program product implemented according to the object rendering culling method of this application installed and running, or the terminal device can be connected to a cloud server container, where the computer program product runs. After the computer program product runs, it accesses the game service cluster, allowing the player to control the player character in the game through the terminal device and interact with various service instances of the game, such as engaging in combat with hostile entities.
[0015] Each service instance can maintain a real-time connection with the player's terminal device 80 via the network, handling various events and interactions in the game, such as player character movement, attacks, and item usage. The server provides necessary data support to the terminal device to ensure smooth game operation. This data includes, but is not limited to, map model datasets. These datasets contain map model data for each battle instance's play map and resource model data for its battle scene resources, such as scene buildings, player character models, enemy player models, enemy monster models, and various other neutral or non-biological models. These are used by the terminal device 80 to render and generate corresponding real-time images. Based on the received map model dataset, the terminal device 80 can generate high-quality real-time images and display them in the graphical user interface, presenting the corresponding game scene to the player. Players obtain visual information about the game through real-time images of the game scene, thereby implementing gameplay.
[0016] This application is not only applicable to the gaming experience of single players, but can also be extended to multiplayer online game environments. In multiplayer games, multiple players' (users') terminal devices connect to the game service cluster simultaneously, and each service instance needs to handle interaction requests from multiple players and update the game status in real time.
[0017] In an exemplary application scenario of this application, consider a massively multiplayer online role-playing game (MMORPG) where players can freely explore a vast open-world map and control their character to enter various specific dungeon maps to complete quests. In this game, the player character can frequently switch between different maps, such as switching from a bustling city map to a mysterious dungeon map, or from one room to another.
[0018] The object rendering culling method provided in this application can be widely deployed in various virtual environment systems with combat interaction gameplay, especially suitable for application scenarios such as video games, virtual reality experiences, and simulation training platforms. In a typical technical architecture, the execution entity of this application is usually a terminal device running a client application, such as a personal computer, game console, or mobile device. The game engine or application framework running on the terminal device integrates combat gameplay processing middleware and logic processing units, responsible for real-time rendering of virtual scenes, handling user interactions, and managing the playback of combat performance resources. Combat performance resources and related strategy configuration data can be stored locally on the terminal device or dynamically obtained from a remote server as needed. Real-time monitoring, strategy matching, and object rendering culling processes can be completed locally on the client to ensure low-latency response and a smooth experience.
[0019] In an exemplary object rendering culling process, the system first emits forty sampling rays from the current camera position into the scene. By detecting the intersections of these rays with scene objects, the system identifies the target objects hit by these sampling rays, such as a large tree located behind a wall, with only its crown visible through a hole in the wall. For this target object, the system filters out those sampling rays that were not obscured by other opaque objects in the scene before reaching the target object. It then extracts the world coordinates of the points where each of these sampling rays intersects the surface of the target object, thereby generating a set of hit point coordinates containing the world coordinates of several hit points for the target object. Subsequently, the system establishes a planar coordinate system in the near plane, containing a first and a second coordinate axis that are perpendicular to each other, and determines the full planar projection area and the visible planar projection area of the target object in screen space, respectively. For the full-plane projection area, the system obtains the coordinates of multiple vertices of the axis-aligned bounding box of the target object. These vertex coordinates are projected onto the near plane along the camera's line of sight to obtain the corresponding 2D projection points of the object. The minimum and maximum coordinate values on the first and second coordinate axes are then identified from these projection points. Based on these four extreme values, a 2D bounding box is constructed, and its planar area is calculated; this is the full-plane projection area. For the visible-plane projection area, the system similarly projects each world coordinate point in the hit point coordinate set onto the same near plane along the camera's line of sight to obtain the corresponding visible 2D projection points. The minimum and maximum coordinate values on the first and second coordinate axes are also identified. Based on these four extreme values, a rectangle is constructed, and its planar area is calculated; this is the visible-plane projection area. Next, the system divides the visible-plane projection area by the full-plane projection area. The quotient is used as the visible proportion of the target object, representing the proportion of the unoccluded portion of the target object to its total projection area. Simultaneously, the system calculates the screen-to-body ratio of the target object based on the projected area of the visible plane, the camera distance from the target object to the camera position, and the near-plane distance. Specifically, the screen-to-body ratio is the product of the hit ray ratio, the distance attenuation factor, and the visible area ratio. The hit ray ratio is the ratio of the number of unobstructed rays to the total number of emitted sampled rays; the distance attenuation factor is the square of the ratio of the near-plane distance to the camera distance; and the visible area ratio is the ratio of the projected area of the visible plane to the total area of the near-plane. The system then determines whether both the screen-to-body ratio and the visible area ratio meet their respective culling thresholds, for example, a screen-to-body ratio less than 0.05% and a visible area ratio less than 30%. When both conditions are met, it indicates that the target object's visual contribution to the image in the current frame is below an acceptable level. The system then removes it from the rendering operation of the current frame, no longer submitting it to the graphics processor for rendering, thus concentrating rendering resources on objects that have a substantial impact on the player's visual experience.
[0020] The term "system" as used in this application may refer to a collection of software and hardware environments on the game client and / or server side, used to implement various functions of the game. It includes components such as game engine, physics system, collision detection module, special effects rendering module, and audio system. These components work together to process player input, execute game logic, update game state, generate visual and auditory feedback, and provide players with an interactive experience.
[0021] After providing a general overview of the exemplary network architecture and application scenarios of this application, as well as some basic concepts, the following will continue to describe several specific embodiments of this application.
[0022] Please see Figure 2 The object rendering culling method of this application, in some embodiments, includes the following steps: Step S11: Emitter multiple sampling rays from the camera position, identify the target objects hit by the sampling rays, and obtain the set of coordinates of the hit points formed by the sampling rays that hit the target objects. This step is fundamental for implementing refined rendering culling decisions based on visual contribution. It is executed within each frame of the game's rendering loop, after frustum culling and before the final rendering queue submission. The purpose of this step is to obtain data representing the specific geometric position of the visible portion of the target object within the current camera's field of view through a quantitative detection method, providing a basis for subsequently calculating the target object's visible area in screen space.
[0023] A sampling ray is a virtual line segment emitted from the current camera position in all directions within the 3D scene to detect the visibility of objects. The emission mode of sampling rays can be implemented in various ways, including but not limited to generating a uniformly distributed array of rays within the camera's view frustum, projecting onto a grid based on screen pixels, or performing importance sampling on specific areas. The number of sampling rays can be pre-configured according to performance budget and accuracy requirements. For example, in one embodiment, forty sampling rays are emitted uniformly from the camera position into the scene; in other embodiments, the number of rays can be dynamically adjusted according to the complexity of the scene, emitting more rays in complex areas and fewer in simple areas. Each sampling ray carries its emission direction information and interacts with the scene's physical collision system or geometry intersection detection engine to determine the first object intersecting on the sampling ray path.
[0024] Once a sampled ray is emitted from the camera position, intersection detection is performed. This calculation can be implemented by calling the physics query interface provided by the game engine, such as ray tracing in Unreal Engine or physical raycasting in Unity Engine. During the intersection detection calculation, opaque and transparent objects encountered along the ray path need to be distinguished based on the material properties of scene objects or preset collision channel settings. Specifically, the sampled ray ignores objects marked as transparent (e.g., glass, water) or objects set to a specific collision response type (e.g., "ignore" or "overlap") during its propagation and continues forward. Therefore, the sampled ray can penetrate transparent objects and effectively intersect with the first opaque object encountered after the transparent object.
[0025] If a sampling ray, ignoring all transparent objects, does not effectively intersect with any opaque scene object along its propagation path, it is considered to have missed any object and no further data is generated. Conversely, if a sampling ray, ignoring transparent objects, effectively intersects with an opaque object, that opaque object is identified as the target object in this step. It is important to note that this intersection refers to the first effective collision between the sampling ray and the geometric surface of the opaque object, regardless of whether the opaque object is partially obscured by other opaque objects. For example, in an application scenario, sampling rays are emitted from the camera position into the scene. Several of these rays penetrate a transparent glass window, pass through a hole in a wall, and finally hit a large tree behind the wall. In this case, the tree is identified as the target object processed in this step.
[0026] After identifying the target object hit by the sampled rays, not all sampled rays hitting the target object are included in subsequent processing. Instead, a further selection process is used to identify the hit sampled rays. Hit sampled rays specifically refer to those whose emission paths, ignoring transparent objects, are not blocked by any other opaque objects in the scene before reaching the target object. This selection process is crucial for obtaining data on the truly visible portion of the target object. Continuing with the previous example, of the forty sampled rays emitted from the camera position, after penetrating the glass window, thirty-eight hit the wall before reaching the tree, leaving only two that pass through the hole and directly hit the tree. In this case, only these two unobstructed sampled rays will be identified as hit sampled rays targeting the tree. The selection process can be implemented by performing a secondary verification on each hit sampled ray, for example, by comparing the distance from the camera to the hit point with the distance from the camera to the first opaque obstruction in the direction of the sampled ray, or by setting a flag for the sampled ray to "only consider the first opaque hit" to directly obtain the unobstructed hit results.
[0027] Because of this situation, a sampled ray may indeed hit the target object, but when a complete occlusion analysis is performed on the ray path, the sampled ray is still determined to have been occluded by other opaque objects before reaching the target object. This phenomenon is related to the emission method of the sampled ray, the calling mode of the ray detection interface, and the spatial arrangement of objects in the 3D scene.
[0028] In one implementation, sampling rays are not emitted individually towards single targets, but rather in batches from the camera position into the scene, either uniformly or according to a certain distribution pattern. Each sampling ray is emitted without prior knowledge of which object it will hit. When a sampling ray is emitted, the ray detection interface returns the first hit result, which may be an opaque object or an opaque object that is first hit after penetrating a transparent object. This first hit opaque object is recorded as the target object hit by that sampling ray. However, this only confirms the intersection between the ray and the target object and does not fully reflect whether the ray was blocked by other opaque objects before reaching the target object. To accurately determine the visible portion of the target object, further analysis is needed to determine the specific location where the target object was hit by the ray and whether it is indeed located on a surface directly visible from the camera position.
[0029] In another implementation, the sampling rays are specifically emitted for a particular candidate target object. For example, after a set of potential visible objects has been identified through frustum culling or other coarse screening methods, a set of sampling rays is emitted from the camera position toward its bounding box or surface for each potential visible object. In this case, the ray detection interface may be configured to return only the intersection information with that specific target object, ignoring other objects in the path. While the ray may hit the target object, it cannot directly determine whether there are other occlusions in its path. Therefore, an additional occlusion check needs to be performed after obtaining the hit result.
[0030] There are several ways to perform occlusion verification. One method is to use two raycasts. The first raycast is used to obtain the hit point from the camera position to the surface of the target object. Then, a verification ray is emitted in the opposite direction from the hit point towards the camera position, or a new ray is emitted from the camera position towards the hit point to detect only a specific set of occluders. By comparing the distance or the object identifiers of the two detections, it is determined whether there are other opaque objects between the camera and the hit point. Another method is to request all intersection events on the ray path in a single raycast, rather than just the first hit. By sorting and analyzing all intersection events, it can be determined whether the ray intersected with other opaque objects before reaching the target object. If there are intersection events with other opaque objects, and the location of the intersection event is closer to the camera, then the sampled ray is determined to be occluded.
[0031] Taking the example of a large tree behind a wall, suppose a sampling ray is emitted from the camera towards the tree. This ray first penetrates the glass window, then passes through a hole in the wall, and finally hits the tree's canopy. During its penetration of the glass window and through the hole, the ray does not effectively intersect with any opaque object. Therefore, in the subsequent occlusion check, this ray is determined to be unobstructed. Conversely, if another sampling ray is also emitted towards the tree, but its propagation path is blocked by the solid wall, this ray will have its first effective intersection upon reaching the wall. If the ray detection interface is configured to only return the first hit, the object returned by this ray will be the wall, not the tree. In this case, the tree is not the target object of this ray at all. If the ray detection interface is configured to detect the tree, the detection process will find that the ray's path contains an opaque obstruction—the wall—before reaching the tree. By checking for occlusion, it can be determined that although the sampling ray can theoretically calculate the intersection point on the surface of the tree, in the actual scene, the intersection point is blocked by the wall and is invisible to the camera.
[0032] Therefore, the fact that a sampling ray hits a target object does not equate to the target object's surface position being actually visible. Only when a sampling ray directly hits the target object and does not effectively intersect with any opaque object before reaching the hit point is the sampling ray confirmed as a hit ray, and its corresponding hit point is included in the hit point coordinate set. This selection process ensures that every world coordinate recorded in the hit point coordinate set accurately corresponds to the actual surface position of the target object exposed in the field of view from the current camera perspective, providing an accurate data foundation for subsequent precise calculations of the visible plane's projected area.
[0033] For each sampled ray identified as a hit ray, the precise spatial position where the ray intersects the surface of the target object is obtained; this position is defined as the hit point. The collision data structure returned by the ray detection interface is called, and the 3D world coordinates of the intersection point are extracted from the collision data structure. World coordinates are represented as floating-point triplets, precisely describing the absolute position of a sample point on the unoccluded part of the target object in the virtual scene from the current camera viewpoint. The world coordinates of the hit points of all hit sampled rays corresponding to the same target object are collected, thus generating a unique set of hit point coordinates corresponding to the target object. The hit point coordinate set is essentially an array or list data structure storing several 3D coordinate vectors. For example, for the large tree behind the aforementioned wall, the hit point coordinate set corresponding to the tree will contain the world coordinates of two hit points, corresponding to the specific positions on the tree canopy hit by the two sampled rays. For objects in the scene that are not hit by any sampling rays on their opaque parts, or objects whose hit sampling rays are all blocked by opaque objects, the set of hit point coordinates for the objects is empty. This also provides a clear quantitative basis for subsequent culling decisions.
[0034] By emitting sampling rays from the camera position and clearly distinguishing the different interaction rules between the sampling rays and transparent and opaque objects, the set of coordinates of the hit points that directly hit the visible part of the target object is accurately extracted. This transforms the visibility status of the target object from a traditional binary "yes or no" judgment into quantitative data about the specific geometric position of the visible part of the target object. This data acquisition method lays a solid data foundation for subsequent accurate calculation of the target object's screen ratio and visible proportion, thereby accurately assessing the target object's visual contribution to the final image.
[0035] Step S12: Determine the complete planar projection area and the visible planar projection area of the target object and the hit point coordinate set in screen space, respectively, so as to determine the visibility ratio of the target object based on the complete planar projection area and the visible planar projection area. The complete planar projection area of a target object represents the size of the projected area that the target object should occupy in screen space if it were completely unobstructed by any other object. The method for determining the complete planar projection area is as follows: First, a planar coordinate system is established in the near plane of the camera. This coordinate system includes a first coordinate axis and a second coordinate axis that are perpendicular to each other. The selection of this near plane is related to the camera parameters, and the near plane constitutes the projection reference plane from the 3D world to the 2D screen. Then, the coordinates of multiple vertices of an axis-aligned bounding box of the target object are obtained. The axis-aligned bounding box is a cuboid that tightly wraps around the target object in the 3D world, with its sides aligned with the coordinate axes of the virtual world. The coordinates of the multiple vertices of the axis-aligned bounding box are projected one by one along the line of sight from the camera position, that is, each vertex of the multiple vertex coordinates is mapped from 3D space onto the aforementioned near plane, thereby generating a 2D coordinate point at the corresponding position of each vertex. This 2D coordinate point is recorded as the object's 2D projection point. After obtaining multiple 2D projection points of the object, these points are traversed, and the minimum and maximum coordinate values on the first and second coordinate axes of the planar coordinate system are found. Based on these four extreme values (minimum and maximum coordinate values on the first and second coordinate axes), a 2D bounding box with edges parallel to both the first and second coordinate axes is constructed, which can precisely contain all the object's 2D projection points. The planar area of the bounding box is then calculated, and the result is used as the complete planar projection area of the target object. The calculation of the planar area of the bounding box can be implemented in different ways. For example, the planar area of the bounding box can be directly obtained by multiplying its width and height, where the width is the absolute value of the difference between the maximum and minimum coordinate values on the first coordinate axis, and the height is the absolute value of the difference between the maximum and minimum coordinate values on the second coordinate axis.
[0036] The visible plane projection area of a target object represents the size of the projected area in screen space occupied by the portion of the target object that is not obscured by other opaque objects from the current camera's perspective. The method for determining the visible plane projection area corresponds in principle to the process described above for determining the full plane projection area. The same near plane and its internal coordinate system are used as in calculating the full plane projection area. The set of hit point coordinates corresponding to the target object, generated in the previous steps, is obtained. Each world coordinate point stored in the hit point coordinate set represents a precise sampling position of the unobscured portion of the target object's surface. Each world coordinate point in the hit point coordinate set is projected onto the near plane along the camera's line of sight, generating a two-dimensional coordinate point at the corresponding position of each world coordinate point. This two-dimensional coordinate point is recorded as the visible two-dimensional projection point. After obtaining multiple visible 2D projection points, these points are iterated through to find the minimum and maximum coordinate values on the first and second coordinate axes of the planar coordinate system. Based on these four extreme values, a rectangle with sides parallel to both the first and second coordinate axes is constructed, which can accommodate all the visible 2D projection points. The area of the rectangle is then calculated, and the result is used as the visible planar projection area of the target object. If the set of hit point coordinates is empty, meaning the target object has no visible portion in the current frame, the value of the visible planar projection area is zero.
[0037] After obtaining the full-plane projection area and the visible-plane projection area, the visibility ratio of the target object is determined based on these two data points. Specifically, the visible-plane projection area is divided by the full-plane projection area; the quotient is the visibility ratio of the target object. The visibility ratio is a dimensionless value between zero and one. Its physical meaning lies in precisely quantifying the proportion of the unobstructed portion of the target object relative to its overall size from the current viewing angle. For example, consider a large tree behind a wall. Assuming the full-plane projection area of the tree is 8,000 square pixels, and the visible-plane projection area of the canopy visible through the hole is calculated to be 400 square pixels, dividing 400 by 8,000 gives a visibility ratio of 5%. This visibility ratio indicates that while a small portion of the target object is visible, the vast majority of its surface is obscured by foreground objects from the current viewing angle. If the target object were fully visible, its visible-plane projection area would be equal to its full-plane projection area, resulting in a visibility ratio of 100%. If the target object is completely obscured, the projected area of the target object's visible plane is zero, and the visible proportion is zero.
[0038] The core step of quantitatively assessing the visual contribution of a target object is executed immediately after obtaining the set of hit point coordinates. By projecting the entire target object and its visible portion onto the screen space and calculating the corresponding full-plane projection area and visible-plane projection area, the precise visibility ratio is determined by the ratio of the visible-plane projection area to the full-plane projection area. This transforms the occlusion status of the target object from a traditional binary judgment into a continuous quantitative assessment. The visibility ratio data, combined with subsequently calculated screen ratio data, provides an objective and accurate decision-making basis for determining whether a target object should be removed in the current frame due to its low overall visual contribution to the image.
[0039] Step S13: Based on the projected area of the visible plane, the camera distance to the target object, and the near-plane distance, determine the screen ratio of the target object: The purpose of this step is to calculate a quantitative indicator that can objectively reflect the visual weight of the target object in the current frame, namely the screen ratio, by comprehensively considering the visible area of the target object in the screen space, the spatial distance relationship between the target object and the camera, and the imaging parameters of the camera.
[0040] In calculating the screen-to-body ratio, the first step is to calculate the hit ray ratio of the target object. The hit ray ratio refers to the ratio between the number of unobstructed sampled rays that hit the target object, as counted in the previous steps, and the total number of sampled rays emitted towards that target object. Taking the large tree behind the wall as an example, 40 sampled rays are emitted from the camera position. After filtering, only 2 sampled rays are identified as hit rays. Therefore, the hit ray ratio is 2 divided by 40, which is 5%. From the perspective of ray sampling, the hit ray ratio initially reflects the proportion of the visible portion of the target object in the sampling space.
[0041] Secondly, the distance attenuation factor needs to be calculated. The distance attenuation factor quantifies the degree to which the projected size of a target object is reduced in screen space due to the spatial distance between it and the camera. The distance attenuation factor is calculated by dividing the near-plane distance by the camera distance of the target object, and then squaring the quotient. The near-plane distance refers to the distance between the near clipping plane of the camera's view frustum and the camera position; this near-plane distance is a known quantity related to the camera's imaging parameters. The camera distance of the target object refers to the straight-line distance between the target object's position in the 3D scene (usually the center point or nearest point of its axis-aligned bounding box) and the camera position. The reason for squaring the quotient of the near-plane distance and the camera distance in this calculation is that, under the imaging rules of perspective projection, the linear dimension of an object on the projection plane is inversely proportional to the distance from the object to the camera. Specifically, if the distance from the object to the camera doubles, the height and width of the object on the projection plane are both reduced to half their original size. Since the projected area is a two-dimensional scale, it is affected by the reduction in both height and width linear dimensions; therefore, the projected area is inversely proportional to the square of the distance from the object to the camera. By squaring the distance ratio, the distance attenuation factor can accurately quantify the completeness of the attenuation of the projected area of a target object due to spatial distance. For example, assuming the near-plane distance is 0.1 meters and the camera distance to the target object is 50 meters, the distance attenuation factor is the square of the quotient of 0.1 divided by 50, which is 0.000004. This value indicates that the projected area of the target object at a distance of 50 meters is only four millionths of its projected area at the near-plane distance.
[0042] In addition, the visible area percentage needs to be calculated. The visible area percentage refers to the ratio between the projected area of the visible plane, calculated in the preceding steps, and the total area of the near plane. The projected area of the visible plane represents the size of the projected area of the actual unobstructed portion of the target object on the near plane. The total area of the near plane refers to the complete area of the near clipping plane of the camera's view frustum. This total area of the near plane is related to the camera's field of view angle and the near plane distance, forming a reference frame for the screen space. The physical meaning of the visible area percentage is that it normalizes the projected area of the visible portion of the target object within the entire near plane reference frame, thereby deriving the relative scale of the visible portion of the target object within the entire screen image.
[0043] After obtaining the three intermediate data points—the percentage of hit rays, the distance attenuation factor, and the visible area percentage—the product of these three data points can be used as the screen ratio of the target object. The screen ratio calculation integrates information from three dimensions: the visible proportion at the sampling ray level, the attenuation effect at the distance level, and the relative scale at the projected area level. A higher screen ratio indicates a stronger visual presence of the target object in the current frame and a greater actual contribution to the image. Conversely, a lower screen ratio indicates a weaker target object in the image.
[0044] Taking the large tree behind the wall in the example, assuming the hit ray ratio is 5% and the distance attenuation factor is 0.000004, the visible area ratio is calculated to be 0.0000482. Multiplying these three values together, we get an extremely small screen-to-body ratio for the tree. This value intuitively reflects that although the tree is technically visible, due to its great distance and extremely small exposed portion, its actual visual weight in the final screen image is so low as to be negligible.
[0045] By calculating the proportion of hit rays, the distance attenuation factor, and the visible area ratio separately, and then multiplying these three factors to obtain the target object's screen-to-body ratio, the visual contribution of the target object in the image is transformed into a precise quantitative value that integrates the visible scale, spatial distance attenuation, and screen space ratio. The distance attenuation factor, through squared operations, accurately reflects the imaging law that area is inversely proportional to the square of distance under perspective projection. The combination of screen-to-body ratio and visible area ratio data provides dual objective evidence for subsequently determining whether a target object should be removed in the current frame due to its low overall visual contribution to the image.
[0046] Step S14: When both the screen ratio and the visible ratio meet their respective culling thresholds, the target object is removed from the rendering operation of the current frame. The purpose of this step is to make a final decision on the rendering necessity of the target object in the current frame based on the viewing ratio and screen ratio, and to remove those target objects that have too little contribution to the visual image from the rendering pipeline, thereby concentrating the limited graphics processor computing resources and memory bandwidth on objects that have a substantial impact on the player's visual experience.
[0047] During the judgment process, the calculated screen-to-body ratio of the target object is first compared with a preset culling threshold for screen-to-body ratio. The culling threshold is a pre-configured value used to define whether the visible scale of the target object in screen space has reached the minimum standard for rendering. The specific value of the culling threshold can be flexibly configured according to the performance level of the target hardware platform, the complexity of the game scene, or the user's preferred image quality settings. For example, in one implementation, the culling threshold is configured to 0.05%. The calculated screen-to-body ratio is compared with this culling threshold. If the screen-to-body ratio is less than 0.05%, it indicates that the target object occupies a very low visual weight in the current frame, and its visible portion's projected area on the screen is so small that it is difficult to clearly distinguish with the naked eye.
[0048] Simultaneously, the calculated visible proportion of the target object is compared with a preset culling threshold for the visible proportion. The visible proportion culling threshold is a pre-configured value used to define whether the proportion of the unoccluded portion of the target object relative to its full scale has reached the minimum standard for rendering. The specific value of the visible proportion culling threshold can also be configured according to actual application requirements. For example, in one implementation, the visible proportion culling threshold is configured to 30%. Comparing the calculated visible proportion with this culling threshold, if the visible proportion is less than 30%, it indicates that most of the target object's surface is occluded by foreground objects from the current viewpoint, with only a very small portion exposed to the field of view.
[0049] An object is deemed to have an unacceptable overall visual contribution to the current frame only when both its screen-to-body ratio and visible ratio are below their respective culling thresholds. This dual-condition setting ensures the rigor of the culling decision and avoids erroneous culling due to accidental fluctuations in a single metric. For example, a distant mountain peak with a small screen-to-body ratio but full visibility may meet the culling criteria, but its visibility ratio of 100% does not, so it will be retained for rendering. Similarly, an enemy character nearby but mostly obscured by walls may meet the culling criteria in terms of visibility ratio, but its large screen-to-body ratio due to its proximity does not, so it will also be retained for rendering.
[0050] Taking the large tree behind the wall as an example, its screen-to-body ratio is calculated to be a very small value, less than the culling threshold of 0.05%; its visibility ratio is calculated to be 5%, also less than the culling threshold of 30%. In this case, both conditions are met simultaneously, and the large tree is determined to have no substantial visual contribution to the current frame, and is therefore removed from the rendering operation of the current frame. The specific culling operation includes removing the target object from the rendering queue to be submitted to the graphics processor, or marking the rendering state corresponding to the target object as invisible. Conversely, if either the screen-to-body ratio or the visibility ratio does not meet its corresponding culling threshold, the target object is determined to have a substantial visual contribution to the image, is retained, and the subsequent rendering process continues to render the target object in the scene.
[0051] By comparing screen ratio and visible ratio with their corresponding culling thresholds, and only performing culling operations when both conditions are met simultaneously, a joint culling decision mechanism based on dual quantitative indicators was constructed. This mechanism ensures the accuracy of culling decisions while effectively avoiding erroneous image disappearances caused by misjudgments of a single indicator. It can identify and remove a large number of redundant objects with minimal visual contribution without significantly impacting the player's visual experience, thereby reducing rendering overhead and improving the frame rate stability of the game.
[0052] Based on any embodiment of the method in this application, obtaining the set of hit point coordinates composed of the sampled rays that hit the target object includes: Step S111: Identify the target object hit by any sampling ray, and determine whether the sampling ray reaching the target object is blocked by other objects in the scene along its emission path: After multiple sampling rays are emitted from the camera position into the scene, not all sampling rays can reach the first opaque object in their path without obstruction. For each sampling ray, a complete path occlusion check needs to be performed. Once a sampling ray is emitted from the camera position, it is traversed and detected in the 3D scene along its emission direction. During the traversal and detection process, the sampling ray will intersect with various objects in the scene.
[0053] To accurately determine the visibility of a target object, objects in the scene need to be classified into opaque and transparent objects. Transparent objects include, but are not limited to, glass windows, water surfaces, waterfalls, and translucent walls—objects whose materials are marked as transparent or have translucent properties. Opaque objects refer to solid geometric shapes that completely obstruct the view, such as walls, mountains, buildings, and character models.
[0054] If, during its propagation, the sampling ray encounters an object marked as transparent or an object with a specific collision response type (such as "ignore" or "overlap"), the sampling ray ignores the intersection event and continues propagating forward in its original direction. Therefore, the sampling ray can penetrate transparent objects and effectively intersect with the first opaque object it encounters behind the transparent object.
[0055] If a sampling ray, after penetrating all transparent objects along its propagation path, fails to intersect with any opaque object, it is considered to have missed any object and no further data is generated. Conversely, if a sampling ray, after penetrating a transparent object, intersects with an opaque object, that opaque object is identified as the target object hit by the sampling ray. This intersection represents the first effective collision between the sampling ray and the geometric surface of the opaque object.
[0056] After identifying the target object, the next step is to determine whether the sampling ray was obstructed by any opaque object along its path before reaching the target object. This is done by comparing the straight-line distance from the camera position to the point of impact on the target object with the distance from the first opaque obstruction along the sampling ray's direction to the camera position. If the two distances are equal, it indicates that the sampling ray directly hit the target object after penetrating the transparent object, without being obstructed by any opaque object in between. If the former distance is greater than the latter distance, it indicates that the sampling ray hit another opaque object before reaching the target object, meaning the sampling ray was obstructed by an opaque object. This process distinguishes which sampling rays directly reached the target object after penetrating transparent objects and which were blocked by other opaque objects.
[0057] Taking the example of a large tree behind a wall, a sampling ray emitted from the camera's position first penetrates a transparent glass window and continues forward. Thirty-eight of these sampling rays hit the wall before reaching the tree; since the wall is opaque, these rays are considered obstructed. Only two rays, after penetrating the glass window, pass through a hole in the wall and directly hit the tree; these two rays are considered unobstructed. In another application scenario, a sampling ray is emitted from the camera's position towards a treasure chest behind a waterfall. The ray first encounters the waterfall water; since the water is marked as transparent, the ray ignores this intersection and continues penetrating the waterfall. After penetrating the waterfall, the ray directly hits the treasure chest behind it. In this case, the treasure chest is identified as the target object, and the sampling ray was not obstructed by any opaque object before reaching it.
[0058] Step S112: Determine the hit sampling ray that reaches the target object and is not obstructed: After determining the occlusion of each sampling ray that hits the target object, those sampling rays that were not obstructed by any opaque object before reaching the target object can be selected from all the sampling rays that hit the target object. These selected sampling rays are defined as the hit sampling rays.
[0059] Hit sampling rays specifically refer to those sampling rays emitted from the camera position that, after penetrating all transparent objects, can reach the surface of the target object directly without obstruction. The number of hit sampling rays directly reflects the sampling coverage of the visible portion of the target object from the current camera's perspective. The more hit sampling rays, the more extensive the surface area of the target object is exposed in the field of view. Conversely, the fewer hit sampling rays, the more scattered parts of the target object are not obscured by opaque foreground objects.
[0060] Taking the example of the large tree behind the wall, out of forty sampling rays emitted from the camera position, only two rays, after penetrating the glass window, were not obstructed by the wall and directly hit the tree. In this case, these two sampling rays are identified as the hit sampling rays targeting the tree. Similarly, in the aforementioned example of the treasure chest behind the waterfall, if ten sampling rays are emitted from the camera position towards the treasure chest, and all ten rays penetrate the waterfall and directly hit the treasure chest, then all ten sampling rays are identified as hit sampling rays.
[0061] For objects in the scene that are not directly reached by any hit sampling rays (i.e., all sampling rays hitting these objects are blocked by other opaque objects), the number of hit sampling rays corresponding to these objects is zero. The process of determining hit sampling rays is essentially a spatial sampling of the visible portion of the target object. Each hit sampling ray corresponds to a sampling point on the visible surface of the target object. The set of these sampling points forms the data basis for subsequent calculations of the projected area of the visible plane.
[0062] Step S113: Determine the position where each of the hit sampling rays intersects with the target object as the hit point: For each sampled ray identified as a hit, the precise spatial location where it intersects the target object's surface needs to be obtained. When a sampled ray intersects the geometric surface of the target object, the ray detection interface returns a collision data structure. This collision data structure contains detailed information about the intersection point, including its world coordinates in the 3D virtual scene.
[0063] World coordinates are represented as floating-point triplets, typically denoted as (X, Y, Z), corresponding to three mutually perpendicular axes in the virtual scene's world coordinate system. These world coordinates precisely describe the absolute spatial position of a sampling point on the unoccluded surface of a target object within the virtual scene from the current camera's viewpoint. This intersection point is defined as the hit point. Each hit sampling ray uniquely corresponds to one hit point. The hit point is the precise sampling position of the visible surface of the target object, and its coordinate data serves as the fundamental input for subsequent screen-space projection and area calculations.
[0064] Taking the large tree behind the wall as an example, two sampling rays hit the visible parts of the tree crown through the hole in the wall. One sampling ray hit a leaf in the upper left corner of the crown, with world coordinates (X1, Y1, Z1). The other sampling ray hit a twig in the lower right corner of the crown, with world coordinates (X2, Y2, Z2). These two hit points together identify the two local surface locations of the tree that are actually visible from the current camera's perspective.
[0065] For example, in the case of the treasure chest behind the waterfall mentioned above, ten sampling rays hit different positions on the front of the treasure chest. Each sampling ray corresponds to a world coordinate of the hit point, which together constitute the set of spatial sampling points on the visible surface of the treasure chest.
[0066] Step S114: Obtain the world coordinates of each hit point, and then generate a set of hit point coordinates for the target object, which contains the world coordinates of each hit point. After obtaining the world coordinates of the hit points of all the hit sampling rays corresponding to the same target object, these world coordinate data are aggregated to generate a set of hit point coordinates that uniquely corresponds to the target object.
[0067] The hit point coordinate set is a data container used to store the world coordinates of all hit points of the target object in the current frame. Specific implementations of the hit point coordinate set include, but are not limited to, arrays, lists, vector containers, or other data structures capable of storing multiple 3D coordinate vectors. For example, in one implementation, the hit point coordinate set is implemented as a dynamic array, where each element is a 3D floating-point vector. In another implementation, the hit point coordinate set is implemented as a linked list structure, facilitating the dynamic addition of additional hit points generated by supplementary sampling in subsequent steps.
[0068] Taking the large tree behind the wall as an example, the set of hit point coordinates for the tree will contain the world coordinates of two hit points, namely (X1, Y1, Z1) and (X2, Y2, Z2). Similarly, in the example of the treasure chest behind the waterfall, the set of hit point coordinates for the chest will contain the world coordinates of ten hit points, corresponding to the various locations on the front of the chest hit by ten sampling rays. These two sets of coordinate data will be passed to subsequent steps to calculate the screen ratio and visibility of their respective target objects.
[0069] For objects in a scene that are not directly reached by any hit sampling ray, the set of their corresponding hit point coordinates is an empty set. The empty set also provides a clear quantitative basis for subsequent culling decisions, that is, the target object has no visible part in the current frame, and its screen ratio and visible ratio are both zero.
[0070] In the above embodiments, by identifying the target object, distinguishing between transparent and opaque objects to determine the occlusion state of the sampling rays, filtering the hit sampling rays, extracting the world coordinates of the hit points, and generating a set of hit point coordinates, the visibility state of the target object is transformed from a traditional binary judgment into a set of quantitative data that precisely describes the spatial position of its visible portion. The set of hit point coordinates serves as the basic input for subsequent calculations of screen ratio and visible proportion, providing objective data support for accurately assessing the visual contribution of the target object to the final image.
[0071] Based on any embodiment of the method in this application, determining the complete planar projection area of the target object in screen space includes: Step S121: Establish a planar coordinate system in the near plane, the planar coordinate system including a first coordinate axis and a second coordinate axis that are perpendicular to each other: To map the geometric existence of a target object in a 3D virtual scene to a 2D screen space, a unified projection reference plane needs to be determined first. This projection reference plane is chosen as the near plane of the camera. The near plane is the near clipping plane of the camera's view frustum, and the distance between it and the camera position is a known near plane distance. The spatial orientation of the near plane is perpendicular to the camera's orientation. Within the 2D plane defined by the near plane, a planar coordinate system is established. This planar coordinate system includes two mutually perpendicular coordinate axes, denoted as the first coordinate axis and the second coordinate axis. The intersection of the first and second coordinate axes is the origin of the coordinate system. This planar coordinate system is used to determine the specific position of subsequent projection points on the near plane. In one implementation, the first coordinate axis corresponds to the horizontal direction of the screen space, and the second coordinate axis corresponds to the vertical direction of the screen space. In another implementation, the axes of the planar coordinate system can be arbitrarily determined according to the local coordinate system of the near plane, as long as the first and second coordinate axes remain mutually perpendicular. The purpose of establishing this planar coordinate system is to provide a unified and clear numerical reference system for subsequent mapping from 3D vertex coordinates to 2D projection points, as well as for comparing the coordinate values and calculating the area of 2D projection points.
[0072] Step S122: Obtain the coordinates of multiple vertices of the axis-aligned bounding box of the target object, and project each vertex coordinate onto the near plane along the viewing direction of the camera position to obtain the two-dimensional projection point of the object corresponding to each vertex coordinate. After establishing a planar coordinate system in the near-plane, it is necessary to obtain the geometric extent of the target object in 3D space. To do this, an axis-aligned bounding box is obtained. An axis-aligned bounding box is a cuboid that tightly encloses the target object in the 3D virtual scene, with each edge of the cuboid parallel to the coordinate axes of the virtual scene's world coordinate system. The axis-aligned bounding box is defined by multiple vertices, typically eight, each with a 3D world coordinate. The vertex coordinates of the axis-aligned bounding box can be obtained directly from the game engine's scene management module or physics collision module, or they can be pre-calculated based on all the geometric surface vertices of the target object. Using an axis-aligned bounding box instead of the original complex geometric model of the target object for projection calculations can significantly reduce computational complexity while maintaining the accuracy of the culling decision.
[0073] After obtaining the coordinates of multiple vertices of the axis-aligned bounding box, these vertex coordinates are projected one by one onto the near plane along the line of sight from the camera position. Perspective projection is used here. Specifically, for each vertex coordinate, a straight line is generated connecting the camera position and the vertex, and the intersection of this line and the plane containing the near plane is calculated. The 3D world coordinates of this intersection point lie within the near plane. The 3D world coordinates of this intersection point are converted into 2D coordinates in the plane coordinate system, and the result is the 2D projection point of the object corresponding to that vertex. By performing the above projection operation on each vertex of the axis-aligned bounding box, multiple 2D projection points of the object, the same number as the number of vertices, can be obtained. Taking the large tree behind the wall as an example, the axis-aligned bounding box of the tree has eight vertices. Projecting these eight vertices onto the near plane yields eight 2D projection points of the object. These eight 2D projection points are discretely distributed within the near-plane projection area of the tree, collectively defining the outer contour of the projection range that the tree may occupy in screen space.
[0074] Step S123: Determine the minimum and maximum coordinate values on the first coordinate axis, and the minimum and maximum coordinate values on the second coordinate axis from the two-dimensional projection points of each object. After obtaining multiple 2D projection points of the objects, it is necessary to extract boundary values that define their overall distribution range from these projection points. To do this, all 2D projection points are traversed, and the coordinate values of each projection point on the first coordinate axis are read one by one. The minimum and maximum coordinate values are then found through comparison. Similarly, all 2D projection points are traversed, and the coordinate values of each projection point on the second coordinate axis are read one by one. The minimum and maximum coordinate values are then found through comparison. This process yields four extreme values: the minimum coordinate value on the first coordinate axis, the maximum coordinate value on the first coordinate axis, the minimum coordinate value on the second coordinate axis, and the maximum coordinate value on the second coordinate axis. These four extreme values collectively define the boundary of a rectangular region in the near plane. Since the four boundary lines of this rectangular region are parallel to the first and second coordinate axes respectively, this rectangular region is an axis-aligned rectangle. This rectangular region can precisely accommodate all the 2D projection points of the objects; that is, all 2D projection points of the objects fall within or on the boundaries of this rectangular region. Taking the large tree behind the wall as an example, eight two-dimensional projection points of the object are distributed in the near plane. The minimum and maximum coordinate values of the first coordinate axis, as well as the minimum and maximum coordinate values of the second coordinate axis, are found to form a rectangular area that exactly encloses all eight projection points. This rectangular area represents the complete projection coverage of the target object's axis-aligned bounding box in the near plane.
[0075] Step S124: Construct a two-dimensional bounding box based on the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis, and calculate the planar area of the two-dimensional bounding box as the projected area of the complete plane. After obtaining the four extreme values, a two-dimensional bounding box can be constructed. This bounding box is represented as a rectangular region in the near plane, with its four sides parallel to the first and second coordinate axes, respectively. The width of the bounding box is determined by the difference between the maximum and minimum coordinate values on the first coordinate axis, and the height is determined by the difference between the maximum and minimum coordinate values on the second coordinate axis. In one embodiment, the width of the bounding box is taken as the absolute value of the difference between the maximum and minimum coordinate values on the first coordinate axis, and the height is taken as the absolute value of the difference between the maximum and minimum coordinate values on the second coordinate axis.
[0076] Next, the planar area of the 2D bounding box is calculated. This is done by multiplying the width and height of the bounding box; the product is the planar area. This area is then used as the complete planar projection area of the target object. The physical meaning of the complete planar projection area is that it quantifies the size of the projected area that the target object would occupy in screen space if it were completely unobstructed by any other opaque objects. Taking the large tree behind the wall as an example, assuming the calculated 2D bounding box of the tree is 200 pixels wide and 40 pixels high, then the complete planar projection area of the tree in the current frame is 200 multiplied by 40, or 8000 square pixels. This area value will be used as the denominator in subsequent calculations of the visible proportions.
[0077] The method for calculating the planar area of a two-dimensional bounding box is not limited to multiplying the width and height. In other implementations, if the shape formed by the projection points is not a strictly axis-aligned rectangle, but rather uses other bounding shapes (such as a convex hull), the area can be calculated using appropriate geometric algorithms, such as polygon area formulas or scanline algorithms. However, regardless of the specific algorithm used, the goal is to obtain an area value that accurately reflects the full projection scale of the target object.
[0078] In the above embodiments, by establishing a planar coordinate system in the near plane, the axis-aligned bounding box vertices of the target object are projected onto the near plane and extreme values are extracted to construct a two-dimensional bounding box and calculate its planar area, thereby obtaining the complete planar projected area of the target object. This complete planar projected area serves as the theoretical projection scale of the target object in screen space when it is not occluded, providing an objective benchmark for subsequent comparison with the visible planar projected area to determine the visible proportion.
[0079] Based on any embodiment of the method in this application, determining the visible plane projection area corresponding to the set of hit point coordinates in screen space includes: Step S121': Establish a planar coordinate system in the near plane, the planar coordinate system including a first coordinate axis and a second coordinate axis that are perpendicular to each other: To map the geometric position of the actually visible portion of a target object from the current camera's perspective to a two-dimensional screen space, a projection reference plane and coordinate system identical to those used when calculating the full-plane projected area are required. This projection reference plane is chosen as the camera's near plane. The near plane is the near clipping plane of the camera's view frustum, and its spatial orientation is perpendicular to the camera's orientation. Within the two-dimensional plane defined by the near plane, a planar coordinate system is used, comprising two mutually perpendicular coordinate axes, denoted as the first coordinate axis and the second coordinate axis. The intersection of the first and second coordinate axes is the origin of the coordinate system. Using the same near plane and planar coordinate system as when calculating the full-plane projected area ensures that the full-plane projected area and the visible plane projected area are calculated in the same metric space, making them directly comparable. In one implementation, the first coordinate axis corresponds to the horizontal direction of the screen space, and the second coordinate axis corresponds to the vertical direction of the screen space. In another implementation, the axes of the planar coordinate system can be arbitrarily determined based on the local coordinate system of the near plane, as long as the first and second coordinate axes remain perpendicular to each other.
[0080] Step S122': Obtain each world coordinate point in the set of hit point coordinates, and project each world coordinate point onto the near plane along the line of sight of the camera position to obtain the corresponding visible two-dimensional projection point: After establishing a planar coordinate system in the near-plane, it is necessary to map the surface sampling points of the visible portion of the target object into this planar coordinate system. To do this, a set of hit point coordinates corresponding to the target object is obtained from the already generated set. Each world coordinate point stored in the hit point coordinate set represents a precise sampling position of the unoccluded portion of the target object's surface from the current camera's perspective. Each world coordinate point is represented as a floating-point triple, typically denoted as (X, Y, Z), corresponding to three mutually perpendicular axes in the virtual scene's world coordinate system.
[0081] After obtaining the set of hit point coordinates, each world coordinate point in the set is projected one by one onto the near plane along the line of sight from the camera position. This projection uses perspective projection, the same method used to align the projection axis with the bounding box vertices. Specifically, for each world coordinate point, a straight line is generated connecting the camera position and the world coordinate point, and the intersection of this line and the plane containing the near plane is calculated. The 3D world coordinates of this intersection point lie within the near plane. The 3D world coordinates of this intersection point are converted into 2D coordinates in the planar coordinate system, and the result is the corresponding visible 2D projection point. By performing the above projection operation on each world coordinate point in the hit point coordinate set, multiple visible 2D projection points, the same number as the number of hit points, can be obtained.
[0082] Taking the large tree behind the wall as an example, the tree's hit point coordinate set contains the world coordinates of two hit points. Projecting these two world coordinate points onto the near plane yields two visible 2D projection points. These two visible 2D projection points correspond to the projections of the two visible surface positions on the tree canopy hit by the two sampling rays onto the near plane. Similarly, in the example of the treasure chest behind the waterfall, the treasure chest's hit point coordinate set contains the world coordinates of ten hit points, corresponding to the various positions on the front of the treasure chest hit by ten sampling rays. Projecting these ten world coordinate points onto the near plane yields ten visible 2D projection points. If the hit point coordinate set is empty, meaning the target object has no visible portion in the current frame, this step does not generate any visible 2D projection points.
[0083] Step S123': Determine the minimum and maximum coordinate values on the first coordinate axis, and the minimum and maximum coordinate values on the second coordinate axis from each of the visible two-dimensional projection points: After obtaining multiple visible 2D projection points, it is necessary to extract boundary values from these points that define their overall distribution range. To do this, all visible 2D projection points are traversed, and the coordinate values of each projection point on the first coordinate axis are read one by one. The minimum and maximum coordinate values are then found through comparison. Similarly, all visible 2D projection points are traversed, and the coordinate values of each projection point on the second coordinate axis are read one by one. The minimum and maximum coordinate values are then found through comparison. Through this process, four extreme values are obtained: the minimum coordinate value on the first coordinate axis, the maximum coordinate value on the first coordinate axis, the minimum coordinate value on the second coordinate axis, and the maximum coordinate value on the second coordinate axis.
[0084] These four extreme values collectively define the boundary of a rectangular region in the near plane. Since the four boundary lines of this rectangular region are parallel to the first and second coordinate axes respectively, it is an axis-aligned rectangle. This rectangular region can precisely accommodate all visible 2D projection points; that is, all visible 2D projection points fall within or on the boundaries of this rectangular region. This rectangular region represents the complete projection coverage of the actual visible portion of the target object in the near plane from the current camera's perspective.
[0085] Taking the large tree behind the wall as an example, two visible 2D projection points are distributed in the near plane. The minimum and maximum coordinate values of the first coordinate axis, and the minimum and maximum coordinate values of the second coordinate axis, together form a rectangular area that exactly surrounds these two projection points. This rectangular area represents the projection coverage of the visible part of the tree in the near plane. Since only a very small part of the tree is visible, the area of this rectangular region is relatively small.
[0086] Step S124': Construct a rectangle based on the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis, and calculate the planar area of the rectangle as the projected area of the visible plane: After obtaining the four extreme values, a rectangle can be constructed based on them. This rectangle is represented as a rectangular region in the near plane, with its four sides parallel to the first and second coordinate axes, respectively. The width of the rectangle is determined by the difference between the maximum and minimum coordinate values on the first coordinate axis, and the height of the rectangle is determined by the difference between the maximum and minimum coordinate values on the second coordinate axis. In one embodiment, the width of the rectangle is taken as the absolute value of the difference between the maximum and minimum coordinate values on the first coordinate axis, and the height of the rectangle is taken as the absolute value of the difference between the maximum and minimum coordinate values on the second coordinate axis.
[0087] Next, the planar area of the rectangle is calculated. This is done by multiplying the rectangle's width by its height; the product is the rectangle's planar area. This area is then used as the visible plane projection area of the target object. The physical significance of the visible plane projection area lies in its quantification of the size of the projected area in screen space occupied by the portion of the target object that is not obscured by other opaque objects from the current camera's perspective.
[0088] If the set of hit point coordinates is empty, meaning the target object has no visible portion in the current frame, no visible 2D projection point is generated, and the visible plane projection area is zero. If the set of hit point coordinates contains only one world coordinate point, only one visible 2D projection point is obtained after projection. In this case, the width and height of the rectangle are both zero, and the visible plane projection area is also zero. In practical implementations, for cases where the number of hit points is less than three, a predefined small area value can be used as the visible plane projection area, or it can be directly treated as zero.
[0089] Taking the large tree behind the wall as an example, assuming the calculated rectangle corresponding to the tree is 20 pixels wide and 20 pixels high, the visible plane projection area of the tree in the current frame is 20 x 20, or 400 square pixels. This area value will be used as the numerator for subsequent calculations of the visibility ratio. The full plane projection area corresponding to the tree is 8000 square pixels. Dividing the visible plane projection area of 400 by the full plane projection area of 8000 gives the visibility ratio of the tree as 5%.
[0090] The method for calculating the area of a rectangular plane is not limited to multiplying the width and height. In other implementations, if the shape formed by the visible two-dimensional projection points adopts other enclosing shapes (such as a convex hull), the area calculation can employ corresponding geometric algorithms, such as polygon area formulas or scanline algorithms. However, regardless of the specific algorithm used, the goal is to obtain an area value that accurately reflects the projected scale of the visible portion of the target object.
[0091] In the above embodiments, by using the same near-plane and planar coordinate system as the full-plane projection area, the world coordinate points in the hit point coordinate set are projected onto the near-plane, and extreme values are extracted to construct a rectangle and calculate its planar area, thereby obtaining the visible plane projection area of the target object. This visible plane projection area accurately quantifies the projection scale of the actual visible part of the target object in screen space under the current camera view, providing an objective numerical basis for subsequent comparison with the full-plane projection area to determine the visible proportion.
[0092] Based on any embodiment of the method in this application, determining the screen ratio of the target object based on the projected area of the visible plane, the camera distance of the target object, and the near-plane distance includes: Step S131: Calculate the hit ray ratio of the target object, whereby the hit ray ratio is the ratio of the number of unblocked rays counted for the target object to the total number of sampled rays emitted for the target object. The hit ray ratio refers to the ratio of the number of unobstructed hit sampling rays emitted towards a target object to the total number of sampling rays emitted towards that target object. A hit sampling ray is a sampling ray emitted from the camera position that reaches the surface of the target object directly without being obstructed by any opaque object along its propagation path. During propagation, the sampling ray ignores objects marked as transparent, such as windows, water surfaces, or waterfalls, and continues propagating forward, only intersecting effectively when it encounters an opaque object. By comparing the straight-line distance of the sampling ray from the camera position to the point of impact on the target object with the distance from the first opaque obstruction along the sampling ray's direction to the camera position, it is possible to distinguish which sampling rays reach the target object directly and which are blocked by other opaque objects.
[0093] The total number of sampled rays refers to the total number of sampled rays emitted from the camera position into the scene that target the desired object. Sampled ray emission modes include generating a uniformly distributed array of rays within the camera's view frustum, projecting onto a grid based on screen pixels, or performing importance sampling on specific areas. The number of sampled rays can be pre-configured based on performance budget and accuracy requirements. The hit ray ratio reflects the proportion of the visible portion of the target object in the sampled space from the perspective of ray sampling. A higher ratio indicates a wider exposed surface area of the target object in the field of view. For example, with a large tree behind a wall, 40 sampled rays emitted from the camera position might only hit the tree directly, resulting in a hit ray ratio of 5%. Similarly, with a treasure chest behind a waterfall, all 10 sampled rays might hit directly, resulting in a hit ray ratio of 100%.
[0094] Step S132: Calculate the distance attenuation factor, which is the square of the ratio of the near-plane distance to the camera distance to the target object. The distance attenuation factor quantifies the degree to which the projected size of a target object is reduced in screen space due to the spatial distance between it and the camera. The distance attenuation factor is calculated by dividing the near-plane distance by the camera distance of the target object, and then squaring the quotient. The near-plane distance refers to the distance between the near clipping plane of the camera's view frustum and the camera position; this is a fixed value, such as 0.1 meters, once the camera parameters are determined. The camera distance of the target object refers to the straight-line distance between the target object's position in the 3D scene and the camera position; it can be taken as the distance from the center point of the target object's axis-aligned bounding box or the nearest point to the camera position.
[0095] The reason for squaring the distance ratio in this calculation is that, under the imaging rules of perspective projection, the linear dimension of an object on the projection plane is inversely proportional to the distance from the object to the camera. The projected area is affected by the reduction in both height and width, thus it is inversely proportional to the square of the distance from the object to the camera. For example, assuming the near-plane distance is 0.1 meters and the camera distance to the target object is 50 meters, the distance ratio is 0.002, which squares to 0.000004. This value indicates that the projected area of the target object at a distance of 50 meters is only 4% of its expected projected area at the near-plane distance.
[0096] Step S133: Calculate the visible area ratio, whereby the visible area ratio is the ratio of the projected area of the visible plane to the total area of the near plane. The visible area ratio refers to the ratio between the projected area of the visible plane and the total area of the near plane. The projected area of the visible plane represents the size of the projected region of the target object, which is not actually obscured by other opaque objects from the current camera's perspective, on the near plane. This area is calculated by projecting each world coordinate point in the hit point coordinate set onto the near plane and extracting the extreme values to construct a rectangle. If the hit point coordinate set is empty, the value of the projected area of the visible plane is 0. The total area of the near plane refers to the complete area of the near clipping plane of the camera's view frustum. It is related to the camera's field of view angle parameters and the near plane distance, forming the reference system for screen space.
[0097] The physical meaning of visible area percentage lies in normalizing the projected area of the visible part of a target object within the reference frame of the entire near-plane, thus deriving the relative scale of the visible part of the target object within the entire screen image. A larger visible area percentage indicates a more significant visual contribution of the target object to the image. Taking a large tree behind a wall as an example, with a visible plane projected area of 400 square pixels, and a screen resolution of 1920×1080, the total area of the near-plane is approximately 2,073,600 square pixels. The visible area percentage is approximately 0.000193, accounting for approximately 0.0193% of the entire screen image.
[0098] Step S134: Calculate the product of the hit ray ratio, the distance attenuation factor, and the visible area ratio, and use the calculation result as the screen ratio. After obtaining three intermediate data points—the percentage of hit rays, the distance attenuation factor, and the visible area percentage—the product of these three data points is used as the screen ratio of the target object. Screen ratio integrates information from three dimensions: the visible proportion at the sampled ray level, the attenuation effect at the distance level, and the relative scale at the projected area level. A higher screen ratio indicates a stronger visual presence of the target object in the current frame. Taking a large tree behind a wall as an example, with a hit ray percentage of 5%, a distance attenuation factor of 0.000004, and a visible area percentage of 0.000193, the product of these three values results in a very small screen ratio, reflecting that the actual visual weight of the tree in the image is so low as to be negligible.
[0099] In the above embodiments, by calculating the hit ray ratio, distance attenuation factor, and visible area ratio separately, and multiplying these three factors to obtain the screen ratio, the visual contribution of the target object is transformed into a precise quantitative value that integrates the visible sampling ratio, spatial distance attenuation, and screen space ratio. The combination of screen ratio data and visible ratio data provides dual objective basis for determining whether a target object should be removed.
[0100] Based on any embodiment of the method in this application, after removing the target object from the rendering operation of the current frame, the method further includes: Step S15: Record the frame number of the target object to be removed, as well as the camera position and orientation during removal. After removing a target object from the rendering operation of the current frame, the system records the culling frame number. The culling frame number is the identifier of the frame in the current rendering loop where the target object was determined to have a visual contribution below the culling threshold and was removed from the rendering operation. The frame number is typically an integer value that increments over time, used to uniquely identify each frame in the game's execution. By recording the culling frame number, the system can trace the specific time point of the culling operation in subsequent processing.
[0101] Simultaneously, the system records the camera position and camera orientation when the target object is culled. Camera position refers to the world coordinate position of the virtual camera in the 3D scene in the current frame, usually represented as a 3D floating-point vector, denoted as (X, Y, Z). Camera orientation refers to the viewing direction of the virtual camera in the current frame, which can be represented by Euler angles, including yaw, pitch, and roll angles, or by quaternions or direction vectors. Recording the camera position and orientation at the time of culling provides a spatial reference for subsequent determination of cache invalidation. When the camera moves or rotates significantly, the occlusion relationships of objects in the scene change, and previously culled objects may become visually significant in the image. In this case, their visibility needs to be reassessed, and the culling conclusions from previous frames cannot be reused.
[0102] In one implementation, the culling frame number, camera position, and camera orientation are stored in a cached data structure that uniquely corresponds to the target object. This cached data structure is created when the target object is first culled and is repeatedly accessed in subsequent frames for cache invalidation checks. In another implementation, this information is centrally stored in a global culling cache map, using the target object's unique identifier as the key and the corresponding cached information as the value. Regardless of the storage method used, it is essential to ensure that this cached data can be quickly queried and updated within each frame's rendering loop.
[0103] Step S16: In subsequent frames, determine whether the target object meets any cache invalidation condition. The cache invalidation condition includes: the difference between the current frame number and the discarded frame number is greater than or equal to a preset frame number threshold; the distance between the current camera position and the camera position at the time of discarding is greater than a preset distance threshold; and the angle between the current camera orientation and the camera orientation at the time of discarding is greater than a preset angle threshold. In subsequent frames after the culling status record is completed, the culling conclusion is not applied indiscriminately. Instead, before performing a visibility assessment on the target object in each frame, it is first determined whether the target object is within the cache validity period. This determination is made by checking three cache invalidation conditions one by one. If any one of the three conditions is true, the cache is determined to be invalid, and a complete visibility assessment of the target object needs to be performed again.
[0104] The first cache invalidation condition is that the difference between the current frame number and the culled frame number is greater than or equal to a preset frame count threshold. This condition defines the cache's validity period from a temporal perspective. The preset frame count threshold is a pre-configured integer value, such as 3, 5, or 10 frames. When the difference between the current frame number and the culled frame number reaches or exceeds this threshold, it indicates that enough frames have passed since the last culling operation, allowing sufficient time for cumulative changes in the scene state, and previously existing occlusion relationships may have become outdated. Therefore, the cache is deemed invalid. The specific value of the preset frame count threshold can be flexibly configured based on the game's actual frame rate, the movement speed of objects in the scene, and performance requirements. For high frame rate games or fast-moving scenes, a smaller frame count threshold can be configured to improve response sensitivity. For low frame rate games or static scenes, a larger frame count threshold can be configured to fully leverage the cache's performance optimization effects.
[0105] The second cache invalidation condition is that the distance between the current camera position and the camera position at the time of culling exceeds a preset distance threshold. This condition defines the cache's validity period in terms of spatial displacement. The preset distance threshold is a pre-configured floating-point value, such as 1 meter, 2 meters, or 5 meters, representing the upper limit of the allowable distance for camera movement. The Euclidean distance between the current frame's camera position and the camera position recorded at the time of culling is calculated. When this distance exceeds the preset distance threshold, it indicates that the camera has undergone significant displacement. As the camera moves, the relative positional relationships and occlusion relationships between objects in the scene change. Target objects that were previously occluded and only partially exposed may now have more visible surfaces due to camera movement, and their visual contribution may rise to a level worth rendering. Therefore, this cache is deemed invalid. The specific value of the preset distance threshold can be configured according to the scene scale, object size, and the game's visual style requirements.
[0106] The third cache invalidation condition is that the angle between the current camera orientation and the camera orientation at the time of culling is greater than a preset angle threshold. This condition defines the cache's validity period from the perspective of viewpoint change. The preset angle threshold is a pre-configured floating-point value, such as 15 degrees, 30 degrees, or 45 degrees, representing the upper limit of the allowable angle of camera rotation. The angle between the camera orientation of the current frame and the camera orientation recorded at the time of culling is calculated. In one implementation, the camera orientation is represented by Euler angles, and the angle is calculated by combining the differences in angles along each axis. In another implementation, the camera orientation is represented by quaternions, and the angle is calculated by taking the inverse cosine of the quaternion dot product. When the calculated angle is greater than the preset angle threshold, it indicates that the camera has undergone a significant rotation. Camera rotation changes the field of view; objects that were originally at the edge of the field of view or visible through small gaps may be completely removed from the field of view due to the viewpoint change, or conversely, become partially visible from being invisible. Therefore, the cache is deemed invalid. The specific value of the preset angle threshold can be configured according to the game's viewpoint change sensitivity requirements.
[0107] In other implementations, cache invalidation conditions may also include other types of triggering conditions. For example, when the target object itself moves, its visibility state naturally changes, which should also trigger cache invalidation. Similarly, when the spatial state of other objects in the scene changes, such as a door being opened or a wall being destroyed, causing a fundamental change in occlusion relationships, the relevant caches can also be invalidated in batches through an event-triggered mechanism.
[0108] Step S17: If none of the conditions are met, the target object is removed from the rendering operation of the current frame. If any of the cache invalidation conditions are met, the visibility of the target object is reassessed. After checking each of the three cache invalidation conditions, the corresponding processing branch is executed based on the detection results.
[0109] If none of the three cache invalidation conditions are met—that is, the difference between the current frame number and the culling frame number is less than a preset frame number threshold, the distance between the current camera position and the camera position at the time of culling is not greater than a preset distance threshold, and the angle between the current camera orientation and the camera orientation at the time of culling is not greater than a preset angle threshold—then the cache is still valid. In this case, the already recorded culling state is directly used to remove the target object from the rendering operation of the current frame. During the process of using the culling state, there is no need to re-execute the complete process of emitting sampling rays, calculating the set of hit point coordinates, calculating the full plane projection area and the visible plane projection area, calculating the visible ratio and screen ratio, and comparing thresholds; instead, the previously obtained culling conclusion is used directly. Taking the large tree behind the wall as an example, assuming the tree is determined to be culled in frame 100, the preset frame number threshold is 5 frames, the preset distance threshold is 2 meters, and the preset angle threshold is 30 degrees. In frame 102, the difference between the current frame number and the frame number is 2, which is less than 5 frames. The camera position has only moved 0.5 meters, which is less than 2 meters. The camera orientation was only tilted by 10 degrees, less than 30 degrees. At this point, none of the three conditions were met, and the cache was valid. The large tree was directly removed from the rendering operation of frame 102, saving the overhead of a full visibility assessment.
[0110] If any one of the three cache invalidation conditions is met, it indicates that the cache has expired, and the previously recorded culling status is no longer reliable. In this case, the recorded culling status is abandoned, and a complete visibility assessment process is re-executed for the target object. The process of re-assessing visibility includes: re-firing sampling rays to obtain the set of hit point coordinates, re-determining the full plane projection area and the visible plane projection area, re-determining the visibility ratio, re-determining the screen ratio, and re-comparing the screen ratio and visibility ratio with their respective culling thresholds. This re-assessment process can adapt to changes in scene state and arrive at rendering decisions that conform to the actual situation of the current frame.
[0111] Let's take the example of a treasure chest behind a waterfall. Assume the treasure chest is deemed visible in frame 1 and remains rendered. In a subsequent frame, it's judged to have a visual contribution below a threshold and is removed because the camera moves to a specific angle. The frame number at the time of removal is recorded as frame 200, and the camera position and orientation are also recorded simultaneously. In frame 203, the current frame number difference is 3 frames, which hasn't exceeded the preset frame number threshold. However, due to the player character quickly turning around, the camera orientation shifts by 50 degrees, exceeding the preset 30-degree angle threshold. In this case, the third cache invalidation condition is met, and the cache is deemed invalid. The complete visibility evaluation process is then re-executed for the treasure chest. If the new camera perspective causes the treasure chest to expose more visible surface, and its screen ratio or visible proportion exceeds the removal threshold, the treasure chest will be re-determined as visible and its rendering will resume from the current frame's rendering operation.
[0112] This caching mechanism, with its timeliness and spatial tolerance, avoids repeatedly performing computationally intensive visibility assessment processes on objects within a reasonable timeframe after they have been culled, thus saving significant CPU resources. Simultaneously, the cache invalidation condition settings ensure timely system responses to scene state changes, guaranteeing the accuracy of rendering decisions and the correctness of visual representation.
[0113] In the above embodiments, an adaptive culling state cache reuse mechanism is constructed by recording the culling frame number, camera position, and camera orientation of the target object, and determining whether the cache invalidation conditions of frame number, distance, or angle are met in subsequent frames. This mechanism effectively reduces the computational overhead of repeatedly performing visibility evaluation on objects with low visual contribution without affecting rendering correctness, thereby improving rendering performance and frame rate stability.
[0114] Based on any embodiment of the method in this application, after obtaining the set of hit point coordinates formed by the sampled rays that hit the target object, the method further includes: Step S111': Obtain the visual importance level of the target object, wherein the visual importance level is determined based on at least one of the following: object type of the target object, camera distance, or historical screen ratio. After obtaining the set of coordinates of the hit points formed by the sampled rays that hit the target object, the visual importance level of the target object is further obtained. Visual importance level is a quantitative or hierarchical indicator used to measure the importance of a target object in the current game scene. The higher the visual importance level, the more critical the target object is to the player's gaming experience. It should be handled more carefully when making rendering culling decisions to avoid any noticeable impact on the visual presentation due to its incorrect culling.
[0115] Visual importance levels can be determined based on the object type of the target object. Object type refers to the category to which the target object belongs in the game logic. Different object types have varying degrees of importance in gameplay. In one implementation, object types can include character types, vehicle types, building types, and decorative types. Character objects (e.g., player characters, enemy characters, non-player characters) typically have a direct impact on game progress, and their visual appearance is crucial to the player experience; therefore, they are assigned a high visual importance level. Vehicle objects (e.g., vehicles, aircraft) also have high importance in scenarios involving movement or combat. Decorative objects (e.g., roadside stones, flowers) have less impact on gameplay and can be assigned a lower visual importance level. The correspondence between object types and visual importance levels can be defined and maintained through a pre-configured mapping table. During actual runtime, the type label of the target object is read, and the corresponding visual importance level is obtained by querying the mapping table.
[0116] Visual importance can also be determined based on the camera distance of the target object. Camera distance refers to the straight-line distance between the target object's position in the 3D scene and the camera position. Because perspective projection follows the principle of near objects appearing larger and farther objects smaller, objects closer to the camera occupy a larger projection area on the screen, contributing more significantly to the visual impact of the image, and their detail also has a greater influence on the player's immersion. Therefore, closer target objects are typically assigned a higher visual importance level, while farther target objects are assigned a lower visual importance level. In one implementation, multiple distance ranges and corresponding visual importance levels can be preset. For example, a high level is assigned when the camera distance is less than 10 meters, a medium level between 10 and 50 meters, and a low level when the distance is greater than 50 meters. During runtime, the camera distance of the target object is calculated, and the corresponding visual importance level is determined based on the distance range it falls into.
[0117] The determination of visual importance level can also be based on the historical screen share of the target object. Historical screen share refers to the statistical value of the screen share of the target object calculated in previous frames. Screen share reflects the visual weight of the target object in the screen image. A target object with a high screen share in previous frames indicates that its contribution to the image over consecutive frames is significant. Even if the screen share temporarily decreases in the current frame due to partial occlusion or changes in viewing angle, it should still be conservatively excluded. Historical screen share can be calculated using various statistical methods, including but not limited to the average screen share of the previous 3 frames, the maximum screen share of the previous 5 frames, or a weighted moving average. In one implementation, the average screen share of the previous 3 frames is taken as the historical screen share. During runtime, the screen share records of the previous few frames are read from the historical data cache associated with the target object, the historical screen share value is calculated, and the corresponding visual importance level is determined according to a preset screen share range. For example, a historical screen share greater than 1% is assigned a high level, between 0.1% and 1% is assigned a medium level, and less than 0.1% is assigned a low level.
[0118] In other implementations, the determination of visual importance level can take into account multiple factors mentioned above. For example, the importance levels obtained from evaluating object type, camera distance, and historical screen ratio can be weighted and summed to obtain a comprehensive visual importance level. The weighting coefficients can be configured and adjusted according to the characteristics and performance requirements of the specific game project. Regardless of the determination method used, the visual importance level must be acquired or calculated in real time during the visibility evaluation process of each frame to reflect the latest state of the current frame.
[0119] Step S112': When the visual importance level is higher than a preset level threshold and the number of sampling rays in the hit point coordinate set is lower than a preset number threshold, additional sampling rays are emitted to the target object, and the coordinate points hit by the additional emitted sampling rays are added to the hit point coordinate set. After obtaining the visual importance level of a target object, it is determined whether to trigger a supplementary sampling process for that object. Supplementary sampling requires two conditions to be met simultaneously. The first condition is that the visual importance level is higher than a preset level threshold. The preset level threshold is a pre-configured level limit, for example, configured as "medium level". When the visual importance level of a target object is higher than this preset level threshold, it indicates that the target object has sufficient importance and is worth investing more computational resources to improve the accuracy of its visibility determination. For example, consider a large tree behind a wall. Assuming the tree is marked as a decorative object, the camera distance is 50 meters, and its historical screen share is extremely low, its visual importance level is determined to be low after comprehensive evaluation. In this case, the tree does not meet the supplementary sampling trigger condition. Conversely, consider a treasure chest behind a waterfall. Assuming the treasure chest is marked as an interactive object, the camera distance is 10 meters, and its visual importance level is determined to be high after comprehensive evaluation, the treasure chest meets the first trigger condition.
[0120] The second condition is that the number of sampled rays in the hit point coordinate set is lower than a preset threshold. The number of sampled rays refers to the number of unobstructed, direct-reaching sampled rays identified during the acquisition of the hit point coordinate set. This number reflects the sampling coverage density of the visible portion of the target object. Insufficient sampled rays may lead to inaccurate estimation of the spatial distribution of the visible portion of the target object, thus affecting the accuracy of calculating the projected area and visible proportion of the visible plane. The preset threshold is a pre-configured integer value, for example, 20 rays. When the number of sampled rays in the hit point coordinate set is lower than this threshold, it indicates that the current sampling density is insufficient to adequately describe the visible portion of the target object. For example, assuming only 10 sampled rays were initially emitted, and all 10 directly hit the treasure chest, the number of sampled rays is 10, lower than the preset threshold of 20. In this case, the treasure chest simultaneously meets both trigger conditions, and the supplementary sampling process is triggered. If 40 sampling rays are initially emitted and all hit directly, the number of sampling rays is 40, which is not less than the preset threshold. In this case, even if the visual importance level is high, supplementary sampling will not be triggered. Taking the large tree behind the wall as an example, if 40 sampling rays are initially emitted, and only 2 hit directly, the number of sampling rays is 2, which is less than the preset threshold. However, since the visual importance level of the large tree is low, the first triggering condition is not met, so supplementary sampling will not be triggered.
[0121] When both conditions are met, additional sampling rays are emitted towards the target object. The emission method of these additional sampling rays can be selected in various specific implementations. In one implementation, the emitted sampling rays originate from the camera position and are specifically directionally emitted towards the target object's axis-aligned bounding box or its known visible area. The number of additional sampling rays can be dynamically determined based on the visual importance level; for example, 40 rays for high importance and 20 rays for medium importance. In another implementation, the number of additional sampling rays is a pre-configured fixed value; for example, 30 additional sampling rays are emitted regardless of the visual importance level. In yet another implementation, the number of additional sampling rays is determined based on the difference between the number of sampling rays in the current hit point coordinate set and a preset number threshold, ensuring that the total number of sampling rays after supplementation reaches the preset number threshold.
[0122] The additional sampling rays emitted as supplementary emission also require a complete occlusion assessment process. Each supplementary sampling ray, emitted from the camera position, ignores transparent objects during propagation, only intersecting with opaque objects. For supplementary sampling rays that directly hit the target object, the world coordinates of the point of intersection with the target object's surface are obtained. These supplementary hit point coordinates are added to the original hit point coordinate set, thus updating the target object's hit point coordinate set. The updated hit point coordinate set contains more sampling points, more accurately reflecting the spatial distribution of the visible portion of the target object. The updated hit point coordinate set will participate in subsequent calculations, including determining the projected area of the visible plane, the visible ratio, the screen ratio, and the final culling decision.
[0123] Through the aforementioned supplementary sampling mechanism, for target objects with high visual importance but insufficient initial sampling, richer hit point data can be obtained with less additional computational overhead. This improves the accuracy of calculating their visibility ratio and screen occupancy, effectively reducing the risk of important objects being mistakenly removed. Meanwhile, for target objects with low visual importance, supplementary sampling is not triggered even if initial sampling is insufficient, avoiding unnecessary computational overhead and concentrating computational resources on more valuable objects.
[0124] In the above embodiments, by acquiring the visual importance level of the target object and supplementing it with additional sampling rays to expand the set of hit point coordinates when the level is high and the number of hit points is insufficient, differentiated sampling accuracy control for objects of different importance is achieved. This mechanism significantly improves the accuracy of visibility judgment for high-importance objects without increasing the processing overhead of low-importance objects, thereby effectively controlling computational costs while ensuring rendering quality.
[0125] Please see Figure 3According to one aspect of this application, an object rendering culling device includes: a coordinate set acquisition module 11, a visible ratio determination module 12, a screen ratio determination module 13, and a rendering culling module 14, wherein: the coordinate set acquisition module 11 is used to emit multiple sampling rays from the camera position, determine the target object hit by the sampling rays, and acquire a set of hit point coordinates composed of the sampling rays hitting the target object; the visible ratio determination module 12 is used to determine the complete plane projection area and the visible plane projection area corresponding to the target object and the hit point coordinate set in screen space, respectively, so as to determine the visible ratio of the target object based on the complete plane projection area and the visible plane projection area; the screen ratio determination module 13 is used to determine the screen ratio of the target object based on the visible plane projection area, the camera distance of the target object, and the near plane distance; the rendering culling module 14 is used to remove the target object from the rendering operation of the current frame when both the screen ratio and the visible ratio meet their respective culling thresholds.
[0126] Based on any embodiment of the device in this application, the coordinate set acquisition module 11 includes: a transmission path occlusion determination unit, used to determine the target object hit by any sampling ray, and determine whether the sampling ray reaching the target object is occluded by other objects in the scene on its transmission path; a hit ray determination unit, used to determine the hit sampling ray that reaches the target object and is not occluded; a hit point determination unit, used to determine the position where each hit sampling ray intersects with the target object as the hit point; and a hit point coordinate set generation unit, used to obtain the world coordinates of each hit point, and then generate a hit point coordinate set for the target object with the world coordinates of each hit point.
[0127] Based on any embodiment of the device in this application, the visible scale determination module 12 includes: a planar coordinate system establishment unit, used to establish a planar coordinate system in a near plane, the planar coordinate system including a first coordinate axis and a second coordinate axis that are perpendicular to each other; an object two-dimensional projection point acquisition unit, used to acquire the coordinates of multiple vertices of the axis-aligned bounding box of the target object, project each vertex coordinate onto the near plane along the viewing direction of the camera position, and obtain the object two-dimensional projection point corresponding to each vertex coordinate; a coordinate value determination unit, used to determine the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis from each object two-dimensional projection point; and a complete planar projection area calculation unit, used to construct a two-dimensional bounding box based on the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis, and calculate the planar area of the two-dimensional bounding box as the complete planar projection area.
[0128] Based on any embodiment of the device in this application, the visible ratio determination module 12 further includes: a visible two-dimensional projection point acquisition unit, used to acquire each world coordinate point in the hit point coordinate set, project each world coordinate point onto the near plane along the viewing direction of the camera position, and obtain a visible two-dimensional projection point corresponding to each world coordinate point; a visible coordinate value determination unit, used to determine the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis from each visible two-dimensional projection point; and a visible plane projection area calculation unit, used to construct a rectangle based on the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis, and calculate the plane area of the rectangle as the visible plane projection area.
[0129] Based on any embodiment of the device in this application, the screen ratio determination module 13 includes: a hit ray ratio calculation unit, used to calculate the hit ray ratio of the target object, wherein the hit ray ratio is the ratio of the number of unblocked rays counted for the target object to the total number of sampled rays emitted for the target object; a distance attenuation factor calculation unit, used to calculate the distance attenuation factor, wherein the distance attenuation factor is the square of the ratio of the near-plane distance to the camera distance of the target object; a visible area ratio calculation unit, used to calculate the visible area ratio, wherein the visible area ratio is the ratio of the projected area of the visible plane to the total area of the near plane; and a screen ratio calculation unit, used to calculate the product of the hit ray ratio, the distance attenuation factor, and the visible area ratio, and use the calculation result as the screen ratio.
[0130] Based on any embodiment of the apparatus in this application, the rendering culling module 14 further includes: a culling state recording unit, used to record the culling frame number of the target object and the camera position and camera orientation at the time of culling; a cache invalidation judgment unit, used to determine in subsequent frames whether the target object meets any cache invalidation condition, the cache invalidation condition including: the difference between the current frame number and the culling frame number is greater than or equal to a preset frame number threshold, the distance between the current camera position and the camera position at the time of culling is greater than a preset distance threshold, and the angle between the current camera orientation and the camera orientation at the time of culling is greater than a preset angle threshold; and a cache culling execution unit, used to remove the target object from the rendering operation of the current frame if none of the conditions are met, and to re-determine the visibility of the target object if any of the cache invalidation conditions are met.
[0131] Based on any embodiment of the device in this application, the coordinate set acquisition module 11 further includes: a visual importance level acquisition unit, used to acquire the visual importance level of the target object, wherein the visual importance level is determined based on at least one of the object type of the target object, camera distance, or historical screen ratio; a supplementary sampling judgment unit, used to supplementally emit additional sampling rays to the target object when the visual importance level is higher than a preset level threshold and the number of sampling rays in the hit point coordinate set is lower than a preset number threshold; and a hit point coordinate supplementation unit, used to add the coordinate points hit by the supplementally emitted sampling rays to the hit point coordinate set.
[0132] Another embodiment of this application also provides an object rendering culling device. For example... Figure 4 The diagram shows the internal structure of an object rendering culling device. This device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable, non-volatile storage medium stores an operating system, a database, and computer-readable instructions. The database stores information sequences, and when executed by the processor, these computer-readable instructions enable the processor to implement an object rendering culling method.
[0133] The processor of the object rendering culling device provides computational and control capabilities, supporting the operation of the entire device. The device's memory can store computer-readable instructions, which, when executed by the processor, cause the processor to perform the object rendering culling method of this application. The device's network interface is used for communication with a terminal.
[0134] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the solution of this application, and does not constitute a limitation on the object rendering culling device to which the solution of this application is applied. The specific object rendering culling device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0135] In this embodiment, the processor is used to execute... Figure 3 The specific functions of each module are described, and the memory stores the program code and various data required to execute the above modules or sub-modules. The network interface is used to realize data transmission between user terminals or servers. In this embodiment, the non-volatile readable storage medium stores the program code and data required to execute all modules in the object rendering culling apparatus of this application, and the server can call the server's program code and data to execute the functions of all modules.
[0136] This application also provides a non-volatile readable storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the object rendering culling method of any embodiment of this application.
[0137] This application also provides a computer program product, including a computer program / instructions that, when executed by one or more processors, implement the steps of the method described in any embodiment of this application.
[0138] In summary, this application breaks through the conservative principle of "rendering whatever is visible" in traditional solutions by quantitatively evaluating both screen ratio and visible ratio. It can identify and remove objects whose visual contribution to the image is below a threshold, thereby significantly reducing rendering overhead while ensuring user experience.
[0139] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The aforementioned storage medium can be a computer-readable storage medium such as a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM).
Claims
1. A method for object rendering culling, characterized in that, include: Multiple sampling rays are emitted from the camera position to determine the target object hit by the sampling rays, and the set of hit point coordinates formed by the sampling rays that hit the target object is obtained. The full-plane projection area and the visible-plane projection area corresponding to the coordinates of the target object and the hit point set in the screen space are determined respectively, so as to determine the visibility ratio of the target object based on the full-plane projection area and the visible-plane projection area; The screen ratio of the target object is determined based on the projected area of the visible plane, the camera distance of the target object, and the near-plane distance. When both the screen ratio and the visible ratio meet their respective culling thresholds, the target object is removed from the rendering operation of the current frame.
2. The method according to claim 1, characterized in that, Obtain the set of hit point coordinates formed by the sampled rays that hit the target object, including: Identify the target object hit by any sampling ray and determine whether the sampling ray reaching the target object is blocked by other objects in the scene along its emission path. Identify the hit sampling rays that reach the target object and are not obstructed; The position where each of the hit sampling rays intersects with the target object is determined as the hit point; Obtain the world coordinates of each hit point, and then generate a set of hit point coordinates for the target object, which contains the world coordinates of each hit point.
3. The method according to claim 1, characterized in that, Determining the complete planar projection area of the target object in screen space includes: A planar coordinate system is established in the near plane, the planar coordinate system including a first coordinate axis and a second coordinate axis that are perpendicular to each other; Obtain the coordinates of multiple vertices of the axis-aligned bounding box of the target object, and project each vertex coordinate onto the near plane along the line of sight of the camera position to obtain the two-dimensional projection point of the object corresponding to each vertex coordinate; Determine the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis from the two-dimensional projection points of each object; A two-dimensional bounding box is constructed based on the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis, and the planar area of the two-dimensional bounding box is calculated as the projected area of the complete plane.
4. The method according to claim 1, characterized in that, Determining the visible plane projection area corresponding to the set of hit point coordinates in screen space includes: A planar coordinate system is established in the near plane, the planar coordinate system including a first coordinate axis and a second coordinate axis that are perpendicular to each other; Obtain each world coordinate point in the set of hit point coordinates, and project each world coordinate point onto the near plane along the line of sight of the camera position to obtain the visible two-dimensional projection point corresponding to each world coordinate point; Determine the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis from each of the visible two-dimensional projection points; A rectangle is constructed based on the minimum and maximum coordinate values on the first coordinate axis and the minimum and maximum coordinate values on the second coordinate axis, and the planar area of the rectangle is calculated as the projected area of the visible plane.
5. The method according to claim 1, characterized in that, Determining the screen-to-body ratio of the target object based on the projected area of the visible plane, the camera distance to the target object, and the near-plane distance includes: Calculate the hit ratio of the target object, whereby the hit ratio is the ratio of the number of unblocked rays counted for the target object to the total number of sampled rays emitted for the target object; Calculate the distance attenuation factor, which is the square of the ratio of the near-plane distance to the camera distance of the target object; Calculate the visible area percentage, which is the ratio of the projected area of the visible plane to the total area of the near plane; Calculate the product of the hit ray ratio, the distance attenuation factor, and the visible area ratio, and use the calculation result as the screen ratio.
6. The method according to claim 1, characterized in that, After removing the target object from the rendering operation of the current frame, the process also includes: Record the frame number of the target object to be removed, as well as the camera position and camera orientation at the time of removal; In subsequent frames, it is determined whether the target object meets any cache invalidation condition. The cache invalidation condition includes: the difference between the current frame number and the discarded frame number is greater than or equal to a preset frame number threshold; the distance between the current camera position and the camera position at the time of discard is greater than a preset distance threshold; and the angle between the current camera orientation and the camera orientation at the time of discard is greater than a preset angle threshold. If none of the conditions are met, the target object is removed from the rendering operation of the current frame. If any of the cache invalidation conditions are met, the visibility of the target object is reassessed.
7. The method according to claim 1, characterized in that, After obtaining the set of hit point coordinates formed by the sampled rays that hit the target object, the method further includes: The visual importance level of the target object is obtained, and the visual importance level is determined based on at least one of the target object's object type, camera distance, or historical screen ratio. When the visual importance level is higher than a preset level threshold and the number of sampling rays in the hit point coordinate set is lower than a preset number threshold, additional sampling rays are emitted to the target object, and the coordinate points hit by the additional emitted sampling rays are added to the hit point coordinate set.
8. An object rendering culling apparatus, characterized in that, include: The coordinate set acquisition module is used to emit multiple sampling rays from the camera position, determine the target object hit by the sampling rays, and acquire the set of coordinates of the hit points composed of the sampling rays that hit the target object. The visible ratio determination module is used to determine the full plane projection area and the visible plane projection area of the target object and the hit point coordinate set in the screen space, respectively, so as to determine the visible ratio of the target object based on the full plane projection area and the visible plane projection area. The screen ratio determination module is used to determine the screen ratio of the target object based on the projected area of the visible plane, the camera distance of the target object, and the near plane distance. The rendering culling module is used to remove the target object from the rendering operation of the current frame when both the screen ratio and the visible ratio meet their respective culling thresholds.
9. An object rendering culling device, comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 7.
10. A non-volatile readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.