Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[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.

Product Version: UE 4.21
more ▼

asked Nov 18 '18 at 02:24 AM in C++ Programming

avatar image

99 13 17 29

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question