I'm definitely not expecting miracle answers to this question, what I'm looking for is pretty hard to do procedurally, but I've seen people achieve some amazing addons so I wonder to what extent it's possible and how far anyone has gotten. I want to generate entire 3D levels procedurally based on a random seed or noise, namely buildings with rooms and corridors whether scifi facilities or medieval dungeons. What is the most complex result that is possible with such a system?

This is easy to do for simple layouts: If you only want a one level dungeon with square walls, it's as simple as iterating over a 2D grid of positions at a given scale and filling each spot with either a cube (walls) if noise > 0.5 or a plane (floor) otherwise. But what to do if you want to produce a random facility with rooms that make sense, platforms and bridges and stairways and doors and windows, textures appropriate for each area, let alone scatter details like objects or items? The system should take a seed as its parameter, alongside any other structural properties that can be customized like the sizes of rooms and their amount versus corridors, as well as a texture set to put over surfaces where each is appropriate.

The best I'm hoping for is something of early 90's geometric detail, namely the maps Unreal Tournament 99 used to have: Just generate and connect basic rooms of different shapes and sizes, then if the UV maps are set accordingly the fine details can be achieved using textures to get a modern looking result. Geometry wise I'm aiming for something at the level of complexity in this video, it shows a map that that's generic and polygonal enough to represent something that could be done procedurally, though maybe I'll be amazed and and there's a way to make ones that are even more complex and detailed.

