Closed RichysHub closed 5 years ago
Have added support for this. Need to perform a proper test on the code though, ensure palette is used . This probably needs me to write a palette stripper, to get hold of a .vox file with no RGBA chunk
In testing if the default palette was used, a bug was found causing colors to be different to expectations. This has been fixed in https://github.com/RichysHub/MagicaVoxel-VOX-importer/commit/9e792920fc9c91ec0d07a8226c96ce5a9ea17e52
Loading this sample chr_cat.vox, I have to correct the palette.update
in:
if not palette: # no palette provided, use default
for col in range(256):
palette.update({col + 1: struct.unpack('<4B', struct.pack('<I', DEFAULT_PALETTE[col]))})
Please note the "<I" packing DEFAULT_PALETTE (it is ">I" now)
Okay, I was hesitant to agree, given the above changes, and therefore how confident I was.
However, I have thrown together a quick script (something I clearly never did back in 2017) to visualize the palettes, and I am happy to agree that it is currently incorrect.
struct.unpack('<4B', struct.pack('>I', DEFAULT_PALETTE[col]))
produces:
struct.unpack('<4B', struct.pack('<I', DEFAULT_PALETTE[col]))
produces:
I think there are some slight issues in gamma correction maths currently, and in #8, but I'll detail those there.
Default palette is well defined in the specification of the format, yet currently we do not use this, we simply expect a palette chunk to be present in the .vox file