You’re right, I completely missed that. I assume that when I was recreating the shader I accidentally used the wrong node haha.
It turns out it was a combination of factors that lead to mip maps not working.
- I was using the wrong node in the shader always forcing a mip map level to 0.
- I was using a runtime-generated texture downloaded from my database. It turns out that directly using the texture you get when using DownloadHandlerTexture.GetContent(request) always returns a texture with no mip maps. I fixed this by adjusting my download method to the below:
public async Task<Texture2D> DownloadTextureFromUrl(string downloadUrl)
{
using (UnityWebRequest request = UnityWebRequestTexture.GetTexture(downloadUrl))
{
var asyncOperation = request.SendWebRequest();
while (!asyncOperation.isDone)
{
await Task.Yield();
}
if (request.result == UnityWebRequest.Result.Success)
{
var texture = DownloadHandlerTexture.GetContent(request);
//Generate mip map able texture from downloaded texture.
var mmTexture = new Texture2D(texture.width, texture.height, texture.format, true);
mmTexture.SetPixelData(texture.GetRawTextureData<byte>(), 0);
mmTexture.Apply(true, true);
Object.Destroy(texture);
return mmTexture;
}
Debug.LogError("Error downloading texture: " + request.error);
return null;
}
}
I found the above solution here: Generate mipmaps at runtime for a texture loaded with UnityWebRequest? - #21 by cp1