
[Feature] MCPatcher overlay blend glass rendering
muzikbike opened this issue ยท 3 comments
Is your feature request related to a problem? Please describe.
One of MCPatcher's selling points is that you could set glass to use overlay blending, rather than the standard cutout rendering used by glass or translucency used by stained glass. This was one of the features OptiFine never ended up stealing, and I don't think I've seen any implementations of this beyond 1.7.10.
Describe the solution you'd like
I'd like to see this reimplemented... somehow, either as part of the mod or as something separate. Perhaps it could be implemented as a render layer much like solid, cutout and transparent, and a mod such as JMXL could be used to determine what part of the model uses this render layer, but I've had difficulties in getting that mod to actually work (magistermaks/mod-jmxl#3).
Test pack for use with MCPatcher 1.7.10:
If I understand correctly, this would change how the texture transparency is blended with anything rendered behind it. This isn't really possible with the way Minecraft works (at least for any version I have worked with, so 1.12 and up). Quads for all blocks are first put into buffers for each render type, so one buffer for solid, one for cutout, one for transparent.
The transparent buffer is then sorted, putting quads from furthest to closest. Each buffer is then uploaded in its entirety, with the transparent buffer being uploaded last.
Custom blending would not work well as it would require a custom blend mode and thus a custom render type with its own buffer. This leads to a couple of issues:
- Adding a custom render type to chunk render types, would mean an extra buffer and draw call for each chunk rendered while likely only a couple blocks will actually make use of it.
- Using custom render types for chunk geometry will not work well with other mods. Before 1.19.2, Forge/NeoForge don't have proper API's for checking which render types should be used for a model, hence the model will likely break for any mods rendering models in guis or block entity renderers. It would also break with mods such as Iris and Sodium which overhaul rendering.
- As buffers are uploaded and rendered in their entirety, quads cannot be sorted between the transparent buffer and the new custom render type buffer. This means the overlay blending quads would have to be rendered either before or after all transparent quads and thus will always look incorrect when these quads overlap.
For these reasons, it isn't really viable to add such an 'overlay blending' type.
Here's Wikipedia's explanation:
I believe this piece of code may have been responsible for handling overlay blending rendering for glass in MCPatcher (public domain): https://github.com/pclewis/mcpatcher/blob/0101db070648f96695ee3e080ae036cd71ec1c45/newcode/src/com/pclewis/mcpatcher/mod/RenderPass.java#L91