Dark rims around mipmaps

I’m trying to make custom mipmaps for my isometric game to improve the look from far away.

The idea is to render the smaller textures and either remove or make opaque the transparent pixels depending on their alpha level (so above 0.5 would become 1 else 0)

Everything works except that the colors of the transparent pixels are being distorted.

This is the original

This is how I expect it to look (made with a image editing program)

This is how it comes out

The luminosity of the transparent pixels is lowered. I suppose this has to to with the transparent background (R:0, G:0, B:0, A:0). I tried setting the BlendState to Opaque but that didn’t work. I tried Anisotropic and Linear filtering with the same result. After that I used the Visual Studio graphics debugging tools and it seems that the pixel shader produces those colors before blending occurs.

As I understand it, the GPU isn’t weighing the alpha of the pixels when interpolating between colors.

Is there any way to make it do that?

If you are doing it on the shader inside the texture sampler declaration try setting.
minfilter = POINT;
mipfilter = POINT;

if you are doing it thru spritebatch im not quite sure maybe in begin set the sampler state.
public static SamplerState SS_PointBorder = new SamplerState() { Filter = TextureFilter.Point, AddressU = TextureAddressMode.Border, AddressV = TextureAddressMode.Border };

How to control the blending when downsampling to a mipmap im not to sure though point will just skip pixels and only grab one which should work if its time critical the cheapest but with questionable quality.

That won’t work. Point filtering will make the rims go away but it’ll also reduce the quality. The purpose of this is pre-processing the sprite atlas mipmaps so speed isn’t an issue. I just need a way to downsize sprites at good quality (so not point filtering) and then decide whether to keep the transparent pixels based on their alpha. Only problem is those pixels losing luminosity.

The purpose of this is pre-processing the sprite atlas mipmaps so speed isn’t an issue.

ah my bad.
Well you could write a shader to do it i suppose just multi sample and blend all the texels around a uv for each pixel you draw to and set the alpha yourself.

I have a 9 year old cpu side, huge imaging class, that has a inch of dust on it, horrifys me to look at, Still works and has options i don’t even know what they do.

When used on a heavily partially transparent and non transparent image shrunk by a non uniform amount.
Here is the result.


100 x 50

Ill zip it if you want it might be easier though to just write your own shader how you like the alpha to work.