ozRocker Posted April 30, 2016 Share Posted April 30, 2016 I've successfully cloned a mesh and its skeleton with this code: this.mesh = Assets.avatar.clone(JSON.idx); this.mesh.skeleton = Assets.avatar.skeleton.clone(JSON.idx); I then run an animation like this: this.mesh.skeleton.beginAnimation("Idle",true,1); This works well on Windows browsers. I can have 10 people moving about with their own separate animations. Some running, some walking and some idle. However, this doesn't work on iPhone and iPad. If I animate one of the meshes then all of them will activate the same animation. If one is running then ALL of them will be running. Its as if they are all referencing the same animation. Does anyone know how I can get this to work on iPhone? Quote Link to comment Share on other sites More sharing options...
ozRocker Posted April 30, 2016 Author Share Posted April 30, 2016 So I checked the console on the iPhone and I got these 3 errors. Would that have something to do with the funny animation cloning? BJS - [00:06:48]: Unable to compile effect with current defines. Trying next fallback. _ErrorEnabledbabylon.2.3.js:2:14458 _prepareEffectbabylon.2.3.js:11:23999 (anonymous function)babylon.2.3.js:11:21243 _loadFragmentShaderbabylon.2.3.js:11:22517 (anonymous function)babylon.2.3.js:11:21212 _loadVertexShaderbabylon.2.3.js:11:22187 tbabylon.2.3.js:11:21176 createEffectbabylon.2.3.js:3:9525 isReadybabylon.2.3.js:12:14980 isReadybabylon.2.3.js:8:5960 _checkIsReadybabylon.2.3.js:8:7032 (anonymous function)babylon.2.3.js:8:7227 BJS - [00:06:48]: Vertex shader:default _ErrorEnabledbabylon.2.3.js:2:14458 _dumpShadersNamebabylon.2.3.js:11:23078 _prepareEffectbabylon.2.3.js:11:24093 (anonymous function)babylon.2.3.js:11:21243 _loadFragmentShaderbabylon.2.3.js:11:22517 (anonymous function)babylon.2.3.js:11:21212 _loadVertexShaderbabylon.2.3.js:11:22187 tbabylon.2.3.js:11:21176 createEffectbabylon.2.3.js:3:9525 isReadybabylon.2.3.js:12:14980 isReadybabylon.2.3.js:8:5960 _checkIsReadybabylon.2.3.js:8:7032 (anonymous function)babylon.2.3.js:8:7227 BJS - [00:06:48]: Fragment shader:default _ErrorEnabledbabylon.2.3.js:2:14458 _dumpShadersNamebabylon.2.3.js:11:23120 _prepareEffectbabylon.2.3.js:11:24093 (anonymous function)babylon.2.3.js:11:21243 _loadFragmentShaderbabylon.2.3.js:11:22517 (anonymous function)babylon.2.3.js:11:21212 _loadVertexShaderbabylon.2.3.js:11:22187 tbabylon.2.3.js:11:21176 createEffectbabylon.2.3.js:3:9525 isReadybabylon.2.3.js:12:14980 isReadybabylon.2.3.js:8:5960 _checkIsReadybabylon.2.3.js:8:7032 (anonymous function)babylon.2.3.js:8:7227 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 30, 2016 Share Posted April 30, 2016 So it seems that babylon.js cannot compile exactly the shaders that you want and maybe falling back to software bones. Can you try to turn software bones on and check how it looks on your PC? Quote Link to comment Share on other sites More sharing options...
ozRocker Posted April 30, 2016 Author Share Posted April 30, 2016 56 minutes ago, Deltakosh said: Can you try to turn software bones on and check how it looks on your PC? yeh, if I turn on software bones on the PC then they are all sharing animation. so I guess with software bones you can't clone animations? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 30, 2016 Share Posted April 30, 2016 Hum...this should work..It is more a bug do you mind reproducing it on the PG? I'll fix it for you Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 1, 2016 Author Share Posted May 1, 2016 6 hours ago, Deltakosh said: Hum...this should work..It is more a bug do you mind reproducing it on the PG? I'll fix it for you Ok, here it is in playground http://www.babylonjs-playground.com/#GTHTR Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 1, 2016 Share Posted May 1, 2016 Ok it is not a bug actually When you clone a mesh, the inner geometry is shared and not copied (for performance reason). In your case, you have to copy the geometry and not clone it in order to enable software skinning (where the GPU will update the geometry): http://www.babylonjs-playground.com/#GTHTR#1 Quote Link to comment Share on other sites More sharing options...
ozRocker Posted May 1, 2016 Author Share Posted May 1, 2016 ok, thanks man! Is it better for performance if I just clone and use shaders? I could do this by simply removing bones from the hands. This is the source of the errors in iOS. I have too many bones for my puny iPhone RAM Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted May 1, 2016 Share Posted May 1, 2016 oz, Your assumptions about iPhone's memory are not really correct. The problem is WebGL 1.0 has a minimum required # of Vector4 uniforms of 128. Each bone requires 4 of these. Desktop implementations typically exceed this minimum, but IOS & other mobile platforms do not. That means that absolute max # of bones for WebGL 1.0 on mobile platforms is 128 / 4 = 32. In practice, you also need uniforms for other things, so depending on other parts of your scene, the best you can get is about 22. As of yesterday, you can set the maximum # of lights on your materials. Prior to this, it was fixed at 4. If you have a single light that moves with the camera, try material.maxSimultaneousLights = 1; I do not know how many uniforms you will pick up. It might depend on the light type. In WebGL 2.0, based on OpenGL ES3, you can now have vertex uniform buffers (in addition to uniforms, I think). Looks like the max size of one will hold 32 bones, but you can have up to 12 total. Using buffers will eliminate many bone limitations. Having a buffer also cuts down on the number of calls to pass uniforms in multiple ways: Obviously, 1 call for 32 bones is a 32X decrease. If these buffers can be shared across meshes (think: body, hair, teeth, tongue, eyes, clothes, shoes). This would result in an additional 6X decrease. Vertex shaders require bone info, regardless of no movement in progress. As buffers, you only need to update them when something has changed. Apple supports OpenGL ES3 on processors A5 to present. Doubt they ever increase WebGL 1.0 amounts. Why would they? I am not sure what DK has I'm mind. Maybe a hard limit of 12, 32 bone skeletons per scene. So to recap, ram problem wrong, api problem right, drop your lights for now. ozRocker and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
fernfreak Posted October 16, 2017 Share Posted October 16, 2017 On 5/1/2016 at 10:36 AM, Deltakosh said: var avatar2 = avatar1.clone(); var newGeometry = avatar1.geometry.copy("newgeom"); newGeometry.applyToMesh(avatar2); avatar2.computeBonesUsingShaders = false; I skimmed your sample (http://www.babylonjs-playground.com/#GTHTR#1) and this was incredibly useful for getting the mesh to clone properly on mobile. Unfortunately, once I use geometry.copy, the subMesh data is lost and I am unable to apply my multi-material. (I have subMeshes[2] on the original, but only subMeshes[1] on the clone) such that the textures are screwed up. On the other hand, if I don't do the geometrycopy, I am unable to have unique animations on the clones. Is there some way of doing geometry copy, but maintaining the subMesh data? Thanks in advance for the help! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 16, 2017 Share Posted October 16, 2017 Hello, you can still save the submeshes with var cloned = avatar2.subMeshes.slice(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.