Skip to content

Sort translucent quads in merged world sections - #338

Merged
InventivetalentDev merged 8 commits into
mainfrom
fix/world-transparency-sort
Oct 17, 2026
Merged

InventivetalentDev merged 8 commits into
mainfrom
fix/world-transparency-sort

Conversation

@InventivetalentDev

@InventivetalentDev InventivetalentDev commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Translucent blocks merged into one section could hide the farther surface: their quads drew in placement order, so a nearer quad could draw before a farther one and block it. In the labeled-panel page from #336, blue B disappeared behind red A. Translucent model and water pages in section meshes now draw their quads back to front, as vanilla sorts translucent terrain.

  • Perspective views sort quads by distance from the camera to each quad's centre and re-sort only when the camera enters another block. Vanilla does the same: VertexSorting.byDistance, re-sorted from LevelRenderer.scheduleTranslucentSectionResort when the camera's block changes. Rotating the camera never re-sorts.
  • Orthographic views sort by view depth and re-sort only when the view direction changes, so panning never re-sorts.
  • Ties keep the original quad order, and the index buffer uploads only when the order changes. Sort arrays are allocated on a page's first draw.
  • Depth writes are unchanged: translucent model pages keep them, as vanilla's translucent terrain does, and water keeps them off.
  • Picking resolves the original owning quad through the hit triangle's indexed vertex. Solid and cutout pages, fluid culling, worker geometry buffers, and bounds are unchanged.

The comparison page is provided by #336.

Sorting stays within each atlas page. Intersecting faces and faces in different pages or sections remain approximate; Three.js sorts those meshes as whole objects.

Validation:

  • Build, typecheck, yarn test (803 passed), yarn test:package (11), yarn test:api (18), yarn test:embed (15), and yarn test:node (6) pass locally.
  • Section tests cover distance order and block-crossing re-sorts in perspective views, direction-only re-sorts in orthographic views, stable ties, skipped uploads, transformed parents, both raycast triangles, depth writes per page type, and synchronous/worker parity.
  • check demo/transparency/ in Chrome reports PASS at every preset in both placement orders.

@github-actions github-actions Bot added library Public minerender package (packages/minerender) docs Documentation site, READMEs, and docs/ branches fix Bug fix (fix/ branches) labels Oct 17, 2026
@InventivetalentDev
InventivetalentDev marked this pull request as ready for review October 17, 2026 19:42
Base automatically changed from demo/world-transparency to main October 17, 2026 20:01
@InventivetalentDev
InventivetalentDev merged commit 705bc92 into main Oct 17, 2026
3 checks passed
@InventivetalentDev
InventivetalentDev deleted the fix/world-transparency-sort branch October 17, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation site, READMEs, and docs/ branches fix Bug fix (fix/ branches) library Public minerender package (packages/minerender)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant