-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
[1.20.2] Fix blending issues caused by item decorators #241
Conversation
None of the item rendering in Vanilla seems to be touching the |
The decorator renderers might touch it though, so some kind of reseting is still a good idea in my opinion, considering that people are unlikely to notice this kind of issue (especially with the blending stuff as evidenced by the issue referenced by this PR) because it's not visible with vanilla assets. |
What I would suggest instead is that we add a few Blaze3D patches to retrieve the current blend mode etc, and then use that to always reset to the correct state: + boolean depthTest = RenderSystem.isDepthTestEnabled();
resetRenderState();
for (IItemDecorator itemDecorator : itemDecorators) {
if (itemDecorator.render(guiGraphics, font, stack, xOffset, yOffset))
resetRenderState();
}
+ if (!depthTest) RenderSystem.disableDepthTest(); and similar for the others. BlendFunc might be a bit tricky because it is defined by 4 integers, maybe we want to write that to a mutable struct. This system will generalize nicely to fix other similar issues, and will ensure that we always reset to the correct render state. Might be worth giving this some thought because I expect that mods might want to use similar hooks. Maybe we want to make this more general for GUI state? Something like |
Yeah, I could see that backup and restore approach working quite well for this. I'll prototype something tomorrow. |
…blending after decorators are rendered
I've implemented a simple way to backup and restore the GL state. Not my prettiest work, but it does the trick. To avoid confusion: I have intentionally not added the cull mode to the backup because it's currently never modified and I have also intentionally not added the shader colors stored in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK that's a lot of state saving, but that should be fast enough (since it's just Java field reads and writes). I think we should restrict these methods to the render thread though.
This PR fixes blending issues in inventories by properly resetting the render state - disabling blending specifically - after the
ItemDecoratorHandler
has drawn all decorators. As far as I can tell, this doesn't cause any regressions in other places that call any of the twoGuiGraphics#renderItemDecorations()
overloads (i.e. recipe book ghost recipe, bundle tooltip, merchant list, etc.), but I would appreciate it if someone else would cross-check this.Fixes #185