-
Notifications
You must be signed in to change notification settings - Fork 267
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
Saving and loading two-channel normal maps (ASTC) #346
Comments
Not sure about how BasisU handles this, but when doing normal map compression with BasisU via libKTX, then the correct swizzle for UASTC compressed normal maps would be
Having swizzles of 0 and 1 would, at least in OpenGL terms, mean that you don't take the actual R and G values, but replace them with 0 in rgb and 1 in a when sampling in a shader. Nowadays, the only options one needs to really consider is BCn on desktop platforms (Windows, Linux, OSX, ...) and ASTC on mobile and embedded platforms and if for some reason that doesn't work, you have multiple legacy formats to fallback to (PVRTC1/2 and ETC2/EAC on iOS/Android, S3TC on desktops). Let's assume, we only target BCn and ASTC. When sampling the texture in a shader, the necessary swizzle depends on the platform your running on. When transcoding to ASTC on the target platform, you need to sample with an To be able to use a single swizzle like When not having native texture swizzle support, the only options you have is to either
This gets even more complicated when supporting both compressed and uncompressed normal maps, which you sometimes want, especially with 8-bit normal maps. Assuming the uncompressed data is also stored as a two-channel RG image, then on an ASTC platform, you'd have two cases to consider, because both sampling from I guess going to UASTC->ASTC and UASTC->BC7 and uncompressed RRRG textures would be a viable solution, but when I investigated this avenue, I found some more or less heavy quality issues with UASTC->BC7 transcoding for normal maps. |
I'm trying to implement platform-independent compressed normal maps that use Z reconstruction in the shader.
It looks like this is the correct way to save a two-channel image:
I am working on the assumption that a two-channel image should always be transcoded into BC5 format (or its equivalent on mobile). Is there a way to detect either the swizzle states or number of channels when the image is loaded? I can't seem to find anything like this in the basisu_image_info or basisu_file_info structures. If we had this information it would be very easy to select a transcode format:
I know the KTX2 SDK provides this information, but I prefer to use Basis and DDS for all textures. It is also possible to store hints in the userdata values, but this feels like a hack and I would like something more versatile that will work with any basis file.
The text was updated successfully, but these errors were encountered: