Skip to content

Comments

fix(gltf): add HAS_COLORS define for COLOR_0 vertex attribute#2503

Open
nokonoko1203 wants to merge 1 commit intovisgl:masterfrom
nokonoko1203:fix/pbr-vertex-colors
Open

fix(gltf): add HAS_COLORS define for COLOR_0 vertex attribute#2503
nokonoko1203 wants to merge 1 commit intovisgl:masterfrom
nokonoko1203:fix/pbr-vertex-colors

Conversation

@nokonoko1203
Copy link

Background

When a glTF mesh contains a COLOR_0 vertex attribute (e.g. point cloud data with per-vertex colors), parsePBRMaterial() did not set the HAS_COLORS shader define. The existing code already handled analogous attributes using the same #ifdef pattern.

if (attributes['NORMAL'])     parsedMaterial.defines['HAS_NORMALS'] = true;
if (attributes['TANGENT'] ..) parsedMaterial.defines['HAS_TANGENTS'] = true;
if (attributes['TEXCOORD_0']) parsedMaterial.defines['HAS_UV'] = true;
// COLOR_0 was missing

Without HAS_COLORS, the vertex shader's #ifdef HAS_COLORS block was excluded at compile time, so the in vec3 colors declaration was absent. The COLOR_0 data was uploaded to the GPU but never read by the shader — all vertices were rendered with the default instance color (white).

Downstream consumers such as deck.gl's ScenegraphLayer do not currently handle per-vertex colors from glTF meshes, but would need this define to conditionally declare vertex attribute inputs and blend per-vertex colors with instance colors (e.g. for rendering colored point clouds via 3D Tiles).
The Khronos https://github.com/KhronosGroup/glTF-Sample-Renderer also uses the same compile-time define pattern (HAS_COLOR_0_VEC3 / HAS_COLOR_0_VEC4) for vertex color support.

Change List

  • Add HAS_COLORS define when COLOR_0 attribute is present in parsePBRMaterial() function
  • Add equivalent in the commented-out PBRMaterialParser class for consistency

@nokonoko1203 nokonoko1203 changed the title # fix(gltf): add HAS_COLORS define for COLOR_0 vertex attribute fix(gltf): add HAS_COLORS define for COLOR_0 vertex attribute Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant