Hello,
I am working on creating a tile-based map editor. I am attempting to use the TextureAtlas class to allow the tiles to all share the same material in order to merge all the tiles together into one geometry that I can then export to use in another application.
The problem is that the empty (black) part of the texture atlas causes bleeding in the form of black lines. This happens regardless of mip-map settings and even when the tile textures are the exact same color. Is there anyway to fix this problem? I thought I read somewhere that bleeding shouldn’t occur when using this class as long as I didn’t try to use repeating / wrapped textures.
Here is a test case to demonstrates the problem:
[java]
public class TextureAtlasTestApp extends SimpleApplication {
public static void main(final String[] args) {
TextureAtlasTestApp app = new TextureAtlasTestApp();
app.start();
}
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(25f);
Quad quadAMesh = new Quad(1f, 1f);
Quad quadBMesh = new Quad(1f, 1f);
/* Create a geometry for each 'tile' */
Geometry tileA = new Geometry("TileA", quadAMesh);
Geometry tileB = new Geometry("TileB", quadBMesh);
tileA.rotate(-90f * FastMath.DEG_TO_RAD, 0f, 0f);
tileB.rotate(-90f * FastMath.DEG_TO_RAD, 0f, 0f);
tileB.setLocalTranslation(1f, 0f, 0f);
TextureAtlas textureAtlas = new TextureAtlas(32, 64);
/* Load the texture for each tile and add it to the TextureAtlas */
textureAtlas.addTexture(assetManager.loadTexture("Textures/tileAtex.png"), "ColorMap");
textureAtlas.addTexture(assetManager.loadTexture("Textures/tileBtex.png"), "ColorMap");
/* Create a material and set its ColorMap to the texture from the TextureAtlas */
Material atlasMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
textureAtlas.getAtlasTexture("ColorMap").setMinFilter(MinFilter.Trilinear);
atlasMaterial.setTexture("ColorMap", textureAtlas.getAtlasTexture("ColorMap"));
tileA.setMaterial(atlasMaterial);
tileB.setMaterial(atlasMaterial);
/* Apply the proper coordinates for each texture to the tile meshes */
textureAtlas.getAtlasTile(assetManager.loadTexture("Textures/tileAtex.png")).transformTextureCoords(quadAMesh.getFloatBuffer(Type.TexCoord), 0, quadAMesh.getFloatBuffer(Type.TexCoord));
textureAtlas.getAtlasTile(assetManager.loadTexture("Textures/tileBtex.png")).transformTextureCoords(quadBMesh.getFloatBuffer(Type.TexCoord), 0, quadBMesh.getFloatBuffer(Type.TexCoord));
rootNode.attachChild(tileA);
rootNode.attachChild(tileB);
}
}
[/java]
Note: You’ll have to provide your own 32x32 textures in order to run it. I used two identical solid-pink colored textures and this is the result: