Skip to content

B-rep inspector: shade flat faces flat under the orthographic camera - #102

Merged
andrinr merged 2 commits into
mainfrom
fix/brep-inspector-artifacts
Oct 23, 2026
Merged

andrinr merged 2 commits into
mainfrom
fix/brep-inspector-artifacts

Conversation

@andrinr

@andrinr andrinr commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Fixes the shading artifacts in the B-rep inspector on scenes/starter.py: glows on flat faces, a wrinkle on the blend around the fin-root pocket, and streaks on the left pin.

Cause. The inspector's faces replace the raymarched solid: the solid is hidden and depth is cleared. So neither depth fighting with the SDF surface nor the AO and outline passes play a part. With the payload intercepted, the glows appeared with the served corner normals and never with flat facet normals. There were two causes:

  1. fs_brep took its eye vector from the camera point, normalize(camera_pos - world). The viewer's default orthographic projection has parallel rays, so that vector varied across a plane, and a flat face shaded as a radial gradient. The overlay uniform gains view_dir: the camera's forward axis, with w = 1 when orthographic. The block grows from 112 to 128 bytes. fs_brep uses that direction under orthographic projection and the eye point under perspective. The static bundle is rebuilt.
  2. The corner normals served by diff-brep had mixed signs within a triangle and stepped on blends. That is fixed in andrinr/diff-brep#18.

Verified

  • At identical camera views before and after (origin/main with diff-brep main vs this branch with diff-brep#18): the plane glows and pin streaks are gone, and the pocket wrinkle is reduced.
  • tests/viewer/test_brep_inspector.py: 11 passed. vitest 717 passed, tsc clean.
  • e2e brepInspector.spec.ts and gpu.spec.ts pass.
  • A fresh vite build reproduces the committed bundle.

Left

  • A thin light line on the blend along the wall base. It follows a real fillet that the raymarched solid shows too.
  • Edge strokes look dashed at the pin rim and base (edge-versus-face depth nudge).
  • The blend face spans areas that are geometrically planar, which is diff-brep face segmentation.

🤖 Generated with Claude Code

andrinr and others added 2 commits October 21, 2026 22:12
The face shader took its eye vector from the camera *point*,
normalize(camera_pos - world). Under an orthographic projection, the
viewer's default, every ray is parallel to the view axis, so that vector
varied across a plane and a flat face shaded as a radial gradient,
brightest where the plane passes nearest the eye: the pink "glow" on the
starter's back wall.

The overlay uniform gains `view_dir` (camera forward axis, w = 1 when
orthographic; the block grows 112 -> 128 bytes), and fs_brep uses that
direction under an orthographic projection and the eye point under a
perspective one.

The other half of the starter's artifacts was in the corner normals the
private tier serves: mixed-sign corners on planes, and per-corner blend
normals that stepped. That is fixed in diff-brep (branch
fix/corner-normal-orientation).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tifacts

# Conflicts:
#	cadjoint/viewer/static/assets/main-0Bz4AUvN.js
#	cadjoint/viewer/static/assets/main-CWRSwsGN.js
#	cadjoint/viewer/static/assets/main-CzjXYnhe.js
#	cadjoint/viewer/static/index.html
@andrinr
andrinr merged commit 750f4c3 into main Oct 23, 2026
5 checks passed
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