Pages Menu
Categories Menu

Posted by on Feb 21, 2015

Procedural Environment Generation

Procedural Environment Generation


When we set out to build Quasar one of the things we wanted to ensure was that keeping the environments fresh and unique could be easily accomplished. The easiest way for us to do this was to make the environments generated at some level. We wanted the environment to be made up of existing static meshes, and that the level would pick from those possibilities.

The first iteration of our generation algorithm had the entire environment generated by the server and replicated to all connected clients. This included environment items that were below the field of play, and therefore the player would never ever interact with. It worked fine, but having the server keep track of items that don’t matter to the game was a poor design decision. We decided to tear our generation algorithm apart and start again this time focusing on just the server first and later worrying about keeping any background environment similar across clients without creating them on the server. The generation algorithm now works like this.


Plant the Seed

First and foremost we seed a pseudo random number generator with an integer that is generated by the server. The available play area, which is defined by the number of players in the game, is then broken up into a grid and items that are required/have a limited number of placements are added to the environment on the server first.



In the case of our existing play mode which is FFA the only required/limited number items are player spawn locations (invisible) and what we’re calling Hazards, which are currently asteroid mounted lasers that are controlled by AI.


Fill the Immediate Environment

The remaining play field environment items are then added to the world on the server and these are set to replicate to the clients.



Give the Background Life

This is where the server stops being involved in generation and it’s handed off to the client. At this point the clients have also been going through the motions of generation but not spawning anything. The reason for this is so that the pseudo random number generator is at the same place as the server when the play field has finished generating and the client can continue to generate the background environment from where the server left off. If we didn’t do this the first X number of play field environment items would be mirrored in the background environment.


When the client is done generating the background environment we end up with a look like this. We did this to provide a parallax like effect, and to give the environment depth. The background environment also has a subtle depth of field effect on it to help the player identify what is and isn’t something they could run into.

And finally at this point the client would generate the skybox material (already visible in the screenshots, but not generated until now) as well as which planets to show, and where. In the case of the planets they’re existing in the environment already, the generation just decides what material to use and on which planets and we hide the rest.


Finally when it’s all said and done this is the end result.

One other thing to take note of is that none of the generated items are in the center of their respective slot in the grid. If we placed them that way it’d be incredibly apparent that the world is split up into a grid and it’d ruin the illusion of an asteroid field. We fix this by also using the pseudo random number generator to also generate an offset that keeps the item within the square and offset enough that it creates a more real feel.



We leave you with more game play footage from a recent play test including some developer discussion during play. We’re going to be opening it up in the coming weeks and getting people from Facebook/Twitter/reddit involved in some play tests!