Summary of the use of different kinds of culling (culling) in the rendering process _ rendering pipeline

Source: Internet
Author: User
Tags pixel coloring
Premise

Recently in reading "Real-time Rendering" third edition, found that the different parts of the rendering pipeline specific meaning and the effective phase is not very clear, so did a little research, here to make a record. The elimination methods involved include: the removal of the viewport from the viewport and the removal of the back from the bottom to remove the depth of the removal of the following methods: The removal of the visual vertebral body

Occurs in the application phase (application Stage), generally by the game engine internal implementation or write their own corresponding algorithm to implement, running on the CPU. The crop is based mainly on the camera's field of view (field of view) and the distance between the near cut surface and the far trimmed surface, excluding objects outside of the visible range from rendering, the objects that are excluded will not enter the rendering geometry stage (Geometry Stage). As one of the most effective means to reduce the rendering consumption, the view of vertebral body elimination can greatly reduce the number of vertices and dough involved in rendering without affecting the rendering effect.

Depending on the implementation of the different engines, there may be some places to pay attention to in the real time. After testing, the unity of the default Shadowmap generation will significantly affect the scope of the removal of the vertebral body, for mobile platforms do not use real-time shadow, you can try to turn off the light shadow projection or remove the simple sheder in the fallback (usually contain shadowcaster) , the number of rendering surfaces of the same screen will be greatly reduced. Occlusion culling

Occurs in the application phase (application Stage), which is implemented by the game engine and runs on the CPU. Taking unity as an example, the scene occlusionculling data should be generated beforehand according to the position of the static object in the scene, and the other objects after the static object can be eliminated when running. Occlusion culling is one of the effective methods to reduce the rendering consumption, which can be combined with the treatment of the vertebral body and reduce the rendering consumption.

For the unity of occlusion in the use of exclusion and research, https://blog.csdn.net/cartzhang/article/details/52684127 summed up very well.

With the improvement of hardware technology, the GPU can now support the implementation of occlusion culling on hardware side without additional data in the application phase (after raster, pixel shader is superior to the end of rendering pipeline)
https://blog.csdn.net/cartzhang/article/details/72420731 mentioned in a paper

The modern GPU uses the early-z technique to perform a depth test between the vertex phase and the fragment phase (after raster, fragment), and if the depth test fails, the fragment phase calculation is not necessary. Therefore, there will be a great improvement in performance. However, the final ztest still need to be carried out to ensure that the final occlusion relationship will be the correct result. Viewport culling

Occurs in the geometry phase (Geometry Stage) Later, after the projection transformation, before the screen map, is a necessary part of the rendering pipeline. It is only returned to the grating stage when the entity is in full or in part within the specification cube. Among them, for entities that are entirely within the inner dimensions of the specification cube, the next stage is directly carried out; the entities that are completely outside the canonical cube are completely discarded; some are in the internal entity of the specification cube, then the corresponding cropping is based on the viewport, which may produce a new vertex in the process.

Through the viewport culling, the entity of the viewport can be discarded to reduce the consumption of the grating phase. Back remove

The reverse side culling is the elimination of the back-view entities because they do not contribute to the final rendered image. This is a simple and intuitive operation that operates on one polygon at a time. The basic principle of culling is to determine the orientation of the polygon first and compare it with the current observation direction.

More detailed description can be found in the 14th chapter of "Real-time Rendering", also can refer to the summary of shallow ink
https://blog.csdn.net/poem_qianmo/article/details/78884513

Unity in the back of the screen in the raster phase, the implementation of the vertex Shader, after the fragment Shader chip shader, through the Shader of the command to control the back of the elimination of the opening and closing,
The diagram on the Unity Handbook shows a clearer picture:

https://docs.unity3d.com/Manual/SL-CullAndDepth.html depth Culling

After fragment shader, the fusion phase at the end of the raster phase is performed, also known as depth detection (or Z-cache detection). Each time an entity receipts to the corresponding pixel, calculates the depth value of the entity at the pixel position, compares the value of the corresponding pixel in the depth cache, and updates the value in the depth cache if the newly computed depth is less than the depth in the cache, and the calculation is discarded if the depth value is greater than the value in the depth buffer. The value of the depth buffer does not need to be updated.

In the execution of depth culling, is already at the end of the rendering pipeline, all the color calculation has been completed, so the meaning of processing the visibility of the entity only the problem, for the consumption of the rendering is basically no impact, not the optimization needs to focus on the problem. In the consideration of optimization of rendering, it is necessary to study whether the "exclusion of vertebral body" and "occlusion culling" are normal operation in the project, and these two items will greatly affect the actual rendering consumption. Second, we need to consider the opening of the back removal, in the absence of a large number of one-sided models, the back culling can not affect the display of the premise of less processing half of the pixel coloring operation. Viewport culling and depth culling are inherent parts of the rendering pipeline and are not in the main area of optimization. Some interesting questions.

Unity in shader if you want to do depth-related calculations (depth of fields, soft particles, and other related effects), you need to take the depth of the current pixel value, so you need to use the Shadowcaster channel to ensure that the corresponding object appears on the read depth map (camera extra generated), Why not use the values in the depth cache directly from the current drawing process.

Because the values in the depth cache are not written until the raster fusion phase, Fragment shader is not readable in nature. This is the unity of the implementation is in the formal rendering by the camera before rendering a depth map, and set to the Shaderlab global variable, where only the object with the Shadercaster pass will be drawn in this depth map (here more fascinated, To generate a binding for a shadow projection and a depth diagram. In formal rendering, the corresponding depth value can be obtained from the global variable by the entity's position in the viewport.

Depending on whether the removal of the vertebral body and occlusion will take effect simultaneously, is it necessary to use it together?

Visual vertebral cutting is to exclude objects outside the viewing vertebral body from rendering, by the engine default processing (associated to some special cases may not be ideal, as mentioned in the Shadowmap generation), and occlusion culling is the camera can not see the object, which includes the view of the vertebral body within the scope of some objects, The two items could therefore take effect at the same time and in most cases should be used together.
A picture in the RTR3 is clearly described:

Another recommendation of "Real-time Rendering" third edition this book, for the summary of the rendering process is very in place, is a prerequisite for the introduction of the bibliography, I read after a great benefit, recommend interested students can find the corresponding resources to read, Also recommend the shallow ink big RTR3 reading summary https://blog.csdn.net/poem_qianmo?viewmode=contents.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.