I’m having a serious problem with alphas that’s making my game look terrible! The edges of all the meshes that have an alpha texture show up as faint white lines (see image below). I’ve been very careful in creating these textures, so I’m 99% sure this is something caused by Unity itself.
As you can see in the image, I have lots of polygon planes with a grass texture applied to them. Every single one has a faint white line around the edge of the polygon plane. It’s as though I’ve painted in lines on the alpha layer when making the texture (of course I haven’t!).
Has anyone else had this problem? Anyone know how to fix it?
Unity creates a texture atlas of all of your textures used as detail meshes in the Terrain engine. Sometimes this creates issues with borders from one texture to the next on the texture atlas. To get rid of this problem make sure that each one of your textures has a pixel or two black border around the alpha channel.
Hi! Sorry, but I don’t really understand what you mean. As you can see from the image below, the alpha layer already has a black border. Could you please explain in simple terms what I need to do with this image to get rid of the unwanted borders in Unity? Thanks!
The bottom of your alpha channel still has white touching the border. If you add one or two lines of black at the bottom there the problem should go away. If this is the only texture that you are using for you terrain then make sure that the texture’s wrap mode is set to Clamp in the Inspector.
I took your posted texture and can not reproduce the problem with it. Are there any other textures being used on your terrain for detail meshes or grass?
I currently have 8 textures and 5 detail meshes. All the textures and detail mesh textures are 256x256.
I’ve tried putting a 2-pixel-thick black border around all of their alpha layers - I’ve even tried giving the detail mesh textures an alpha layer they don’t need, just to put a black border around it!
I have your solution.
As antennatree said, it’s because of the atlasing. So the white line is not from the texture you see the mistake on (the grass) but on one of your other detail textures.
If you wanna know how your details are laid out on the atlas texture, please use the script from this thread (SaveAtlastTexture.cs).
Then you can see exactly which detail texture is packed just above the grass texture.
I’m sure that’s it, even though you say you already have put the border on all textures…
EDIT: It’s probably because the atlas texture haven’t been recalculated after you did you borders. The easiest way is to just doubleclick on one of the detail textures inside your terrain tool.
Just one question - what do I actually do to implement this script?! I know how to make a script in Unity, but I don’t understand how I use it to actually save out the atlas texture. Do I need to apply it to the terrain object somehow?
The script that Kragh linked to is just to visualize the atlasing… it’s not necessary to use on the Terrain. I’d take his suggestion and edit something on one of the detail meshes to force Unity to recalculate the texture atlas for all detail meshes.
As aNTeNNa trEE (the name is case sensitive) says, the script has nothing to do with actually solving the issue. All it can do is show you where to look for the problem…
If you want to use it, save it to a folder in your project called “Editor”, and then it’ll appear under either Tools or Terrain in the menu, don’t remember.
I’m getting the same problem as Ganchii, I’ve downloaded the atlas texture script http://forum.unity3d.com/viewtopic.php?t=45907 and placed it in the folder called editor I’ve then selected the terrain the clicked save out atlas texture… the problem is that I’m unaware if the script is working I cannot find the apparent saved atlas texture…
It should be in your project assets folder. If you collapse all your folders in the project view, it should be visible in the root, alongside the standard assets folder…
It’s just occured to me that I’m getting this ‘white border’ issue on pretty much every flat, single-poly surface in the game. So it can’t be the atlas texture. (Thanks BTW Kragh - your script was interesting, even if it didn’t help solve the problem).
Just to mention, sometimes, white lines appear when an image that’s meant to clamp the object is in repeat mode… Just change its wrap mode on inspector…