New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poor normal map compression quality #99
Comments
Hi - Looking at your command line, you aren't using the -q option to increase the quality level. (-comp_level doesn't increase quality much, and is only intended for video compression.) So definitely try "-q 255". The default quality level is -q 128. You can also boost quality even higher than -q 255 - see below. Basis Universal doesn't handle 3D normal maps encoded into RGB well because the internal encoding is ETC1S (a subset of ETC1). However, if you use the "-seperate_rg_to_color_alpha" command line option, that'll put X into RGB and Y into Alpha, then you can recover Z in your pixel shader using z=sqrt(1-xx-yy). Quality with this encoding is much higher for tangent space normal maps. We are working on a new much higher quality universal format due out within a couple months. Also there's this info in the docs:" "For high quality tangent space normal maps, here's one suggested solution that should work well today: Start with 2 component normalized XY tangent space normal maps (where XY range from [-1,1]) and encode them into two 8-bit channels (where XY is packed into [0,255]). Now put X in color, and Y in alpha, and compress that 32-bit PNG using basisu. The command line tool and encoder class support the option "-seperate_rg_to_color_alpha" that swizzles 2 component RG normal maps to RRRG before compression, aiding this process." |
I compressed your normal map using "-seperate_rg_to_color_alpha", and the quality looks pretty good. (It could be even higher if I used -max_selectors 16128 and -max_endpoints 16128 instead of -q 255.) We're getting 38.8 dB on RGB and 39.1 dB on Alpha. I've included the unpacked X and Y images below. basisu -file c:\dev\nm.png -seperate_rg_to_color_alpha -normal_map -q 255 -stats Slice: 0 |
As quality with 3D XYZ normal maps encoded into RGB textures is a known issue (it was an explicit tradeoff we decided to make), this is not a bug. The system has really strong support for XXXY normal maps. |
Note that the transcoder has full support for XXXY encoded normal maps. You can transcode them to two ETC1 textures, two PVRTC1 textures, or a single ETC2, BC3, BC5, ASTC, BC7, PVRTC2, etc. texture. (You could try a single PVRTC1, but I doubt it would look acceptable.) So these normal maps should work well on all devices, if you're willing to do the legwork. |
Hi Rich, Thank you for the info and for clarifying the -q option. Also, I look forward to trying out your new universal format when it's ready! Storing a normal map in two textures (and so requiring two texture reads) on devices that only support etc1 (i.e. quite often older slower devices) is bit of a performance and resource double whammy. It also complicates the engine and shader paths. It may be better in this case to transcode to an uncompressed rgb565. I would like to add that we are very excited to get basis working everywhere for everything in our pipeline, because it simplifies significant parts of our tooling and asset delivery and packaging. Thanks again! |
Hi @richgel999 , We swizzle normal maps to GGGR and reconstruct Z in shader as is normal/suggested. However we have found up to now that the quality of the GGG channel on iOS is so poor we transcode to RGBA8 instead of PVRTC. (The alpha R channel is fine). We were hoping uastc would improve on this, but from a quick test on one of our difficult cases I don't see substantial improvement. In fact the resulting GGG data for both etc1 and uastc are very similar. Am I right to conclude that in general switching to uastc won't improve quality of PVRTC? Thanks! |
Sorry and one more thing, am I right in saying that basis etc1 internal format will have higher quality than uastc when transcoded to etc1? |
Hello!
We are busy integrating basis into the Playcanvas asset pipeline and find the resulting quality of tangent space normal maps particularly poor, so poor as to make them unusable. We understand there are superior approaches to normal map compression in general (as explained in the basis README), however we have many existing assets that would benefit from basis compression. Please see an example side-by-side comparison below. It appears basis nearly filters out the diagonals running top left to bottom right:
The DXT image was created using PVRTexTool.
The basis image was created using flags: -y_flip -mipmap -comp_level 5 -normal_map
Full versions of the test normal maps
Original:
Basis compressed:
DXT:
Is this drop in quality expected under basis? Is there anything we can do to improve quality?
Thanks!
The text was updated successfully, but these errors were encountered: