Skip to content

feat(sdf3d): triplanar PBR texture maps (albedo/metallic/roughness/normal/emission) - #355

Merged
jeffcrouse merged 1 commit into
mainfrom
feat-sdf3d-triplanar-pbr
Aug 16, 2026
Merged

feat(sdf3d): triplanar PBR texture maps (albedo/metallic/roughness/normal/emission)#355
jeffcrouse merged 1 commit into
mainfrom
feat-sdf3d-triplanar-pbr

Conversation

@jeffcrouse

Copy link
Copy Markdown
Member

Adds PBR material-map support to SDF3D — so a raymarched metaball can carry real surface detail (normal / roughness / metallic / albedo / emission) and keep the gooey smooth-union merge. Triplanar-projected in the SDF's local space, so no UVs are needed and the texture survives the merge.

What it adds

  • 5 texture INPUT ports mirroring Blender's Principled BSDF core: Base Color · Metallic · Roughness · Normal · Emission. Wire an Image/Video node into any of them.
  • Two params: tex_scale (tiling) and normal_strength.
  • WGSL: triplanar sampling + a whiteout normal blend (Ben Golus) so the normal map genuinely perturbs the lit surface; modulates base_color/normal/roughness/metallic/emission at the ray hit.
  • Unwired ports fall back to neutral 1×1 defaults → zero cost, byte-identical to the old look when unused (triplanar is gated off).

Scope / design

  • Entirely self-contained in sdf3d.cpp — no renderer changes. (Render3D only binds group 0 for custom raymarch fragments, so SDF3D owns its pipeline + a single group-0 bind group, extended 4→10 entries and rebuilt when an input's view changes.)
  • Bug fixed along the way: a disconnected texture port surfaces a non-null 1×1 default view (not nullptr); a port now counts as connected only when it supplies a real (>1×1) texture, else triplanar would wrongly turn on and a black default albedo would zero untextured SDFs.

Verification

Built locally and tested on the blob demo: the hero metaball renders as a bump-textured, PBR-lit surface with the gooey merge intact, while untextured metaballs light exactly as before.

Follow-ups (not in this PR): AO + height ports; possibly an ADR note for the operator feature.

🤖 Generated with Claude Code

…rmal/emission)

SDF3D can now take PBR material maps, projected triplanar in the SDF's local
space — so a raymarched metaball gets real surface detail (normal/roughness/
metallic/albedo/emission) AND keeps the gooey smooth-union merge (no UVs needed).

- Five texture INPUT ports mirroring Blender's Principled BSDF core: Base Color,
  Metallic, Roughness, Normal, Emission. Wire an Image/Video node into any of
  them; unwired ports fall back to neutral 1x1 defaults, so untextured SDF3D is
  the old look at zero cost (triplanar is gated off).
- WGSL: triplanar sample + a whiteout normal blend (Ben Golus) so the normal map
  perturbs the lit surface; modulates base_color/normal/roughness/metallic/
  emission at the ray hit. Two params: tex_scale (tiling) + normal_strength.
- C++: repeat sampler + 5 fallback textures; group-0 bind group extended 4->10
  entries and rebuilt when an input's view changes. Self-contained in SDF3D
  (Render3D only binds group 0 for custom raymarch fragments — no renderer change).
- A port counts as connected only when it supplies a real (>1x1) texture: a
  disconnected texture port surfaces a non-null 1x1 default view, which would
  otherwise enable triplanar and zero the surface to black.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QB6eSNJE55ru3g4vsL77GT
@jeffcrouse
jeffcrouse enabled auto-merge (squash) August 16, 2026 15:53
@github-actions

Copy link
Copy Markdown
Contributor

Production gate (core): ✅ PASS

  • 83/83 tests passed (0 failed) in 16.529s

@jeffcrouse
jeffcrouse merged commit 7e5d084 into main Aug 16, 2026
10 of 11 checks passed
@jeffcrouse
jeffcrouse deleted the feat-sdf3d-triplanar-pbr branch August 16, 2026 20:26
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