ByterDance Posted July 8 Share Posted July 8 At the time of forge 1.16.5, I used this code: RenderSystem.enableBlend(); RenderSystem.disableAlphaTest(); RenderSystem.defaultBlendFunc(); // render RenderSystem.disableBlend(); RenderSystem.enableAlphaTest(); But when switching to version 1.20.1, I ran into a problem: GL_ALPHA_TEST cap can no longer be enabled, and if you specify any color with alpha less than 1.0 in the shader, then the pixel color will still be with alpha 1.0 My current code: Shader: #version 330 core out vec4 fragColor; void main() { fragColor = vec4(1.0, 0.0, 0.0, 0.5); } @SubscribeEvent public static void registerShader(RegisterShadersEvent event) { try { event.registerShader(new ShaderInstance(event.getResourceProvider(), new ResourceLocation("untitled", "tst"), DefaultVertexFormat.POSITION), instance -> { shaderInstance = instance; }); } catch (IOException e) { e.printStackTrace(); } } @SubscribeEvent public void render2D(RenderGuiOverlayEvent.Post event) { RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.setShader(() -> shaderInstance); Tesselator tesselator = Tesselator.getInstance(); BufferBuilder bufferBuilder = tesselator.getBuilder(); bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION); bufferBuilder.vertex(0, 0, 0).endVertex(); bufferBuilder.vertex(0, 50, 0).endVertex(); bufferBuilder.vertex(100, 50, 0).endVertex(); bufferBuilder.vertex(100, 0, 0).endVertex(); tesselator.end(); RenderSystem.disableBlend(); } If anything, the shader itself is working. I also tried rendering using POSITION_TEX vertex format, but nothing has changed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.