Map 3D: sort decal and see-through draws by model so they join #480

Closed
github-bot wants to merge 1 commit from github-bot/gh-480 into master AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 17:36 UTC · original
holdmysocks:six-map3d-latedraws → master · +26 −13 · 2 files · 1 commits · closed without merging

Decal and see-through meshes made 680 to 1,507 draw calls per frame in the city views, about a third of all draws. #477 joins them when they follow on in the same model and material, but they were sorted far to near by mesh, so meshes of different models interleaved and almost none followed on.

What changes:

  • Sort by model. Decals are sorted by layer, then opaque before blended (as before), then far to near by the centre of the model's placements. See-through meshes are sorted far to near the same way. Within a model they go in buffer order (by material, see #477), so a model's decals or glass of one material follow on and join into one draw.
  • Distance. The model's distance is taken from the centre of its normally drawn placements, or its own box centre when that is unknown. Before, the mesh centre was in the model's own space, so for placed models it was not the distance to the camera anyway.
  • What can change on screen: see-through surfaces that overlap within one model (glass in front of glass, glass over water) are no longer ordered by mesh. Between models the order stays far to near.
  • README updated.

Results: to follow from the second PC (A/B against master at the same four city views as #477).

**@⁠holdmysocks** on GitHub · 2026-11-27 17:36 UTC · [original](https://github.com/holdmysocks/SixNG/pull/480) `holdmysocks:six-map3d-latedraws` → `master` · +26 −13 · 2 files · 1 commits · closed without merging Decal and see-through meshes made 680 to 1,507 draw calls per frame in the city views, about a third of all draws. #477 joins them when they follow on in the same model and material, but they were sorted far to near by mesh, so meshes of different models interleaved and almost none followed on. What changes: - **Sort by model.** Decals are sorted by layer, then opaque before blended (as before), then far to near by the centre of the model's placements. See-through meshes are sorted far to near the same way. Within a model they go in buffer order (by material, see #477), so a model's decals or glass of one material follow on and join into one draw. - **Distance.** The model's distance is taken from the centre of its normally drawn placements, or its own box centre when that is unknown. Before, the mesh centre was in the model's own space, so for placed models it was not the distance to the camera anyway. - **What can change on screen:** see-through surfaces that overlap within one model (glass in front of glass, glass over water) are no longer ordered by mesh. Between models the order stays far to near. - README updated. Results: to follow from the second PC (A/B against master at the same four city views as #477).
Decal and see-through meshes were sorted far to near by mesh, which interleaved models and left almost every mesh its own draw. They are now sorted by layer, then far to near by the centre of the model's placements, and within a model in buffer order, so a model's decals or glass of one material follow on and join into one draw.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 17:43:49 +00:00
github-bot closed this pull request 2026-11-27 18:07:55 +00:00
Author
Owner

@⁠holdmysocks on GitHub · 2026-11-27 18:06 UTC · original

Closing: measured on the second PC this saves only 0 to 2 draws per frame, because a model's decal and see-through meshes almost all have their own material, so there is nothing to join. It also changes road decal layering: within a model the mesh order is the layer order, and the buffer's material order drew lower layers over higher ones (lane lines and tyre marks covered by pale grime). Glass and water did not change.

**@⁠holdmysocks** on GitHub · 2026-11-27 18:06 UTC · [original](https://github.com/holdmysocks/SixNG/pull/480#issuecomment-7225126737) Closing: measured on the second PC this saves only 0 to 2 draws per frame, because a model's decal and see-through meshes almost all have their own material, so there is nothing to join. It also changes road decal layering: within a model the mesh order is the layer order, and the buffer's material order drew lower layers over higher ones (lane lines and tyre marks covered by pale grime). Glass and water did not change.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.