Working on a prologue type level where there is a mountain in a forest. Of course since it’s a forest, it needs to have so many trees but I encountered a problem. It’s really laggy, there are about 3758 trees in that area and since are pretty high quality (I got it from the tool box) it’s pretty much using all resources. How do I fix this problem without eliminating/removing some trees? If there is such way please tell me.
First of all, wrong category, this belongs in #help-and-feedback:building-support. Please put it there!
Second, you can do this by making a tree yourself or just importing that tree into blender and removing triangles. If you have so many trees then about 500-1000 triangles per tree would be fine. Or one more thing you could do is to make and optimization script to unrender any trees that are far away and are being blocked.
Essentially what @awry_y said, optimization. Let me expand on that, one great way is by lowering tri count in Blender, for example. Seeing as it is just a tree, you might be able to get it down to maybe ~200 tris if you remove a lot of uneeded geometry. Along with that, at a certain distance, you can start rendering trees as just a flat, 2d billboard image, although you’ll need to have some knowledge of coding for that.
If your map and trees are basically completely static, then you can make a certain number of trees into one mesh, so there’s much less strain on your CPU, it could deal with 20 instances instead of 200, for example. Along with that, make sure you uncheck properties that those trees don’t need to have. For example, double-sided (depends on the mesh, just choose whatever looks good), FluidForces, and an important one, collision. If the player won’t ever touch the trees, then turn the collision off (cancollide off, collisionfidelity to Box), if the player will, then I suggest you turn it to something other than PreciseConvexDecompisition, as that will lag a ton (Box and Hull are good, Default could work it just depends on your coliision needs and balance of performance).
Finally, you could also render the trees completely on the client, so the server won’t kill itself for unnecessary reasons, and lag will be basically depending on the player’s specs only.
(essentially just try to have less of… everything, from tris, to collision calculations, etc.)
Best of luck!
deforest all of ur game get rid of it delete them all for performance gain
haha, no. trees are very important. u never know the secrets that lies within the trees
gotta say thanks to the folks that said to make my own trees cuz the trees that the game is using has alot if triangles. regrading what @Gucci_Dabs222 said about billbaord gui, it will probably ruin the emersion im giving to this game but iam creating 2 trees where 1 tree is lower quality while the other is a bit more high quality.
will not be closing this but thanks for the tips!11
By default I don’t think Roblox has culling (correct me if I am wrong), so one of the things I would recommend is implementing a simple culling system with raycasts or an alternative method and check for culling not every frame but every time the player either moves the camera or the character body. You will probably want to divide the trees up into chunks so that way you can avoid checking every single tree individually. I haven’t tried this before myself so I’d recommend testing for performance differences between regular gameplay/viewing and gameplay/viewing with the optimization stuff added in.
Depends on the amount of trees you have but trust me, checking if an object is within camera view or not like every frame is gonna kill your performance, if not every frame then still most likely some lag spikes. With Roblox’s current system, you’re probably better off performance-wise without custom culling, the detriments outweigh the benefits.
Anyways, Roblox already has frustum culling, although not occlusion culling just yet (it’s on roadmap for 2024 though ). Just to demonstrate the difference:
I think it’s just better to wait for occlusion culling to get released, since it’s predicted to be within this year.
Best bet is to make a chunk loading system that unloads trees outside a certain range