Create Entire Cities Automatically With PCG Splines! Procedural Content Generation in Unreal Engine
Summary
TLDRこのビデオでは、Unreal Engineのプロシージャルコンテンツ生成フレームワークを使って中世の町を数分で作り上げる方法を紹介します。スプラインを使用して町の形を定義し、スプラインロードで町を通過させ、スプラインに沿って道路ジオメトリーを生成して効果を豊かにします。PCG初心者向けガイドもリンクしています。プロシージャルな森の周りに町を生成し、スプラインを用いた建物の配置と道路のカットアウトを学ぶことができます。
Takeaways
- 🏰 スクリプトはUnreal Engine内でプロシージャルコンテンツ生成フレームワークを使用して中世の町を短時間で作成する方法を紹介しています。
- 🛠 スプラインを使用して町の形状を定義し、スプラインロードを通して町を切り抜き、スプラインに沿って道路ジオメトリを生成する方法を学びます。
- 🔍 PCGの初心者向けガイドは、ビデオの下にリンクされているため、必要な場合は参照できます。
- 📐 まず、既存のPCGボリュームを切り抜くためのスプライン形状を作成する必要があります。
- 🔌 「modeling tools editor mode」というプラグインを有効にする必要があり、編集とプラグインのセクションで「modeling」を入力して確認します。
- 🎨 「Modeling」ツールを使用してスプラインを作成し、地面上に円を描画し、ループをチェックして閉じる方法が紹介されています。
- 📂 スプラインにタグを追加し、PCGボリュームで使用するスプラインと他のスプラインを区別します。
- 🌳 フォレストのPCGボリュームを設定し、スプラインを使用して木々が生える地域を定義します。
- 🏠 新しいPCGグラフを作成し、町に建物を自動生成するための設定を行います。
- 🛤️ 町を通過するロードを作成し、スプラインを使用して建物との重なりをカットアウトします。
- 🌲 ロードに沿って繰り返し生成される地面メッシュを追加して、自然な道のりを実現します。
Q & A
ビデオで紹介されている Unreal Engine のプロシージャルコンテンツ生成フレームワークとは何ですか?
-ビデオでは、Unreal Engineのプロシージャルコンテンツ生成フレームワーク(PCG)を使用して中世の街を短時間で作成する方法が紹介されています。これは、ランダム性やルールに基づいた方法でコンテンツを自動生成する機能です。
ビデオで使用されているスプラインとは何で、どのような役割を果たしますか?
-スプラインは、Unreal Engineのモデリングツールの一つで、曲線や形状を定義するために使用されます。ビデオではスプラインを使用して街の形状を定義し、道を通過させるためのスプラインも作成されています。
ビデオのチュートリアルでは、どのようにして森に囲まれた中世の街を作成する予定ですか?
-ビデオでは、まずPCGボリュームを作成し、森を生成した後、スプラインを使用して街の形状を定義し、その中に街を生成するプロセスが説明されています。
スプラインを使用する前に、Unreal Engineに必要なプラグインを有効にする必要がありますか?
-はい、ビデオでは「modeling tools editor mode」プラグインを有効にする必要があると説明されています。これにより、スプラインなどのモデリングツールを使用できるようになります。
スプラインを描画する際に「World」オプションをオフにすることによって何が得られますか?
-「World」オプションをオフにすることで、スプラインを地面平面上に限定して描画することができます。これにより、スプラインが周囲の木々などに描画されることを防ぎます。
ビデオで紹介されている街の形状を定義するスプラインにタグを追加する目的は何ですか?
-タグを追加することで、PCGボリュームが特定のスプラインを認識し、その形状に基づいてコンテンツを生成するように指定することができます。
PCGグラフ内で「Difference」ノードを使用する目的は何ですか?
-「Difference」ノードは、スプラインから得られるポイントと、他のポイント(例えば森の木々のポイント)を比較し、重複するポイントを削除する役割を果たします。これにより、街のクリアリングが作成されます。
ビデオで使用されている「Spline Sampler」ノードの「Interior」オプションとは何を意味しますか?
-「Interior」オプションは、スプラインの内部にあるポイントのみをサンプリングするように指示します。これにより、街の形状の内部にポイントが生成されるため、建物が適切に配置されるようになります。
建物をランダムに配置する際に「Attribute Noise」ノードを追加する理由は何ですか?
-「Attribute Noise」ノードは、メッシュスポーンのランダム性を調整し、建物の配置をより自然に見せるために使用されます。ノイズの値を調整することで、建物の配置のランダム性をコントロールできます。
ビデオで作成される道のスプラインにはどのようなタグが付けられますか?
-道のスプラインには「Road shape」というタグが付けられます。これにより、PCGグラフが道を特定し、それに沿ってポイントを生成するように指示されます。
ビデオの最後に、道に沿って繰り返される地面メッシュを追加する目的は何ですか?
-地面メッシュを道に沿って繰り返すことで、道に自然な土の道のような見た目を与えることができます。これにより、街の道にリアルな雰囲気が生まれます。
Outlines
🏰 制作中世纪城镇的开始
このビデオでは、Unreal Engineのプロシージャルコンテンツ生成フレームワークを使用してわずか数分で中世の町を作り上げる方法を紹介します。スプラインを使用して町の形状を定義し、スプライン・ロードで町を通過させ、ロードジオメトリをスプラインに沿って生成する方法を説明します。PCG初心者向けガイドもリンクしてあります。
🛠 スプラインを使用した町の形状の定義
Unreal Engineのモデリングツールを使用してスプラインを描き、町の輪郭を作ります。スプラインを閉じるためにループオプションをチェックし、タグを追加してPCGボリュームから他のスプラインと区別します。次に、PCGグラフ内で差分ノードを使用して、スプラインが定義する領域のポイントをカットアウトします。
🏘️ 中世の町の建物の配置
新しいPCGグラフを作成し、スプラインデータを取得して町の内側のポイントをサンプリングします。ポイントサイズを調整して建物が適切に配置されるようにし、静的メッシュスポナーを使用して様々な中世の建物を追加します。建物の配置が不自然な場合は、シードを調整するかノイズノードを追加してランダム性を増します。
🛤️ 道のスプラインと路面の生成
町を通過する道のスプラインを作成し、そのスプラインデータをPCGグラフに取り込み、ポイントを距離ベースで均等に配置します。路面として森の床面メッシュをスポーンし、サイズと回転を調整して自然な道の見た目を作り出します。最後に、道が建物を通過するように差分ノードを設定し、路面を道に沿って繰り返しスポーンさせることで完成します。
🎨 プロジェクトへの応用とさらなる学習へのリンク
このビデオを通じて学んだ技術を使ってどんなプロジェクトに応用するかコメント欄で共有を呼びかけています。ビデオが役立った場合は好評を示し、さらなる複雑な効果やアニメーション、フィルム作成に関するUnreal Engineの学習を希望者はリンクされた無料トレーニングや関連ビデオをチェックするよう促します。
Mindmap
Keywords
💡プロシージャルコンテンツ生成(PCG)
💡スプライン
💡Unreal Engine
💡スプラインサークル
💡スプラインロード
💡タグ
💡PCGボリューム
💡ステンシルデータ
💡静的メッシュスポナー
💡属性ノイズ
Highlights
展示如何在几分钟内使用Unreal Engine中的程序化内容生成框架制作中世纪城镇。
使用样条曲线圆定义城镇的形状。
使用样条道路切割城镇并生成沿样条的道路几何体。
为初学者提供程序化内容生成(PCG)的入门指南链接。
介绍如何设置PCG体积以生成围绕中世纪城镇的森林。
启用建模工具编辑模式插件以创建样条。
使用建模工具直接创建样条比使用蓝图更简单快捷。
通过绘制样条工具在地面上绘制城镇的圆形样条。
使用标签区分不同的样条,以便PCG体积正确识别。
通过差分节点和样条数据创建一个清除点,以生成空地。
创建新的PCG图来生成城镇本身的结构。
调整样条采样器的参数以控制建筑物的分布。
使用静态网格生成器添加不同的中世纪建筑。
通过调整种子和属性噪声增加建筑物分布的随机性。
添加变换点节点以调整建筑物的方向。
创建道路样条并使用它来切割城镇的点。
使用变换点和静态网格生成器沿道路生成地面网格。
鼓励观众分享他们如何将此效果应用于不同项目。
提供链接到更多关于Unreal Engine动画和电影制作的免费培训。
Transcripts
hello in this video I'm going to be
showing you how I made this medieval
town in just a few minutes using splines
with the procedural content generation
framework inside of Unreal Engine I'm
going to be showing you how to use a
spline Circle to define the shape of
your town how to use a spline road to
cut through that town and then how to
spawn a road geometry along that spline
in order to fill out the effect and if
you're new to PCG and you want more of a
beginner's guide I will link that video
below this so let's get into it so
here's the town we're going to be
building I'm just going to come over
here to the spline actors and the PCG
actors and go ahead and delete them and
you'll notice I have already set up a
PCG volume inside of this level to spawn
the forest that's going to be around
this medieval town but if you'd like
tutorials on how to do that I will link
that as well below this video so what we
need to do to make a Town spawned inside
of this Forest is first to create a
spline shape that will cut out the
existing PCG volume that I've already
set up here so we need to make sure sure
there's one plugin enabled here and that
is under edit and plugins we're going to
type in modeling and you want to make
sure you have modeling tools editor mode
checked on and if it prompts you to
restart the engine go ahead and do that
now I'm going to come up here to the
drop down in the top left corner and I'm
going to choose modeling here this is
going to open some modeling tools for me
on the left side here and this is a much
easier way to make a spline then to make
a blueprint with a spline inside of it
which some of you may be familiar with
if you've made splines before this is a
much easier way and gets us the result
we want much quicker so I'm going to go
ahead and come to the draw spline tool
here and you can find that if you're not
in it in the create button on the top
left corner here so click on that click
on draw spline and one thing I want to
check here is that I uncheck world I
really just want to Draw It On The
Ground plane I don't want the spline to
like draw onto trees up and down so I'm
going to uncheck world but if you need a
draw spline on other objects make sure
that's checked on so then I'm just going
to go ahead and click around in a circle
however big I want my town to be here
and in the top left corner here where it
says Loop I'm going to go and check that
so it closes the loop for me and I'm
going go ahead and hit accept right here
so now I have a spline for the shape of
my town this can always be changed later
as well if you want to edit it I just
come out of the modeling mode and I can
choose one of these points and move them
around so the way that we're going to
tell the PCT volume to use this spline
and not other splines we're making in
our level like the one we're going to
make for the road is to add a tag to it
with that spline actor selected I'm
going to come over here and on the right
side here I'm just going to go ahead and
search tag to save us some time in the
search bar here and under the actor tag
section here I'm going to hit the plus
button to add a new tag to this object
and we're just going to call it town and
then outside and pay attention to what
you name it here cuz you'll need to
remember it and type it into the PCG
volume later so I'm going to go ahead
and hit enter I come over here to my PCG
volume here for the forest uh I click
clear the tag section here that I added
and I scroll down to the PGG component
open the PCG and graph instances and
then instance this is a PCD graph that's
connected to the volume here so I'll
double click on that to open it okay so
this is what I have set up for the
forest I have just a landscape surface
sampler coming into a transform points
to give the trees some random rotation
and then I have some density filters to
adjust how many points are on the
surface and then I have a static mesh
spawner for trees rocks and things like
that okay super simple so what I need to
do is cut out these points in this area
here right before they're used to spawn
so once I've done all the adjustments to
those points that I want we're going to
be creating a difference node so I'm
going to draw off here and type in
difference and I'll hold alt and click
on this input here to disconnect it and
reconnect it to the output and you want
to make sure that the source here which
is the point spawning those trees is
plugged into source and then the
differences section here that's where
we'll plug in the data from our spline
so in the difference node I need to
change the density function here to
Binary what this is doing is it's
basically telling this node that when we
give it the points that the spline has
created inside of it which we're going
to set up in a second to either choose
one or the other so basically to
completely remove all the points that
overlap with the points from the spline
so now we're going to right click in the
empty space down here and I'm going to
type in spline I'm going to choose get
spline data first because we need to get
this spline into the PCG graph and with
that node selected I'm going to come
over to the actor filter drop it down
and choose all World actors so it's
going to sample all the splines I have
in my scene but I'm going to choose by
tag here so it's going to choose the
spline with the correct tag which if
you'll remember we made as town outside
and if that tag exists in the world
you'll see the error on that spline data
go away so it's got that's a good thing
that means it's gotten the data from our
spline now I'm going going to drag off
of the get spline data here and we need
to make a sampler just the same way we
would sample a landscape so I'm going to
type in spline again to get spline
related stuff and we're going to choose
a spline sampler here in the spline
sampler there's a few different ways we
could sample this spline and later on
we'll use a different one but for this
we want the inside of the spline so if I
come up to the dimensions and instead of
on spline I switch it to Interior it's
going to get all the points inside that
shape that closed shape that we made so
let's actually take a look and make sure
this is working so I'm going to come
over and disconnect my mesh spawning so
that we can actually see what the graph
is doing then I'll contract this down so
this is the shape of our town here and
in the spline sampler I'm going to go
ahead and press D to debug and we have
one problem which is that this is only
being sampled inside the bounds of our
PCG volume which I actually turned off
for the trees so it would fold the
entire landscape so we actually have to
to turn that off for the spine sampler
as well and it's not actually super
important to have only things spawn
inside that volume because we're
actually using the spline itself to tell
us where the points are so we don't
actually need that bounding shape of the
volume so I'm going to come over to the
spline sampler and choose Unbound here
once we do that it's going to show you
that it's spawned all these points all
over the place so now we can come over
to the differences node and let's take a
look at what the points that we're using
to spawn the trees look like so UND
debug the spine sniper and debug the
transform point and these are all the
points I'm using for the trees and rocks
so if we plug the spine sampler into the
differences node here and we debug that
you can see that the spline sampler is
using the points from the spline data
node to cut out those tree points so now
if we plug it back into our mesh spawner
section we can see we have successfully
created an empty
clearing all right so let's make a new
pcga volume for or the town itself I'm
going to close this for now right click
in my content browser and come to PCG
and choose PCG graph as I mentioned in
other tutorials if you don't have the
PCG option in your content browser it
means you need to enable the plugin
procedural content generation framework
plug-in so I'm going to call this new
PCG graph
PCG town and I will drag it in to the
environments I'll hit generate on the
right side here and then I'll double
click on it to open okay so we're going
to come into the empty space here right
click and type in and get the get spline
data node here like we used before and
we'll come over here to the action
filter on the right side and choose all
World actors and again under the buy Tag
section we will type in town outside
there we go so we're going to drag off
of the out again here type in spline and
get the spline sampler same as before
this time let's go ahead and hit D to
debug this particular node so we can see
what we're working with and same as
before we need to come over to this
blind sampler and choose under Dimension
where it says on spline you want to
switch it over to on interior and scroll
down again and choose Unbound or you
could scale the PCG volume up far enough
so that it would cover the whole spline
shape it's up to you okay so it's pure
white here and that's because all of the
individual points are too big so I need
to actually mess with those Point sizes
so that it doesn't spawn too many
buildings when I actually connect up the
geometry spawner to it so we can start
modifying these options here right now
the interior sample spacing is 100 that
means there's 100 units in between each
sample if I increase that number to say
something like 500 we can see it makes
the dots smaller because it's giving a
500 space in between them I'm going to
go ahead and actually increase this to
2,000 and you'll notice by default these
points are getting spawned in a grid
which is what we want for a town if you
were to sample the landscape not using
this method you would get points in a
more random layout or random format and
in this case we're getting a grid by
default which is good one thing I do
want to modify here is the bounds of
each point since they're kind of small
if I were to run a road through it which
we're going to do in a in a second they
would not actually probably overlap any
of the points and therefore not cut them
out they need to be roughly the size and
shape of the buildings that we're about
to add later so I'm going to go ahead
and drag off of the out here and type in
bounds and choose bounds modifier and
we'll just up the bounds m Max to 10 on
all of these once we've done that we can
go ahead and debug that node and we can
see these are much larger cubes which
will work a lot better when we're
cutting it out with the road okay now
it's time to add our static mesh spawner
to put our buildings in I'll drag off of
the bounce modifier here type in static
mesh spawner okay so we have the static
mesh spawner I'll come over here to the
mesh entries and expand that now I have
downloaded a medieval buildings pack
which I will link below this video if
you're interested in using those as well
but it contains all of these buildings
here so I have a bunch of different
buildings that I'm going to be adding to
my mesh spawner so I'll just add one to
show you how to do it which is to expand
the mesh entries under the static mesh
instance here and drag in a building of
your choice then contract it hit the
plus button again add another one open
the descriptor drag in another building
and we can see that we're already
starting to populate our little village
here now this is actually going to
really look the best if you have a lot
of different building options and I
actually do I have around 22 of these
buildings so I'm going to go ahead and
plug all of those into this mesh spawner
all right now they're all plugged in and
we can see we already have a village
that's looking pretty good here if
you're not really happy with sort of the
placement of the buildings or it doesn't
quite look random enough you can come
over here to the static mesh spawner and
you can adjust the seed which is going
to choose a just a random different
selection of buildings here or if you're
still not getting enough random
something I have noticed helps a little
bit is to add an additional node which
I'll grab by typing in noise and I'll
choose attribute noise and I'll plug
that in in between and in the attribute
noise under the input source I'm going
to click on the little plus button here
and choose seed and by default it's
going to have only one building and then
as I increase this noise Max here it's
going to just creep increasing the
randomness till I get something that I
like that looks pretty good and if we
have our buildings pointing in the wrong
direction we you can always modify that
as well by adding a transform points
note here in between coming over here to
the rotation Min and Max and adding a
rotation in Z maybe 9° and that will
rotate all of the buildings 90° now this
really works best if you've modeled or
at least rotated your building assets
that you're starting with to be all
facing the correct direction if they're
all have the front of the building faced
in different positions they're not going
to quite look that well here and instead
of adding like a lot of logic in to make
sure they're all pointing the same
direction it's just simpler to make sure
each of your assets is you know
efficiently pointing in the direction
that you want them to point you could
also use this rotation to add like a
slight bit of Randomness maybe not too
much but maybe between -5 and 5 that
just rotates the building ever so
slightly depends how gridlike you want
them to look so now we're ready to add
our road and the road is going to be
another spline that we add on top here
and it's going to cut through the points
that we've already laid out for the town
so come back over here to the mod
modeling drop down and choose my draw
spline option here I'm just going to
have it go straight through the middle
of my town I'll go ahead and hit enter
switch back to selection mode and our
second spline actor here we need to add
a tag as well too so I'm going to come
over here and insert type in tag for the
asset and choose a little plus button
here and type in Road shape or whatever
you want to add next we'll come back
into our graph here we'll right click
and get spline data again and and this
time we'll choose all World actors and
the tag will be Road shape then we'll
drag off of that sample it and I'm going
to actually disconnect the houses here
so that I can actually see the points
that this new road is making so hold
down alt and disconnect the static
meshes and we'll go ahead and hit D to
look at the spline sampler and I'm going
to come over here to the mode here where
it says subdivision and switch it to
distance this is going to lay the points
out along the curve more evenly we will
keep it as on spline here in contrast to
what we did for the town earlier and
we'll drag off of here and make a bounds
modifier we'll debug that and let's
expand those points because right now
there are actually points being
simulated but they're too tiny to see so
we'll just come over to the bounds Min
and Max and let's in the Y AIS increase
it to 500 here we can see the points
have expanded the width of about the
shape of the road that we want however
they're only getting simulated again
within the volume the PCD shape so
probably we should have just made it
bigger but at this point I'm committed
to using the Unbound option here so I'll
come over to the spinee sampler and
check on Unbound and now you can see the
points are being simulated all along
this line okay so now we have our road
and we have the points of the town so we
need to make a difference node in
between here so drag off of the
transform points that we're using to
simulate the buildings make a difference
node and the difference is going to plug
into those points from the road let's go
ahead and look at what that looks like
and you can see the road is cutting
right through the building here however
nothing is happening as because in the
difference Zone we need to come back
over here if you remember earlier we
need to switch the density function to
Binary and then it will cut out the
buildings that overlap with those points
now we can plug it back into our static
mesh spawner and we have a road that
will dynamically cut through our town
and to make this road look a little bit
better I'm going to add a mesh to be
simulated and spawned along it and
repeated to make kind of a muddy path so
I'll drag off of the actual Road points
here and make a transform points node so
I know I will need it to modify the mesh
then I'll drag off of that and type in
static mesh spawner and I will be adding
the forest ground mesh which you can
find in the quickel bridge so add a mesh
entry here drag that in and we can see
it is a bit too small so we'll come over
to the transform points and increase the
scale Min and Max by five We'll add a
random rotation as well in the rotation
Max section here under the Z axis We'll
add a 360 so it'll rotate from 0 to 360
and to push it down into the ground ever
so slightly to help it blend a little
bit better I'll come over to the offset
mid and Max and add in a negative one to
the Z axis and if I feel like there are
maybe too many meshes getting spawned in
a line here I can just come over to the
spline sampler here and this distance
increment is very similar to the one we
used for the placement of the buildings
so I can come over here and increase
this to 500 so create fewer points um
along the spine there you have have it
that's how you make a medieval town in
just a few minutes this can go very
complicated very quickly if you'd like
to add additional Logic for how the
buildings are placed or how the road
maybe spawns other meshes I could
imagine you having Street lamps that are
spawned along the outside of the spline
on either side but the starting point is
really to get that spline shape in the
overall shape of the town and then the
road spline that goes through it let me
know in the comments what you end up
actually using this effect for I'm very
curious to see how you all will apply it
in different types of projects if you
found this video helpful shoot me a
thumbs up so I know to make more on this
type of thing and if there you're out
there and you're a beginner and you're
just confused and you want more of an
onramp up to these more complicated
effects and specifically making
animations or films with Unreal Engine I
have a free training which you can take
a look at which is linked below this
video as well as a bunch more videos on
ptg specifically right here so I will
see you in the next one
5.0 / 5 (0 votes)