gltf exporter does not export non-byte color and non-face-corner vertex colors in 3.3 alpha #99005

Closed
opened 2022-06-20 05:04:59 +02:00 by Ivan Notaros · 19 comments

Blender Version
3.3.0-alpha+master.6ad9d8e2247d-windows.amd64-release

Short description of error

Exact steps for others to reproduce the error

  1. Create an object
  2. Add color attribute layer (don't choose Face Corner + Byte Color) optionally paint something on it with Vertex Paint
  3. Export as glft/glb
  4. Make sure the Vertex Color export option is enabled in Geometry tab
  5. gltf doesn't have vertex color

Opening the gltf you can see that the attributes are:

                    "attributes" : {
                        "POSITION" : 0,
                        "NORMAL" : 1,
                        "TEXCOORD_0" : 2
                    },

COLOR_0 is missing

test_vertex.blend
2022-07-07 10-12-27.mp4

**Blender Version** 3.3.0-alpha+master.6ad9d8e2247d-windows.amd64-release **Short description of error** **Exact steps for others to reproduce the error** 1. Create an object 2. Add color attribute layer (don't choose Face Corner + Byte Color) optionally paint something on it with Vertex Paint 3. Export as glft/glb 4. Make sure the Vertex Color export option is enabled in Geometry tab 5. gltf doesn't have vertex color Opening the gltf you can see that the attributes are: ``` "attributes" : { "POSITION" : 0, "NORMAL" : 1, "TEXCOORD_0" : 2 }, ``` COLOR_0 is missing [test_vertex.blend](https://archive.blender.org/developer/F13264690/test_vertex.blend) [2022-07-07 10-12-27.mp4](https://archive.blender.org/developer/F13264687/2022-07-07_10-12-27.mp4)
Author

Added subscriber: @nothke

Added subscriber: @nothke

#99509 was marked as duplicate of this issue

#99509 was marked as duplicate of this issue

Added subscriber: @scurest

Added subscriber: @scurest

What kind of color attribute layer? The exporter still only supports pre-3.2 style vertex colors, ie. Face Corner + Byte Color.

What kind of color attribute layer? The exporter still only supports pre-3.2 style vertex colors, ie. Face Corner + Byte Color.
Member

Added subscriber: @PratikPB2123

Added subscriber: @PratikPB2123
Member

Added subscriber: @JulienDuroure

Added subscriber: @JulienDuroure
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Author

In #99005#1376715, @scurest wrote:
What kind of color attribute layer? The exporter still only supports pre-3.2 style vertex colors, ie. Face Corner + Byte Color.

Oh, that's true, it's still possible to export only with face corner + byte color, it's not a regression then. I managed to transfer vertices to corners via Geometry Nodes and export like that.

Aaaanyway, the reason why I wanted to export vertex-based and not face-corner based color was just so vertex color bakes would look better, but it turned out that this was not the issue with color domain, but with baking and denoising.

> In #99005#1376715, @scurest wrote: > What kind of color attribute layer? The exporter still only supports pre-3.2 style vertex colors, ie. Face Corner + Byte Color. Oh, that's true, it's still possible to export only with face corner + byte color, it's not a regression then. I managed to transfer vertices to corners via Geometry Nodes and export like that. Aaaanyway, the reason why I wanted to export vertex-based and not face-corner based color was just so vertex color bakes would look better, but it turned out that this was not the issue with color domain, but with baking and denoising.
Ivan Notaros changed title from Regression: gltf exporter does not export vertex colors in 3.3 alpha to gltf exporter does not export non-byte color and non-face-corner vertex colors in 3.3 alpha 2022-06-21 14:48:44 +02:00

It's technically straightforward to add support for this. Main considerations:

  • It's easiest to first refactor the exporter to handle generic attributes, each with their own domain/type. Vertex position etc. can be treated as a generic attribute too. This also makes it easy to add custom attribute support.
  • Byte colors should continue to export as unorm16x4.
  • Float colors should probably export as floatx4, with full precision.
  • If float colors are all opaque, can export as RGB floatx3 instead. (Could also do it for byte color, but it wouldn't save space because of alignment.)
  • Per-vertex color (unlike per-corner color) can be exported for loose point/line primitives. (Keep in mind though it's invalid to have noncontiguous n in COLOR_n.)
  • Since color attributes don't have a controllable sort order, it doesn't make much sense to linearize them onto COLOR_0, COLOR_1, ... anymore IMO. It makes more sense to me to export only the active attribute as COLOR_0 and not export COLOR_1 or higher at all. Cf.
It's technically straightforward to add support for this. Main considerations: - It's easiest to first refactor the exporter to handle generic attributes, each with their own domain/type. Vertex position etc. can be treated as a generic attribute too. This also makes it easy to add custom attribute support. - Byte colors should continue to export as unorm16x4. - Float colors should probably export as floatx4, with full precision. - If float colors are all opaque, can export as RGB floatx3 instead. (Could also do it for byte color, but it wouldn't save space because of alignment.) - Per-vertex color (unlike per-corner color) can be exported for loose point/line primitives. (Keep in mind though it's invalid to have noncontiguous n in COLOR_n.) - Since color attributes don't have a controllable sort order, it doesn't make much sense to linearize them onto COLOR_0, COLOR_1, ... anymore IMO. It makes more sense to me to export only the active attribute as COLOR_0 and not export COLOR_1 or higher at all. [Cf.](https://github.com/KhronosGroup/glTF-Blender-IO/pull/807#issuecomment-1143804923)
Julien Duroure self-assigned this 2022-06-25 15:50:37 +02:00
Member

I will take care of that. Hoping for 3.3

I will take care of that. Hoping for 3.3
Member

Added subscriber: @1029910278

Added subscriber: @1029910278
Member

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'
Member
A PR is under review here: https://github.com/KhronosGroup/glTF-Blender-IO/pull/1678
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Member

Fixed by 2fcac97522

Fixed by 2fcac97522de

Added subscriber: @tomjk

Added subscriber: @tomjk

I'm still having an issue exporting color-type vertex colors with gltf in blender 3.3.0 official release for linux.

steps (basically same as in original post):

  1. add object
  2. under color attributes, click add attribute, select domain: face-corner, data type: color, press ok.
  3. export gltf (selected only; y-up; mesh with uvs, normals, vertex colors; material with export/auto; no animation).

Vertex colors don't appear in exported file.

example for an exported plane (edited for clarity):

{
    "asset" : {
        "generator" : "Khronos glTF Blender I/O v3.3.27",
        "version" : "2.0"
    },
    "scene" : 0,
    "scenes" : [...],
    "nodes" : [...],
    "meshes" : [
        {
            "name" : "Plane.001",
            "primitives" : [
                {
                    "attributes" : {
                        "POSITION" : 0,
                        "NORMAL" : 1,
                        "TEXCOORD_0" : 2
                    },
                    "indices" : 3
                }
            ]
        }
    ],
    "accessors" : [...],
    "bufferViews" : [...],
    "buffers" : [
        {
            "byteLength" : 140,
            "uri" : "data:application/octet-stream;base64,AACAvwAAAAAAAIA/AACAPwAAAAAAAIA/AACAvwAAAAAAAIC/AACAPwAAAAAAAIC/AAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAIA/AACAPwAAAAAAAAAAAACAPwAAAAAAAAEAAwAAAAMAAgA="
        }
    ]
}
I'm still having an issue exporting color-type vertex colors with gltf in blender 3.3.0 official release for linux. steps (basically same as in original post): 1. add object 2. under color attributes, click add attribute, select domain: face-corner, data type: color, press ok. 3. export gltf (selected only; y-up; mesh with uvs, normals, vertex colors; material with export/auto; no animation). Vertex colors don't appear in exported file. example for an exported plane (edited for clarity): ``` { "asset" : { "generator" : "Khronos glTF Blender I/O v3.3.27", "version" : "2.0" }, "scene" : 0, "scenes" : [...], "nodes" : [...], "meshes" : [ { "name" : "Plane.001", "primitives" : [ { "attributes" : { "POSITION" : 0, "NORMAL" : 1, "TEXCOORD_0" : 2 }, "indices" : 3 } ] } ], "accessors" : [...], "bufferViews" : [...], "buffers" : [ { "byteLength" : 140, "uri" : "data:application/octet-stream;base64,AACAvwAAAAAAAIA/AACAPwAAAAAAAIA/AACAvwAAAAAAAIC/AACAPwAAAAAAAIC/AAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAIA/AACAPwAAAAAAAAAAAACAPwAAAAAAAAEAAwAAAAMAAgA=" } ] } ```
Member

@tomjk Confirmed. Seems there was some change in API between this fix and final release. Will check, and fix. This should be included in 3.3.x release (trying 3.3.1)

@tomjk Confirmed. Seems there was some change in API between this fix and final release. Will check, and fix. This should be included in 3.3.x release (trying 3.3.1)
Member

Fixed in 4feb92043c

Fixed in 4feb92043cbd
Sign in to join this conversation.
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#99005
No description provided.