Posted May 6, 20232 yr So, i want to render complex visual effects in minecraft 1.18.2, from creating simple lines, to things more complicated, like ray beams, electricity/lightning, explosions, player rendering, etc. Im guessing i need the knowledge of Tesselator, BufferBuilder, OpenGL etc. Do you know where could i learn from almost 0 this things? I dont mean a tutorial for creating this effects, but something to get me started, and something to give me enough knowledge to start this renderings.
May 8, 20232 yr Probably the best place to start is OpenGL and its integration into LWJGL. From there, it's mainly just looking over the vanilla source code and see how they abstract those features into Blaze3D (since Blaze3D has no documentation).
May 8, 20232 yr Author 1 hour ago, ChampionAsh5357 said: Probably the best place to start is OpenGL and its integration into LWJGL. From there, it's mainly just looking over the vanilla source code and see how they abstract those features into Blaze3D (since Blaze3D has no documentation). this things can be rendered from anywhere? or i have to use the "RenderLevelLastEvent"?
May 10, 20232 yr On 5/8/2023 at 1:38 PM, ElTotisPro50 said: this things can be rendered from anywhere? or i have to use the "RenderLevelLastEvent"? It depends on what you are doing. For example, entities would use an EntityRenderer while an overlay may use IOverlayRenderer. You will need to figure out what you are trying to render and how you want to implement it.
May 10, 20232 yr Author 1 hour ago, ChampionAsh5357 said: It depends on what you are doing. For example, entities would use an EntityRenderer while an overlay may use IOverlayRenderer. You will need to figure out what you are trying to render and how you want to implement it. im trying to render a simple line (two vertex) in the world, so im using RenderLevelLastEvent, the problem is that, is not working (does not render anything), the game does not crash, or give errors, or anything, if you know a bit about this, can you help to solve this? thanks btw: the start and end Vecs are positions of 2 blocks on my world, I tripled checked them, the positions are correct, so the problem is not the start and end positions. @SubscribeEvent public static void test(RenderLevelLastEvent event) { if (mc.player != null && mc.player.isAlive()) { Player player = mc.player; Level level = player.level; PoseStack stack = event.getPoseStack(); Matrix4f matrix = stack.last().pose(); Tesselator tesselator = Tesselator.getInstance(); BufferBuilder buffer = tesselator.getBuilder(); Vec3 start = new Vec3(-74, -61 ,-39); Vec3 end = new Vec3(-74, -54 ,-39); RenderSystem.disableTexture(); RenderSystem.enableDepthTest(); RenderSystem.depthFunc(515); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.depthMask(false); drawLine(start,end, 1.0f); RenderSystem.enableCull(); RenderSystem.depthMask(true); RenderSystem.disableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.enableTexture(); } public static void drawLine(Vec3 start, Vec3 end, float alpha) { if(start == null || end == null) return; PoseStack stack = RenderSystem.getModelViewStack(); Matrix4f matrix = stack.last().pose(); Tesselator tes = Tesselator.getInstance(); BufferBuilder buffer = tes.getBuilder(); RenderSystem.setShader(GameRenderer::getPositionColorShader); RenderSystem.lineWidth(1); buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); buffer.vertex(matrix,(float)start.x,(float)start.y,(float)start.z).color(1.0f,1.0f,1.0f, alpha).endVertex(); buffer.vertex(matrix,(float)end.x,(float)end.y,(float)end.z).color(1.0f,1.0f,1.0f, alpha).endVertex(); tes.end(); } Edited May 10, 20232 yr by ElTotisPro50
May 11, 20232 yr 21 hours ago, ElTotisPro50 said: btw: the start and end Vecs are positions of 2 blocks on my world, I tripled checked them, the positions are correct, so the problem is not the start and end positions. First of all, you should be using RenderTypes instead of direct RenderSystem calls. Second, you need to transform the line based on the vector of the projected view before drawing to the screen. You should be able to see how this is done by looking at any entity call. Third, don't use pose stacks interchangeably, each is for their individual purpose. If you are rendering in the world, use the posestack provided by the event.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.