Home Unreal Engine

Channel Packing for UE4

polycounter lvl 9
Offline / Send Message
Yogensya polycounter lvl 9
Hi,

I've been reading a bit on channel packaging today.

I'd like to know what you guys think, which methods you prefer or if you have anything to add or correct to what I've gathered so far. Hopefully this also helps some peeps that didn't know about the little details regarding channel packaging.

In the UE4 Docs there's this bit of info:
Masking and Channel Artifacts

Because of a quirk with DirectX, the Green Channel of a texture will often offer the best compression. If any of your masks suffer greatly from compression artifacts, first try placing the information into the Green Channel to see if that helps. If that does not fix the issue, then try using the Alpha channel to store the information.

* Be careful when trying to use the Alpha channel of a texture to store Mask Textures. Adding an Alpha channel to a texture will greatly increase the memory footprint of that texture and if you do this enough, you could lose all the saving you gained by packing different Mask Textures in to the RGB channels of a textures.

The quote above kinda suggests the Roughness should be in the Green channel, as roughness is the texture where we want to preserve as much detail as possible. Not to mention Metal tends to be black and white, with almost no fine details. However I see that the most accepted method of packing mask is RMA (R = Roughness, G = Metalness, B = AO).

Wouldn't MRA be best, with Roughness in the green channel and Metalness in the Red one, or would the difference be negligible?

And when is it worthwhile to use the alpha channel if it has such an impact on memory? Maybe for more important assets like characters?

I've also seen some artists come up with their own packaging schemes, going as far as packaging roughness in the blue channel of a BC7 normal map (if I understood correctly).

I've also read that channel packaging reduces memory but at the cost of increasing draw calls. Is this something an artist should be concerned about?

To end the post I'll just add some extra pointers for those of you who didn't know:

  • As mentioned in the quote above, generally it's a good idea to avoid the alpha channel as it greatly increases the use of memory which defeats the purpose of channel packaging.
  • Channel packed textures needs to be stored in linear space (in UE4 you need to open the texture and untick the sRGB checkbox) or they won't look correctly in the engine.

Replies

  • musashidan
    Options
    Offline / Send Message
    musashidan high dynamic range
     In UE4 DXT compression, the Green channel has the most data and because the Roughness map is the most important, Green is best for it. Also, good idea to drop the Metal map(if it's just a black/white value) and save without the alpha. That way you'll be using DXT1 compression rather than DXT5, which is 2X the memory footprint.

    Also, packing is reducing calls as you're only using 1 texture node as opposed to 2 or 3.

    This is why choosing dxt1 or dxt5 for packing can sometimes balance out calls vs memory footprint.

    This is my understanding anyway. I'm no tech artist. Hopefully @obscura or somebody will chime in.
  • radiancef0rge
    Options
    Offline / Send Message
    radiancef0rge ngon master
    Because of a quirk with DirectX, the Green Channel of a texture will often offer the best compression. 

    I wouldn't call this a quirk, its expected behavior the green channel has one extra bit as the channels of DXT1 are compressed at R5G6B5 which fits into a 16 bit color format. Therefore ideally your most important map is packed into the green channel, in most cases this is roughness/gloss. That being said I highly doubt you will notice a difference. 

    Here are some thoughts on alpha channel and texture packing - http://polycount.com/discussion/182251/questions-about-materials-shaders-and-textures. Some engines pack normal and roughness together so they can apply Toksvig filtering without depending on finding the other texture on disk.  
    As mentioned in the quote above, generally it's a good idea to avoid the alpha channel as it greatly increases the use of memory which defeats the purpose of channel packaging
    I don't buy into this theory at all. Reducing texture fetches can be paramount, its one of the slowest things you can do in a shader.
    Channel packed textures needs to be stored in linear space (in UE4 you need to open the texture and untick the sRGB checkbox) or they won't look correctly in the engine.

    Some maps are authored in sRGB. (Specular and roughness/gloss maps are often authored in sRGB) I don't know for sure but I would find it hard to believe that AO maps are baked in linear - but maybe I'm wrong. Its fairly simple to independently apply gamma correction to a single channel in a shader. 

     Going as far as packaging roughness in the blue channel of a BC7 normal 

    In reality BC7 can double your texture footprint when compared to DXT. Its pretty tough to justify channel packing like this when the texture is twice the size. BC5 normal maps compressed at R8G8 can look better at half or even quarter res than a DXT normal map. So there can be some savings there. 

  • Froyok
    Options
    Offline / Send Message
    Froyok greentooth
    Channel packed textures needs to be stored in linear space (in UE4 you need to open the texture and untick the sRGB checkbox) or they won't look correctly in the engine.

    Some maps are authored in sRGB. (Specular and roughness/gloss maps are often authored in sRGB) I don't know for sure but I would find it hard to believe that AO maps are baked in linear - but maybe I'm wrong. Its fairly simple to independently apply gamma correction to a single channel in a shader. 

    AO and more generally Lightmaps are baked as Linear, simply because they are lighting information. There is no reason to store/bake them as sRGB.
  • radiancef0rge
    Options
    Offline / Send Message
    radiancef0rge ngon master
    Froyok said:
    AO and more generally Lightmaps are baked as Linear, simply because they are lighting information. There is no reason to store/bake them as sRGB.
    Oh word, is this true Substance only though? IE Is something like the designer hbao node have no tonemapping applied when its rendered to texture? And is that true of Xnormal or Maya etc? Seems that that would be as dependable as saying normal maps are baked in DX orientation by default no?
  • Yogensya
    Options
    Offline / Send Message
    Yogensya polycounter lvl 9
    Thanks for the input so far guys.

    As for the green channel, even if it's not nearly noticeable, when it comes to either performance or image quality every little bit helps so I'd definitely be willing to use MRA packaging from now own, since roughness detail is more crucial to the material than the other masks.

    Regarding sRGB vs linear, in my experience Specular maps (in spec workflow) and Albedo/BaseColor are sRGB, but Normal maps & masks like Roughness/Gloss/Metalness/AO aren't, Opacity being an exception for instance saved in the BaseColor alpha, therefore in sRGB. That's just how I've always made and tested them, though so not sure if it can change depending on the project/engine.

    I definitely to agree on BC5 for normals maps, in my opinion it's very much worth the quality bump over other formats and like you said it even allows for smaller textures when needed at similar definition.

    Regarding draw calls vs textures, that's something i'd like to hear more about and maybe test personally.
  • Millenia
    Options
    Offline / Send Message
    Millenia polycount sponsor
    I tend to have roughness in G just so I can tick the nice little "flip green" tickbox if someone accidentally authors the roughness as a gloss map.
  • IacopoAntonelli
    Options
    Offline / Send Message
    IacopoAntonelli polycounter lvl 3
    Oh god, reading that MRA is better than RMA after finishing the setup of our open world game shaders (using RMA) is a great joy.
Sign In or Register to comment.