I have a material with a spritesheet texture (albedo) and an emission map. The spritesheet has 32x32 squares. The emission has a 32x32 square that is an emission for the magma-looking square.
It works well on the magma, however, the glow also spreads to the sand, grass, planks, and snow_grass textures. You can clearly see it spread on the sand (bottom-rightmost opaque texture) in the right because it isn't directly touching the magma. Here is another picture where it is attached
You can still see the spreading of glow if you look closely. Now, you can definitely see it glow here
How do you stop that from happening? That artifact is really weird and i really need it to go away. I've tried decreasing the size of the square in the emission map but it still was there. Please help.
Thanks.
EDIT 1 Here is how I apply uv
` public static Dictionary textureMap = new Dictionary();
public static void Initialize(string texturePath, Texture texture)
{
Sprite[] sprites = Resources.LoadAll<Sprite>(texturePath);
foreach (Sprite s in sprites)
{
Vector2[] uvs = new Vector2[4];
uvs[0] = new Vector2(s.rect.xMin / texture.width, s.rect.yMin / texture.height);
uvs[1] = new Vector2(s.rect.xMax / texture.width, s.rect.yMin / texture.height);
uvs[2] = new Vector2(s.rect.xMin / texture.width, s.rect.yMax / texture.height);
uvs[3] = new Vector2(s.rect.xMax / texture.width, s.rect.yMax / texture.height);
//Debug.Log(s.name);
if (!textureMap.ContainsKey(s.name))
{
textureMap.Add(s.name, uvs);
}
}
}
public static bool AddTextures (Block block, Direction direction, int index, Vector2[] uvs)
{
string key = FastGetKey(block, direction);
Vector2[] text;
if (textureMap.TryGetValue(key, out text))
{
//Debug.Log(key);
uvs[index] = text[0];
uvs[index + 1] = text[1];
uvs[index + 2] = text[2];
uvs[index + 3] = text[3];
return true;
}
text = textureMap["Default"];
uvs[index] = text[0];
uvs[index + 1] = text[1];
uvs[index + 2] = text[2];
uvs[index + 3] = text[3];
return false;
}
`
Where Direction is a direction (example north) and Block is a short. Index is the vertex index of the mesh. Texture is the sprite texture (.png)