LibBlockAttributes icon indicating copy to clipboard operation
LibBlockAttributes copied to clipboard

Rendering Fluids in fabulous graphics mode GUI doesn't work

Open shartte opened this issue 4 years ago • 5 comments

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 avatar Jul 21 '20 17:07 shartte

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.

shartte avatar Jul 21 '20 18:07 shartte

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

AlexIIL avatar Jul 21 '20 19:07 AlexIIL

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.

shartte avatar Jul 21 '20 22:07 shartte

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.

AlexIIL avatar Jul 21 '20 23:07 AlexIIL

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...

shartte avatar Jul 21 '20 23:07 shartte