I have a sphere with tiles. I need to check if a tile is visible or not. See the image. Tiles are red squares, "screen" is represented by yellow quad.

enter image description here

Currently, I calculate coordinates of tiles in spherical coordinates, convert them to Cartesian and project them from world to screen space. This works only partially (the missing tiles are correctly removed). However, this process has several false positives. For example tile in blue quad should not be visible, but its screen space bounding box overlaps with my virtual "yellow screen" => tile is visible.

How do I solve this problem correctly?

  • \$\begingroup\$ Do you care whether the tiles are on the front of the sphere from the current viewpoint? \$\endgroup\$
    – DMGregory
    Oct 30 '19 at 18:16
  • \$\begingroup\$ I have test for tiles that are on the back side of the sphere. I test them via dot product of the normal vector with viewer ray. So in theory for this, I do not care if the tile is on the front/back side of the sphere. Only requirement is if it is inside "screen". \$\endgroup\$ Oct 30 '19 at 18:27
  • \$\begingroup\$ Building a quad tree and subdividing your tiles further would give you a level more of accuracy, But, this I believe doesn't solve the issue, I assume you want the finest level of testing where literally no vertex on the tile is seen within the screen. Correct? \$\endgroup\$
    – ErnieDingo
    Oct 30 '19 at 21:04
  • \$\begingroup\$ @ErnieDingo This is achieved automatically by OpenGL frustrum culling. I need to do that manually and discard entire non-visible tile before rendering starts. So yes, no vertex of the tile is visible, however, it wont be visible regardles of my culling. \$\endgroup\$ Oct 30 '19 at 21:19
  • \$\begingroup\$ Can you elaborate a bit on what you're trying to do? Would a bounding box (not AABB) help? It seems like per-vertex frustum culling would solve the issue as it is written. \$\endgroup\$
    – Jay
    Nov 1 '19 at 1:37

You can use frustum culling to eliminate entities from the render queue based on the geometry. This will help reduce false positives as well as reduce the need to convert the geometry to screen space.

There is a good tutorial on how to implement view frustum culling here http://www.lighthouse3d.com/tutorials/view-frustum-culling/

  • 1
    \$\begingroup\$ This user is already using a form of frustum culling, by comparing a bounding box against the screen edges. Doing this in 3D does not solve the problem that sometimes a bounding box corner falls inside the frustum when the object's mesh is wholly outside it. \$\endgroup\$
    – DMGregory
    Oct 31 '19 at 10:01

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.