Advanced XRay (Fabric Edition)

Advanced XRay (Fabric Edition)

1M Downloads

PoseStack was replaced with Matrix4fStack in Blaze3D / 1.20.6 Porting Attempt

gaberust opened this issue ยท 2 comments

commented

I was attempting to port this over to 1.20.5/1.20.6, and noticed that RenderSystem.getModelViewStack() now returns a Matrix4fStack object instead of PoseStack. In fact, I think PoseStack has been removed from Blaze3D completely. I attempted to rewrite some of the transformation code in the RenderOutlines class:

Matrix4fStack matrixStack = RenderSystem.getModelViewStack();
matrixStack.pushMatrix();

if (canvasLoaded == 1) {
    float f = (camera.getXRot()) * 0.017453292F;
    matrixStack.rotateX(f);
    f = (camera.getYRot() + 180f) * 0.017453292F;
    matrixStack.rotateY(f);
}

RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.applyModelViewMatrix();
RenderSystem.depthFunc(GL11.GL_ALWAYS);

context.projectionMatrix().lookAt(cameraPos.toVector3f(), cameraPos.toVector3f().add(camera.getLookVector()), camera.getUpVector());

vertexBuffer.bind();
vertexBuffer.drawWithShader(matrixStack, new Matrix4f(context.projectionMatrix()), RenderSystem.getShader());
VertexBuffer.unbind();
RenderSystem.depthFunc(GL11.GL_LEQUAL);

matrixStack.popMatrix();
RenderSystem.applyModelViewMatrix();

Mathematically, this should be exactly the same as the PoseStack/Quaternion implementation, but for some reason the rotation is still off. (Lines do not render on target blocks and move when camera does)
image

Any luck with this/ similar results?

commented

Port Completed

commented

Yeah, this was a bit of a pain, just turned out the old forge way of doing it didn't mirror well to the fabric way of doing it with this event