Jump to content

skeleton bones limit


Recommended Posts

i have a model with 32 bones, and it can display and do animation in my computer.

but it make wrong in ipad. 

and more than 70 bones model will not display in other android device.

the error was: "too many uniforms"

but in early version, i have 48 bones model and it works in my pad. and after update engine, it cant display...

Link to comment
Share on other sites

I don't know Babylon.js so it's just a guess but is your 48 bone model maybe using submeshes (such that each part only uses a few of the bones).

128 is the guaranteed number of uniforms supported in WebGL / openGL ES 2, GPUs can offer more but you should maybe query this at runtime if you need to use them I think.

Each uniform is a 4D vector, so for the matrices needed for bones you need 4 of them. eg. 32bones needs 128 uniforms.

You can't use all of the vertex uniforms on bones though, as you (Babylon.js) likely use them for lighting and other effects.

Link to comment
Share on other sites

Here is the declaration section of the default shader.  Ignore the varying declarations.  As you can see, knowing whether you have gone over budget has a lot of input.  If you wish to run on iPad, without falling back to cpu skinning, you need take this into account as well as get the uniform limit for that device.  Also, older iPads may handle less.

@chg , a Vec2 counts as 1, not 0.5, right?

// Attributes
attribute vec3 position;
#ifdef NORMAL
attribute vec3 normal;
#ifdef UV1
attribute vec2 uv;
#ifdef UV2
attribute vec2 uv2;
attribute vec4 color;

	uniform mat4 mBones[BonesPerMesh];

	attribute vec4 matricesIndices;
	attribute vec4 matricesWeights;
		attribute vec4 matricesIndicesExtra;
		attribute vec4 matricesWeightsExtra;

// Uniforms

attribute vec4 world0;
attribute vec4 world1;
attribute vec4 world2;
attribute vec4 world3;
uniform mat4 world;

uniform mat4 view;
uniform mat4 viewProjection;

#ifdef DIFFUSE
varying vec2 vDiffuseUV;
uniform mat4 diffuseMatrix;
uniform vec2 vDiffuseInfos;

#ifdef AMBIENT
varying vec2 vAmbientUV;
uniform mat4 ambientMatrix;
uniform vec2 vAmbientInfos;

#ifdef OPACITY
varying vec2 vOpacityUV;
uniform mat4 opacityMatrix;
uniform vec2 vOpacityInfos;

varying vec2 vEmissiveUV;
uniform vec2 vEmissiveInfos;
uniform mat4 emissiveMatrix;

varying vec2 vLightmapUV;
uniform vec2 vLightmapInfos;
uniform mat4 lightmapMatrix;

#if defined(SPECULAR) && defined(SPECULARTERM)
varying vec2 vSpecularUV;
uniform vec2 vSpecularInfos;
uniform mat4 specularMatrix;

#ifdef BUMP
varying vec2 vBumpUV;
uniform vec2 vBumpInfos;
uniform mat4 bumpMatrix;

uniform float pointSize;

// Output
varying vec3 vPositionW;
#ifdef NORMAL
varying vec3 vNormalW;

varying vec4 vColor;

uniform vec4 vClipPlane;
varying float fClipDistance;

#ifdef FOG
varying float fFogDistance;

#ifdef SHADOWS
#if defined(SPOTLIGHT0) || defined(DIRLIGHT0)
uniform mat4 lightMatrix0;
varying vec4 vPositionFromLight0;
#if defined(SPOTLIGHT1) || defined(DIRLIGHT1)
uniform mat4 lightMatrix1;
varying vec4 vPositionFromLight1;
#if defined(SPOTLIGHT2) || defined(DIRLIGHT2)
uniform mat4 lightMatrix2;
varying vec4 vPositionFromLight2;
#if defined(SPOTLIGHT3) || defined(DIRLIGHT3)
uniform mat4 lightMatrix3;
varying vec4 vPositionFromLight3;

varying vec3 vPositionUVW;

varying vec3 vDirectionW;

uniform float logarithmicDepthConstant;
varying float vFragmentDepth;


Link to comment
Share on other sites

yeah, thank u both.

i think i see more clearly...

the defines make deafultVertex special number uniforms.

add bone*4 uniforms should < 128. 

otherwise maybe shader build will throw error,  but it can show anyway, just ignore the uniforms over 128.. so i saw the not complete model...


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...