waverider Posted December 28, 2017 Share Posted December 28, 2017 Hy guys, i'm working on a rpg project, and the fps is dropping now to about 15fps-19fps, i fear this will affect the game when i finally go multiplayer. I'll be grateful to any suggestion or idea Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 28, 2017 Share Posted December 28, 2017 This is impossible to debug given the information you have provided... None of us are psychic none of us have looked at you'r script and have no clue what you are actually doing... A PG or some samples of code are necessary. Points: Make sure you are using Clones and Instances correctly. Push Dynamic and static meshes to a quadtree. Make sure things are being disposed of correctly. Check your draw calls. waverider 1 Quote Link to comment Share on other sites More sharing options...
waverider Posted December 28, 2017 Author Share Posted December 28, 2017 lol it's a very longlist of code, but i'll try to chunk it: Maybe i'm doing the instances and cloning wrong, here's the code i used to create the lampost Game.prototype.createLamposts = function(){ var mat = this.mat[4]; var scale = 4; var build = this.verybigbuilding //gems var gemshapes = [] for(var i = 0; i<10; i++){ var myMat4 = new BABYLON.StandardMaterial("mat1", scene); myMat4.alpha = 1.0; myMat4.diffuseColor = new BABYLON.Color3(0.5, 7, 0.5); var icosphere = BABYLON.MeshBuilder.CreatePolyhedron("oct", {type: 4, size: 0.7}, scene); icosphere.scaling.y = 3 icosphere.position.z = Math.sin(i)*3 icosphere.position.x = Math.cos(i)*3 icosphere.material = myMat4 icosphere.rotation.z = -Math.sin(i)*4 icosphere.rotation.x = -Math.cos(i)*4 gemshapes.push(icosphere) } var gems = new BABYLON.Mesh.MergeMeshes(gemshapes) gems.scaling.set(20, 20, 20) //lamposts for(var i = 0; i<this.pos.length; i++){ var lampost = BABYLON.Mesh.CreateCylinder("cylinder", 3, 3, 3, 16, 1, scene, false) lampost.scaling.set(16.2*scale, 505, 16.2*scale); lampost.material = this.mat[1] this.lamposts.push(lampost) this.torch = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene); this.torches.push(this.torch) this.vent = new BABYLON.Mesh.CreateBox("vent", 60, scene) this.vent.scaling.y = 0.4 this.vent.scaling.x = 0.4*scale this.vent.scaling.z = 2.5*this.worldscale; this.vent.material = this.mat[2]; var box = this.vent.getBoundingInfo() box.boundingBox.maximum.copyFrom(new BABYLON.Vector3(30, -968, 30)) this.vent2 = this.vent.clone() this.vents.push(this.vent) this.vents.push(this.vent2) if(i%9 == 0){ this.verybigbuilding.rotation.y = 82.1415926535898 this.verybigbuilding.position.set(this.pos[i].x+400, this.pos[i].y, this.pos[i].z-160) } if(i%8 == 0){ this.vent.scaling.y = 50 this.vent.material = mat //this.vent.position.y = 100 } if(i%2 == 0){ this.torch.position.x = this.pos[i].x+60 this.torch.position.y = this.pos[i].y+80 this.torch.position.z = this.pos[i].z+(60*this.worldscale) lampost.position.x = this.pos[i].x lampost.position.y = this.pos[i].y lampost.position.z = this.pos[i].z+(95*this.worldscale) this.vent.position.x = this.pos[i].x this.vent.position.y = this.pos[i].y+200 this.vent.position.z = this.pos[i].z this.vent2.position.x = this.pos[i].x this.vent2.position.y = this.pos[i].y+400 this.vent2.position.z = this.pos[i].z } } for(var i = 0; i<this.pos.length; i++){ var lampost2 = BABYLON.Mesh.CreateCylinder("cylinder", 3, 3, 3, 16, 1, scene, false) lampost2.scaling.set(19.2*scale, 505, 19.2*scale); lampost2.material = this.mat[1] this.torch2 = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene); this.torches.push(this.torch2) var gem2 = gems.clone() gem2.position.y = 24 this.gems.push(gem2) this.lamposts.push(lampost2) if(i%2 == 0){ gem2.position.set(Math.random()*this.pos[i].x, this.pos[i].y, this.pos[i].z-(60*this.worldscale)) this.torch2.position.x = this.pos[i].x+60 this.torch2.position.y = this.pos[i].y+80 this.torch2.position.z = this.pos[i].z-(60*this.worldscale) lampost2.position.x = this.pos[i].x lampost2.position.y = this.pos[i].y lampost2.position.z = this.pos[i].z-(95*this.worldscale) } } } Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 29, 2017 Share Posted December 29, 2017 Post a screenshot of the debuger as well please, with a mesh list. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 29, 2017 Share Posted December 29, 2017 I looking at the code and you are doing huge scaling. Your scene may be too big. It's better to use small scales for an entire game. The larger your object, the bigger your ground will be and this will have an impact on performance. Ensuring you also use octree can increase performance. There are many solutions to optimize. Look in the documentation. waverider 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 29, 2017 Share Posted December 29, 2017 13 minutes ago, Dad72 said: I looking at the code and you are doing huge scaling. Your scene may be too big. It's better to use small scales for an entire game. The larger your object, the bigger your ground will be and this will have an impact on performance. Ensuring you also use octree can increase performance. There are many solutions to optimize. Look in the documentation. size should not effect fps. a plane that is 1 b 1 and 1 poly is the same as a plane that is 1000000000 by 1000000000 and 1 poly... same draw calls, maybe a slight difference in parsing due to large numbers but I think they would have to be astronomical to even be something noticeable.https://www.babylonjs-playground.com/#WGTPLJ Unless there is something I am missing. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 29, 2017 Share Posted December 29, 2017 10 hours ago, Pryme8 said: size should not effect fps. a plane that is 1 b 1 and 1 poly is the same as a plane that is 1000000000 by 1000000000 and 1 poly... same draw calls, maybe a slight difference in parsing due to large numbers but I think they would have to be astronomical to even be something noticeable. The larger the models, the larger the terrain should be with a larger subdivision if you want to make mountains. The weight of the scene also increases with large objects. The distance from the camera also increases if you want to see the sky for example. this has a noticeable impact on performance. The poly number also has an impact. It is not with a single object that one can see it, but with a concrete scene. It's a bit like image resolution, the bigger it is, the more the weight increases. Performance is tied to a lot of things. Quote Link to comment Share on other sites More sharing options...
waverider Posted December 29, 2017 Author Share Posted December 29, 2017 @Pryme8 Are you talking about these? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 29, 2017 Share Posted December 29, 2017 You have lots of active particles, maybe trying to reduce the numbers. and you also have more than 100 active meshes, it can do a lot if not optimizing number of poly . Try to merge some mesh that go together. Then use an octree. this should get you back up the FPS waverider and Pryme8 2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 29, 2017 Share Posted December 29, 2017 5 hours ago, Dad72 said: The larger the models, the larger the terrain should be with a larger subdivision if you want to make mountains. The weight of the scene also increases with large objects. The distance from the camera also increases if you want to see the sky for example. this has a noticeable impact on performance. The poly number also has an impact. It is not with a single object that one can see it, but with a concrete scene. It's a bit like image resolution, the bigger it is, the more the weight increases. Performance is tied to a lot of things. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 29, 2017 Share Posted December 29, 2017 In fact Pryme, what I want to say is that the fact of making large model requires to create great world (large skybox and large terrain, which says large terrain says more subdivision, so loss of performance because more of poly ... By large the large mesh leads to the creation of larger world, with more models, more subdivision on the ground and others. It is not the mesh that is given to the scale that makes losing perfs, but the consequences that entails then. Do you see what I mean? I have experienced it. Quote Link to comment Share on other sites More sharing options...
waverider Posted December 29, 2017 Author Share Posted December 29, 2017 I'm trying to merge the instances as one mesh, but i don't think it's rendered in the scene. the new merged mesh should be moving but it's not. http://www.babylonjs-playground.com/#FULI8D Quote Link to comment Share on other sites More sharing options...
Dad72 Posted December 29, 2017 Share Posted December 29, 2017 You can not merge instances. I believe you can merge clones and meshes normal, but no instances. waverider 1 Quote Link to comment Share on other sites More sharing options...
waverider Posted December 29, 2017 Author Share Posted December 29, 2017 Thanks that clarifies it Quote Link to comment Share on other sites More sharing options...
waverider Posted December 29, 2017 Author Share Posted December 29, 2017 still the same http://www.babylonjs-playground.com/#FULI8D#2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 29, 2017 Share Posted December 29, 2017 25 minutes ago, Dad72 said: In fact Pryme, what I want to say is that the fact of making large model requires to create great world (large skybox and large terrain, which says large terrain says more subdivision, so loss of performance because more of poly ... By large the large mesh leads to the creation of larger world, with more models, more subdivision on the ground and others. It is not the mesh that is given to the scale that makes losing perfs, but the consequences that entails then. Do you see what I mean? I have experienced it. That is scope, not scale but yes I know understand what you are saying ^_^! 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.