Skip to content

perf(runner): backface-cull one-sided world faces - #29

Merged
tannevaled merged 1 commit into
mainfrom
backface-cull
Jul 6, 2026
Merged

perf(runner): backface-cull one-sided world faces#29
tannevaled merged 1 commit into
mainfrom
backface-cull

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

World surfaces are one-sided, but the renderer drew every PVS+frustum face including those whose plane the camera is behind (never visible), wasting per-face setup + fill pixels. Skip them with the standard side test (tyrquake R_RecursiveWorldNode's SURF_PLANEBACK cull): a face on plane (normal, dist) is visible iff dot(normal, viewOrigin) - dist is > 0 (Side 0) or < 0 (PLANEBACK). Planes load once at setup; the per-face test is a dot product.

Measured (lq_e0m1, water-room view, temp overdraw meter, since removed)

before after
world faces 340 274
world-fill pixels ~1.00M ~0.78M
overdraw 2.1× 1.6×

20% less world-fill work. Verified visually — the world renders identically, no holes (a wrong cull would punch holes). Adds faceFrontFacing + a unit test (front/back/PLANEBACK/offset-plane).

🤖 Generated with Claude Code

World surfaces are one-sided, but the renderer drew every PVS+frustum face
including those whose plane the camera is BEHIND (never visible), wasting both
per-face setup and fill pixels. Skip them with the standard side test
(tyrquake R_RecursiveWorldNode's SURF_PLANEBACK cull): a face on plane
(normal, dist) is visible iff dot(normal, viewOrigin)-dist is > 0 (Side 0) or
< 0 (PLANEBACK). Planes are loaded once at setup; the per-face test is a dot
product.

Measured in-browser (lq_e0m1, water-room view) with a temporary overdraw meter
(since removed): world faces 340 -> 274, world-fill pixels ~1.00M -> 0.78M,
overdraw 2.1x -> 1.6x -- ~20% less world-fill work. Verified visually: the
world renders identically, no holes (a wrong cull would punch holes).

Adds faceFrontFacing + a unit test (front/back/PLANEBACK/offset-plane cases).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit d302d19 into main Jul 6, 2026
7 checks passed
@tannevaled
tannevaled deleted the backface-cull branch July 6, 2026 14:56
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.

1 participant