No Man's Sky

A practical look at “Procedural Generation 2.0” or template based procedural generation for No Mans Sky

So yesterday u/Viloneo made This post suggesting No Mans Sky ditch the current noise based generation for a more hand crafted template based procedural generation approach. While I appreciate the enthusiasm for addressing the issues with proc gen in the game I don't think this approach would really work unfortunately. After commenting there that I thought it wasn't likely to be the fix they imagined it to be and getting a response I went to reply and ended up writing a lot more than I had intended to.

I'm a game developer and while I've never done anything quite on the scale of NMS I have implemented a lot of different types of procedural generation (I can provide links if you'd like but I'm not here for self promo I just love this game :3 ) and while templates can work great (here's a great interactive walkthrough of how Spelunky generates with templates) they have some major downsides such as making grid structures more obvious and massively increasing dev time.

(If I have some time I might see if I can add some diagrams into this post if people are interested)

I'm curious about this suggestions practicality so I'm going to do some math and see how it might work out in detail.

Part One. Setting up our example area:

So you want a chunk full of randomised patterns and you likely want minimal repeats, lets say you're working in a 32×32 km area and each template defines a 1×1 km chunk of templated terrain using noise to add some degree of variation. That'll be 1024 chunks to be filled in. Lets be generous and say we can get away with repeating the same structure 8 times across that and hoping the noise will differentiate things enough that they won't be noticeably the same (this is likely to break down regularly and create very noticeably similar results) we'll need a total of 1024÷8 or 128 unique chunks to fill in that area.

Part Two. The logistics of designing templates:

so lets think reasonably about how long it would take to create these templates. For a 1km² area I've spent multiple days in the past to create maps with the unity terrain system. However this only deals in height values without the possibility for caves or overhang that the NMS terrain allows (I believe it uses marching cubes). One positive way in which this isn't entirely comparable is that creating a template isn't necessarily filling in every single detail just laying out the rough forms of the landscape. We can assume that the talented team at Hello games could make a tool suited to this workflow(I'm not going to guess how long making the tool would take but if it's being used on a massive scale you want a pretty robust tool built from scratch) allowing the designer to define the landforms and areas where certain detail objects will be placed (eg. where forest goes). With this tool we can say the developer will take maybe half a day to make one template and another half to test it in engine with all the different biomes it can appear in and make any necessary tweaks (there's 11 major biomes in the game so I think this is a fair if not generous estimate). So for just this 32km² chunk with templates possibly repeating 8 times within it that makes it 128 days worth of work. This can obviously be split up between a team but it will still cost the same amount in wages.

Read more:  A brief word from someone who has only just started playing the game today

Part Three. Stitching the seams:

Cool so now we have a relatively varied 32km² area of template based generation. But hang on how are we even blending these chunks together. We don't want the edge of one chunk to just be a massive wall against the edge of the next. One thing we can do is to apply them to a larger height map and make sure all their edges are flat and line up this means the edges inherit the height from the heightmap but would need to be relatively featureless. Now the edges have less detail which is a problem because if you play enough you'll likely start noticing the chunk grid, so maybe we should try to define a set of rules about which chunks can go together? We could use something cool and cutting edge like Wave Function Collapse (it's really cool you should definitely read up on it here's a neat open source implementation) well okay now we have a consistent level of detail across everything. But hang on I'm playing our new template based NMS with chunks that match up nicely but what's that?! I've seen roughly that sort of mountain beside roughly that sort of lake 5 times while exploring this one planet? Hmm turns out there's a sacrifice you have to make if you're going to take an approach where certain chunks can go beside each other and others cant. each chunk now has a limited amount of other chunks it can actually appear beside and the reoccurrence of these patterns of chunks beside each other will become much more noticeable than if any chunk can go beside any other.In the end I don't quite know what the best solution for this would be but remember every piece of hand designed content can take a lot more time to develop than you might expect so it's unlikely merging the edges by hand is the right way to go.

Read more:  An open letter to Hello Games

Part Four. 32km² would be a very small planet:

Lets assume we get over our chunk boundary issues and we have a lovely 32km² area of procedural generation with only minimal repeats and some variation applied to the repeats. now we need to fill 18 quintillion plus planets with this stuff. I did some searching and found this post about estimating the sizes of planets in NMS. For the planet they use in the example they get a total area of 478,000,000,000m² or 478,000,000km². That's a lot bigger than 32 if we take our current set of 128 chunks we'll have roughly 3,734,375 repeated occurrences of each chunk. Even if we can scale up and produce 512 unique chunks that's still about 933,593.75 repeats on this single planet. In practice I suspect even a really good implementation of a template system for No Mans Sky would lead to a very similar level of infinite variations on the same thing as the current system does.

Some unfortunate side effects could also be:

  1. It would likely eliminate the current possibility that the noise and other structures used to generate the existing planets have of creating super rare combinations of features that are nearly unpredictable.
  2. Larger form features such as the curved trenches that form on some planets would be very hard to keep around.
  3. More than likely this would have big performance overheads.
Read more:  Please don't give *new* players millions worth of items

In conclusion while I also want improved variation to the generation I can't say I think templates are the right approach and I'm going to wait and be patient and try to make the most out of the current generation while it lasts. If it is ever replaced I'm sure there'll even be people going back to previous versions of the game to revisit it just like people do with pathfinder nowadays.

If you made it this far I hope you enjoyed what I was saying and maybe learned a thing or two. I'd love to write a bit more about topics like this so I'll keep an eye on discussions of the proc gen going forward.

Planets big, templates small. You need a lot of templates to fill a planet with minimal repeats and matching up the edges of templates in a natural way is a major task.

edit: fixed some weird wording.

edit 2: fixed some broken formatting


Similar Guides

More about No Man's Sky

Post: "A practical look at “Procedural Generation 2.0” or template based procedural generation for No Mans Sky" specifically for the game No Man's Sky. Other useful information about this game:

Top 20 NEW Medieval Games of 2021

Swords, dragons, knights, castles - if you love any of this stuff, you might like these games throughout 2021.

10 NEW Shooter Games of 2021 With Over The Top Action

We've been keeping our eye on these crazy action oriented first and third person shooter games releasing this year. What's on your personal list? Let us know!

Top 10 NEW Survival Games of 2021

Survival video games are still going strong in 2021. Here's everything to look forward to on PC, PS5, Xbox Series X, Nintendo Switch, and beyond.

You Might Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *