-
Notifications
You must be signed in to change notification settings - Fork 231
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
Improve handling of perceptual encoding metrics #392
Comments
This should affect UASTC as well wrt mipmap generation presumably, even if the error metric used by the encoder is flat. |
What do you want to happen? sRGB is perceptual. Linear is not. So how else to select use of the encoder's perceptual flag? It sounds like you want options to set the per-channel weights. You want these in the ktxBasisParams struct and toktx? What metrics are you talking about? toktx currently doesn't compute any metrics. Are you saying you want KTX-Software to expose an option to specify in which space the Basis encoder computes its error metrics?
??? Filtering for mipmap generation is done in linear space. |
Yes, which is controlled by |
As far as I can see, this is independent of @lexaknyazev's request. |
Since the currently used perceptual weights are hard-coded to Rec. 709 in the encoder, the perceptual flag makes less sense in a case when different primaries are used. Once the encoder starts accepting custom channel weights, KTX-Software should just set them directly based on actual primaries instead of using that perceptual flag.
Yes, once the encoder supports this option. It's not there yet. |
Looking into this again, I think we do not need physically-linear metric for sRGB-encoded data, because the perceptual luma (Y') is by definition a weighted sum of non-linear values. |
PR #534 adds a --astc_perceptual flag for the astc encoder. Here's the doc:
Since this is not tied to sRGB inputs it seems to me different from perceptual in the BasisU encoder as the latter is tied to sRGB, so we made it astc-specific. @lexaknyazev please take a look and answer the following: is this actually similar to what you are requesting here for the BasisU encoder, minus being able to specify the weights?
Please explain. Are you saying perceptual mode should only be applied to non-sRGB inputs? |
There are two different aspects to perceptual metrics - chroma bias, and gamma bias. The current The gamma bias is something I'm not yet sure how to correct for (or even if it's desirable to do so). For sRGB textures the gamma-corrected luminance curve means that an error of X should have the same weight no matter the absolute luminance involved, so I think it's safe to ignore gamma bias. For linear textures that store color, the significance of an error X depends on the absolute luminance you are starting with, as it is obviously not following the perceptual curve. I think the standard fix for this is using Y'CbCr for error calculations, as this can correct for both the gamma curve and the luma-chroma perceptual significance differences. However, if you care enough about gamma correcting your errors you should probably really be using sRGB textures for color data anyway, so I'm in two minds about whether this really has much value. There doesn't seem much point using a gamma corrected error metric in the compressor only to stuff the compressed data into a non-gamma corrected encoding. |
Ping @lexaknyazev. Please answer the questions in my comment and let us know if you have any thoughts about what @solidpixel wrote. |
Yes.
Technically, this is covered by the @solidpixel's comment above. We do need configurable chroma bias everywhere, regardless of transfer functions (think raw Correcting the gamma bias (i.e., decoding 8-bit sRGB to linear floats before computing the error) may even produce worse final results because errors in lower values are usually more important than errors in upper values for color data. |
Basis encoder has a "perceptual" flag. When enabled, it assigns uneven weights to red, green, and blue channels for computing the error metric. By the way, only ETC1S is affected by that for now.
Ideally, the settings should be more flexible:
[0.2126, 0.7152, 0.0722]
(matches the current "perceptual")[0.2627, 0.6780, 0.0593]
Currently, the
perceptual
flag is tied to the source transfer function which is a bit misleading./cc @zeux
The text was updated successfully, but these errors were encountered: