I’ve made a lot of progress on my personal project both with designing and programming the logic as well as optimizing everything… except for Depsgraph.
My final scene is going to require a lot of objects. I’m using object pools to keep the objects loaded and just moving them where I need them when I need them and also making them visable/invisable when i need them. (originally I was spawning them in with the edit object actuator but it was slowing everything down to like 5 fps)
So the only thing that is causing me a bunch of lag is the depsgraph. I’ve tried to researh it now for a few days but I can’t find a whole lot of information about it and just earlier today I noticed its not in older versions of blender. Or at least its not visable in the debug options.
So what things are related to the depsgraph? How can I optimize them? Or am I out of luck because of how many objects I need loaded?
I’ve read a lot of posts and watched several videos on how to optimize your game but they’re all outdated or not relevant.
Also, if you have any tips for optimizing the Rasterizer that would be great. Currently its not a huge problem but all optimizations help. Currently the only efforts I’m making towards the Rasterizer are turning objects invisible when they aren’t needed, which has helped a great deal but could always be improved.
For UPBGE 0.3+, depsgraph relates to operations in Blender specifically such as geometry-nodes, modifiers, etc - things that require dynamic updating. I think physic simulations (not to be mistaken with BGE physics) also fall under that category, not sure. Read the official documentation about Blender’s depsgraph here.
So first of all, thank you RPaladin for that link. I found it a week ago but lost it before I could read it. It definitely helped me to understand the depsgraph however it didn’t really help me to figure out how to optimize my game for it.
Secondly, musikai, unfortunately there is no static scenery in my game. Everything, including the terrain can me manipulated by the player. I have all the functionality fleshed out in smaller test maps but once I put everything together and scale up the map, I run into problems.
Which brings me to this. Logic and Physics can be turned off with activity culling and other methods, and the Rasterizer can be improved by making unused objects invisible. Is there any way to remove objects from the depsgraph until I get close to them? Or something similar? Or can the depsgraph be disabled all together in UPBGE 0.3? I fired up UPBGE 2.5 and noticed there is no despgraph under the profile debug menu when running the game and was hoping this could be achieved in 0.3.
But as it stands, with my existing knowledge on blender/UPBGE, I feel like my best course of action is to just rebuild my game in UPBGE 2.5.
The scenegraph impacts rendering. So you can use a old fashion culling technique of hiding objects that aren’t near the player (or player camera) and unhide them when they are - or vice versa, however you want.
I already use Activity Culling, both physics and logic, on all the objects in the object pools so when they aren’t near the player they aren’t pulling any resources. I also use a setup similar to the logic you showed to turn objects invisible or not depending on how close they are and if the player is facing them. But all of this only effects logic, physics, and the rasterizer. (Scenegraph has never been an issue. At least not yet.)
The depsgraph is only affected by how many objects/empties I have loaded. Nothing I do to the logic, or physics, or graphics, seems to effect the depsgraph. But if I delete half of my objects the depsgraph goes down by half. Originally I used the Edit Object Actuator to spawn everything in as needed but this created lots of lag that object pools don’t have.
I understand that my game requires more objects to be loaded than most games out there so I’m completely fine with rebuilding it in UPBGE 2.5 since the depsgraph doesn’t exist in it to the best of my knowledge.
But I also know there are a lot of people on the internet that are much smarter than me so I’m hopeful someone with a solution stumbles across this post soon.
I’m going to mark this post as solved since it technically was solved. My original question was simply ‘what is the depsgraph?’ and I now know what it is. But none of the suggestions have helped me to optimize for it.
I’m gonna make another post later with a more accurate title to my problem to hopefully get more eyes on it.
the main issue with the depsgrapgh is when you have to add new objects to the scene as the depsgraph has to recalculate the relations. One possible solution, not available yet, is to incorporate a pool object system to avoid relations recalculation.
lordloki_reloaded, The problem with this is that I’m not adding objects to the scene. I’m using a make shift object pool to keep everything loaded and only updating the objects position when I need to. But even if I strip away all the logic and physics and just have a bunch of static objects in the scene the depsgraph eventually gets too bogged down once you add too many. And nothing is being updated.
BluePrintRandom, I need to look into this, thank you.
im running into the same issue where im using geometry nodes to cull out the grass that is preloaded. problem is its slowing me down to 2 fps and depsgraph is 97%. Has anyone figured out a way to make it so it only calls the geometry nodes every few ticks?
Hi, I also encountered such a problem when I make my space simulator - I need to add stones, rocks, and other objects to the planet in large quantities of about 1500 per region next to the player’s camera, when I used the raycast node and the sphere attached to the camera for the region, the scene’s dysgraph dropped to 4.5-7 frames per second, I untied this sphere from the camera and moved it with a script to the camera position if the player is next to the planet - this allowed me to update the regions and at least partially eliminate the fps loss now the fps loss with this movement is 15-20 frames, apparently because the data on the position of the collider object for the node is not updated every frame, but only once when the player moves around regions I am still experimenting with geometry nodes in the hope of finding the best option for such generation, since I have not yet found a way to combine the physics of instance objects with the physics of a static planet
the image does not show the moment of transition when the sphere through which the instance objects are generated changes position when the camera is removed from it, but I assure you I lose the above 15-20 frames only once for 0.5-1 seconds, I hope in the future the developers will optimize the geometry nodes that will allow us to load and generate large worlds, maybe adding a volcano will somehow solve this problem in the future
I forgot to write - there is also a dependence of the scene’s disgraph on the subdivision of the object and modifiers that add polygons to the model on which geometry nodes are used - the fewer the number of polygons of the object, the more points of instances can be added to the geometry node - my tests showed that a planet with the number of polygons in 300-400 thousand works much faster with instances in large quantities without freezing, a planet with a number of polygons of 4 million freezes recalculations of instances when moving the collider object for 2 minutes - I’m still inclined to think that for such an addition of instances it is better to use a lowpoly mesh that will be a grid of collisions - a simplified version of the collision and instances decorators that will add the graphic part - make the picture beautiful - I think in this case it will work better than adding a large number of instances to a heavy grid model in any case, as BluePrintRandom wrote - there are many options for using geometry nodes in UPBGE, only they need to be treated from the point of view of optimization and performance balance - then we will be able to generate and receive large worlds and also fill them with content objects - in any case, thanks to the UPBGE developers for what they do
This is an old topic but I want to contribute something that may be a solution using UPBGE 03. I don’t know why but I’ve noticed that UPBGE version 2020-03-30 (which uses Blender 2.83) is faster than the new versions. My game in the new versions gives me less than 20 FPS while this version gives me between 40 and 60 FPS. I’m leaving it for download from Mega because this version is no longer available from the official UPBGE website: UPBGE-EEVEE-Win64-2020-03-30.7z (Based in Blender 2.83)
EDIT:
I forgot to mention: for this version of UPBGE to run at higher frame rates, it’s essential that all objects in the scene that use nodes NOT use the Principled BSDF shader, but instead use the Specular shader.
That is, open the Shader Editor and Outliner, select objects in Outiler and if that object has the Principled BSDF shader, you’ll need to change it to the Specular shader.
Yes @musikai . But I dont´understand why GPU Latency is high but FPS is high too while in the other version the GPU Latency is very slow but FPS is slow too.