[Feature Request] Move "bFillPNGZeroAlpha" into factory/import setting of UTextureFactory.

While digging through engine sources I discovered that the engine destroys existing color information in png images on pixels that have zero alpha set on them.

I don’t think this is documented anywhere, but the offending lines are located within “Epic Games\UE_4.21\Engine\Source\Editor\UnrealEd\Private\Factories\EditorFactories.cpp” at lines 3138…3145.

It looks like this:

			if ( PngImageWrapper->GetRaw( Format, BitDepth, RawPNG ) )
			{
				uint8* MipData = Texture->Source.LockMip(0);
				FMemory::Memcpy( MipData, RawPNG->GetData(), RawPNG->Num() );

				bool bFillPNGZeroAlpha = true;
				GConfig->GetBool(TEXT("TextureImporter"), TEXT("FillPNGZeroAlpha"), bFillPNGZeroAlpha, GEditorIni);

				if (bFillPNGZeroAlpha) 
				{
					// Replace the pixels with 0.0 alpha with a color value from the nearest neighboring color which has a non-zero alpha
					FillZeroAlphaPNGData(Texture->Source, MipData);
				}
			}

So, uh apparently this is the reason:

/**
 * For PNG texture importing, this ensures that any pixels with an alpha value of zero have an RGB
 * assigned to them from a neighboring pixel which has non-zero alpha.
 * This is needed as PNG exporters tend to turn pixels that are RGBA = (x,x,x,0) to (1,1,1,0)
 * and this produces artifacts when drawing the texture with bilinear filtering. 
 *
 * @param TextureSource - The source texture
 * @param SourceData - The source texture data
*/

(this is a comment for FillZeroAlphaPNGData function)

While I see the point, this flag causes issues when you need to import png data that is known to contain correct information, for example, a map with glossiness information in alpha channel, possibly from another engine.

What’s more, the flag is set as an engine config switch, and cannot be altered if you’re, for example making a plugin that imports such png file.

As such it would be nice if the switch were moved into factory settings, where engine config switch would determine its default state… and the switch would need to be visible in texture import settings as well from UI side.

In this case original behavior would be retained, while it would be possible to import png texture without destroying its color data.