Curious, did you put the chunk generation on a separate thread?
On my Procedural World Generation project
Testing some cool lights.
Next will be different coloured lights.
[
Nice :-)
I spend the whole day trying to get this project working in Godot 4.
My plans for this project is fixing some of the world generation and make an easy system to add biomes.
SuperDoomKing
I'm sorry for breaking in! You are working on a very interesting project! And it really looks awesome!
May I ask you for a hint? I'm wondering how you create chunks of blocks without FPS drop. When I'm doing similar thing (instantiate a few scenes in a loop) my project stalls for a moment even if the number is like 10. I tried to do instantiation in a separate thread and add instances to the tree afterwards. But in that case the game crashes with some probability.
Thank you!
z80
I just do the generation in a separate thread and some optimizations.
Also, as part of the optimizations, these blocks aren't real blocks, they are mostly just planes only showing one or a few sides.
When the player is not able to see something, there is no need to render it.
I don't know your issue, but it could just be bad optimization.
SuperDoomKing
Hello! Thanks for the explanation!
All I do is something like:
for i in range(10):
var inst: Spatial = AssetScene.instantiate()
self.add_child( inst )
inst.transform = transforms[i]
I thought that may be there is a trick how to instantiate objects so that it doesn't cause a game to stall.
z80
Assuming that's for loading in chunks, it's similar to what I did.
Meaning your issue probably lies in the chunks themselves.
How much geometry do you make?
How big are your chunks?
It may be easier for us to know what your issue is if you provide some pictures.
SuperDoomKing It may be easier for us to know what your issue is if you provide some pictures.
Sure, sorry for the ambiguity! Here is the video below demonstrating the problem.
Basic setup is, I guess, similar to yours. The vicinity of the camera is split into 3x3x3 cubic blocks. As soon as camera leaves central block, the game deletes 9 blocks and creates new 9 blocks. I.e. makes the camera to be in the central block again. In the video because it is on the perfectly flat large sphere, only 3 blocks actually contain geometry. So it should be even faster.
And I checked, it is the trees creation what slows it down. As soon as I remove trees creation but keeping all the computations, ex. like where to put the trees, I no longer have the stalling issue.
- Edited
z80 Make sure that all your tree resources (mesh, material, shader) have "local to scene" disabled. Otherwise they will be duplicated with each instance. This may cause hiccups if large number of instances is created in a frame, as all vertex data needs to be duplicated, and each shader recompiled.
Btw. which version of engine are you running this in?
- Edited
xyz Make sure that all your tree resources (mesh, material, shader) have "local to scene" disabled. Otherwise they will be duplicated with each instance. This may cause hiccups if large number of instances is created in a frame, as all vertex data needs to be duplicated, and each shader recompiled.
Btw. which version of engine are you running this in?
Each tree is a glb scene file. It's ~ 2.9Mb. I didn't intentionally turn on "local to scene".
Currently it is 4.0.2 version. But I used to be on 3.5.2. But I don't really feel the performance difference.
z80
Are you using MultiMesh for the trees?
If not maybe it could help out.
I (almost) successfully converted to Godot 4.
It was quite confusing trying to fix this project, since I didn't touch it for more than a half year.
Didn't help I didn't comment anything. Damn you past me!
I turned off the foliage and structures since I want to redo those systems later.
I also did some other tool and export related changes, so it's easier to configure how I want the generation to be.
Now I can also see the world in the editor, very convenient.
I just have to work on the biome generation and then the world generation is kind of done, ignoring foliage and structures.
As a side note, the caves are pretty nice.
- Edited
I am very interested in this sort of thing, it's going to be up to us front end types to show off exactly how powerful Godot 4 really is.