When I load a tiny gltf with only 1 rectangles using COLOR_0 everything is ok using those shaders:
The green rectangle made of 2 triangles appears in any viewer .
<script id="vertexShader" type="x-shader/x-vertex">
#version 300 es
in vec3 color;
attribute uint thematic;
//layout(location=2) in uint thematic;
out vec3 vCouleur;
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
vCouleur = color;
//if(thematic > uint(0x00FF)) vCouleur = vec3(0.9, 0.1, 0.1);
}
</script>
<script id="fragmentShader" type="x-shader/x-fragment">
#version 300 es
in vec3 vCouleur;
out vec4 out_FragColor;
void main() {
out_FragColor = vec4(vCouleur, 1.0);
}
</script>
gltf
{
"asset" : {
"version" : "2.0",
"generator": "GeoMaitre20" },
"extras" : { "REM" : "test for custom vertex attribut" },
"scenes" : [ { "nodes" : [ 0 ] } ], "scene": 0,
"nodes" : [ { "mesh" : 0 } ],
"meshes" : [
{
"primitives" : [
{
"mode" : 4,
"attributes" : {
"POSITION" : 1 ,
"COLOR_0":2 },
"indices" : 0 } ]
}
],
"buffers" : [
{ "uri" : "data:application/octet-stream;base64,AgABAAAAAgAAAAMAAAAAAIptJr94/j4/r5UTPnP1cwHZnCW/a7w/P5/cEj5z9XMBNkklv2u8Pz8Zoxg+c/VzAX4ZJr94/j4/cGMZPnP1cwE=",
"byteLength" : 80 }
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 12,
"target" : 34963 },
{
"buffer" : 0,
"byteOffset" : 16,
"byteLength" : 64,
"target" : 34962,
"byteStride": 16
}
],
"accessors" : [
{
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5123,
"count" : 6,
"type" : "SCALAR",
"max" : [ 3 ], "min" : [ 0 ]
},
{
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 4,
"max": [-0.6456483603, 0.7489687800, 0.1497933865] ,
"min": [-0.6501089334, 0.7460703850, 0.1434197277],
"type" : "VEC3"
} ,
{
"bufferView" : 1,
"byteOffset" : 12,
"componentType" : 5121,
"count" : 4,
"type" : "VEC3",
"normalized" : true
}
]
}
Now if I change COLOR_0 for a custom attribute named _THEMATIC , “componentType” : 5125 and accessor type by SCALAR and remove normalized everything is accepted in Khronos validator and draw in viewer like gltf.insimo.com
It also draw OK with 3js if I do NOT use the thematic attribute. When I do I got this error
GL_INVALID_OPERATION: Vertex shader input type does not match the type of the bound vertex attribute.
But “componentType” : 5125 IS uint.
So, what am I missing?