City Generator Scripting

Can you guys modify this so it looks like a billion dollar game ? In layer 1 press SPACEBAR once to generate city. If you press more than once it might crash because it will generate again but only in one direction.


City Generator 001.blend (154 KB)

You should randomize! I will add edit later

Here is a new version check which one you like more. This one has a caricature that can be useful for color changes on each building or the windows on each building. There is a UFO running around in disco mode with GLSL color changes. LOL

Wow there is some kind of bug in the second example because when the UFO is switching states the rasterizer goes from 1% to 20%. Can anybody figure out why is overloading the rasterizer on state changes ?


City Generator 002.blend (587 KB)

Here is another version. This one is not overloading the rasterizer anymore at least not as much as “002” which jumped at 23% sometimes. I still don’t know why it did that but it had something to do with that UFO in scene.


City Generator 008.blend (589 KB)

modify this so it looks like a billion dollar game

Only if you give me a billion dollars…

LOL … I give you a billion dollar but I have to make a trillion dollars from this game first. So, how do we turn it into a trillion dollar game when you guys are so boring and not very enthusiastic about the city generator and making the trillion dollar kickass game.

How do we make a proper road system for the city generator ? Anybody ?


City Generator A.blend (632 KB)

This version is creating a list of all objects from inactive layers and if those objects have a property called [‘tile’] they get added to the list to be used in the generator. It took me a long time to figure out why it was not adding the objects from second layer to the list. You have to use scene.objectsInactive instead of scene.objects. WOW


City Generator B.blend (541 KB)

This is cool thing! This way we could also make a procedural terrain. Maybe make it auto generate and LOD? You could use GlobalDict to save generated structure and always load the same :slight_smile:

Any ideas how to create a road and highways system ? The roads that are modeled into the tile don’t align anymore when the tile gets rotated by 90 degrees.

Here’s the thing. I could write about 7 pages of information on how to generate a city, right now, from the top of my head. Then I could spend a month or two implementing them.
What I used to do was to write a massive post outlining methods and ideas about every such topic. But recently I’ve stopped as I realized that the most interesting, open-ended questions come from people who don’t have the experience to use the knowledge. People reading it later might, but as I never see people use the information, I get very little satisfaction from writing it down.

That said, here we go again.
***What is a city?
Let’s start from the very beginning. We’re trying to replicate something that exists. If we look at a road-map of a city we see that it isn’t just a massive grid (except for dunedin), but there is a definite ‘grain’ where roads tend to travel perpendicular. You could almost say that every intersection is right-angled.
But if you zoom out, you’ll notice that cities have a grid-like central city, and further away it turns into a spider-web: the roads running away or perpendicular to the center of the city.

So let’s start with the center of the city. We’ll generate a grid, and remove some connections to create interest. Then we’ll move each node slightly. Apply a smoothing operation and we have:

Looks a little like a central city. Maybe those empty spaces are parks or something.

Now let’s make the ‘web.’ Take a couple of those edge roads and extend them outwards, randomizing their points joining things here and there. And now we have:

Starting to look like a city, isn’t it? The transitions a little harsh though. With a bit of tweaking you could sort that out.

So, is this procedurally generated? Yup, we followed a procedure. It’s be easy enough to get the computer to do all that for us.

We want our player to be down at street level, walking around so obviously we need buildings. I’m not going to go into generating buildings, I’ll just assume there’s a pack of them and it picks them, actually, let’s assume there are a couple of packs such as residential, industrial, comercial. Then we can place them seemingly realistically. The central city will be purely comercial in the middle, with a couple residential blocks around the edge. Further out it will remain residential but with a couple clumps of industrial.
If I had bothered to implement this as a script, figuring out how to place those buildings would be very easy.

***So there you go, one hour of time, $20 by the going standard (at least where I live). I’ve suggested a method for creating street layouts. If you want me to implement it in a script, you’ll have to convince me that I should. Otherwise, have a look at scene city generator. It’s intended for rendering, but I imagine with a little tweaking you could get it running (minus some features) in the game engine.

