Подведи собственные итоги года совместно с YOUGAME и забери ценные призы! Перейти

Вопрос Проблема с render glow (1.19.4)

  • Автор темы Автор темы pan4ur
  • Дата начала Дата начала
Начинающий
Начинающий
Статус
Оффлайн
Регистрация
8 Апр 2021
Сообщения
318
Реакции
22
Если рендерить текстуру через VertexFormats.POSITION_TEXTURE, то все нормально. А если через VertexFormats.POSITION_COLOR_TEXTURE (для градиент текстуры), то обрезается альфа по краям. В чем может быть дело?

Код:
Expand Collapse Copy
    public static void renderTexture(MatrixStack matrices, double x0, double y0, double width, double height, float u, float v, double regionWidth, double regionHeight, double textureWidth, double textureHeight) {
        double x1 = x0 + width;
        double y1 = y0 + height;
        double z = 0;
        Matrix4f matrix = matrices.peek().getPositionMatrix();
        RenderSystem.setShader(GameRenderer::getPositionTexProgram);
        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
        bufferBuilder.vertex(matrix, (float) x0, (float) y1, (float) z).texture((u + 0.0F) / (float) textureWidth, (v + (float) regionHeight) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x1, (float) y1, (float) z).texture((u + (float) regionWidth) / (float) textureWidth, (v + (float) regionHeight) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x1, (float) y0, (float) z).texture((u + (float) regionWidth) / (float) textureWidth, (v + 0.0F) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x0, (float) y0, (float) z).texture((u + 0.0F) / (float) textureWidth, (v + 0.0F) / (float) textureHeight).next();
        BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
    }

    public static void renderGradientTexture(MatrixStack matrices, double x0, double y0, double width, double height, float u, float v, double regionWidth, double regionHeight, double textureWidth, double textureHeight,Color c1,Color c2,Color c3,Color c4) {
        double x1 = x0 + width;
        double y1 = y0 + height;
        double z = 0;
        Matrix4f matrix = matrices.peek().getPositionMatrix();
        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
        RenderSystem.setShader(GameRenderer::getPositionColorTexProgram);

        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE);
        bufferBuilder.vertex(matrix, (float) x0, (float) y1, (float) z).color(c1.getRGB()).texture((u + 0.0F) / (float) textureWidth, (v + (float) regionHeight) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x1, (float) y1, (float) z).color(c2.getRGB()).texture((u + (float) regionWidth) / (float) textureWidth, (v + (float) regionHeight) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x1, (float) y0, (float) z).color(c3.getRGB()).texture((u + (float) regionWidth) / (float) textureWidth, (v + 0.0F) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x0, (float) y0, (float) z).color(c4.getRGB()).texture((u + 0.0F) / (float) textureWidth, (v + 0.0F) / (float) textureHeight).next();
        BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
    }


Снимок экрана 2023-06-02 112058.png
 
Посмотреть вложение 249471

А GL11. ничего не делает либо крашит
ну тогда не знаю, поэкспериментируй, попробуй не рендерить первый квадрат, попробуй убрать строчку RenderSystem.setShader, попробуй заменить последнюю строчку на tessellator.end() если там есть такое
 
Если рендерить текстуру через VertexFormats.POSITION_TEXTURE, то все нормально. А если через VertexFormats.POSITION_COLOR_TEXTURE (для градиент текстуры), то обрезается альфа по краям. В чем может быть дело?

Код:
Expand Collapse Copy
    public static void renderTexture(MatrixStack matrices, double x0, double y0, double width, double height, float u, float v, double regionWidth, double regionHeight, double textureWidth, double textureHeight) {
        double x1 = x0 + width;
        double y1 = y0 + height;
        double z = 0;
        Matrix4f matrix = matrices.peek().getPositionMatrix();
        RenderSystem.setShader(GameRenderer::getPositionTexProgram);
        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
        bufferBuilder.vertex(matrix, (float) x0, (float) y1, (float) z).texture((u + 0.0F) / (float) textureWidth, (v + (float) regionHeight) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x1, (float) y1, (float) z).texture((u + (float) regionWidth) / (float) textureWidth, (v + (float) regionHeight) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x1, (float) y0, (float) z).texture((u + (float) regionWidth) / (float) textureWidth, (v + 0.0F) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x0, (float) y0, (float) z).texture((u + 0.0F) / (float) textureWidth, (v + 0.0F) / (float) textureHeight).next();
        BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
    }

    public static void renderGradientTexture(MatrixStack matrices, double x0, double y0, double width, double height, float u, float v, double regionWidth, double regionHeight, double textureWidth, double textureHeight,Color c1,Color c2,Color c3,Color c4) {
        double x1 = x0 + width;
        double y1 = y0 + height;
        double z = 0;
        Matrix4f matrix = matrices.peek().getPositionMatrix();
        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
        RenderSystem.setShader(GameRenderer::getPositionColorTexProgram);

        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE);
        bufferBuilder.vertex(matrix, (float) x0, (float) y1, (float) z).color(c1.getRGB()).texture((u + 0.0F) / (float) textureWidth, (v + (float) regionHeight) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x1, (float) y1, (float) z).color(c2.getRGB()).texture((u + (float) regionWidth) / (float) textureWidth, (v + (float) regionHeight) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x1, (float) y0, (float) z).color(c3.getRGB()).texture((u + (float) regionWidth) / (float) textureWidth, (v + 0.0F) / (float) textureHeight).next();
        bufferBuilder.vertex(matrix, (float) x0, (float) y0, (float) z).color(c4.getRGB()).texture((u + 0.0F) / (float) textureWidth, (v + 0.0F) / (float) textureHeight).next();
        BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
    }


Посмотреть вложение 249463
У тебя получилось в итоге? Отпиши в дискорд, может быть смогу помочь - дима рокеткин#0037
 
Последнее редактирование:
Назад
Сверху Снизу