Guekka / bethutil

Common utilities for working with bethesda assets (dds, nif, bsa, hkx...)
https://guekka.github.io/bethutil/
Mozilla Public License 2.0
4 stars 2 forks source link

feat(tex): improve texture optimization #50

Closed mklokocka closed 4 months ago

mklokocka commented 4 months ago

Introduced some further improvements to the texture optimization process:

1) Do not decompress images when there is no need, that is, when resizing is required. There is no need for decompressing and compressing an image again if resizing is not applied. 2) Enforce conversion of results when input has no/opaque alpha to a format without alpha (either compressed, or not). This fixes the issue with Resize introducing full white alpha to the image, which can break stuff like normal maps. Normal maps with full white alpha are not the same as those with no alpha (alpha represents specularity). 3) Never remove mipmaps - if resizing is applied and the input had mipmaps, regenerate them after resize. This is because mipmaps are very important to game visuals and performance. Removing them while resizing doesn't make sense even if mipmaps are not requested.

An important point: recompressing with a "higher" BC does not improve quality. If the input is already block compressed, decompressing does not restore quality, and thus compressing it again with better BC does not improve on the input at all. In fact, it only increased the size of the resulting image without any benefits.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 80.40%. Comparing base (cd47770) to head (dbd6565).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/Guekka/bethutil/pull/50/graphs/tree.svg?width=650&height=150&src=pr&token=llth93S2Em&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar)](https://app.codecov.io/gh/Guekka/bethutil/pull/50?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar) ```diff @@ Coverage Diff @@ ## main #50 +/- ## ========================================== + Coverage 80.36% 80.40% +0.03% ========================================== Files 38 38 Lines 1691 1694 +3 ========================================== + Hits 1359 1362 +3 Misses 332 332 ``` | [Files](https://app.codecov.io/gh/Guekka/bethutil/pull/50?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar) | Coverage Δ | | |---|---|---| | [src/tex/optimize.cpp](https://app.codecov.io/gh/Guekka/bethutil/pull/50?src=pr&el=tree&filepath=src%2Ftex%2Foptimize.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar#diff-c3JjL3RleC9vcHRpbWl6ZS5jcHA=) | `72.58% <100.00%> (+0.67%)` | :arrow_up: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/Guekka/bethutil/pull/50?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/Guekka/bethutil/pull/50?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar). Last update [cd47770...dbd6565](https://app.codecov.io/gh/Guekka/bethutil/pull/50?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Edgar).
mklokocka commented 4 months ago

Not sure why the pipeline failed this time, nothing changed besides a comment.

Guekka commented 4 months ago

Not sure why the pipeline failed this time, nothing changed besides a comment.

Looks like a spurious fail