Skip to content

Translucency Sorting With Quad Splitting #2993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: dev
Choose a base branch
from

Conversation

douira
Copy link
Collaborator

@douira douira commented Jan 24, 2025

  • Fixes translucency sorting for geometry that is intersecting or otherwise unsortable by splitting quads in the partition tree.
  • Introduces a setting with the states "off", "safe", "unlimited" that controls to which degree quads are split. The default is "safe", where it doesn't disable normal quantization and limits how many quads can be generated compared to the original number. (i.e. the geometry amplification is capped)
  • Removes some unnecessary classes from the translucent data class hierarchy
  • Simplifies vertex/quad count handling and translucent data object construction
  • Reorders translucent sorting to be before meshing so that modifications to meshing can be performed
  • Refactors TQuad construction to happen mostly in its own class

A 1.21.1 version of this patch is available at https://github.com/douira/sodium/tree/1.21.1/translucent-quad-splitting (currently outdated)

Fixes #2943

overview
split

@jellysquid3
Copy link
Member

Also fixes an old mistake in the sort triggering code in the form of a wrong equals implementation on AlignableNormal.

Would it make sense to pull this patch out of this pull request so we can backport it? I'm not sure what it is breaking exactly.

@douira
Copy link
Collaborator Author

douira commented Jan 24, 2025

It does break things that require sort triggering on unaligned normals but it's unlikely anyone would notice unless the geometry is particularly weird. It only becomes more noticeable with this patch because previously the partition tree wouldn't generate unaligned partition (i.e. triggering) planes, and unaligned trigger planes were only generated by the super rarely used dynamic topo sorting mode.

I could split it out if you'd merge such a fix before 0.7, which is when I'd expect this to be ready for as a whole.

@muzikbike
Copy link
Contributor

Does this fix #2943? May be worth marking as such if so.

@muzikbike
Copy link
Contributor

Does this also fix #2802? Images posted in the discord thread certainly appear to imply so.

@jellysquid3
Copy link
Member

Does this also fix #2802?

Not completely. This only splits geometry based on the information available in a per-chunk basis. There is no splitting that happens across chunk boundaries, so any over-sized model with translucent geometry will render incorrectly if it crosses into another chunk. Likely the problem will never be fixed, since it would complicate render code dramatically for what is arguably a broken model.

@douira douira force-pushed the translucent-quad-splitting branch from db29175 to 4cfb2d4 Compare February 16, 2025 00:32
@douira douira force-pushed the translucent-quad-splitting branch 2 times, most recently from 67411df to d8ca421 Compare February 27, 2025 15:14
@douira douira force-pushed the translucent-quad-splitting branch from d8ca421 to 1044cdb Compare March 6, 2025 15:54
@douira douira force-pushed the translucent-quad-splitting branch from a34bac3 to c84be9c Compare March 14, 2025 16:39
@douira douira marked this pull request as ready for review March 14, 2025 16:58
@douira
Copy link
Collaborator Author

douira commented Mar 14, 2025

This is ready for review and merging. No open in-scope issues found during testing remain.

Note that the bug fix PR #3033 is included in this for testing reasons and once it gets merged into upstream I'll drop it from this.

@douira douira force-pushed the translucent-quad-splitting branch from 5343d79 to 0d11b5f Compare April 6, 2025 12:41
@douira douira force-pushed the translucent-quad-splitting branch from 0d11b5f to 959498e Compare April 21, 2025 18:55
@douira douira added this to the Sodium 0.7 milestone May 29, 2025
douira added 9 commits May 29, 2025 23:58
…ns instead of using instanceof

Signed-off-by: douira <douira100@gmail.com>
…ome bugs around quad count handling and quad init
…update logic, fix split case logic to take on-plane vertices into account
… later would not be added to the triggering system even though they should have been, this was caused by a buggy equals implementation in AlignableNormal.

remove AlignableNormal and replace with a Vector3f & int pair in NormalList and NormalPlanes, associated refactors to remove custom hashing strategy usage again,
douira added 23 commits May 29, 2025 23:59
…o avoid getting into an inconsistent when later calculations yield different results because precision was lost along the way
…uish between index and mesh sizes.

Revert ChunkMeshBufferBuilder to be mostly how it was before, without write methods and instead allow it to write to an external buffer.
Modified quads are no longer repeatedly written during splitting and instead just written out once in their modified form.
Clarified the difference between index and mesh quad counts throughout the translucency sorting code.
Removed MixedDirectionData and SplitDirectionData as part of moving the translucency sorting before the meshing code so that meshes may be modified more easily.
…perfect triggering at the cost of many more normal planes being used.
@douira douira force-pushed the translucent-quad-splitting branch from 959498e to 067b8e4 Compare May 29, 2025 22:04
douira added a commit to douira/sodium that referenced this pull request May 29, 2025
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.

Translucency sorting for intersecting translucent planes
3 participants