forked from zeux/meshoptimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gltfpack: Implement support for custom color bit count
8 bit colors are not always enough, especially since glTF uses linear storage for vertex colors which is suboptimal - in general ~10 bits are required for linear storage to eliminate visible banding for 8-bit sRGB output, and more bits are required if the output is higher than 8 bits. This change implements support for custom bit counts for color components. To maximize the compression ratio, when bit count isn't 8 or 16, the bottom bits of the resulting value are set to 0 or 1 based on the high bit. Varying the bit is important as this preserves 0 and 1 exactly. A more correct scheme would involve replicating multiple top bits into the bottom bits, but this results in significantly worse compression ratio for N > 8, as the compressor can't exploit the corellation between the high and low bytes. With 0 or 1 simply replicated, the byte structure is easier to discern and the result compresses better.
- Loading branch information
Showing
3 changed files
with
57 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ struct Settings | |
int pos_bits; | ||
int tex_bits; | ||
int nrm_bits; | ||
int col_bits; | ||
|
||
int trn_bits; | ||
int rot_bits; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters