Skip to content

Cull tiles based on current view #91

Description

@cmbruns

Feature Proposal: Spherical Boundary‑Based Tile Visibility & Overlap System

Summary

Introduce a unified geometric system for determining visibility, ordering, and overlap of image tiles—whether planar, equirectangular, Mercator, or dual‑fisheye—based entirely on boundary interactions on the unit sphere S2. This replaces ad‑hoc culling logic with a mathematically principled, Gauss/Stokes‑inspired approach using spherical polygons, great‑circle/small‑circle arcs, and spherical clipping.

This system supports:

  • Tile visibility determination
  • Tile priority ordering
  • Overlap area computation (steradians)
  • Progressive refinement
  • Exact clipping for equirectangular/Mercator
  • Approximate clipping for dual‑fisheye

Motivation

Tile visibility in vimage currently relies on projection‑specific heuristics. As we expand to:

  • equirectangular panoramas
  • Mercator tiles
  • dual‑fisheye tiles
  • perspective and stereographic displays

…the logic becomes brittle.

The sphere S2 is the natural domain for all panoramic imagery. If both tiles and display footprints are represented as spherical regions with boundaries, visibility becomes a pure geometric problem.

This proposal unifies all tile types under one spherical framework.


Core Idea

Represent every tile and every display footprint as:

  • A closed boundary on S2

    • Great‑circle arcs (planes through origin)
    • Small‑circle arcs (offset planes)
    • For dual‑fisheye: clipped arcs + approximated arcs
  • Optional interior point(s)

  • Optional Jacobian/tangent vectors for adaptive sampling

Then visibility reduces to:

  1. Hemisphere shortcuts
  2. Spherical boundary clipping
  3. Overlap polygon existence

No containment tests required.


Hemisphere Rules (Fast Path)

1. Display footprint ≥ hemisphere

If the display covers ≥ half the sphere (angular radius ≥ 90°):

  • Render all tiles
  • Culling is pointless because almost everything intersects the view

2. Tile ≥ hemisphere

If a tile covers ≥ half the sphere:

  • Always render it
  • Its boundary is too large to reliably cull

These two rules eliminate pathological cases and simplify logic.


General Case: Both < Hemisphere

When both tile and display footprints are strictly smaller than a hemisphere:

Use spherical boundary clipping.

This is the spherical analogue of polygon clipping in planar computational geometry.

Procedure

  1. Represent tile boundary as spherical arcs
  2. Represent display boundary as spherical arcs
  3. Compute all arc–arc intersections
  4. Walk boundaries to assemble the clipped spherical polygon
  5. If clipped polygon has ≥ 1 vertex → tile overlaps
  6. If clipped polygon is empty → tile does not overlap

This is a Gauss/Stokes‑style approach:
the boundary determines the interior.

No winding numbers.
No containment tests.
No special cases.


Boundary Types

Equirectangular tiles

  • Latitude edges → small circles
  • Longitude edges → great circles
  • Perfect spherical arcs
  • Perfect clipping

Mercator tiles

  • Latitude edges → small circles
  • Longitude edges → great circles
  • Perfect clipping

Dual‑fisheye tiles

  • Valid fisheye circle → perfect small circle
  • Outside region → arbitrary curve
  • Strategy:
    • Clip the tile boundary against the fisheye circle
    • Inside portion becomes exact small‑circle arcs
    • Outside portion approximated by short great‑circle segments
    • Clipping still works

This is where the “real non‑Euclidean computational geometry” happens.


Distance Thresholds (“Close = Hit”)

Even with exact arcs, we allow a tolerance:

  • Angular distance between two arcs < ε → treat as intersection
  • ε chosen using projection Jacobians
    • High Jacobian → larger ε
    • Low Jacobian → smaller ε

This ensures conservative visibility without expensive oversampling.


Optional: Overlap Area (Steradians)

Once clipping yields a spherical polygon, compute its area using:

  • Girard’s theorem
  • Or any spherical polygon area formula

This gives a priority metric for tile decoding and rendering.


Applications

1. Tile visibility

Exact and projection‑independent.

2. Tile ordering

Sort by:

  • Angular distance to view center
  • Overlap area
  • Jacobian magnitude (stability)

3. Progressive refinement

Decode central tiles first.

4. Real‑time updates

Only tiles near the view boundary need re‑evaluation.

5. Unified geometry

Same logic for:

  • perspective displays
  • stereographic displays
  • equirectangular tiles
  • Mercator tiles
  • dual‑fisheye tiles

Implementation Notes

Data structures

  • Spherical arc: plane normal + endpoints
  • Boundary: cyclic list of arcs
  • Tile: boundary + interior point + optional Jacobians
  • Display: same

Operations

  • Arc–arc intersection
  • Spherical clipping
  • Angular distance
  • Spherical polygon area

Performance

  • Hemisphere shortcuts eliminate most work
  • Clipping only needed for tiles near view boundary
  • Great‑circle intersections are extremely cheap
  • Small‑circle intersections are still closed‑form

Conclusion

This feature introduces a mathematically clean, projection‑agnostic, spherical geometry engine for tile visibility and overlap. It is robust, elegant, and future‑proof—exactly the kind of foundation vimage should have as it grows into more advanced panoramic and fisheye workflows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions