Начинающий
- Статус
- Оффлайн
- Регистрация
- 8 Апр 2021
- Сообщения
- 318
- Реакции
- 22
Если рендерить текстуру через VertexFormats.POSITION_TEXTURE, то все нормально. А если через VertexFormats.POSITION_COLOR_TEXTURE (для градиент текстуры), то обрезается альфа по краям. В чем может быть дело?
Код:
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());
}