I talked to crazy_stewie more about how to workaround the ViewportTexture does not have mipmaps issue with a shader. My previous solution (20240621054605), which emulates mipmaps, is quite slow as it needs to do two passes in order to determine the colors to interpolate between based on the LOD.
Instead, we can do a single pass. Instead of relying on the LOD, we can determine how many texels we want to sample based on how the UV value is changing across the surface. I tried doing this before (20240621214324), but it probably failed because the shader I wrote was trying to make way too many samples at once for a single pixel, causing the GPU to think there was a hang. This can be addressed by clamping the number of samples we want to make.
crazy_stewie wrote a shader which they shared with me that takes this approach successfully. I’ve added comments to it below to note my understanding of how it works. We have previously come to an understanding that a pixel is a pixel on a screen and a texel is a pixel on a texture and that the terms exist only to reduce confusion between which kind of pixel we are talking about. So, I’ll be using that definition here.
This results in an image that is less blurry, which improves image quality.