You may have noticed quite a few posts over the last month about the city generation tools I’ve been working on. So far it’s been quite an interesting challenge so far and I thought it would be a good idea to track its development in a blog instead of solely on Twitter. So without further ado…
Began development of building generation system within the city, it currently “builds” out from the side of the road and creates a rectangular shape. If that rectangle overlaps over buildings or streets it simply doesn’t create the building in that zone, if the rectangle doesn’t overlap it creates a mesh. This mesh is just based on the floor plan and extruded out to a random height. I also multi-threaded the code in order to speed up the generation time, you can see it in the video embedded in the tweet with the output in the bottom left. Once it’s finished it outputs the finished mesh data back into the main Unity thread where it’s presented to the user.
Began removing the particle rendering hack out of the road rendering. Before this point every single road was created by rendering out particles along their path until it reached the end of the road. Now it creates a mesh along its path, effectively stripping tens of thousands of triangles out of the scene and causing a noticeable performance increase (~10 FPS to ~70 – 90 FPS).
Finished implementing the road mesh generator, tweaked the visual style to fit more with the vision I’m after. I’ve also fixed up the landscape generator, turns out it was causing quite a large memory leak with one mis-type (.mesh instead of .sharedmesh).
Plots of land are now a thing in the cities, thanks to the Clipper Library I was able to offset (thank you @JasperStocker for pointing out the right word!) the road path into sections of land. These plots are then turned into buildings by dividing up the plot into “parcels of land” and then generating buildings on them depending on their zone type. This effectively removes the previous building generation system and the huge load it took on the generation time as it doesn’t need to check the building plots against each other as we know that the parcels of land are valid ahead of time.
This is when everything felt like it was coming together, up until this point the cities were limited to being a certain size, mostly due to the complexity of the road meshes and the lack of effective culling. At this point I had been able to add in a very basic culling system to generate and remove off-screen meshes using the quad-tree system I had previously implemented.
Further toying with the visuals and implemented a basic LOD system to help with the frame-rate. Beginning to really fall for this style at this point.
December 15 – 16th
Playing with camera transition styles to help you navigate around the generated city.
That’s everything so far! This was my last tweet about the project before heading off for the Christmas holidays.