Option to export vertex colors as non-color data
See original GitHub issueI’m currently using vertex colors as data, so I want to preserve the raw values as I enter them in blender. For example, I might use one color channel to determine how much sway foliage has for a vertex shader. However, if I enter 0.5, for 50% sway, after the sRGB->linear conversion happens, I end up with a value of ~0.22, meaning I have to compensate for this when I color the verts, or I have to do a linear->srgb conversion in the shader, and I’d prefer not to add more calculations. Also, there’s data loss if I convert the values when I try to set them in Blender, since it appears that the colors are stored as 8bits per channel.
Note: Original issue filed was incorrect (I had colorspaces backward in my head), and this became repurposed, so I edited this. Leaving the original post below:
The glTF exporter runs vertex colors through a function called color_srgb_to_scene_linear(). There are a couple issues with this:
- I’m using vertex colors as data, not colors, so I want to preserve the raw values.
- color_srgb_to_scene_linear() seems to be backward:
def color_srgb_to_scene_linear(c):
if c < 0.04045:
return 0.0 if c < 0.0 else c * (1.0 / 12.92)
else:
return pow((c + 0.055) * (1.0 / 1.055), 2.4)
srgb->linear conversion should be using 1/2.4. Basically seems like these function names are reversed.
To Reproduce Steps to reproduce the behavior:
- Export using the glTF format.
- Note the vertex color values are LOWER than the values in blender
Expected behavior If values stored in the glTF format are supposed to be linear, and Blender is using sRGB, the sRGB -> linear conversion should make the values HIGHER/BRIGHTER. If Blender is already using linear values (not sure what the Blender vertex colorspace is), no conversion should take place. Would be nice to have a checkbox for export saying “I’m already using Linear vertex color values” to avoid conversion.
Version
- Blender Version [e.g. 2.80 (2019-05-17)]
Additional context Looks like this is where the color conversion was introduced: https://github.com/KhronosGroup/glTF-Blender-IO/issues/261
Issue Analytics
- State:
- Created 4 years ago
- Comments:32 (15 by maintainers)
Top GitHub Comments
@jitspoe
When you create a color attribute, make it’s Data Type “Color” instead of “Byte Color” (this is the default since 3.2). These colors are already stored in linear inside Blender so they get exported as-is without sRGB->Linear conversion.
Hello, Not sure this feature is still required, as Blender has now Attributes, that is the way to go for exporting data that are not colors.
Can I close this ticket?