Giant stretched-out black triangles glitch

Hello! I'm deving a mod called Mirage. Recently I've switched to using VertexBuffers to render fake structures but I came across this bug whenever I enable shaders: Is there anyway I can change my code to work with yours?
No description
1 Reply
PHOBOSS
PHOBOSSOP11mo ago
I initialize the VertexBuffers with this method whenever I rightclick on the projector block:
public void initBuffer(BlockPos projectorPos) {

MatrixStack matrices = new MatrixStack();

this.mirageStateWOEntities.forEach((key,block)->{
matrices.push();
BlockPos fakeBlockPos = BlockPos.fromLong(key);
BlockPos relativePos = fakeBlockPos.subtract(projectorPos);
matrices.translate(relativePos.getX(),relativePos.getY(),relativePos.getZ());

RenderLayer renderLayer = RenderLayers.getEntityBlockLayer(block.blockState,true);

blockRenderManager.renderBlock(block.blockState,fakeBlockPos,world,matrices,

this.mirageBufferStorage.getLayerBuffer(renderLayer),//over here

true,random);

matrices.pop();
});

this.mirageBufferStorage.uploadBufferBuildersToVertexBuffers();

}
public void initBuffer(BlockPos projectorPos) {

MatrixStack matrices = new MatrixStack();

this.mirageStateWOEntities.forEach((key,block)->{
matrices.push();
BlockPos fakeBlockPos = BlockPos.fromLong(key);
BlockPos relativePos = fakeBlockPos.subtract(projectorPos);
matrices.translate(relativePos.getX(),relativePos.getY(),relativePos.getZ());

RenderLayer renderLayer = RenderLayers.getEntityBlockLayer(block.blockState,true);

blockRenderManager.renderBlock(block.blockState,fakeBlockPos,world,matrices,

this.mirageBufferStorage.getLayerBuffer(renderLayer),//over here

true,random);

matrices.pop();
});

this.mirageBufferStorage.uploadBufferBuildersToVertexBuffers();

}
MirageBufferStorage:
public void uploadBufferBuildersToVertexBuffers() {
this.mirageLayerBuffers.forEach((renderLayer,bufferBuilder)->{
if(bufferBuilder.isBuilding()){
bufferBuilder.end();
this.mirageVertexBuffers.get(renderLayer).upload(bufferBuilder);
}
});
}
public void uploadBufferBuildersToVertexBuffers() {
this.mirageLayerBuffers.forEach((renderLayer,bufferBuilder)->{
if(bufferBuilder.isBuilding()){
bufferBuilder.end();
this.mirageVertexBuffers.get(renderLayer).upload(bufferBuilder);
}
});
}
Then I render the VertexBuffers in my Projector block's BER:
public void render(BlockPos projectorPos,float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay){
MatrixStack matrixStack = RenderSystem.getModelViewStack();
matrixStack.push();
matrixStack.multiplyPositionMatrix(matrices.peek().getPositionMatrix());

this.mirageBufferStorage.mirageVertexBuffers.forEach((renderLayer,vertexBuffer)->{
renderLayer.startDrawing();
vertexBuffer.setShader(matrixStack.peek().getPositionMatrix(), RenderSystem.getProjectionMatrix(),RenderSystem.getShader());
renderLayer.endDrawing();

});

matrixStack.pop();
public void render(BlockPos projectorPos,float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay){
MatrixStack matrixStack = RenderSystem.getModelViewStack();
matrixStack.push();
matrixStack.multiplyPositionMatrix(matrices.peek().getPositionMatrix());

this.mirageBufferStorage.mirageVertexBuffers.forEach((renderLayer,vertexBuffer)->{
renderLayer.startDrawing();
vertexBuffer.setShader(matrixStack.peek().getPositionMatrix(), RenderSystem.getProjectionMatrix(),RenderSystem.getShader());
renderLayer.endDrawing();

});

matrixStack.pop();
I heard you guys are using custom vertex formats is that right? embeddedt says it might have something to do with it
Want results from more Discord servers?
Add your server