GLTF Multi Primitive Geometry Is OFF

#1

Yo @bghgary … I noticed a little bug in our multi primitive gltf loading…

Here is a TestTree

First … the primitives generated in babylon dont match the sub mesh materials…

For instance branches should be prim 0, some leave prim 1, other leaves prim 2 etc…

But the last primitive has both leaves and branches… and the prim 1 and 2 barley have anything

Please download and take a look in the babylon sandbox

Its should look like this Original Unity Shot:

And to compare… PlayCanvas show good… Nice full leaves and everything:

Even Three.JS renders nice full leaves:

But our babylon tree looks SKIMPY … not showing all the leaves and there are GAPS in the branches:

So something is a bit off with our geometry loader :frowning:

0 Likes

#2

Yo @bghgary … i cant really tell if its just multi primitives or primitives in general :frowning:

0 Likes

#3

The reason why this asset doesn’t work right is because there is a bug with the handling of alphaMode and jpg textures. I will fix this, but the asset should also be fixed. This is the second primitive and the second material. Since the jpg cannot have alpha, the material should not be marked with an alphaMode. Never mind, it’s actually something else. Will reply when I figure it out.

0 Likes

#4

The problem is the vertex colors of the second primitive and the material being marked as MASK. The second primitive has a whole bunch of vertex colors with an alpha value of 0. According to the glTF spec, the correct behavior is to multiple this against the baseColor which will result in an alpha value of 0 to the shader. This combined with the alphaMode of MASK causes the all the pixels to be discarded.

From glTF/specification/2.0 at master · KhronosGroup/glTF · GitHub

In addition to the material properties, if a primitive specifies a vertex color using the attribute semantic property COLOR_0 , then this value acts as an additional linear multiplier to baseColor .

The fact that different implementations handle this differently is not great, but this is mostly an issue with the asset.

0 Likes

#6

That fixed it… I now set the alpha in VERTEX COLORS to 1.0… Look beautiful now:

YO @bghgary … Thanks Bro :slight_smile:

1 Like