AlexIIL / LibBlockAttributes

Library mod for fabric that adds items and attribute API's for blocks.
Mozilla Public License 2.0
43 stars 12 forks source link

Rendering Fluids in fabulous graphics mode GUI doesn't work #23

Open shartte opened 4 years ago

shartte commented 4 years ago

I am using the following code to render a Fluid slot (s) in my GUI, which works perfectly in fancy or fast graphics, but is invisible in fabulous graphics.

                List<FluidRenderFace> faces = new ArrayList<>();
                faces.add(FluidRenderFace.createFlatFaceZ(0, 0, 0, 16, 16, 0, 1 / 16., false, false));

                matrices.push();
                matrices.translate(s.x, s.y, 0);

                FluidVolume fluidStack = fs.getFluidStack();
                fluidStack.render(faces, FluidVolumeRenderer.VCPS, matrices);
                FluidVolumeRenderer.VCPS.draw();
                matrices.pop();
shartte commented 4 years ago

I tracked it down to the following: Translucent layers are rendered into a separate framebuffer, which is never blitted back to screen after the world itself has already been drawn (which is under the GUI).

Workaround: RenderSystem.runAsFancy(FluidVolumeRenderer.VCPS::draw);

That is deprecated though.

AlexIIL commented 4 years ago

That's annoying. I'll change ExpandingVcp.draw to go through RenderSystem.runAsFancy.

shartte commented 4 years ago

I am also not sure how to solve this going forward. This should also affect item renderers in theory, I guess, or the fluid rendering should not actually render to the "transparent" layer for the UI.

AlexIIL commented 4 years ago

Do item renders have their own VCP? I know this isn't a problem for blocks, as they use the main one.

(For simplicities sake I'll expose a draw method that doesn't use runAsFancy - that way if they don't they can use that).

Drawing translucent fluids in GUIs should be fine so I'm hesitant to try to change fluid rendering just for this.

shartte commented 4 years ago

As long as they render into the transparent layer they will have this problem. Root cause here is net.minecraft.client.render.RenderPhase#TRANSLUCENT_TARGET, because that will switch the render target.

Thinking about this some more: RenderLayers should really not be used when rendering for the UI I think...