Вопрос Почему пиксели?

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
30 Июн 2025
Сообщения
34
Реакции
2

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

Привет.Не понмимаю почему закругления рендерит с пикселями

Код:
Expand Collapse Copy
public static void drawRoundOne(MatrixStack matrices, float x, float y, float width, float height, float radius, Color color, int roundedCorners) {
    setupRender();
    GL40C.glEnable(GL40C.GL_MULTISAMPLE);
    GL40C.glEnable(GL40C.GL_LINE_SMOOTH);
    GL40C.glHint(GL40C.GL_LINE_SMOOTH_HINT, GL40C.GL_NICEST);
    RenderSystem.setShader(GameRenderer::getPositionColorProgram);
    Matrix4f matrix = matrices.peek().getPositionMatrix();
    BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);

    float cr = color.getRed() / 255f;
    float cg = color.getGreen() / 255f;
    float cb = color.getBlue() / 255f;
    float ca = color.getAlpha() / 255f;

    float toX = x + width;
    float toY = y + height;
    double[][] corners = {
            {toX - radius, toY - radius, radius},
            {toX - radius, y + radius, radius},  
            {x + radius, y + radius, radius},
            {x + radius, toY - radius, radius}  
    };

    float centerX = x + width / 2f;
    float centerY = y + height / 2f;
    bufferBuilder.vertex(matrix, centerX, centerY, 0.0F).color(cr, cg, cb, ca);

    int samples = 64;
    for (int i = 0; i < 4; i++) {
        double[] corner = corners[i];
        double cx = corner[0];
        double cy = corner[1];
        double rad = corner[2];

        if ((roundedCorners & (1 << i)) != 0) {
            for (double r = i * 90; r <= (i * 90 + 90); r += 90.0 / samples) {
                float rad1 = (float) Math.toRadians(r);
                float sin = (float) (Math.sin(rad1) * rad);
                float cos = (float) (Math.cos(rad1) * rad);
                bufferBuilder.vertex(matrix, (float) cx + sin, (float) cy + cos, 0.0F).color(cr, cg, cb, ca);
            }
        } else {
            float cornerX = (float) (i == 0 || i == 1 ? toX : x);
            float cornerY = (float) (i == 0 || i == 3 ? toY : y);
            bufferBuilder.vertex(matrix, cornerX, cornerY, 0.0F).color(cr, cg, cb, ca);
        }
    }

    double[] firstCorner = corners[0];
    if ((roundedCorners & 1) != 0) {
        float rad1 = (float) Math.toRadians(0);
        float sin = (float) (Math.sin(rad1) * firstCorner[2]);
        float cos = (float) (Math.cos(rad1) * firstCorner[2]);
        bufferBuilder.vertex(matrix, (float) firstCorner[0] + sin, (float) firstCorner[1] + cos, 0.0F).color(cr, cg, cb, ca);
    } else {
        bufferBuilder.vertex(matrix, toX, toY, 0.0F).color(cr, cg, cb, ca);
    }

    BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
    GL40C.glDisable(GL40C.GL_LINE_SMOOTH);
    GL40C.glDisable(GL40C.GL_MULTISAMPLE);
    endRender();
}

Как тут например

1752676587536.png


Рендерю так
Код:
Expand Collapse Copy
RenderList.drawRoundOne(context.getMatrices(), getPosX(), getPosY(), hAnimation, 16, HudEditor.hudRound.getValue(), new Color(0xF4191919, true), 0b0110);
Версия 1.21 fabric
 
Привет.Не понмимаю почему закругления рендерит с пикселями

