#[Fabric/Iris] Transparency issues with custom RenderLayer when using shaderpacks

10 messages · Page 1 of 1 (latest)

native sluice
#

Hey everyone 👋

I’m drawing a simple 3D shape (basically a translucent cylinder, like a “zone” marker) in Fabric.
Without shaders, everything works perfectly, the gradient and transparency look great.

However, when a shaderpack is enabled, the render either becomes completely opaque or turns into weird broken triangles (see screens).

I’m not very experienced with how Iris handles render layers or transparency passes, so I’d really appreciate some guidance on how to make a custom translucent RenderLayer work properly with shaderpacks.

I’ve already tried several different approaches to fix this before posting here but nothing works ;/
Here’s the code I’m currently using:

#
ModRenderLayer:

public static final RenderLayer ZONE_FILLED = RenderLayer.of("zone_filled", VertexFormats.POSITION_COLOR, VertexFormat.DrawMode.QUADS, 1536, false, true, RenderLayer.MultiPhaseParameters.builder().program(RenderLayer.POSITION_COLOR_PROGRAM).transparency(RenderLayer.TRANSLUCENT_TRANSPARENCY).depthTest(RenderPhase.LEQUAL_DEPTH_TEST).cull(RenderLayer.DISABLE_CULLING).writeMaskState(RenderPhase.COLOR_MASK).target(RenderPhase.TRANSLUCENT_TARGET).build(false));
#
public static final int DEFAULT_CIRCLE_SEGMENTS = 64;

public static void drawZone3D(MatrixStack matrixStack, VertexConsumerProvider consumers, double centerX, double centerY, double centerZ, double radius, double height, int color) {
        VertexConsumer vertexConsumer = consumers.getBuffer(ModRenderLayer.ZONE_FILLED);
        MatrixStack.Entry entry = matrixStack.peek();
        Matrix4f matrix = entry.getPositionMatrix();

        final double angleStep = 2.0 * Math.PI / DEFAULT_CIRCLE_SEGMENTS;
        final float y1 = (float) centerY;
        final float y2 = (float) (centerY + height);

        float[] xs = new float[DEFAULT_CIRCLE_SEGMENTS + 1];
        float[] zs = new float[DEFAULT_CIRCLE_SEGMENTS + 1];
        for (int i = 0; i <= DEFAULT_CIRCLE_SEGMENTS; i++) {
            double a = i * angleStep;
            xs[i] = (float) (centerX + radius * Math.cos(a));
            zs[i] = (float) (centerZ + radius * Math.sin(a));
        }

        final int bottomColor = ColorHelper.withAlpha((int) (ColorHelper.getAlpha(color)/1.5), color);
        final int topColor = ColorHelper.withAlpha(0, color);

        for (int i = 0; i < DEFAULT_CIRCLE_SEGMENTS; i++) {
            float x1 = xs[i], z1 = zs[i];
            float x2 = xs[i+1], z2 = zs[i+1];

            // QUADS
            vertexConsumer.vertex(matrix, x1, y1, z1).color(bottomColor);
            vertexConsumer.vertex(matrix, x2, y1, z2).color(bottomColor);
            vertexConsumer.vertex(matrix, x2, y2, z2).color(topColor);
            vertexConsumer.vertex(matrix, x1, y2, z1).color(topColor);
        }
    }
#

(1) Complementary shaderpacks
(2) Chocapic shaderpacks

#

With no shaderpacks

#

NB: I also asked about this on the Iris Discord server but just hoping someone here might have an idea! Sorry

light pewter
#

You'll have a lot more success on the Iris discord. Generally you should avoid custom render layers and shaders when you want compatibility with iris, because shaderpacks won't support them directly

onyx venture
#

@native sluice use a texture for the rendering, it fixed my problem

native sluice