Exporting vertex color and vertex alpha via GLTF?

   Views 282   Replies 1   Subscribers 0
User Avatar
Member
142 posts
Joined: 9月 2017
Offline
Hi! I've noticed vertex colors come through great with the ROP GLTF SOP. However, I don't understand how to export vertex alpha. In the GLTF spec(0), it mentions that COLOR_n may be VEC3 or VEC4 so I tried setting color as a vec4 as such but it's not working:

p@Cd = set(v@P.x, v@P.y, v@P.z, relbbox(0, v@P).y);
p@Cd = clamp(v@Cd, {0, 0, 0, 0}, {1, 1, 1, 1});



Inspecting the generated GLTF file (a .glb) I see that COLOR_0 is still set to VEC3 so the alpha didn't make the journey successfully.

How do I export vertex alpha with the ROP GLTF SOP? I don't see anything about vertex color or vertex alpha mentioned on either its help page(1) or the overall GLTF help page(2). So far I've tried exporting these values as point attribs, vertex attribs and prim attribs but nothing has worked.

Thanks!

(0) https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html [registry.khronos.org]
(1) https://www.sidefx.com/docs/houdini/nodes/sop/rop_gltf.html [www.sidefx.com]
(2) https://www.sidefx.com/docs/houdini/io/gltf.html [www.sidefx.com]
Edited by nicholasralabate - 2025年4月12日 20:03:40

Attachments:
GLTF_spec.png (17.0 KB)

User Avatar
Member
142 posts
Joined: 9月 2017
Offline
Quick follow-up question, I found this GLTF exporter code in the sideffects repo here:

https://github.com/sideeffects/HoudiniGLTF/blob/Houdini18.5/src/ROP/ROP_GLTF_Refiner.C [github.com]


    else if (attrib_name == GA_Names::Cd)
{
uint32 vertex_colors = AddAttrib(attrib_data, GLTF_COMPONENT_FLOAT, 3,
0, GLTF_BUFFER_ARRAY);

prim.attributes.insert({"COLOR_0", vertex_colors});
}

Is this accurate to what is currently in Houdini? The description says this repo contains the source for the GLTF exoprter code but it also hasn't been updated in five years, so it seems like it is abandoned? Just wondering if I could hunt around the C code in lieu of documentation.
  • Quick Links