niftools / blender_niftools_addon

The Blender Niftools Addon is a Blender add-on to enable import and export of NetImmese File Formats including .nif, .kf, .egm.
http://www.niftools.org
Other
388 stars 104 forks source link

Imported vertex colors are incorrect #640

Open SodiumEyes opened 2 months ago

SodiumEyes commented 2 months ago

When importing a nif, the vertex colors end up lighter than they should be. This only happens on Blender 3.2.0+. On Blender 3.1, the colors are correct.

3.6 Capture

3.1 Capture2

Candoran2 commented 1 month ago

Could you attach the nif?

SodiumEyes commented 1 month ago

Could you attach the nif?

potionhealthgreat.zip

ja231c commented 1 month ago

In older versions than 3.2 it gets imported as a vertex color. In 3.2+ vertex color was replaced by Color Attribute and gets imported as a Color Attribute of type Vertex > Color. If you load a pre 3.2 blend file the vertex color gets converted to a Color Attribute of Face Corner > Byte Color, not Vertex > Color.

The Byte Color ones are INT8 sRGB, the Color ones are FP32 linear.

The 3.2+ Vertex > Color one is actually the more accurate one as far as preserving the same data on export is concerned (as the vertex colors are often stored as FP32). The ones with Face Corner > Byte Color result in slightly different vertex color values on export.

Whichever is correct visually depends on the game. Both types export with same looking values, the visual difference is only in Blender.

Basically, both are correct, and incorrect, at the same time.

I don't think anything can be done about this, not without breaking anything at least, unless we are fine with the accuracy loss of Byte Color, and it being wrong for games that do use linear vertex colors (Fallout 4+, probably). Or applying the gamma correction on import and export, depending on game, which will break export for all already imported meshes (and cause a very very tiny accuracy loss), unless an option to disable the correction is added.