LibBlockAttributes
LibBlockAttributes copied to clipboard
Rendering Fluids in fabulous graphics mode GUI doesn't work
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();
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.
That's annoying. I'll change ExpandingVcp.draw
to go through RenderSystem.runAsFancy
.
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.
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.
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...