-
Notifications
You must be signed in to change notification settings - Fork 236
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
Astc normal maps #493
Astc normal maps #493
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please modify the documentation for normal mode so that it says something along the lines of
If the input file has 3 or 4 components, a 2 component normal map will first be generated. The 2-component normal map will be encoded with X in the RGB channels and Y in the alpha channel of the compressed texture. The encoding is optimized for normal maps by such things as disabling RDO, if RDO is available, and tuning for angular error rather than PSNR.
This allows us to support 2-component inputs without needing an option to invoke the 3 to 2 conversion and lets us extend the normal map support to the Basis encoders. The next release of Basis will have optimization for angular error. At some point I plan to add RDO for ASTC to get better results when zstd compression is used.
@MarkCallow I have now started another PR for this because my fork has changed, but before I create that one and close this one. I would like to resolve the documentation update you requests. We already have the following regarding
Thinking about your request:
I think, all the information is there. You have worded it differently. Is there still a need for wording it like you suggested or shall I leave it as is? Or did you want me to add this documentation somewhere else? |
The main thing I want to change is the assumption that the input is a 3 component linear normal map. We need to allow both 2 and 3 component inputs. So I'd reword like this:
I've struck "LDR" as well. Wouldn't you want do the same things for HDR normal maps? By the way does it give an error if the input is not linear? The document suggests it will. We can probably strike the "linear"s that are in line in the text. The last validity statement is sufficient but I didn't notice it until I'd already written them. |
Ok makes sense. I don't know much about HDR normal maps though not very common at least.
It does in basis case, I will add it to astc section as well. KTX-Software/tools/toktx/toktx.cc Line 1347 in 86231df
Also I am moving this error message outside the
I would move it first statement. that was its more useful and if thats all what people read it will probably be enough without knowing what we do with these different component. |
Yes, looks like a bug. Well caught! Please fix it as part of this PR. |
Tests failed because the source reference image |
@wasimabbas-arm my mail server is having problems so my reply to your e-mailed question has not been sent. Here it is. You'll get this in e-mail too once the server comes back up. toktx currently assumes .jpg files are sRGB because for the most part they are as the underlying YUV space is non-linear. At some point it should be updated to understand the various APPn tags in which color space information can be stored. toktx does not support ICC profiles. I was hoping to address both of these things by using OpenImageIO but I’m not sure that is going to work out. You can override the file’s OETF by using |
The first image (the one where you said you converted the .jpg to a .png) has an ICC profile, which as I said are not yet supported. I do not know what is in the profile. The second image has no color space information at all. In that case I suspect the first image is actually the Adobe RGB or Apple RGB image and the second one the "untagged" image. You need to specify linear (may be you have to say gamma = 1.0) for the output when converting from the JPG image. But it is better to try to find an original. By the time it has been encoded to .jpg the damage to the original normal data has been done. In the meantime you can use the |
I only have one image attached to the comment the .png. The first image is a screenshot from photoshop only to show its "Untagged RGB" its not to be used for testing.
This is the actual .png I created I really need some help from an artist here it seems. I think for now I will go with your advice |
So looks like the tests pass now but Appveyor 1h limit is messing up some of them. |
They have passed now. I don't know what problem you were seeing. The limit for this repo has been set at 2 hours for a few weeks now. Perhaps the new limit doesn't apply to PR builds. I need to verify the requested changes were made. I've forgotten what they were so I'll have to review the conversations and changes. It will likely be a couple of days before I can get to it. If you find a non-JPEG normal map image, please let me know. |
@wasimabbas-arm I spotted a few typos in the documentation. Please fix them. Also the doxygen/html documentation for I have received from the person who created Iron_Bars a PNG version but it is 4k x 4k. It needs resampling as it is too large to include in the tests (56Mb). Resampling normal maps requires renormalizing the normals after filtering. I need to find a tool to resample and renormalize this PNG to avoid adding 56Mb to This also flags up the need to implement renormalizing when generating mipmaps for normal maps. There is a TODO for that at line 1240 in |
I think I have fixed everything you have raised.
I have photoshop and can do stuff with it but I don't know if it can do that with normal maps it also adds ICC profiles and what not that toktx didn't like. I asked our artist to understand better if this is possible. I think its not straight forward within Photoshop. We might have more luck with xNormal or Crazy Bump but I am not familiar with those. Also I did some manual investigations of the normal map we have, its pixels are not normalized normals either. So we are starting with unnormalized data. Usually people would normalize normals when they read it in shaders.
I don't mind but I am in training this whole week so will have to wait. Unless we can merge this PR and do that next. |
I've looked at the DFD channel id problem. I see the cause and I have a fix in progress. |
Here is a fixed The problem was that toktx is setting the There is no actual need to set The commit message should read
You will need to regenerate the reference images. 3 will be changed after the rewrite: |
Generalize detection of luminance textures. Do not use number of input components to determine how to rewrite DFDs.
@wasimabbas-arm, It looks like we may be suffering a case of non-determinism in the ETC1S encoder across platforms. Did you generate the golden image on macOS? I seem to recall that in some previous work you made a way to retrieve failing images from the CI build. Please remind me how that worked so I can investigate a failing image. |
Yes. @MarkCallow I have had a hit and miss success with artefacts pulling. I remembering having tried all of the following with some success: https://github.com/KhronosGroup/KTX-Software/blob/master/.travis.yml#L112 However what have reliably worked was to reproduce the issue on Linux, which I have and managed to reproduce this one as well. For Appveyor I had to remote desktop to the machine from windows machine. |
Please attach the bad image here so I can compare it with the golden image. Have you already compared them? |
Yes I did compare. You probably missed the email I sent about it. Here it is again.
-supercompressionGlobalData.byteLength: 6829
+supercompressionGlobalData.byteLength: 6838
-Level0.byteOffset: 0x1bed
-Level0.byteLength: 257480
+Level0.byteOffset: 0x1bf6
+Level0.byteLength: 257414
Level0.uncompressedByteLength: 0
-selectorCount: 2668
+selectorCount: 2666
-selectorsByteLength: 5820
-tablesByteLength: 789
+selectorsByteLength: 5828
+tablesByteLength: 790
-rgbSliceByteLength: 130493
+rgbSliceByteLength: 130461
-alphaSliceByteLength: 126987
-alphaSliceByteOffset: 0x1fdbd
+alphaSliceByteLength: 126953
+alphaSliceByteOffset: 0x1fd9d
Here is the failed test image. |
Yes. See BinomialLLC/basis_universal#60. It is an issue with the ETC1S encoder. Mac version works because that is where the golden image was generated. The image from the failed test looks fine so I am sure it is this same issue. What we did for the other problem cases is only run them on APPLE. See KTX-Software/tests/toktx-tests.cmake Lines 152 to 159 in 91c6cb4
toktx-tests.cmake .
Feel free to put an |
Yea I have seen those |
Ok I think we are good to go. appveyor failed in debug builds due to 1h limit again. But usually for some reason it just clears up after a while or you do some magic, don't know. |
I don't do anything. PR's seem to launch 2 builds, the first gets the standard 1 hour limit and fails, the second gets the extended 2 hour limit on the repo and succeeds. I haven't tried to investigate deeply what is going on and it always eventually clears up. |
@wasimabbas-arm thank you for persevering with this. You have created a very useful addition to the functionality which makes it easier to create normal maps. |
normalMap in ktxAstcParams and ktxBasisParams (`--normal_mode` in `toktx`), causes the encoders to split the R & G components of the input into the RGB & alpha channels of the encoded texture and to apply encoder-specific settings that improve quality for normal maps. Add `--normalize` option to `toktx. Add tests for normalMap and normalize functionality. Deprecate `separateRGToRGB_A` and remove related code. Fixes KhronosGroup#455. Co-authored-by: Wasim Abbas <[email protected]>
normalMap in ktxAstcParams and ktxBasisParams (`--normal_mode` in `toktx`), causes the encoders to split the R & G components of the input into the RGB & alpha channels of the encoded texture and to apply encoder-specific settings that improve quality for normal maps. Add `--normalize` option to `toktx. Add tests for normalMap and normalize functionality. Deprecate `separateRGToRGB_A` and remove related code. Fixes KhronosGroup#455. Co-authored-by: Wasim Abbas <[email protected]>
normalMap in ktxAstcParams and ktxBasisParams (`--normal_mode` in `toktx`), causes the encoders to split the R & G components of the input into the RGB & alpha channels of the encoded texture and to apply encoder-specific settings that improve quality for normal maps. Add `--normalize` option to `toktx. Add tests for normalMap and normalize functionality. Deprecate `separateRGToRGB_A` and remove related code. Fixes KhronosGroup#455. Co-authored-by: Wasim Abbas <[email protected]>
normalMap in ktxAstcParams and ktxBasisParams (`--normal_mode` in `toktx`), causes the encoders to split the R & G components of the input into the RGB & alpha channels of the encoded texture and to apply encoder-specific settings that improve quality for normal maps. Add `--normalize` option to `toktx. Add tests for normalMap and normalize functionality. Deprecate `separateRGToRGB_A` and remove related code. Fixes KhronosGroup#455. Co-authored-by: Wasim Abbas <[email protected]>
normalMap in ktxAstcParams and ktxBasisParams (`--normal_mode` in `toktx`), causes the encoders to split the R & G components of the input into the RGB & alpha channels of the encoded texture and to apply encoder-specific settings that improve quality for normal maps. Add `--normalize` option to `toktx. Add tests for normalMap and normalize functionality. Deprecate `separateRGToRGB_A` and remove related code. Fixes KhronosGroup#455. Co-authored-by: Wasim Abbas <[email protected]>
First attempt at making 2-component normal mapping working.