I am creating a pixel-art game in MonoGame, and have written a shader to perform various effects on a sprite when rendering it, such as performing palette swaps, highlighting outlines, etc.. Most of these effects work by comparing the color of a texture coordinate with a reference color, and if they match then the color is swapped for another. Simple stuff as long as you use nearest-neighbor filtering on the texture. (These effects are used in a very dynamic way, which is why they are done using a shader instead of, say, a separate texture-atlas for each color palette).
However, in the game there is quite a lot of floating-point camera scaling and movement going on, resulting in choppy-looking visuals when using nearest-neighbor filtering. Luckily there is a way of scaling pixel-art that looks much smoother without taking away the crispness, which is to use a texture with bilinear filtering enabled but only use interpolated colors on the boundary between pixels. Here and here are a couple of open-source shaders using this technique.
The problem is of course that you cannot do palette-swaps on a texture with bilinear filtering because the colors are all blended together. In other words the two aforementioned techniques seem to be completely incompatible with one another, yet I really need both of them.
As far as I can tell the logical solution would be to perform the palette-swapping and similar effects on the texture before scaling and filtering it, however I have no idea of how to actually do this from within a shader, and what the performance implications of doing so would be.
I am still very much a novice when it comes to shaders, so any help here would be deeply appreciated!