Three.js: allocateBones problem

Created on 19 Nov 2019  路  8Comments  路  Source: mrdoob/three.js

Description of the problem

I have 2 skinnedMesh, use the same material. And one has 13 bones, another has 19 bones, then the allocateBones function will return 13 or 19, but not max(13, 19). It has led to some problem in Android.

Three.js version r103
RK3399 Android7.0

All 8 comments

I'm afraid your problem is somewhat unclear. Please invest more effort in this issue and demonstrate the problem with a live example. Alternatively, sharing a git repository with a reproduction test is also a good idea.

It has led to some problem in Android.

Please avoid using vague phrases like "some problems" or "not working". Try to formulate your post as concrete as possible. What problems do you see on Android? Any error messages or warnings?

I have 2 object, for example A and B.
A.skeleton=[bone1], B.skeleton=[bone1, bone2]
A.material = material1, B.material = material1
then if capabilities.floatVertexTextures is false, the allocateBones will return 1, and the shader on material1 will #define MAX_BONES 1

the allocateBones will return 1,

Please demonstrate this with a live example since I'm unable to reproduce. Because of the following line, the function should return 2 for the second skeleton:

https://github.com/mrdoob/three.js/blob/c23622828aa2415979a700c5df68a7828edcbd36/src/renderers/webgl/WebGLPrograms.js#L75

sorry for my English.....

but the allocateBones won't execute twice, because of the same material.
this is a live example
https://jsfiddle.net/0h7ykj3p/

Okay, now I see what you mean. As a workaround, you have to apply a material per skinned mesh. Also try to avoid using the same bones in different skeletons.

I use FBX file from Maya, so it's hard to do that~

What happens if you convert the FBX file to glTF via:

https://github.com/facebookincubator/FBX2glTF

I assume this issue here is a Won't fix because of several reasons:

  • only a small number of devices are affected (84% of all devices support floating point textures and 98% support at least four texture units in the vertex shader).
  • it only happens when materials are shared between skinned meshes with different bone count
  • implementing a fix in setProgram() is complicated since the renderer would need the ability to match one material to multiple shader programs (we only support the other way around, see #15047)
  • as an alternative fix, the renderer could use nVertexMatrices as maxBones value in allocateBones(). But as a result, the renderer might allocate too many resources depending on the use case.
  • the issue does not happen with WebGL 2
Was this page helpful?
0 / 5 - 0 ratings

Related issues

konijn picture konijn  路  3Comments

akshaysrin picture akshaysrin  路  3Comments

filharvey picture filharvey  路  3Comments

makc picture makc  路  3Comments

zsitro picture zsitro  路  3Comments