Skip to content
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

Automatic material downgrading of quads with appropriately simple textures #2515

Open
douira opened this issue May 23, 2024 · 0 comments
Open
Labels
S-needs-triage Status: Needs triage T-enhancement Type: Enhancement

Comments

@douira
Copy link
Contributor

douira commented May 23, 2024

Request Description

It's generally not common for models to assign different materials (opaque, cutout, translucent) to different quads. It's technically possible, but only with special mods and nobody does it. If the parts of a texture that a quad in a translucent or cutout model uses can be scanned for being non-translucent or even opaque, then that quad could be rendered in different pass.

For example, grass blocks are rendered as cutout while all quads except for the side overlays could actually use opaque. This can bring performance improvements.

Another example is that some mods and resource packs add models where only few quads are translucent but the whole model is marked as translucent in lieu of a better way of signaling this information. Translucency sorting can't apply certain sorting optimizations when complex models are treated as fully translucent. Detecting that most quads can actually be rendered identically as opaque or cutout would improve performance of both sorting and rendering.

Scanning the texture of an arbitrary quad like this is complicated, since it might require a complicated mapping of the triangles if the quad is a weird shape. However, a best-effort approach that only checks quads that map to rectangular whole-pixel sections of the texture would be significantly simpler. Weirdly shaped quads could be checked with a conservative approach that only downgrades the quad's material if the entire texture-space AABB of the quad satisfies the condition (all pixels have binary opacity, or are fully opaque). For good meshing performance, this check's results should be cached for the model so that it doesn't need to be performed more often than necessary.

@douira douira added S-needs-triage Status: Needs triage T-enhancement Type: Enhancement labels May 23, 2024
@douira douira changed the title Automatic detection of more efficient materials for quads whose textures support it Automatic material downgrading of quads maping to appropriately simple textures May 23, 2024
@douira douira changed the title Automatic material downgrading of quads maping to appropriately simple textures Automatic material downgrading of quads with appropriately simple textures May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-triage Status: Needs triage T-enhancement Type: Enhancement
Development

No branches or pull requests

1 participant