Posted September 11, 2024 by Redspark
Just a quick update still on the rendering part of the game. I found this wonderful blog post which covers implementing bilinear filtering on the CPU. This was exactly what I needed. I had to adapt it to be compatible with a Texture Atlas but other than that, much of what was covered was applicable and 4 times faster than the code I had originally written.
As you can see from the example screenshot below, the Bilinear filtering takes out some of the noisiness of the Nearest Neighbour sampling by smoothing out some of the highs and lows. But, it does cause the texture to be slightly blurry which can be seen in the foreground texture of the wood on the wharf.
However, Bilinear filtering interpolates 4 pixels together, so it retains more of the details in the texture when the texture is being shrunk. You can see this in the cracks in the plaster of the house walls. The Nearest filtering is just grabbing one pixel at a time from the texture and can sometimes lose details when samples are farther apart in the texture. By sampling more pixels, it can represent the texture more accurately.