3
\$\begingroup\$

quad or plane

In the above picture, when the left camera shows two small parts of the quad, all of that is rendered (it can be a very large quad). But in the right one only two small parts of it is rendered. Which of them has better performance?

On the other hand if camera rotates by 180 degrees then what? plane seems to have more vertices to be loaded than the quad.

What the overall decision should be? using quads or planes?

\$\endgroup\$
  • 2
    \$\begingroup\$ Are we really talking about planes*? I can only see bigger quads and smaller quads. Moreover your picture does not look like occlusion culling but rather like frustum culling. Can you clarify your question please? * plane is infinite \$\endgroup\$ – wondra Jan 24 '16 at 10:49
  • \$\begingroup\$ @wondra Yeah it's about the size and count. As you know in unity there's a plane object which consists of 100 quads. Yeah the picture seems to be frustum culling but I mean occlusion culling. docs.unity3d.com/Manual/OcclusionCulling.html \$\endgroup\$ – Mahdyfo Jan 24 '16 at 11:42
2
\$\begingroup\$

Unity's built-in frustum and occlusion culling features work on a per-renderer level. They'll disable the rendering of whole objects that can't be seen, but they don't select individual triangles to cull out of a single mesh.

In both your examples above, the full mesh will be processed by the GPU, because at least part of it is visible.

The extra vertices of the "plane" primitive are unlikely to give any noticeable performance impact unless you're rendering very many of them (modern game engines and GPUs are built to handle character and environment models which are far more complex than this!) so use whichever primitive is most convenient for what you need it to do.

Note that in the two cases you showed, it's really clipping that's at work, not culling. Clipping is the stage in the graphics pipeline that removes triangles (and parts of triangles) that are outside the rendering viewport and the near & far planes. So in both cases, your fragment shader is only being invoked for the pixels of each mesh which are actually in front of the camera. The rest of the surfaces are discarded after some (usually quite cheap) vertex transformations to determine they're outside the rendered area.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ When using "clipping", does GPU actually process the whole mesh but not display far tris? or it doesn't process far triangles at all? \$\endgroup\$ – Mahdyfo Jan 24 '16 at 16:28
  • 1
    \$\begingroup\$ @meh The GPU transforms every vertex into normalized device coordinates, and checks each triangle to see if it is wound the right way (to discard back faces), and if any part of it overlaps the rendering viewport. Only the portion of the triangle that is actually within the rendering frustum gets rasterized into pixels for pixel/fragment-shading (and early-Z can discard some of these too). So yes, the GPU processes the whole mesh, but there are degrees of processing, and the expensive rasterization & shading is skipped in most cases where it's unnecessary. \$\endgroup\$ – DMGregory Jan 24 '16 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.