Create A City in Blender - Full beginners Tutorial

Decor Design 3D
20 followers
In today's video, I will show you the way for making cities with Blender.
It will be an easy method and can apply to many things regarding distribution.
We will also go through some of the common problems that occur with beginners in geometry nodes,
so enjoy and let us start.
In a new Blender file, clear the viewport by selecting everything and hit X to delete it.
Then, with Shift A, add a mesh plane.
The default plane goes at 2 by 2 meters,
and you can keep that since we're not doing this up to a designed scale.
For me, I will make the ground plane around 11 or 12 meters.
Now to work on geometry nodes, we can open a new workspace and change it into that,
or from the top, switch it from the layout to the geometry nodes tab.
The space on the left is not needed in this video, so we can merge it with the viewport.
To add a geometry node to any mesh, simply select it, and hit new.
Now two nodes will show up in the nodes area.
This one on the left is the geometry input, meaning the plane,
so if we delete this, the mesh will disappear.
The one on the right is the final stop, and every node will be linked to it in one way or another.
So to distribute things over this mesh, or scatter anything in mind,
whether it's people, grass or buildings, we need a node called distribute points on faces.
Just add it and drop it on the line.
Now the plane we had will be displayed as points.
If the points are too few, that's probably cause we need to apply scale on the plane,
and take it as a general rule in blender, always check the applied scale when something weird
happens. To apply scale hit control A in object mode, and select scale.
After that we can see the right number of hollow points scattered over the mesh.
To bring the plane back, and sometimes we need it, as in today,
we're making a city and we need the ground, so to connect the input and output directly,
we have what is called a join geometry node, this one works like the mix in material nodes,
hit shift A and type join to locate it, then add it right before the group output,
and connect the input to it along with the distribute.
Now to the real deal, we need to change those dots or points into objects, as we said,
you can use characters, plants, animals, or anything in mind and replace the dots with
those objects, so to keep it simple, I will explain the next step on a cube,
and we will switch it with some buildings later.
To switch the points into the cube, you need the next node, it's called instance on points,
and place it after the distribute. In this node there is an instance slot or input,
and there, we can assign any mesh or object we want it to appear instead of the points,
let us drag the cube from the layers section, and drop it at the geometry nodes area,
then connect its geometry slot to the instance one.
Let us scale those cubes down to see what happened, you can hold shift and highlight
all the x y and z values in the instance nodes scale, and let me turn on the wireframe on those
cubes to see it clearly. There are 2 problems from what I am seeing, first is the intersection
between objects, and this one is asked many times, how can we make objects not intersecting
with each others, well there is a fix, doesn't apply on all cases but in our case it works,
and that's by switching the distribution type from random to disk, this will allow you to set
a minimum distance between objects, and that will fix the problem, however, this value it not
synced with the scale, so you need to adjust it when you rescale the mesh. Below the distance
value you have the density max and factor, both control the number of objects scattered on the
plane, so experiment with it. The second problem we can see is the alignment of objects on the
plane, and that's due to the center point of the cube, as you see, the cube center is in the middle
of it, so we can fix this by simply moving the cube in edit mode, just an easy fix. If that is
not accessible or you can't move the object, there's a node called transform, so hit shift
A and look for it, then add it after the object info, and if you have a problem with why we place
it after the cube info and not before, understand that we need the cube to transform first, and that
need to happen before we assign it as an instance, mainly cause the last node don't have a location
transform tab. Now, since the cube center is in the middle, and the cube by default is 2 meters in
height, we will insert half that into the translation Z value. Now to replace those cubes
with buildings, I have this set of low poly mesh. The link for it is in the description, and again,
you can use anything you have since the method is the same. I will copy everything here with control
C, and paste it into the scene, or use a pen from the file menu, that will give you the same result.
Let's make a new collection for the buildings, so we can assign them together as instances,
and this collection will replace the object info, so delete the last one and drag the
buildings collection. With collections, we need to check 3 boxes, first in the instance on point,
check the pick instance option, then in the collection itself, check the separate children
to make it use each and every buildings type we have in the collection, and also the reset
children to fix their position. Again a problem occurs, so let's apply scale on the buildings,
hide the ground plane for now, and from the layer section, select everything in the collection,
then hit control A and choose scale. It appears that we need to apply rotation, so do that,
and try not to apply location, since with most online models, the pivot points can scatter all
around the scene. Now we have what looks like a collection of buildings, but not a city, and
that's because we need randomness in life, that will apply mainly on the scale and the rotation
of buildings. The buildings are hovering on the ground since we have a transformation node,
so put the Z value back to zero, or delete it by hitting control X, since we already have rotation
and scale in the instance node. To make a variation in the building scale, we can drag the
scale slot in the instance on point, then add on it a random value node. With this new node,
we can set a limit from minimum to max and randomly scale the buildings. I will set it from 0.2 to 0.8
on all axes, and as we said before, this will affect the minimum distance value between the
objects, so we need to adjust that every time we scale the buildings. If you have objects going
off the plane by a lot, you can change the distribution seeds until you find a suited one.
Now one of the problems that happens when we randomly scale objects is stretching,
and let me find a clear one to show you, cause many people ask about this. For example, those
two objects of the same model are stretched not only scaled, that's happened when we use the
random scale on vector, the easy fix is to switch it to float, with this, if we applied the same
values, the result will be better and no stretching will occur. Another thing we need to fix is the
rotation, since if you noticed, all buildings of the same model have the same direction,
like this type, if we look around, all the similar ones are directed toward the minus y,
so to give it some life, we can add another random value node in the instance rotation.
Now in many things like vegetation or characters, we can just make the x and y value at 0,
and play with the max z value to randomly rotate trees or grass, however, with buildings,
rotation must be on a 90 degree value, so to make this, we need to change the random value
type to integer, then connect it to the rotation slot. What this node do now is assign how many
times the building will rotate, and it will be from 0 to 3 times, but we will make it into that
later, cause first we need a math node, add it and place it right after the random value.
Set the math type on multiply, and for the value at the bottom, we will insert what equals to 90
degree but with radiant, and that will be 1.571, for any other degree you can search it on google.
The max value on the random will be 3 since the 4th turn will bring the building back to the same
position. The last thing we need to fix in the random is to set it on the z axis only,
so look for combine x y z node, and place it after the math multiplier,
then plug the math into the z slot. Here you have it, might not look cool yet,
but with simple materials and some lights, you can have many city options in couple of minutes.
Let's go through what we did here. The input geometry, aka the ground plane, goes into the
distribution node to generate scattered points, and also goes back to the group output to remain
visible, meaning we still have a ground. If you have another floor on the side, just cut the top
wire. The points we generated will be replaced by instances with the instance on points node,
and this last node needs an object information assigned in it, so we plug the buildings
collection. Lastly, we add some randomization on both rotation and scale using the random value
node. Now some might say, what about roads, how can we add those? My recommendation is to separate
the mesh before working on it, and that is easy if you work with 2d software, like cad or evit or
anything similar. For the render I showed you, I added a plane with some cuts, then in edit mode,
I selected some of the faces to make it as roads or buildings area, and hit p to separate them.
If you are working on anything other than buildings, there are 2 ways, I'm not diving
into them, but just to mention that if you want to search for it, the first is using the raycast
node, that will go into the distributions selection slot, and between those 2 you need
a boolean math to cut building using any object, raycast node has a target geometry slot,
and there you can assign any object to work as a cutter, somehow similar to the boolean modifier.
The second method is to plug the selection back into the group input, that will help you re-scatter
the objects in many ways including weight paint. Weight paint of course needs subdivision so we
make some cuts on the plane, and draw with the weights brush to assign the empty and occupied
areas. Those are 2 ways to fix distribution or control them, but none of them are usable with
city models since we need sharp lines, so try to set up your work areas before starting with the
geometry node. Before we wrap this video, let me show you the wood material I used,
it has a mix between wood and white color. The wood is from the kit library which is free,
a link to it is in the description, and we mixed it with the white using a geometry node,
so in the mix factor, take the normal slot from the geometry node, plug it into a separate x y z,
then connect the z axis to the factor in the mix, this will make every horizontal face white.
And that's it, hope you enjoyed it, like the video if you're still here,
and tell me your thoughts and comments down below, stay sharp guys, goodbye.
