Reputation: 1
Here's a picture of the graphical glitch. It essentially creates concentric rings of discoloration around the camera, including the player camera or the scene editor camera.
I ran into this problem in a larger project of mine, but after playing around with the editor for a while, I figured out how to recreate the problem easily.
To recreate:
The graphical glitch goes away as soon as I set the filter mode off "Point", but filtering the asset makes the pixel art look blurry, so I'm not really willing to consider that as a fix. Does anyone have any idea what's happening here and/or how to go about fixing it?
Here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TerrainGenerator : MonoBehaviour
{
public int width = 100;
public int height = 100;
Mesh mesh;
List<Vector3> vertices = new List<Vector3> ();
List<int> triangles = new List<int>();
List<Vector2> uvs = new List<Vector2>();
int vertexCounter = 0;
// Start is called before the first frame update
void Start() {
mesh = gameObject.GetComponent<MeshFilter>().mesh;
mesh.Clear();
vertices.Clear ();
triangles.Clear ();
uvs.Clear ();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
addFace(i, j, 1, 1);
}
}
mesh.vertices = vertices.ToArray();
mesh.triangles = triangles.ToArray();
mesh.uv = uvs.ToArray();
mesh.RecalculateNormals();
}
private void addFace(int x, int y, int width, int height) {
vertices.Add(new Vector3(x, 0, y));
vertices.Add(new Vector3(x, 0, y + height));
vertices.Add(new Vector3(x + width, 0, y));
vertices.Add(new Vector3(x + width, 0, y + height));
vertices.Add(new Vector3(x + width, 0, y));
vertices.Add(new Vector3(x, 0, y + height));
triangles.Add(vertexCounter++);
triangles.Add(vertexCounter++);
triangles.Add(vertexCounter++);
triangles.Add(vertexCounter++);
triangles.Add(vertexCounter++);
triangles.Add(vertexCounter++);
uvs.Add(new Vector2(0, 0));
uvs.Add(new Vector2(0, 1));
uvs.Add(new Vector2(1, 0));
uvs.Add(new Vector2(1, 1));
uvs.Add(new Vector2(1, 0));
uvs.Add(new Vector2(0, 1));
}
}
Upvotes: 0
Views: 570
Reputation: 125
On the texture settings for the asset, under advanced > disable 'generate mip maps'. Wikipedia article on mipmaps. See below screenshots for before and after. Good luck with the project :)
mip maps disabled mip maps enabled
Upvotes: 0