For Godot the most immediate solution that comes to mind is CSG: A script could spawn a bunch of CSG shapes in logical order, maybe subtract the rooms with big boxes then use more subtractive cubes to connect them with corridors and create windows... even so the script for knowing what shapes to use and how to scale them would be complex, plus CSG still had issues where random combinations of shapes caused broken polygons and holes in the mesh. The script could built its own geometry from scratch, but that sounds even more complex and would likely require some cleverly predefined patterns.

    MirceaKitsune procedural generation is a complex topic that requires expertise.
    you need an algorithms side, a data side and a visual/physical side.

    the easiest way is to create rooms in blender and add them in game, the advantage of godot over other engines like unity is that it can calculate lighting and pathfinding on the fly.
    these rooms can start by being the same size.
    a more advanced version would have rooms of different sizes, this would require more advanced coding.

    MirceaKitsune This is easy to do for simple layouts: If you only want a one level dungeon with square walls, it's as simple as iterating over a 2D grid of positions at a given scale and filling each spot with either a cube (walls) if noise > 0.5 or a plane (floor) otherwise.

    no that doesn't work, only for terrains and even then it's not good.
    a random noise results in unsolvable mazes. you need more complex algorithms.

    MirceaKitsune But what to do if you want to produce a random facility with rooms that make sense, platforms and bridges and stairways and doors and windows, textures appropriate for each area, let alone scatter details like objects or items?

    a very popular method is the wave function collapse, or make your own. again, you need to know algorithms, try doing 2D terrains before going into something this complex.

    NO.

      Jesusemora My initial goal was to use modules, I could code a wavefunction collapse system and achieve what I want with more precision then. The problem is I couldn't find any good ones so far, if anyone is aware of quality textured sets that are freely licensed I'd definitely appreciate it! Doing them in Blender proved to be a pain and I never got a good result: I might try making the pieces using CSG then instancing the scenes in GDScript based on connection joints, that part actually feels easy if I had proper assets.

      xyz Unique world each time, that's part of the point for what I wanted to do. The plan was to use modules which is likely what I'll return to: The map could be either procedural (wavefunction collapse for 3D tilesets) or an in-world editor may allow placing them on the grid to create maps out of segments without having to model each wall manually. I now have a good idea of what is possible with CSG, and apart from some incorrectly stretched UV maps I should be able to use that.

      • xyz replied to this.

        MirceaKitsune The sooner you ditch procedural generation, the sooner you'll actually make a game. Tinkering with it is an endless time sink. Procedurally generated stuff never feels "unique". It's a pipe dream. You can't avoid noticeable patterns that become obvious and boring very quickly. Better to put the effort into crafting few static but interesting levels. You can achieve much more "uniqueness" that way than rearranging the same boxes over and over into million configurations that are technically "unique" but have no actually impactful distinct features.

        And going full frontal into 3d level pg, without first having made a smaller 2d pg game is just borderline insane 😃

          xyz

          xyz Procedurally generated stuff never feels "unique". It's a pipe dream.
          No!
          Valheim has procedurally gen world. Its not infinite but still random. Feels very cozy. They used unity.
          Deep rock galactic had procedural cave system. I kinda want to understand and know how to do it in godot. They used UE4 i think

          xyz The sooner you ditch procedural generation, the sooner you'll actually make a game.

          Yes, and this was the reason i still havent made anything close to a game 😃.

          xyz You can achieve much more "uniqueness" that way than rearranging the same boxes over and over into million configurations that are technically "unique" but have no actually impactful distinct features.

          This part could be automagically randomized. And if you have already made assets to place in the world, it wouldnt be hard to iterate and randomize the placement.

          xyz And going full frontal into 3d level pg, without first having made a smaller 2d pg game is just borderline insane

          Hold my onions!

          • xyz replied to this.

            kuligs2 Feels very cozy.

            I can assure you that this is not due to procedural generation 🙂

            kuligs2 xyz And going full frontal into 3d level pg, without first having made a smaller 2d pg game is just borderline insane

            Hold my onions!

            😂

            Procedural generations is a medicine to developer's soul but poison to player's soul. The substance can be slow or fast acting, it varies among the cases. Now you be the judge if such a thing is something your game project needs or not, but remember that most soul medicines are addictive and have nasty long term side effects 😃.

              I think it can be a good idea when done right. Procedural generation is the main reason Minecraft was such a big thing, both before and after Microsoft ruined it. Of course MC is a particular odd case in which it works well: The same concept can't be easily applied to things of higher quality without exponentially more complexity, but still you can do some great things with it.

              The best example for what I've actually been aiming at is the old SCP containment breach game; That's a fine case of using modules to get an unique world of quality each time. Doesn't need to be all procedural like what I imagined here for a moment, but even unique room placement can do a lot to give you a new world every time so you don't get bored as fast.

              Especially with modules it's not that hard: You just need a script that places the set pieces for you based on neighbors, 99% of the time I spent in Godot that's what I toyed with over the years so I know that part too well. Finding the right assets has been a tad harder, but at least for a prototype CSG with an unique texture atlas should do. Also tiles of different sizes, you want a fixed grid size unless you want a new layer of complexity filling multiple cells and requesting different neighbors per tile.

                I think its a fart to say there is no place in games for procedural generation, but I will also concede that the type of generation you are describing here is very time consuming to build. You've got the right idea with modules and what not.

                A simple approach, which is re-usable for 3D, would be to place one module, and then have a function go a single room at a time randomly choosing another module next to the first that has matching connections. WFC is an algorithm that is used to match connections, but you can make up whatever logic you want for this, and it could be as simple as saying module with north door flag must be next to module with south door flag. Then you could have a set of modules that are "end walls" and when the max distance from the original module is reached you choose from only dead end rooms to cap off the space. Those older games you mention are doing this in 2D, but in each 2D array position they are placing a 3D room model. For some newer games, you can see that Alien Isolation is doing this with a 3D array, and The Bunker(by Frictional Games) is doing the same thing but with a 2D array.

                When I built a procedural voxel thing, I built it on a single 2D layer first so that the logic was easier to work out, and then just switched all my arrays to 3D multidimensional/nested arrays and expanded the logic to additionally check from up and down directions. Like start simply by making a 2D generator and then layer your 2D generator on top of itself like a cake.

                As for the off-size tile issue you mention in your last post, its good to keep in mind that the placement of your premade rooms does not actually have to correspond to the first array. The array you are generating can tell you what modules are next to each other but does not have to refer to global positions, that can be its own logic. This is hard to explain, here is a video with a variety of resources that might get you thinking about that.

                Unrelated, Deep Rock Galactic devs posted a really cool dev log where they do procedural work here. They spawn a bunch of pre-made rooms in a sphere, and then they draw a line between connections and generate a cylinder shape around the line to be a hallway. Then they apply noise patterns to blend the meshes together into caves. Neat

                Anyway this is a hole that you can fall down forever.

                  xyz procedural generation is a tool like many others, it has its uses.
                  it can be used to create unique never before seen maps like in minecraft and spelunking and civilization and diablo and
                  but if it is not done right it can lead to bad maps. this is not a procedural generation problem, it's a bad/insufficient code problem.

                  MirceaKitsune I think it can be a good idea when done right.

                  but you are not going to do it right the first time. go and learn algorithms, do something simple, create a 2D map.
                  I'm using procedural generation, but before getting to this I made dozens of perlin generators and other things, it's not something you just go and do on the first try. so stop planning and start trying, you are a newbie.

                  MirceaKitsune Procedural generation is the main reason Minecraft was such a big thing

                  minecraft was ALL procedural generation, the guy worked on it for years and read books. you don't get to just go and do it with a 30 second search and a youtube tutorial.

                  MirceaKitsune Finding the right assets has been a tad harder

                  how about you make your own assets? what are you contributing to your project? you want the code done and the art done and just to assemble it like LEGOs AND for it to be perfect.

                  MirceaKitsune prototype CSG with an unique texture atlas should do

                  forget about CSG. or don't, ignore all the advice from more experienced people, make your mistakes.
                  but please learn from them.

                  MirceaKitsune Also tiles of different sizes, you want a fixed grid size unless you want a new layer of complexity filling multiple cells and requesting different neighbors per tile.

                  you can do same size tiles and still get a good map, just make the tiles more complex. a tile can have a little maze and still connect 4 ways. add doors inside, traps, obstacles.
                  when you randomize it all the tiles will still be valid, then add a start and end, and then you generate the scenes for the maze.
                  which is what I told you: an algorithms side, a data side and a generation side.
                  you can do SCG all you want, but if your algorithm is bad the map will be bad, and if there's no data you can't check if the map is good at runtime, and your players will run into walls.

                  CakeCadaver Unrelated, Deep Rock Galactic devs posted a really cool dev log where they do procedural work here. They spawn a bunch of pre-made rooms in a sphere, and then they draw a line between connections and generate a cylinder shape around the line to be a hallway. Then they apply noise patterns to blend the meshes together into caves. Neat

                  that is neat

                  • xyz replied to this.



                    This is a view of what I managed to do today and the approach I'm likely to be taking, still very preliminary but it shows what CSG can do. For now they can be placed by hand, I may later have fun writing a wavefunction collapse script for producing them procedurally as you explore. The result is less unique but it's the only way that works consistently without insane levels of complexity.

                    Jesusemora procedural generation is a tool like many others, it has its uses.
                    it can be used to create unique never before seen maps like in minecraft and spelunking and civilization and diablo and
                    but if it is not done right it can lead to bad maps. this is not a procedural generation problem, it's a bad/insufficient code problem.

                    I've never seen a Minecraft map that I've never seen before. They all look the same to me. They're just endless spatial permutations of the exact same stuff. If you've seen one map, no map you see afterwards can surprise you anymore. Ditto for Civ and Spelunky, and most other such games.

                    But as usual, you've completely missed my point. If you enjoy tinkering with pg, knock yourself out, do it 24/7. However, from project management standpoint, using this "tool" only makes sense if it'll save time/money. For a one-man-band, developing and balancing a pg system is often much more work than just building "fixed" content while the final impact on the player experience may be exactly the same and often worse with pg. Especially if you raise their expectations by touting how "unique" each generated level is.

                      So far I've encountered one notable annoyance with making CSG modules, which is UV mapping: Godot knows how to generate it correctly for a deformed polygon, but for some strange reason diagonals can get this sort of weird zig-zag shape if they don't have enough resolution. I'll have to check if there's a better way to doing diagonal corridors apart from using a 360* spin with 4 faces.


                      The other thing is path deforms: No matter how I tweak the curve there's always a place where the shape self-intersects when you don't want it to. I looked at the curve settings as well as the CSG polygon but nothing fixes the mapping, thankfully there are ways around it so this isn't ultimately a problem and I have what I need overall.

                      xyz I've never seen a Minecraft map that I've never seen before. They all look the same to me.

                      it doesn't have to do so much with what they look like but how they play.
                      from a mechanical standpoint each game of minecraft can be different because the order in which the resources can be acquired and the enemies that are fought are different, so to the average player it feels like a different adventure with unique moments.
                      this is what a game is.

                      xyz They're just endless spatial permutations of the exact same stuff.

                      so is the universe

                      xyz If you've seen one map, no map you see afterwards can surprise you anymore.

                      not really, one map you find lava on the surface, in another you find a village very close by, in another there's a ravine, in another, an ocean.
                      maybe you are thinking of starfield/no mans sky where there's absolutely nothing on the endless planets, but minecraft has plenty of content.
                      yes the content can run out, but that's true of any game.

                      and what makes these worlds work is the exploration part, that primal part of our brains that enjoys experiencing new things, being in a completely new environment and trying to memory it.

                      xyz If you enjoy tinkering with pg, knock yourself out, do it 24/7. However, from project management standpoint, using this "tool" only makes sense if it'll save time/money.

                      it does save time. a game with procedural generation takes away the need to manually build the levels. these can still be designed, procedural isn't always random. for example in diablo 2 there's always going to be teleporters in the same areas.

                      xyz For a one-man-band, developing and balancing a pg system is often much more work than just building "fixed" content while the final impact on the player experience may be exactly the same and often worse with pg.

                      depends on the game, if procedural generation is a core area of the game, it is essential to have it. but for something like a metroidvania it would often be better to have an actual designed level.
                      look at 2 games that fail at replayability: subnautica and planet crafter. they use manually constructed levels, this helps with telling a story but the game can only be player once, which is a problem for planet crafter.

                      xyz Especially if you raise their expectations by touting how "unique" each generated level is.

                      you ARE thinking of no mans sky and starfield 😆

                      MirceaKitsune I want to generate entire 3D levels procedurally based on a random seed or noise, namely buildings with rooms and corridors whether scifi facilities or medieval dungeons.

                      Are you specifically interested in PG or just want variety in the cards? You could try replacing Artificial Intelligence with Natural Intelligence. Allow players to create their own maps by releasing the appropriate tools. It would also increase the appeal of the game.

                      The main mistake in many pg attempts is in thinking that pg is all about generative algorithms. The key thing in fact may be quite non-technical, even artistic; it's designing a modular/mutable system that allows for making interesting enough and varied enough combinations but having as few "degrees of freedom" as possible at input. Once you conceive such a system, driving it via some common generative algorithm is simple.

                      Mainly wanted to know how close you can get to creating unique buildings with interiors out of GDScript. I had this idea for several projects, one being a FPS that would have unique maps each time you play a match. The best approach is definitely using modules with a wavefunction collapse algorithm, which would still allow editing maps manually by letting the mapper fill each cell with a desired segment and only generating missing ones if desired. Here's one more screenshot of what I got tonight after further refining the texture atlas used by the CSG polygon.

                        MirceaKitsune I had this idea for several projects, one being a FPS that would have unique maps each time you play a match.

                        There's a term for it: reconnaissance. When a person is going somewhere, he usually preliminarily studies the terrain. Maps for shooters are usually designed taking into account the balance of positions: for close ambush, for snipers... I'm not saying that it can't be realized in any way... but there are too many very complicated rules to be taken into account for automatic creation of such a map.

                        Here's one more screenshot of what I got tonight after further refining the texture atlas used by the CSG polygon.

                        Exploring a battlefield under fire is an extremely dubious endeavor. How does a player know what awaits him around that corner?

                        Mainly wanted to know how close you can get to creating unique buildings with interiors out of GDScript.

                        As close as imagination and skill will allow. It should be taken into account that the engine is developing and if the game is interesting, the developers of the engine can take into account the wishes of the creators of the game.