Skip to content

TESRs Translucency Sorting#1384

Open
Ruling-0 wants to merge 6 commits intomasterfrom
te-ordering
Open

TESRs Translucency Sorting#1384
Ruling-0 wants to merge 6 commits intomasterfrom
te-ordering

Conversation

@Ruling-0
Copy link

@Ruling-0 Ruling-0 commented Feb 13, 2026

Due to how TESRs are currently handled, they are not included in translucency sorting for blocks. This PR makes two key changes to add this:

  • When building the chunk, iterate through blocks towards the camera instead of from origin to max. This means the TESRs are already likely to be sorted in the correct order, while using the same number of iterations. I don't think this should have any measurable performance cost unless the function calls I used for cleanliness introduce noticeable overhead.
  • When rendering TESRs, if Translucency Sorting is enabled, non-zero render passes will sort the provided entity lists by distance squared from the camera. To mitigate foreseeable performance issues, only TESRs renderable this pass are copied and sorted, and the above change should mean most of the data is already somewhat sorted (exception being stale and close chunk builds).

Tested in game and can confirm translucent TESRs now consistently render in the correct order.

Critically, this only works for TESRs closely tied to the coordinates of the underlying TE. Adding translucency sorting for all TESRs would probably require much more work in redirecting all renderTileEntity draws so they can be later sorted.

@mitchej123 mitchej123 requested a review from embeddedt February 13, 2026 18:35
Copy link
Collaborator

@embeddedt embeddedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to the block iteration order significantly complicates the core meshing loop (which is a hot path), and is unlikely to be beneficial to visuals in many scenarios, as chunks do not get remeshed when the camera moves, only when blocks within them change.

Sorting the TEs in CeleritasWorldRenderer on each frame makes more sense and I'm ok with this change. Really you need to sort the emitted geometry, not just render the TEs in a given order, but that is probably difficult to do with 1.7.10 since everything uses direct GL calls.

@Ruling-0 Ruling-0 requested a review from embeddedt February 14, 2026 01:18
@Ruling-0
Copy link
Author

The change to the block iteration order significantly complicates the core meshing loop (which is a hot path), and is unlikely to be beneficial to visuals in many scenarios, as chunks do not get remeshed when the camera moves, only when blocks within them change.

Sorting the TEs in CeleritasWorldRenderer on each frame makes more sense and I'm ok with this change. Really you need to sort the emitted geometry, not just render the TEs in a given order, but that is probably difficult to do with 1.7.10 since everything uses direct GL calls.

Makes sense. I've reverted the iteration order changes. Agree on needing to sort the emitted geo, but I think this is at least good fairly often as many TESRs are closely located with the block.

@mitchej123
Copy link
Collaborator

Can you run a profile of this vs before in a TE heavy world?

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.

3 participants