For interest’s sake, let’s take your billion dollars. Let’s say we have a company of 2, just me and you. To start off development we spend 5000 on really good hardware, some good rigs for us to work on and a few to bake images. Let’s rent a premise in central city while we’re at it, and pay our wages too. Let’s be modest, $20 an hour. $2000 for the both of us for a week, plus 1000 a week for power and office space. Now we’ll spend the first week planning our city generator, deciding on what we mean by a ‘city’, bam, 3 grand gone. The next month we spend implementing it in python and twekaing it to get a road-layout we like, and placing stand-in blocks. Now, because we don’t want to step on too many toes, let’s start building models. First off we have to tweak our city generator to make proper roads and intersections, that takes a week. Then the time-consuming bit begins, building buildings. I’d guess nearly 3-4 months of this (remember that extra hardware?) Finally we get our city generated, buildings and all.
Time to add in street-lamps, fire hydrants, and a thousand other details we forgot.

We then discover that we have a framerate of 0.5fps - on our really good hardware. So we start optimizing, generating the data on the fly rather than all at the beginning. A seeded number generator ensures that things remain the same for each city. Call it a year total work.
How much money has been spend? Probably 500,000 or so. At this rate we can keep working for 20 years. Bear in mind we don’t have a game yet, just a city.

We now start on the actual game, adding in half-a-year for the menu system, a year for the character animations+models, a couple months for detailed planning + concept work (that should have come before the city generator really). Maybe 5 years after we started, 2,500,000 later and we have a game. Let’s hope it sells…

How is my caricature city generator supposed to create that complication from scene-city ? This is not about other generators. It’s about the caricature generator that I posted here. My caricature generator knows how to do a little bit of something something too even if it’s not that advanced. Yet.

Wait a second. We start the business as billionaires and then we need a $20 an hour paycheck for what ? For coffee and donuts or what ?

What if the game sells really good and we can’t keep up with customer complaints because the game is still buggy as hell ? Could happen like that too.


City Generator C.blend (575 KB)City Generator D.blend (793 KB)

Interesting subject.
Cities are affected by terrain. Here’s how a city started.

  • The basic! Intersection of road-road, road-river, road-rail, road-sea/port, etc.
  • From that center, it spread (population #) like bacteria (game of life) - affected by terrain (eg height, swamp, etc).
  • It can spread randomly or systematically - mesh.
  • Later, it will get connected to nearby cities - another intersection will start another city.
  • Higher building are closer to the city center.
  • Bridges n road/rail tunnels are possible for big cities.

This looks better and better :wink:

Lovin those flashing road in the latest city version.

I should create a second shader so they flash differently. Right now it’s using the same one from that UFO. You guys are always welcome to improve it. Don’t wait for me cause I’m still a noob at scripting.

Maybe you could try to make it autogenerate in all directions and work iwth LOD? maybe disappear when far away?

Good idea but that’s going to take me a few months of figuring out what works and what doesn’t. It’s going to be a long while I’m guessing. Plus as soon as you rotate the tile roads are not going to align anymore so I have to try like a multi pass or multi layer style generator. Something like:

  • Pass 1 , create road networks.
  • Pass 2 , add buildings with different colors in areas not covered by roads ? Maybe ?
  • Pass 3 , create terrain and fill remaining areas ? Something like that ?

The textures don’t align properly either. I’m pretty sure I need textures to align without seems too which means extra complications.

Here is the spectacular road system that GTA V is not able to match anytime soon. LOL
There is no LOD switching on this map. It’s all there all the time.


City Generator F.blend (798 KB)

Here is the multi layer concept. GTA V doesn’t have anything like this. LOL

  1. Click spacebar once to generate terrain.
  2. Click RMB multiple times to create multiple layers of roads.


City Generator G.blend (800 KB)

Is your GTA V editor, the one that is not available to the public because Rock Star loves to scam it extra, able to generate these kinds of scenes so quick ?

I think not.

Tell Rock Star to try again because GTA V is not able to match a super-noob-ish city generator like mine.
Did I mention that I’m no programmer nor artist ?

I have to replace the file because all materials got screwed when I tried to reduce file size and I also discovered a but.

If I attach a lamp onto the UFO is not interacting with the material from the terrain.


City Generator I.blend (757 KB)

The G file has a problem:
On horison 20 FPS. When I watch upwards, I get 60 FPS. When I watch downwards on terrain - 30FPS. Now, again on horison and add road - 60 FPS. Watch upwards and add multiple roads(even hundreds of them) and stay at 60 FPS. Now watch at horison - 10 FPS :smiley: