question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to export vertex colors as non-color data

See original GitHub issue

I’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:

  1. I’m using vertex colors as data, not colors, so I want to preserve the raw values.
  2. 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:

  1. Export using the glTF format.
  2. 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:open
  • Created 4 years ago
  • Comments:32 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
scurestcommented, Dec 20, 2022

@jitspoe

Would be nice if there was just an option to export the color values as-is without conversion to linear like I originally requested.

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.

1reaction
juliendurourecommented, Dec 20, 2022

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Export vertex colors - 3Dflow.net forum
How would I go about exporting the vertex colors to Maya? I'm using the free version of Zephyr. Obj doesn't seem to store...
Read more >
How to export vertex colors - Blender Stack Exchange
I was using Vertex domain and Color data type, switching to Face Corner and Byte Color correctly exports the vertex colors! @scurest You...
Read more >
Exporting Per Vertex Color in Meshmixer - Autodesk Forums
Solved: I'm trying to export per vertex color from meshmixer with no luck. Has anyone actually been able to get that to work?...
Read more >
GLTF Vertex Colors - Bugs - Babylon.js Forum
There seems to be an issue with vertex colors. I have been compressing my GLTF file ... Option to export vertex colors as...
Read more >
4.4 - Ply Data Format — LearnWebGL
(The OBJ file format only allows you to assign a material property (color) to a complete face (or triangle), not individual vertices. Exporting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found