Sodium Reloaded (Unofficial)

Sodium Reloaded (Unofficial)

0 Downloads

Automatic material downgrading of quads with appropriately simple textures

douira opened this issue ยท 1 comments

commented

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.