After days of headaches, I finally have a natural generated structure.

Yay, structure generation.
Also I did some improvements with the performance.

[

I think I want to make this project very dense with buildings. I need to make some very tall buildings, hopefully it won't tank the performance.


I already knew how to change grass colour, so I thought it would be nice to be able to change colours of other blocks.
This will definitely help me out to make interesting structures, without having to make new blocks.

Testing some cool lights.
Next will be different coloured lights.

[

8 months later

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.

  • z80 replied to this.

    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.

      • z80 replied to this.

        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 so that it doesn't cause a game to stall.

          Your scene may be too "big" I guess. Instantiating scene can be very fast especially if there is not much to do on init & ready functions.
          I wonder if there is not also some physics involved which may increase the work needed on addition.

          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.

          • z80 replied to this.

            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.


            • xyz replied to this.

              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?

              • z80 replied to this.

                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.