# Cashgen - (kinda) Infinite Procedural World Generator

**URL:** <https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131>\
**Category:** Game Development\
**Tags:** unreal-engine\
**Created:** [May 6, 2016, 4:37pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131 "2016-05-06T16:37:03Z")\
**Posts on this page:** 20\
**Page:** 14

<div class="post-metadata">

**Author:** ![Haoris](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Haoris](https://forums.unrealengine.com/u/Haoris)\
**Post date:** [July 26, 2017, 10:37pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/269 "2017-07-26T22:37:52Z")

</div>

> [@AinSophAur;741873](#):
>
> @Haoris  
> Hi.
> 
> Are you referring to the “flat” land from the branch, the tiles, not the spherical ?  
> As far as I know, there is no event added to tell when a tile has been placed.  
> With that said. I don’t think it’s too hard to add it. I’ve been playing around with the CGWorld more than the terrain part, so I can’t say it for sure.  
> I would have to do more research before I could tell you how tho.

Hi,  
Yes I was refering to the first video on the first page. I was wonder which technique he used.

---

<div class="post-metadata">

**Author:** ![AinSophAur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AinSophAur](https://forums.unrealengine.com/u/AinSophAur)\
**Post date:** [July 26, 2017, 11:00pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/270 "2017-07-26T23:00:27Z")

</div>

I think I’ve read somewhere that he used ray-cast. Ah, there it is…

> [@mid\_gen;728942](#):
>
> The heightmap and mesh data is managed by a pool in CGTerrainManager so once it’s been used to render the terrain, it’ll get re-used by another job.
> 
> If you want to place things accurately on the surface of the terrain though, you’ll need to raycast. You can’t just use the noise generator to get the surface height because the actual position of the mesh at that point will be different everywhere but right on a vertex. The advantage of the ray cast is that you get the normal.
> 
> This was done by raycasting :
> 
> [https://youtube.com/watch?v=KyDR3Nim4cQ](https://youtube.com/watch?v=KyDR3Nim4cQ)

I think that is the answer to what technique he used.

---

<div class="post-metadata">

**Author:** ![mid\_gen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mid\_gen](https://forums.unrealengine.com/u/mid_gen)\
**Post date:** [July 27, 2017, 6:35am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/271 "2017-07-27T06:35:58Z")

</div>

> [@AinSophAur;740426](#):
>
> Thank you very much! No need to be sorry. 😃  
> I mean, you are taking the time to do work on the this awesome plugin while working on something else.
> 
> I will have a look at it in a bit. Trying to get through a C++ course to get a better understanding of this untamed beast. Well, it’s a beast to me at least. 😛
> 
> I can understand that taking in a new engine makes the brain boil.  
> Mind telling what engine it is? I know it’s like a unwritten rule that says not to mention other engines on an engine forum and so on. But just out of curiosity. 🙂

It’s one of our in-house engines at Ubisoft, so not competition.

Fixed the collision now. I’m sure I didn’t have to explicitly cook the collision before, but anyway, you can pull the branch and it’ll work now.

Looks like I’ll have some free time this weekend to do a little work on this again.

---

<div class="post-metadata">

**Author:** ![mid\_gen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mid\_gen](https://forums.unrealengine.com/u/mid_gen)\
**Post date:** [July 27, 2017, 6:37am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/272 "2017-07-27T06:37:23Z")

</div>

> [@Haoris;741865](#):
>
> For my foliage question, at least is there a way to know when a tile has been generated so I can’t start an event right after each tile generation, event which raytracing and spawning foliage meshes?

I’ll add an event you can handle when the update completes this weekend.

---

<div class="post-metadata">

**Author:** ![AinSophAur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AinSophAur](https://forums.unrealengine.com/u/AinSophAur)\
**Post date:** [July 27, 2017, 7:11am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/273 "2017-07-27T07:11:36Z")

</div>

> [@mid\_gen;742134](#):
>
> It’s one of our in-house engines at Ubisoft, so not competition.
> 
> Fixed the collision now. I’m sure I didn’t have to explicitly cook the collision before, but anyway, you can pull the branch and it’ll work now.
> 
> Looks like I’ll have some free time this weekend to do a little work on this again.

Sweet! Thanks. 😃  
In-house engines, no wonder you had a lot to focus on.

Sounds good. And btw, if this where to be used in a commercial product, what license does your plugin go under?

**EDIT:**  
The in my case by adding the cook there. Is that it’s slowing down the process of making 10 planets. It’s closing up to the point where it takes too long to make. That is not this plugins fault, that’s for sure. But I’m going to see if I can add a component to my setup that cooks those meshes in their own thread or something.  
But for a single world, the MeshComponent-\>CookCollisionNow() works great.

Also, the first world that’s made has 2 runtime mesh components pr worldface while the rest has only 1 pr worldface.  
In my case, that adds up another 100 components.  
I know, it’s a lot of meshes and probably way too inefficient, but it’s the part of the process where we make things work, even tho it’s ugly, then polish and make things look good at a later stage. 😃

---

<div class="post-metadata">

**Author:** ![Haoris](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Haoris](https://forums.unrealengine.com/u/Haoris)\
**Post date:** [July 27, 2017, 3:25pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/274 "2017-07-27T15:25:28Z")

</div>

> [@mid\_gen;742136](#):
>
> I’ll add an event you can handle when the update completes this weekend.

Oh nice ! Thanks  
So you used line trace in your videos to get the Z value of the landscape to spawn instanced static meshes? or you added a procedural foliage spawner volume to each tiles? an other technic?

---

<div class="post-metadata">

**Author:** ![mid\_gen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mid\_gen](https://forums.unrealengine.com/u/mid_gen)\
**Post date:** [July 27, 2017, 3:33pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/275 "2017-07-27T15:33:51Z")

</div>

> [@AinSophAur;742143](#):
>
> Sweet! Thanks. 😃  
> In-house engines, no wonder you had a lot to focus on.
> 
> Sounds good. And btw, if this where to be used in a commercial product, what license does your plugin go under?
> 
> **EDIT:**  
> The in my case by adding the cook there. Is that it’s slowing down the process of making 10 planets. It’s closing up to the point where it takes too long to make. That is not this plugins fault, that’s for sure. But I’m going to see if I can add a component to my setup that cooks those meshes in their own thread or something.  
> But for a single world, the MeshComponent-\>CookCollisionNow() works great.
> 
> Also, the first world that’s made has 2 runtime mesh components pr worldface while the rest has only 1 pr worldface.  
> In my case, that adds up another 100 components.  
> I know, it’s a lot of meshes and probably way too inefficient, but it’s the part of the process where we make things work, even tho it’s ugly, then polish and make things look good at a later stage. 😃

Collision cooking is on the game thread…it’s slow. No way around that at present, just keep your mesh sizes down.

---

<div class="post-metadata">

**Author:** ![mid\_gen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mid\_gen](https://forums.unrealengine.com/u/mid_gen)\
**Post date:** [July 27, 2017, 3:34pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/276 "2017-07-27T15:34:55Z")

</div>

> [@Haoris;742311](#):
>
> Oh nice ! Thanks  
> So you used line trace in your videos to get the Z value of the landscape to spawn instanced static meshes? or you added a procedural foliage spawner volume to each tiles? an other technic?

Yep I just used a line trace to find the position and rotation to spawn instanced static meshes on the terrain.

---

<div class="post-metadata">

**Author:** ![AinSophAur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AinSophAur](https://forums.unrealengine.com/u/AinSophAur)\
**Post date:** [July 27, 2017, 3:54pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/277 "2017-07-27T15:54:27Z")

</div>

> [@mid\_gen;742319](#):
>
> Collision cooking is on the game thread…it’s slow. No way around that at present, just keep your mesh sizes down.

I’m currently adding all the RuntimeMeshComponents in one big array. Will there be any issues if I make a new thread to handle the cooking?  
The array is made trough blueprint, but I can access it through code. I know it works in the game thread, and I don’t see an to make a new thread to handle this, or even multiple threads to speed up the cooking.

---

<div class="post-metadata">

**Author:** ![AinSophAur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AinSophAur](https://forums.unrealengine.com/u/AinSophAur)\
**Post date:** [July 27, 2017, 3:55pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/278 "2017-07-27T15:55:36Z")

</div>

> [@mid\_gen;742320](#):
>
> Yep I just used a line trace to find the position and rotation to spawn instanced static meshes on the terrain.

Are all those static meshes?  
If I recall correctly, there is a way to use a volume to place foliage. If they haven’t removed that option that is…

EDIT:  
This should work in 4.15 as far as I know. By using the event to spawn this should be possible I think.[https://youtube.com/watch?v=lWfKe07tuq8](https://youtube.com/watch?v=lWfKe07tuq8)  
More EDIT:  
Here is a thread that says it should work in 4.15:  
[Generating foliage with procedural foliage volume drains system memory, and takes forever - World Creation - Epic Developer Community Forums](https://answers.unrealengine.com/questions/558330/generating-foliage-with-procedural-foliage-volume.html)

---

<div class="post-metadata">

**Author:** ![Haoris](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Haoris](https://forums.unrealengine.com/u/Haoris)\
**Post date:** [July 27, 2017, 5:18pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/279 "2017-07-27T17:18:48Z")

</div>

> [@AinSophAur;742331](#):
>
> Are all those static meshes?  
> If I recall correctly, there is a way to use a volume to place foliage. If they haven’t removed that option that is…
> 
> EDIT:  
> This should work in 4.15 as far as I know. By using the event to spawn this should be possible I think.[https://youtube.com/watch?v=lWfKe07tuq8](https://youtube.com/watch?v=lWfKe07tuq8)  
> More EDIT:  
> Here is a thread that says it should work in 4.15:  
> [Generating foliage with procedural foliage volume drains system memory, and takes forever - World Creation - Epic Developer Community Forums](https://answers.unrealengine.com/questions/558330/generating-foliage-with-procedural-foliage-volume.html)

Yep, that’s what I meant by “procedural foliage spawner volume”. I will try both once mid-gen add this event and give my results here.  
I will try to use the radius of a collision sphere to generate foliage only on tiles closest to player pawn.

---

<div class="post-metadata">

**Author:** ![OmniMachina](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OmniMachina](https://forums.unrealengine.com/u/OmniMachina)\
**Post date:** [July 28, 2017, 2:54am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/280 "2017-07-28T02:54:23Z")

</div>

Hey,

is it possible to change the terrain material parent to a material instance?  
Are there any limitations or what exactly is the reason for material parents? Material instances should be more flexible, right?  
Im also not able to create a dynamic material instance via BP…

Is there a way to flatten the edges of the map? For islands etc.?  
Maybe radial noise map or something similar…

anyway, thanks for the nice plugin bruh! I would even pay for it… especially for multiplayer support \<3

---

<div class="post-metadata">

**Author:** ![mid\_gen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mid\_gen](https://forums.unrealengine.com/u/mid_gen)\
**Post date:** [July 29, 2017, 10:58am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/281 "2017-07-29T10:58:46Z")

</div>

Added Radial module. You’ll need to pull the latest UnrealFastNoise for it.

Islands:

 ![F41Ho2y-QhaX_GrNCNMTBA.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/6/069e888e5dbbf49f144debd686890e49522decc3.png)

Can also be used to make a Death Star 🙂

 ![GhxIW_YXQ9yd_UfL0GDayw.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/2/02cb0d16b58718a6e3ffe2f59c9913c228f0512d.png)

Added two delegates to CGTile,

One fires when the Mesh Updates is called  
One fires when the LOD opacity transition is complete

```
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FTileMeshUpdated, int, previousLOD, int, newLOD);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FTileTransitionComplete, int, previousLOD, int, newLOD);

```

I’ve merged CG\_WORLD branch into now, I won’t develop in that branch any more.

---

<div class="post-metadata">

**Author:** ![mid\_gen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mid\_gen](https://forums.unrealengine.com/u/mid_gen)\
**Post date:** [July 29, 2017, 11:00am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/282 "2017-07-29T11:00:52Z")

</div>

> [@OmniMachina;742591](#):
>
> is it possible to change the terrain material parent to a material instance?  
> Are there any limitations or what exactly is the reason for material parents? Material instances should be more flexible, right?  
> Im also not able to create a dynamic material instance via BP…

At the moment I create a dynamic material instance from the parent provided as I need to manipulate the opacity values at runtime for the LOD dithering.

---

<div class="post-metadata">

**Author:** ![AinSophAur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AinSophAur](https://forums.unrealengine.com/u/AinSophAur)\
**Post date:** [July 29, 2017, 11:15am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/283 "2017-07-29T11:15:43Z")

</div>

> [@mid\_gen;743134](#):
>
> Added Radial module. You’ll need to pull the latest UnrealFastNoise for it.
> 
> Islands:
> 
> ![F41Ho2y-QhaX_GrNCNMTBA.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/6/069e888e5dbbf49f144debd686890e49522decc3.png)
> 
> Can also be used to make a Death Star 🙂
> 
> ![GhxIW_YXQ9yd_UfL0GDayw.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/2/02cb0d16b58718a6e3ffe2f59c9913c228f0512d.png)
> 
> Added two delegates to CGTile,
> 
> One fires when the Mesh Updates is called  
> One fires when the LOD opacity transition is complete
> 
> ```
> DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FTileMeshUpdated, int, previousLOD, int, newLOD);
> DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FTileTransitionComplete, int, previousLOD, int, newLOD);
> 
> ```
> 
> I’ve merged CG\_WORLD branch into now, I won’t develop in that branch any more.

That’s awesome!  
Will see if I can pull/download the and implement my own code into the new . 😃  
It should be relatively easy tho. 😛

EDIT:  
I guess it’s called clone, not pull. I’m kinda new to this source control thing. Still learning. 🙂

---

<div class="post-metadata">

**Author:** ![mid\_gen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mid\_gen](https://forums.unrealengine.com/u/mid_gen)\
**Post date:** [July 29, 2017, 12:31pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/284 "2017-07-29T12:31:58Z")

</div>

> [@AinSophAur;743140](#):
>
> That’s awesome!  
> Will see if I can pull/download the and implement my own code into the new . 😃  
> It should be relatively easy tho. 😛
> 
> EDIT:  
> I guess it’s called clone, not pull. I’m kinda new to this source control thing. Still learning. 🙂

That delegate setup I initially uploaded won’t have been much use to you, I’ve updated now. The CGTerrainManager now broadcasts :

DECLARE\_DYNAMIC\_MULTICAST\_DELEGATE\_OneParam(FTileMeshUpdated, ACGTile\*, Tile);

When a tile is updated.

---

<div class="post-metadata">

**Author:** ![AinSophAur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AinSophAur](https://forums.unrealengine.com/u/AinSophAur)\
**Post date:** [July 29, 2017, 12:47pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/285 "2017-07-29T12:47:21Z")

</div>

> [@mid\_gen;743151](#):
>
> That delegate setup I initially uploaded won’t have been much use to you, I’ve updated now. The CGTerrainManager now broadcasts :
> 
> DECLARE\_DYNAMIC\_MULTICAST\_DELEGATE\_OneParam(FTileMeshUpdated, ACGTile\*, Tile);
> 
> When a tile is updated.

That’s good. A that will be useful for sure. Good for when populating the planets on a later stage of the world building. 🙂

The code I’ve implemented checks when all the tiles for a world is done, then runs an BlueprintImplementableEvent.  
It’s nothing fancy, but it gets the work done.  
And it’s handy when having multiple planets.

---

<div class="post-metadata">

**Author:** ![mid\_gen](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mid\_gen](https://forums.unrealengine.com/u/mid_gen)\
**Post date:** [July 29, 2017, 1:23pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/286 "2017-07-29T13:23:03Z")

</div>

Ok I’ve added this to CGWorld which broadcasts when the world is fully rendered.

DECLARE\_DYNAMIC\_MULTICAST\_DELEGATE(FDrawComplete);

I don’t really have time to imagine or create any uses for this plugin at the moment…so feel free to keep posting requests and I’ll drop them in when I get a .

---

<div class="post-metadata">

**Author:** ![AinSophAur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AinSophAur](https://forums.unrealengine.com/u/AinSophAur)\
**Post date:** [July 29, 2017, 1:31pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/287 "2017-07-29T13:31:55Z")

</div>

> [@mid\_gen;743164](#):
>
> Ok I’ve added this to CGWorld which broadcasts when the world is fully rendered.
> 
> DECLARE\_DYNAMIC\_MULTICAST\_DELEGATE(FDrawComplete);
> 
> I don’t really have time to imagine or create any uses for this plugin at the moment…so feel free to keep posting requests and I’ll drop them in when I get a .

It’s all good. I’m not expecting you to add all sorts of features I’m throwing at you. hehe. But thank you very much!  
I’m using those as opportunities to learn some code on my own. And as you add these kind of things. I can learn to see how it’s suppose to be done. 😃

---

<div class="post-metadata">

**Author:** ![OmniMachina](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OmniMachina](https://forums.unrealengine.com/u/OmniMachina)\
**Post date:** [July 29, 2017, 6:56pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/288 "2017-07-29T18:56:16Z")

</div>

> [@mid\_gen;743134](#):
>
> Added Radial module. You’ll need to pull the latest UnrealFastNoise for it.

You are my hero! seriously… 🙂  
a fast and easy solution, perfect!  
thank you sooo much! \<3

> [@mid\_gen;743136](#):
>
> At the moment I create a dynamic material instance from the parent provided as I need to manipulate the opacity values at runtime for the LOD dithering.

hmm… that means the material is already instanced?! well, maybe the reason why i cant instance it again  
can I get a reference to the terrain material instance in BP somehow? (i could set all my material parameters manually via BP then… this is time consuming and not really flexible but still better than nothing)

the problem is: I already got a complex terrain material and because of the complexity its a lot of work to search & change the parameters (manually by hand inside the material editor)

you mentioned the LOD dithering…  
and if i dont use LODs at all? Im generating small maps without LODs… I dont need big maps and LOD support actually…

[Previous page](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131.md?page=13)

[Next page](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131.md?page=15)