Код:
Expand Collapse Copy
public static void drawRoundOne(MatrixStack matrices, float x, float y, float width, float height, float radius, Color color, int roundedCorners) {
    setupRender();
    GL40C.glEnable(GL40C.GL_MULTISAMPLE);
    GL40C.glEnable(GL40C.GL_LINE_SMOOTH);
    GL40C.glHint(GL40C.GL_LINE_SMOOTH_HINT, GL40C.GL_NICEST);
    RenderSystem.setShader(GameRenderer::getPositionColorProgram);
    Matrix4f matrix = matrices.peek().getPositionMatrix();
    BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);

    float cr = color.getRed() / 255f;
    float cg = color.getGreen() / 255f;
    float cb = color.getBlue() / 255f;
    float ca = color.getAlpha() / 255f;

    float toX = x + width;
    float toY = y + height;
    double[][] corners = {
            {toX - radius, toY - radius, radius},
            {toX - radius, y + radius, radius}, 
            {x + radius, y + radius, radius},
            {x + radius, toY - radius, radius} 
    };

    float centerX = x + width / 2f;
    float centerY = y + height / 2f;
    bufferBuilder.vertex(matrix, centerX, centerY, 0.0F).color(cr, cg, cb, ca);

    int samples = 64;
    for (int i = 0; i < 4; i++) {
        double[] corner = corners[i];
        double cx = corner[0];
        double cy = corner[1];
        double rad = corner[2];

        if ((roundedCorners & (1 << i)) != 0) {
            for (double r = i * 90; r <= (i * 90 + 90); r += 90.0 / samples) {
                float rad1 = (float) Math.toRadians(r);
                float sin = (float) (Math.sin(rad1) * rad);
                float cos = (float) (Math.cos(rad1) * rad);
                bufferBuilder.vertex(matrix, (float) cx + sin, (float) cy + cos, 0.0F).color(cr, cg, cb, ca);
            }
        } else {
            float cornerX = (float) (i == 0 || i == 1 ? toX : x);
            float cornerY = (float) (i == 0 || i == 3 ? toY : y);
            bufferBuilder.vertex(matrix, cornerX, cornerY, 0.0F).color(cr, cg, cb, ca);
        }
    }

    double[] firstCorner = corners[0];
    if ((roundedCorners & 1) != 0) {
        float rad1 = (float) Math.toRadians(0);
        float sin = (float) (Math.sin(rad1) * firstCorner[2]);
        float cos = (float) (Math.cos(rad1) * firstCorner[2]);
        bufferBuilder.vertex(matrix, (float) firstCorner[0] + sin, (float) firstCorner[1] + cos, 0.0F).color(cr, cg, cb, ca);
    } else {
        bufferBuilder.vertex(matrix, toX, toY, 0.0F).color(cr, cg, cb, ca);
    }

    BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
    GL40C.glDisable(GL40C.GL_LINE_SMOOTH);
    GL40C.glDisable(GL40C.GL_MULTISAMPLE);
    endRender();
}

Как тут например

Посмотреть вложение 311164

Рендерю так
Код:
Expand Collapse Copy
RenderList.drawRoundOne(context.getMatrices(), getPosX(), getPosY(), hAnimation, 16, HudEditor.hudRound.getValue(), new Color(0xF4191919, true), 0b0110);
Версия 1.21 fabric
бля опять гл
 
Потому-что растеризация(может меш кривой, а может и еще чего), шейдером такое делать эффективнее банально потому что у тебя меш состоять будет из 6 вершин, а не из сотни другой
Пример как такое делать на
Пожалуйста, авторизуйтесь для просмотра ссылки.

А что не так с OpenGL?
 
Привет.Не понмимаю почему закругления рендерит с пикселями

Код:
Expand Collapse Copy
public static void drawRoundOne(MatrixStack matrices, float x, float y, float width, float height, float radius, Color color, int roundedCorners) {
    setupRender();
    GL40C.glEnable(GL40C.GL_MULTISAMPLE);
    GL40C.glEnable(GL40C.GL_LINE_SMOOTH);
    GL40C.glHint(GL40C.GL_LINE_SMOOTH_HINT, GL40C.GL_NICEST);
    RenderSystem.setShader(GameRenderer::getPositionColorProgram);
    Matrix4f matrix = matrices.peek().getPositionMatrix();
    BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);

    float cr = color.getRed() / 255f;
    float cg = color.getGreen() / 255f;
    float cb = color.getBlue() / 255f;
    float ca = color.getAlpha() / 255f;

    float toX = x + width;
    float toY = y + height;
    double[][] corners = {
            {toX - radius, toY - radius, radius},
            {toX - radius, y + radius, radius},
            {x + radius, y + radius, radius},
            {x + radius, toY - radius, radius}
    };

    float centerX = x + width / 2f;
    float centerY = y + height / 2f;
    bufferBuilder.vertex(matrix, centerX, centerY, 0.0F).color(cr, cg, cb, ca);

    int samples = 64;
    for (int i = 0; i < 4; i++) {
        double[] corner = corners[i];
        double cx = corner[0];
        double cy = corner[1];
        double rad = corner[2];

        if ((roundedCorners & (1 << i)) != 0) {
            for (double r = i * 90; r <= (i * 90 + 90); r += 90.0 / samples) {
                float rad1 = (float) Math.toRadians(r);
                float sin = (float) (Math.sin(rad1) * rad);
                float cos = (float) (Math.cos(rad1) * rad);
                bufferBuilder.vertex(matrix, (float) cx + sin, (float) cy + cos, 0.0F).color(cr, cg, cb, ca);
            }
        } else {
            float cornerX = (float) (i == 0 || i == 1 ? toX : x);
            float cornerY = (float) (i == 0 || i == 3 ? toY : y);
            bufferBuilder.vertex(matrix, cornerX, cornerY, 0.0F).color(cr, cg, cb, ca);
        }
    }

    double[] firstCorner = corners[0];
    if ((roundedCorners & 1) != 0) {
        float rad1 = (float) Math.toRadians(0);
        float sin = (float) (Math.sin(rad1) * firstCorner[2]);
        float cos = (float) (Math.cos(rad1) * firstCorner[2]);
        bufferBuilder.vertex(matrix, (float) firstCorner[0] + sin, (float) firstCorner[1] + cos, 0.0F).color(cr, cg, cb, ca);
    } else {
        bufferBuilder.vertex(matrix, toX, toY, 0.0F).color(cr, cg, cb, ca);
    }

    BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
    GL40C.glDisable(GL40C.GL_LINE_SMOOTH);
    GL40C.glDisable(GL40C.GL_MULTISAMPLE);
    endRender();
}

