Skip to content

Merge very small varying-data islands at mesh export (fewer submesh fragments) - #1114

Merged
howetuft merged 3 commits into
LuxCoreRender:mainfrom
howetuft:fix/submesh-fragments
Nov 10, 2026
Merged

howetuft merged 3 commits into
LuxCoreRender:mainfrom
howetuft:fix/submesh-fragments

Conversation

@howetuft

@howetuft howetuft commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

One submesh per tiny island creates many small fragments on big models (CannelleEtFromage: 7692 submeshes, one plane alone 3321 islands of 2-4 triangles). Islands < 64 triangles are now unioned with an adjacent island via a second union-find pass. Result: 1733 submeshes (worst mesh 782). Verified: subdivBLC.blend still renders the full Suzanne, cube stays watertight (8 pts / 12 tris), crease export unchanged.

…sland

One submesh per tiny island creates many small fragments on big models
(each submesh is a full LuxCore mesh with per-point arrays); e.g.
CannelleEtFromage exported ~90k submeshes, one plane alone 84k islands of
2-4 triangles (dense split normals). Islands smaller than
MIN_ISLAND_TRIANGLE_COUNT (64) triangles are now unioned with an adjacent
island via a second union-find pass, collapsing chains in one go.

Merging never crosses a hard edge: the angle between the two sides' normals
must be below MIN_ISLAND_MERGE_COS_ANGLE (30 deg), otherwise flat faces
would be smoothed away (the default cube keeps its 6 face-islands and
correct normals). Merging otherwise only affects varying data gathered at
shared points (last write wins).

CannelleEtFromage now exports 2307 submeshes (was ~90k); default cube still
exports 6 submeshes with correct flat-face normals.

Also adds an env-gated (BLC_DEBUG_ISLANDS) island size histogram log.
@howetuft
howetuft force-pushed the fix/submesh-fragments branch from 919c002 to c4d8100 Compare November 8, 2026 22:00
…hapes

The watertight envelope is now built in C++ (SubdivShape, via
subdiv_envelope.cpp) from the meshes sharing the welded point buffer, so
convert() only exports the per-(material, island) submeshes (first submesh
owns the shared point buffer). Each submesh gets its material slot written
as triangle AOV layer MATERIAL_TRI_AOV_INDEX (= 2); object_cache sets
scene.shapes.<subdiv shape>.matslot = <material index> for subdiv shapes.
Generated images are not packed by default and image.pack() does not work
for them (also their pixels may not exist yet in background mode). Save them
to a temp file via image.save_render() instead, cached per image name, and
replace the assert in _save_to_temp_file with a proper RuntimeError.
@howetuft
howetuft merged commit 04d7e89 into LuxCoreRender:main Nov 10, 2026
2 checks passed
@howetuft
howetuft deleted the fix/submesh-fragments branch November 10, 2026 07:37
@howetuft
howetuft restored the fix/submesh-fragments branch November 11, 2026 08:51
howetuft added a commit to howetuft/BlendLuxCore that referenced this pull request Nov 11, 2026
…e per-submesh slot id in tri AOV layer 2

Ported from the feature branch onto current main (the rest of the branch
was already merged via LuxCoreRender#1114/LuxCoreRender#1115):

- set_matslot_on_subdiv_shape() walks a shape chain via the source links and
  sets matslot on the subdiv shape itself (the shape LuxCore reads matslot
  from), falling back to the final shape.
- Each submesh (material x island group) gets a unique slot id (group index
  + 1; +1 because the wireframe texture reads tri AOV layer 2 and skips an
  edge class when the value is 0), written to the tri AOV and passed as
  matslot to the subdiv shape, so the C++ subdiv envelope resplits per
  submesh instead of merging all islands of one material.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
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