MasterK Posted January 12, 2016 Share Posted January 12, 2016 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... Quote Link to comment Share on other sites More sharing options...
chg Posted January 12, 2016 Share Posted January 12, 2016 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. Quote Link to comment Share on other sites More sharing options...
MasterK Posted January 12, 2016 Author Share Posted January 12, 2016 yes, i know this reason... now i use the 20151104 version Babylon.js, the model can display and animate in pad... the bones number is 48... it's the key problem... Quote Link to comment Share on other sites More sharing options...
MasterK Posted January 12, 2016 Author Share Posted January 12, 2016 ignore "early version"... in same latest version, in one project, the 48 bones can display... in other project, 32 bones(and 58 bones, 74 bones) can't display, 16 bones can display... Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 12, 2016 Share Posted January 12, 2016 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; #endif #ifdef UV1 attribute vec2 uv; #endif #ifdef UV2 attribute vec2 uv2; #endif #ifdef VERTEXCOLOR attribute vec4 color; #endif #if NUM_BONE_INFLUENCERS > 0 uniform mat4 mBones[BonesPerMesh]; attribute vec4 matricesIndices; attribute vec4 matricesWeights; #if NUM_BONE_INFLUENCERS > 4 attribute vec4 matricesIndicesExtra; attribute vec4 matricesWeightsExtra; #endif #endif // Uniforms #ifdef INSTANCES attribute vec4 world0; attribute vec4 world1; attribute vec4 world2; attribute vec4 world3; #else uniform mat4 world; #endif uniform mat4 view; uniform mat4 viewProjection; #ifdef DIFFUSE varying vec2 vDiffuseUV; uniform mat4 diffuseMatrix; uniform vec2 vDiffuseInfos; #endif #ifdef AMBIENT varying vec2 vAmbientUV; uniform mat4 ambientMatrix; uniform vec2 vAmbientInfos; #endif #ifdef OPACITY varying vec2 vOpacityUV; uniform mat4 opacityMatrix; uniform vec2 vOpacityInfos; #endif #ifdef EMISSIVE varying vec2 vEmissiveUV; uniform vec2 vEmissiveInfos; uniform mat4 emissiveMatrix; #endif #ifdef LIGHTMAP varying vec2 vLightmapUV; uniform vec2 vLightmapInfos; uniform mat4 lightmapMatrix; #endif #if defined(SPECULAR) && defined(SPECULARTERM) varying vec2 vSpecularUV; uniform vec2 vSpecularInfos; uniform mat4 specularMatrix; #endif #ifdef BUMP varying vec2 vBumpUV; uniform vec2 vBumpInfos; uniform mat4 bumpMatrix; #endif #ifdef POINTSIZE uniform float pointSize; #endif // Output varying vec3 vPositionW; #ifdef NORMAL varying vec3 vNormalW; #endif #ifdef VERTEXCOLOR varying vec4 vColor; #endif #ifdef CLIPPLANE uniform vec4 vClipPlane; varying float fClipDistance; #endif #ifdef FOG varying float fFogDistance; #endif #ifdef SHADOWS #if defined(SPOTLIGHT0) || defined(DIRLIGHT0) uniform mat4 lightMatrix0; varying vec4 vPositionFromLight0; #endif #if defined(SPOTLIGHT1) || defined(DIRLIGHT1) uniform mat4 lightMatrix1; varying vec4 vPositionFromLight1; #endif #if defined(SPOTLIGHT2) || defined(DIRLIGHT2) uniform mat4 lightMatrix2; varying vec4 vPositionFromLight2; #endif #if defined(SPOTLIGHT3) || defined(DIRLIGHT3) uniform mat4 lightMatrix3; varying vec4 vPositionFromLight3; #endif #endif #ifdef REFLECTIONMAP_SKYBOX varying vec3 vPositionUVW; #endif #ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED varying vec3 vDirectionW; #endif #ifdef LOGARITHMICDEPTH uniform float logarithmicDepthConstant; varying float vFragmentDepth; #endif Quote Link to comment Share on other sites More sharing options...
MasterK Posted January 13, 2016 Author Share Posted January 13, 2016 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... Quote Link to comment Share on other sites More sharing options...
MasterK Posted January 13, 2016 Author Share Posted January 13, 2016 and the fallbacks will reduce some defines. not very useful for many bones. Quote Link to comment Share on other sites More sharing options...
MasterK Posted January 13, 2016 Author Share Posted January 13, 2016 it's an auto change mesh.computeBonesUsingShaders = false; so the problem here is, when use cpu to compute bones, the display is not right... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 13, 2016 Share Posted January 13, 2016 Can you share a demo somewhere? Quote Link to comment Share on other sites More sharing options...
MasterK Posted January 14, 2016 Author Share Posted January 14, 2016 http://42.62.1.80/test/ Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 14, 2016 Share Posted January 14, 2016 I thought I would get the iPad uniform limits. I did a search and got the table below from here The values are not expressed in # of uniforms, so which ones would you use? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 14, 2016 Share Posted January 14, 2016 Wait. If I had read further, I would have seen OpenGL ES 2.0 stuff. Since mobile hardware is already supporting OpenGL ES 3.0, when will WebGL? More searching gets me that FireFox Nightly just started supporting WebGL 2.0. Should BJS 2.4 be about moving to WebGL 2.0? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.