Skip to content

Honor camera near/far and report the Far Limit as Miss Depth - #385

Merged
tarcila merged 1 commit into
next_releasefrom
camera-near-far-miss-depth
Nov 2, 2026
Merged

tarcila merged 1 commit into
next_releasefrom
camera-near-far-miss-depth

Conversation

@jeffamstutz

Copy link
Copy Markdown
Collaborator

Summary

ANARI 1.1 defines near/far clip distances on perspective and orthographic cameras, but VisRTX ignored them. The spec also never says what channel.depth holds for a pixel with no hit, and the RTX renderers disagreed on it:

  • fast, interactive and default left FLT_MAX.
  • debug and quality wrote the primary ray's t.upper. A cutting plane could shorten that to the cut distance, or to 0.

This PR makes them consistent:

  • Clip planes: cameras read near/far as clip planes measured from position along direction, and every primary ray is bounded by them. Surfaces and volumes outside the range are clipped.
  • Miss Depth: a pixel with no hit reports its ray's Far Limit:
    • far / cosθ for perspective;
    • exactly far for orthographic;
    • ray.tmax for the ray-buffer camera;
    • FLT_MAX when nothing bounds the ray, which matches what apps see today by default.
  • Cutting planes no longer change what a miss reports.
  • Invalid ray buffer: it now misses with an empty range at FLT_MAX instead of [0, 0].
  • Invalid near/far: a pair that breaks the spec's rules (0 < near < far perspective, 0 ≤ near < far orthographic) produces a warning and is ignored. A value left unset is always valid.
  • test renderer: reports the far limit instead of a hard-coded 1.0.

ADR 0011 records the design choices: treating far as a plane rather than a sphere, and FLT_MAX rather than +inf when far is unset. The render-pipeline glossary gains Miss, Far Limit and Miss Depth.

The GL device is out of scope: its depth channel is window-space [0,1].

Testing

  • TestCameraNearFar runs against the default, debug, fast, interactive and quality renderers. It covers:
    • no clipping when far is unset (misses report FLT_MAX);
    • perspective far (far sphere clipped, misses report far / cosθ) and perspective near;
    • orthographic far, and orthographic near = 0;
    • cutting-plane misses;
    • ray-buffer ray.tmax, and the invalid ray buffer;
    • invalid near/far pairs (warning, no clipping).
  • All 54 RTX API test binaries pass locally.

ANARI 1.1 gives perspective and orthographic cameras `near`/`far` clip
distances but VisRTX ignored them, and the spec never says what
`channel.depth` holds for a pixel with no hit. The renderers disagreed:
fast/interactive left FLT_MAX, while debug/quality wrote the primary ray's
`t.upper`, which a cutting plane could shorten to the cut distance (or 0
for a ray that never enters the visible half-space).

Cameras now read `near`/`far` as clip planes measured from `position` along
`direction`, and every primary ray is bounded by them. A Miss reports that
ray's Far Limit: the distance along it to the far plane (far / cos for
perspective, exactly far for orthographic), the ray buffer's `ray.tmax`, or
FLT_MAX when nothing bounds the ray. Cutting planes no longer change what a
Miss reports. An invalid ray buffer now misses with an empty interval at
FLT_MAX instead of [0, 0]. Invalid near/far pairs warn and are ignored.

ADR 0011 records why `far` is a plane and why unset `far` reports FLT_MAX
rather than +inf; the render-pipeline glossary gains Miss, Far Limit and
Miss Depth. TestCameraNearFar covers every renderer subtype.
@jeffamstutz
jeffamstutz requested a review from tarcila October 31, 2026 04:14
@tarcila
tarcila merged commit 4ce0fee into next_release Nov 2, 2026
8 checks passed
@tarcila
tarcila deleted the camera-near-far-miss-depth branch November 2, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants