pjoe
May 27, 2024, 2:12pm
1
Using Blender and glTF, it is possible to add additional vertex color channels and get them exported - their name need to start with _ to follow the glTF spec
Application-specific attribute semantics MUST start with an underscore, e.g., _TEMPERATURE
. Application-specific attribute semantics MUST NOT use unsigned int component type.
Is there a way to access these in a node material in NME?
I think you can but by code only by changing the name of the attribute in the input block ?
pjoe
May 28, 2024, 1:54pm
3
This should work as you need to precise the type of the attribute:
Unfortunately webgl forbids the use of 2 consecutives underscores so I wonder if in gltf they can be named differently or @Evgeni_Popov any ideas ?
pjoe
May 29, 2024, 7:02am
5
FWIW: here is how it shows up in glTF:
"meshes":[
{
"name":"Cube",
"primitives":[
{
"attributes":{
"_MY_COLOR":0,
"POSITION":1,
"NORMAL":2,
"TEXCOORD_0":3
},
"indices":4,
"material":0
}
]
}
],
"accessors":[
{
"bufferView":0,
"componentType":5126,
"count":24,
"type":"VEC4"
},
...
I can’t see the MY_COLOR vertex attribute:
cc @bghgary , it seems we don’t support custom attributes when reading a glTF file?
loadAttribute("POSITION", VertexBuffer.PositionKind);
loadAttribute("NORMAL", VertexBuffer.NormalKind);
loadAttribute("TANGENT", VertexBuffer.TangentKind);
loadAttribute("TEXCOORD_0", VertexBuffer.UVKind);
loadAttribute("TEXCOORD_1", VertexBuffer.UV2Kind);
loadAttribute("TEXCOORD_2", VertexBuffer.UV3Kind);
loadAttribute("TEXCOORD_3", VertexBuffer.UV4Kind);
loadAttribute("TEXCOORD_4", VertexBuffer.UV5Kind);
loadAttribute("TEXCOORD_5", VertexBuffer.UV6Kind);
loadAttribute("JOINTS_0", VertexBuffer.MatricesIndicesKind);
loadAttribute("WEIGHTS_0", VertexBuffer.MatricesWeightsKind);
loadAttribute("JOINTS_1", VertexBuffer.MatricesIndicesExtraKind);
loadAttribute("WEIGHTS_1", VertexBuffer.MatricesWeightsExtraKind);
loadAttribute("COLOR_0", VertexBuffer.ColorKind, (accessor) => {
if (accessor.type === AccessorType.VEC4) {
babylonMesh.hasVertexAlpha = true;
}
});
1 Like