Create barkless antecedent texture from base texture.
@@ -36,10 +36,11 @@ public class ThickRingTextureAtlasSprite extends TextureAtlasSprite {
this.height = srcHeight * 3;
PixelBuffer srcPixbuf = new PixelBuffer(baseTexture);
+ PixelBuffer antPixbuf = createBarklessAntecedent(srcPixbuf);
PixelBuffer dstPixbuf = new PixelBuffer(width, height);
for(int i = 0; i < 9; i++) {
- srcPixbuf.blit(dstPixbuf, (i % 3) * srcWidth, (i / 3) * srcHeight);
+ antPixbuf.blit(dstPixbuf, (i % 3) * srcWidth, (i / 3) * srcHeight);
}
//Load the pixels into the TextureAtlasSprite
@@ -51,6 +52,47 @@ public class ThickRingTextureAtlasSprite extends TextureAtlasSprite {
return false;
}
+ PixelBuffer createBarklessAntecedent(PixelBuffer baseBuffer) {
+ PixelBuffer antecedent = new PixelBuffer(baseBuffer);
+
+ //Place the 4th pixel ring against the corners of the image.
+ //Rotate 90deg to break up the pattern
+ baseBuffer.blit(antecedent, 3, 3, 1);
+ baseBuffer.blit(antecedent, -3, 3, 1);
+ baseBuffer.blit(antecedent, 3, -3, 1);
+ baseBuffer.blit(antecedent, -3, -3, 1);
+
+ //Copy a 6 wide strip of pixels from the 4th pixel ring and place
+ //it over the bark texture for all 4 edges. Alternate the placement
+ //to break up the pattern
+ PixelBuffer ringStrip = new PixelBuffer(6, 1);
+ baseBuffer.blit(ringStrip, -5,-3);
+ ringStrip.blit(antecedent, 0, 2, -1);
+ ringStrip.blit(antecedent, 15, 8, 1);
+
+ baseBuffer.blit(ringStrip, -5,-12);
+ ringStrip.blit(antecedent, 0, 8, 1);
+ ringStrip.blit(antecedent, 15, 2, -1);
+
+ ringStrip = new PixelBuffer(1, 6);
+ baseBuffer.blit(ringStrip, -3,-5);
+ ringStrip.blit(antecedent, 2, 0, -1);
+ ringStrip.blit(antecedent, 8, 15, 1);
+
+ baseBuffer.blit(ringStrip, -12,-5);
+ ringStrip.blit(antecedent, 8, 0, 1);
+ ringStrip.blit(antecedent, 2, 15, -1);
+
+ ringStrip = null;
+
+ //Copy the center 14x14 pixels of the original back over the result
+ PixelBuffer center = new PixelBuffer(14, 14);
+ baseBuffer.blit(center, -1, -1);
+ center.blit(antecedent, 1, 1);
+
+ return antecedent;
+ }
+
@Override
public Collection<ResourceLocation> getDependencies() {
return ImmutableList.of(baseRingLocation);
