Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

spacer.png

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.