Как тут например

Посмотреть вложение 311164

Рендерю так
Код:
Expand Collapse Copy
RenderList.drawRoundOne(context.getMatrices(), getPosX(), getPosY(), hAnimation, 16, HudEditor.hudRound.getValue(), new Color(0xF4191919, true), 0b0110);
Версия 1.21 fabric
Шейдеры наше все бро, скорее всего это растеризация*

*Растеризация, или растрирование, - это процесс преобразования векторной графики (определяемой математическими объектами, такими как линии и кривые) в растровую графику (изображение, состоящее из сетки пикселей). Проще говоря, растеризация переводит чертежи в картинки, понятные для компьютера.
 
Потому-что растеризация(может меш кривой, а может и еще чего), шейдером такое делать эффективнее банально потому что у тебя меш состоять будет из 6 вершин, а не из сотни другой
Пример как такое делать на
Пожалуйста, авторизуйтесь для просмотра ссылки.


А что не так с OpenGL?
Спасибо
 
Привет.Не понмимаю почему закругления рендерит с пикселями

Код:
Expand Collapse Copy
public static void drawRoundOne(MatrixStack matrices, float x, float y, float width, float height, float radius, Color color, int roundedCorners) {
    setupRender();
    GL40C.glEnable(GL40C.GL_MULTISAMPLE);
    GL40C.glEnable(GL40C.GL_LINE_SMOOTH);
    GL40C.glHint(GL40C.GL_LINE_SMOOTH_HINT, GL40C.GL_NICEST);
    RenderSystem.setShader(GameRenderer::getPositionColorProgram);
    Matrix4f matrix = matrices.peek().getPositionMatrix();
    BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);

    float cr = color.getRed() / 255f;
    float cg = color.getGreen() / 255f;
    float cb = color.getBlue() / 255f;
    float ca = color.getAlpha() / 255f;

    float toX = x + width;
    float toY = y + height;
    double[][] corners = {
            {toX - radius, toY - radius, radius},
            {toX - radius, y + radius, radius}, 
            {x + radius, y + radius, radius},
            {x + radius, toY - radius, radius} 
    };

    float centerX = x + width / 2f;
    float centerY = y + height / 2f;
    bufferBuilder.vertex(matrix, centerX, centerY, 0.0F).color(cr, cg, cb, ca);

    int samples = 64;
    for (int i = 0; i < 4; i++) {
        double[] corner = corners[i];
        double cx = corner[0];
        double cy = corner[1];
        double rad = corner[2];

        if ((roundedCorners & (1 << i)) != 0) {
            for (double r = i * 90; r <= (i * 90 + 90); r += 90.0 / samples) {
                float rad1 = (float) Math.toRadians(r);
                float sin = (float) (Math.sin(rad1) * rad);
                float cos = (float) (Math.cos(rad1) * rad);
                bufferBuilder.vertex(matrix, (float) cx + sin, (float) cy + cos, 0.0F).color(cr, cg, cb, ca);
            }
        } else {
            float cornerX = (float) (i == 0 || i == 1 ? toX : x);
            float cornerY = (float) (i == 0 || i == 3 ? toY : y);
            bufferBuilder.vertex(matrix, cornerX, cornerY, 0.0F).color(cr, cg, cb, ca);
        }
    }

    double[] firstCorner = corners[0];
    if ((roundedCorners & 1) != 0) {
        float rad1 = (float) Math.toRadians(0);
        float sin = (float) (Math.sin(rad1) * firstCorner[2]);
        float cos = (float) (Math.cos(rad1) * firstCorner[2]);
        bufferBuilder.vertex(matrix, (float) firstCorner[0] + sin, (float) firstCorner[1] + cos, 0.0F).color(cr, cg, cb, ca);
    } else {
        bufferBuilder.vertex(matrix, toX, toY, 0.0F).color(cr, cg, cb, ca);
    }

    BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
    GL40C.glDisable(GL40C.GL_LINE_SMOOTH);
    GL40C.glDisable(GL40C.GL_MULTISAMPLE);
    endRender();
}

Как тут например

Посмотреть вложение 311164

Рендерю так
Код:
Expand Collapse Copy
RenderList.drawRoundOne(context.getMatrices(), getPosX(), getPosY(), hAnimation, 16, HudEditor.hudRound.getValue(), new Color(0xF4191919, true), 0b0110);
Версия 1.21 fabric
во первых, ты долбаеб и не надо лезть в кастомный рендер, ибо есть готовое, во вторых это гпт код и нормальные люди рендерят шейдерами без хуйни, в третьих удали свой аккаунт на данном форуме
 
На имгуе обычно данные проблемы решаются включением антиалиасинга. Мб на вашей яве есть такой прикол
 
Назад
Сверху Снизу