BC7 ::: Normal texture and alpha map

Hi,

I want to setup a .psd texture as normal including additional alpha map.

2874064--210710--Untitled-1.jpg

and import this as a normal texture with the separate alpha as BC7 format.

Unity shows RGB(A) as BC7. But in shader code .a it’s completely BLACK after a texture lookup.

fixed4 n = tex2D(_MyTex, IN.uv_MyTex);
o.albedo = n.a;

I want to use Normal and Alpha as additional detail in a custom PBR shader to prevent a separate texture LooUp because of performance reasons.

Is this a bug, or does it not work for technicaly reasons?
Thanks!

Just don’t set it as a normal map and that’ll likely fix it. Unity might complain that it’s “not a normal map” but it should keep working.

The normal map texture type with 5.5’s BC5 or 5.4’s (and earlier) DXT5 only keep the red and green channels and black out the others (well, BC5 only has R and G channels, but it might still black out the other channels before compression). I suspect normal maps using BC7 do the same, especially since I believe that unlike BC3 / DXT5 where the alpha component is completely separate, the alpha can introduce artifacts in the other color channels.

Thanks, yes. Does it not have any side effects onto internal gama/linea conversion?

Yes, you’ll want to disable sRGB sampling, though I’ve not upgraded to 5.5 yet do I don’t know exactly how to do that with the new texture importer settings.

Actually, the DXT5nm format keeps the red and green channels, but they are stored in green and alpha of a DXT5 compressed texture.

So there is also simply no room left to store an alpha channel. The whole point of DXT5nm is to rearrange the channels to minimize the impact of compression on the normal map.

I haven’t looked into BC5/BC7 yet.

Edit: Just did. BC5 is in essence two times the alpha part of DXT5. So pretty much an optimized version of DXT5nm, though I can see other uses. (And no support for alpha, like DXT5nm.)

BC7 is a way more general compression standard that consists of 8 different modes. So I’d have to dive into that more.

BC5 is a massively welcomed addition, it’s absence in Unity has been a point of pain for a while as it’s been around for a long time and is a significant bump in quality over BC3 / “DXT5nm”. Note DXT5nm is not an actual format, it’s just a regular DXT5 texture with the red channel copied the alpha.

It is unfortunate Unity doesn’t actually support BC5 as the default normal map format still, and choose to use BC7 for “High Quality” normal maps. Using BC5_SNORM for normal maps (not that Unity supports SNORM either) can be a significant quality improvement over even BC7, especially with smooth or organic surfaces.

As soon as our current project moves to 5.5 I’ll probably convert over our normal maps and shaders to use BC5.

Actually, right when I learned about the specifics of DXT2/3/4/5 I was thinking that the 4 bit alpha encoding was very interesting. (And that is quite some years ago.) Because it offers 50% compression with hardly any quality loss. It’s actually a bit of an improved version of 4 bit ADPCM in audio (if you still remember that one.) And that trick to switch between 8 interpolation points and 6 with a fixed 0 and 1 is also pretty nice.

So as soon as I read about solutions of storing a normal in the green and alpha channel of DXT5 I thought, they should make a format with 1 DXT5 alpha channel and a format with 2 DXT5 alpha channels. And finally, here are BC4 and BC5. I’ll also use them for normal maps in 5.5, but I also see some other great options.

I know DXT5nm is not an actual format, but it’s such a common thing to do it almost is.