Texture map visibility issue

Hey there, I’ve been trying to figure out this problem for a while now, but have finally decided to see if anyone knows why this is happening.

So to give a bit of background, I’m working on a script which dynamically creates a texture map from a series of images, which appears to work well, but when the textures are rendered on the screen, it is possible to see the padding from the atlas in the meshes being drawn (example below)
3109855--235047--upload_2017-6-16_13-54-53.png

I believe the issue is with the generation of the texture, but i cant say I’m 100% sure.

I can also verify that increasing the padding increases the width of the ‘grey lines’ in the mesh as well.

        /// <summary>
        /// Builds a texture map based on the specific type of data passed in.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static Texture BuildTextureMap(List<PointTemplate> data)
        {
            Texture2D[] textures = LoadImages(data);
            SubTextures = textures;

            Texture2D atlas = new Texture2D(1,1);
            atlas.PackTextures(textures, 1);

            if (debug)
            {
                byte[] pngdata = atlas.EncodeToPNG();
                File.WriteAllBytes("./output.png", pngdata);
            }

            Texture = atlas;
            return atlas;
        }

The atlas generated from this looks like:

This texture is being applied to a mesh with the following code…

private void Start()
        {
            renderer =GetComponent < Renderer >();
            renderer.material.mainTexture = TextureConnector.Texture;
            _filter = GetComponent<MeshFilter>() ;
            _meshCollider = GetComponent<MeshCollider>();
        }

Is there anything else i would need to do to this texure?

Yes using tiling on atlased textures will do this.

The simplest solution is to not atlas any textures you want to be tileable. Instead use a texture array and Renderer.SetPropertyBlock for example.

If you still want to use an atlas, the simplest solution would be to turn off mipmapping, but this can lead to undesirable results. To get mipmapping, you would need to generate your own mipmaps.

You should be able to find other solutions to this problem by googling for atlased tileable textures, it is a well known issue.

Cheers! that gives me a way forward. The reason I’ve gone with with a tileable texture is because the mesh is procedural generated.

I think the key word i was missing was ‘tileable textures’, doing a search specific to that has suggested shader solutions.

This may be the best solution for me as i intend to attempt to mix up to three textures together(or up to four).

Cheers for that!