Skip to content
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

gltfpack: Introduce optional floating-point normal quantization #634

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

zeux
Copy link
Owner

@zeux zeux commented Nov 16, 2023

Usually normalized integer storage is optimal for normals; however, morph target deltas require a [-2, 2] storage range. During quantization we clamp them to [-1, 1] which ends up usually working fine, however there are some use cases where this doesn't work well when the normal deformation is extreme.

This can be solved by scaling normals by 0.5, so we'll use [-0.5, 0.5] range for base normal and [-1, 1] range for normal deltas. This usually works fine with any glTF renderers as they normalize the normal (which is more or less required for handling non-uniform scale transforms).

However, the validator treats files like this as invalid. Validator doesn't process files with -c/cc so technically we could fix this when compression is enabled, but that would result in an odd mismatch where compression improves quality instead of degrading it...

For now we introduce an option to use floating point normals, quantized using reduced mantissa and stored, when compression is enabled, using exponential filter. Similarly to -vtf, this isn't normally the recommended mode but there might be cases where it's a desireable tradeoff.

Fixes #632.

Usually normalized integer storage is optimal for normals; however,
morph target deltas require a [-2, 2] storage range. During quantization
we clamp them to [-1, 1] which ends up usually working fine, however
there are some use cases where this doesn't work well when the normal
deformation is extreme.

This can be solved by scaling normals by 0.5, so we'll use [-0.5, 0.5]
range for base normal and [-1, 1] range for normal deltas. This usually
works fine with any glTF renderers as they normalize the normal (which
is more or less required for handling non-uniform scale transforms).

However, the validator treats files like this as invalid. Validator
doesn't process files with -c/cc so technically we could fix this when
compression is enabled, but that would result in an odd mismatch where
compression *improves* quality instead of degrading it...

For now we introduce an option to use floating point normals, quantized
using reduced mantissa and stored, when compression is enabled, using
exponential filter. Similarly to -vtf, this isn't normally the
recommended mode but there might be cases where it's a desireable
tradeoff.
@zeux zeux merged commit 8bac922 into master Nov 17, 2023
12 checks passed
@zeux zeux deleted the gltf-vnf branch November 17, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gltfpack: floating point attributes for normals
1 participant