0x3C50 / Renderer

An easy to use rendering library for Minecraft mods using the Fabric toolchain
Other
185 stars 17 forks source link

Inconsistency rendering a texture on the screen #36

Closed Emafire003 closed 10 months ago

Emafire003 commented 10 months ago

Bug Description

While rendering a PNG texture on the screen it sometimes displays it correctly and some other times it gets drawn more badly, more "pixellated", and I can't figure out why, if it's something I miscofigured or not. Images below.

Code

RenderEvents.HUD.register(matrixStack -> {
            MSAAFramebuffer.use(MSAAFramebuffer.MAX_SAMPLES, () -> {
                center_x = MinecraftClient.getInstance().getWindow().getScaledWidth()/2;
                center_y = MinecraftClient.getInstance().getWindow().getScaledHeight()/2;
                scale_factor = MinecraftClient.getInstance().getWindow().getScaleFactor();

                if(LightWithinClient.isLightReady()){
                    ClipStack.addWindow(matrixStack.getMatrices(),new Rectangle(1,1,1000,1000));
                    Renderer2d.renderTexture(matrixStack.getMatrices(), new Identifier(LightWithin.MOD_ID, "textures/lights/light.png"), x, y, 20, 20);
                    ClipStack.popWindow();
                }

(isLightReady returns true for 10ish seconds after a packet is sent from the server, if you need more context [here is the full source])(https://github.com/Emafire003/LightWithin/blob/main/src/main/java/me/emafire003/dev/lightwithin/client/RendererEventHandler.java)

Expected Behavior

I would expect the icons/textures/images to be rendered at least the same way each time, and not changing after a few seconds.

Screenshots

2024-01-14_14 30 28 correct 2024-01-14_14 30 38 incorrect

Desktop

Additional Context

Sometimes it starts as pixellated and then after a few seconds turns normal. Also, this is one of the files that should be rendered, along with how it turns out. correct correct incorrect incorrect

Also sometimes dying while the icon is displayes makes it dispaly as more pixellated or whatever and when the icon disappears it seems briefly to display normally.

0x3C50 commented 10 months ago

does, by any chance, a chat message appear the same time it goes funky? it might be a blending issue, and the chat overlay is a common event creating that problem. try to enable blend and set the default blend func before rendering the texture.

Emafire003 commented 10 months ago

Yes, a chat message is displayed in the action bar. I tried what you said and it worked, thank you!