Reputation: 53
I have a gltf in which I apply png textures on rectangular mesh. I have a rectangle png and circle png. rectangle node is at z = 0.01 and circle at z = 0.0. alpha mode used for the materials is BLEND. material is double sided.
GLTF
{
"scenes" : [
{
"nodes" : [
0
]
}
],
"nodes" : [
{
"name" : "Node_0",
"children" : [
1,
3
]
},
{
"name" : "Symbol 2",
"children" : [
2
],
"translation" : [
240.25,
-126.300003,
0
]
},
{
"name" : "Node_2",
"mesh" : 0,
"scale" : [
0.656657,
0.656657,
1
]
},
{
"name" : "Symbol 1",
"children" : [
4
],
"translation" : [
170,
-89.050003,
0
]
},
{
"name" : "Node_4",
"mesh" : 1,
"translation" : [
0,
0,
-0.01
],
"scale" : [
2.059968,
1.399979,
1
]
}
],
"meshes" : [
{
"primitives" : [
{
"attributes" : {
"POSITION" : 1,
"TEXCOORD_0" : 2
},
"indices" : 0,
"material" : 0
}
]
},
{
"primitives" : [
{
"attributes" : {
"POSITION" : 1,
"TEXCOORD_0" : 2
},
"indices" : 0,
"material" : 1
}
]
}
],
"buffers" : [
{
"uri" : "data:application/octet-stream;base64,AQAAAAAAAAADAAAAAwAAAAIAAAABAAAAAAAAAAAAAIAAAAAAAAAAAAAAyMIAAAAAAADIQgAAyMIAAAAAAADIQgAAAIAAAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAq6oqPacaKD+nGig/AACAP6caKD+nGig/AACAPwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAACAAACAPwAAAACrqio9AACAPwAAgD8AAIA/AACAPwAAgD8AAIA/AAAAAABAcEOamfzCAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIA/AAAAAKuqKj2G1gNAfzKzPwAAgD+G1gNAfzKzPwAAgD8AAAAAAAAAAAAAAIAK1yO8AAAAAAAAAAAAAAAAAAAAgAAAgD8AAAAAq6oqPQAAgD8AAIA/AACAPwAAgD8AAIA/AACAPwAAAAAAACpDmhmywgAAAAAAAAAAAAAAAAAAAAAAAACAAACAPw==",
"byteLength" : 376
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteOffset" : 0,
"byteLength" : 24,
"target" : 34963
},
{
"buffer" : 0,
"byteOffset" : 24,
"byteLength" : 48,
"target" : 34962
},
{
"buffer" : 0,
"byteOffset" : 72,
"byteLength" : 32,
"target" : 34962
}
],
"accessors" : [
{
"name" : "accessor_0",
"bufferView" : 0,
"byteOffset" : 0,
"componentType" : 5125,
"count" : 6,
"type" : "SCALAR",
"max" : [
3
],
"min" : [
0
]
},
{
"name" : "accessor_1",
"bufferView" : 1,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 4,
"type" : "VEC3",
"max" : [
100,
0,
0
],
"min" : [
0,
-100,
0
]
},
{
"name" : "accessor_2",
"bufferView" : 2,
"byteOffset" : 0,
"componentType" : 5126,
"count" : 4,
"type" : "VEC2",
"max" : [
1,
1
],
"min" : [
0,
0
]
}
],
"materials" : [
{
"pbrMetallicRoughness" : {
"baseColorTexture" : {
"index" : 0
}
},
"alphaMode" : "BLEND",
"doubleSided" : true
},
{
"pbrMetallicRoughness" : {
"baseColorTexture" : {
"index" : 1
}
},
"alphaMode" : "BLEND",
"doubleSided" : true
}
],
"samplers" : [
{
"magFilter" : 9729,
"minFilter" : 9987,
"wrapS" : 33071,
"wrapT" : 33071
}
],
"textures" : [
{
"sampler" : 0,
"source" : 0
},
{
"sampler" : 0,
"source" : 1
}
],
"images" : [
{
"uri" : "Image0.png"
},
{
"uri" : "Image1.png"
}
],
"asset" : {
"version" : "2.0"
}
}
I am using ThreeJs gltf viewer. https://gltf-viewer.donmccurdy.com/ blending works fine at some angles but when i rotate around some angles blending does not work. screenshots
Can Someone explain this behaviour to me and how can i achieve correct blending at all angles.
Upvotes: 0
Views: 912
Reputation: 5421
If these are three separate nodes, and they all live at 0,0,0
you might have a sorting problem. GLTF is readable, but I'm not as familiar with the spec to tell what is going on. The nodes mentioned in the file that do not have a translation field, might all be positioned at 0,0,0
Either way, the remedy for something like this, if you want to keep sorting is to assign a different yourMesh.renderOrder = yourDesiredOrder
. So for these elements you could set 1,2,3,4... and control when you want them to draw / tell the sorting to consider these weights.
Upvotes: 1