I’ve been struggling with this issue for a few weeks and haven’t been able to find a solution to it. I’m creating a 2D game and one of the components needs a texture to be tiled but the ends should have a different texture. All of the tiling information I’ve been able to find is for uniform tiling without edge images. I’ve been attempting to stitch together the textures manually, but all I get is a black box. Below I’ve attached my attempt at making a valid texture, but I’m open to any suggestions on a better way to do this. I’m need to keep it to 1 materially that is projected onto a box.
The hope of the code below is to create a texture that is the 4 initial textures stacked in 2D space along the Y axis.
Texture texture1 = loadTexture("end");
Texture texture2 = loadTexture("side");
Texture texture3 = loadTexture("side");
Texture texture4 = loadTexture("end");
Image image1 = texture1.getImage();
Image image2 = texture2.getImage();
Image image3 = texture3.getImage();
Image image4 = texture4.getImage();
ByteBuffer buffer1 = image1.getData(0);
ByteBuffer buffer2 = image2.getData(0);
ByteBuffer buffer3 = image3.getData(0);
ByteBuffer buffer4 = image4.getData(0);
int size1 = buffer1.capacity();
int size2 = buffer2.capacity();
int size3 = buffer3.capacity();
int size4 = buffer4.capacity();
int totalSize = size1 + size2 + size3 + size4;
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(totalSize)
.put(buffer1)
.put(buffer2)
.put(buffer3)
.put(buffer4);
Image image = new Image(image1.getFormat(), image1.getWidth(), image1.getHeight() * 4, byteBuffer, image1.getColorSpace());
Texture texture = new Texture2D(image);