# 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:** 12

<div class="post-metadata">

**Author:** ![Mr\_SquarePeg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mr\_SquarePeg](https://forums.unrealengine.com/u/Mr_SquarePeg)\
**Post date:** [June 26, 2017, 12:39am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/227 "2017-06-26T00:39:30Z")

</div>

> [@mid\_gen;728260](#):
>
> Yep. Noise stuff hooked in now.
> 
> Still loads of stuff to sort out, normals are a mess.
> 
> [https://youtube.com/watch?v=AQKtuDsUtzs](https://youtube.com/watch?v=AQKtuDsUtzs)

So I have a question.

How big are you planning on these planets on being?

Just curious 🙂

---

<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:** [June 26, 2017, 6:57am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/228 "2017-06-26T06:57:46Z")

</div>

> [@HeadClot;728364](#):
>
> So I have a question.
> 
> How big are you planning on these planets on being?
> 
> Just curious 🙂

No idea, will have to see how the engine copes. I would say that ultimately I am aiming to build a system similar to No Man’s Sky. Which means :

1. The planets are actually really tiny compared to real planets
2. When you enter the atmosphere, the spherical world (CGWorld) is swapped out for a flat tile-based one (CGTerrainManager), hidden with some visual . With the noise coordinates used on CGTerrain Manager being mapped onto the sperical world it should look pretty seamless, and circle round on itself ok.

Really depends on perforamnce though. I’m still using the RMC/PMC normal+tangent calculation which is achingly slow and on the game thread so I don’t have a good idea yet.

---

<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:** [June 26, 2017, 7:02am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/229 "2017-06-26T07:02:23Z")

</div>

> [@MichaelWion;728342](#):
>
> Hi! I’m trying to procedurally place trees, foliage, etc depending on height, slope, etc…  
> Is there a function somewhere that can return the (Z)-height/slope of the terrain at (X,Y)-Location?  
> I know I can use raycasts for this, but I was hoping that this information was already stored somewhere in code so that it would be faster than performing traces all the time.

You’re using the CGTerrainManager right? Well you can pack this information into one of the vertexcolour channels, although it may not be that easy to get at on the game thread.

Alternatively, considering some mathematical techniques :

[Building Worlds Using Math(s)](http://www.gdcvault.com/play/1024514/Building-Worlds-Using) Around the 33:00 mark Sean Murray talks about calculating the analytical derivative which in very basic terms gives you some information about the slope on a given point.

---

<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:** [June 26, 2017, 10:02am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/230 "2017-06-26T10:02:58Z")

</div>

To use the plugin in it’s current state, can I add noise through blueprints, or is the noise added by code at this point?

---

<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:** [June 26, 2017, 11:23am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/231 "2017-06-26T11:23:50Z")

</div>

> [@AinSophAur;728489](#):
>
> To use the plugin in it’s current state, can I add noise through blueprints, or is the noise added by code at this point?

Blueprints, tutorial video I posted covers it.

![dec5f291682f3cd09110ecc7923f20a83ea12cf7.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

---

<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:** [June 26, 2017, 1:03pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/232 "2017-06-26T13:03:41Z")

</div>

I was probably unclear. :o  
Does that go for the CG World part as well? I’m pulling the plugin from the CG\_World branch.  
And that looks amazing!

---

<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:** [June 26, 2017, 1:30pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/233 "2017-06-26T13:30:48Z")

</div>

Yep, uses the same UnrealFastNoise modular generation system.

That image is using a few different blended generators and masks + domain warping.

---

<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:** [June 26, 2017, 2:35pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/234 "2017-06-26T14:35:52Z")

</div>

When I make a CG World actor, I’m unable to get the Set Up Terrain node to compile. Cause it needs a target.  
I might be totally blond here and miss something tho.

EDIT: No offence to blond people, just a figure of speech. :o

---

<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:** [June 26, 2017, 2:43pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/235 "2017-06-26T14:43:33Z")

</div>

It’s called SetupWorld on CGWorld :\>

---

<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:** [June 26, 2017, 2:57pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/236 "2017-06-26T14:57:37Z")

</div>

Nope, no SetupWorld node.

 ![UE4Editor_2017-06-26_16-55-53.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/f/b/fb5ee9c24ea3398ca10be3ce021636ac1a4fb5e5.png)

**EDIT** : I downloaded the plugin again and now there is a Setup World node. I was really sure I had downloaded right after you had updated the changes.  
Anywho, time to make some planets! 😃

---

<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:** [June 26, 2017, 9:40pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/238 "2017-06-26T21:40:28Z")

</div>

@mid_gen  
Is there any plans of making the CGWorldFaces that’s created to be a child of the CGWorld that creates them?

---

<div class="post-metadata">

**Author:** ![MichaelWion](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MichaelWion](https://forums.unrealengine.com/u/MichaelWion)\
**Post date:** [June 27, 2017, 5:05am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/239 "2017-06-27T05:05:04Z")

</div>

> [@mid\_gen;728435](#):
>
> You’re using the CGTerrainManager right? Well you can pack this information into one of the vertexcolour channels, although it may not be that easy to get at on the game thread.

Just to clarify, I was hoping to do this in the game thread. Slopes aren’t super-important, just as long as I can return the (Z)-height of an (XY)-point from a _ **CGTile** _ to make it easy to place foliage on a tile’s surface.  
An example of such a function would be: _**auto fSurfaceZ = myCGTile-\>GetHeightAtPoint(x, y); myTree-\>SetActorLocation(x, y, fSurfaceZ);**_  
Is height information stored anywhere in your code, perhaps on a per-tile basis? Because then it should be as simple as exposing this information to other classes/blueprints.  
Or maybe to coincide with what I’m doing, whilst keeping it thread-safe, perhaps a multicast delegate could be triggered once a tile’s height information is generated, passing out a copy of the data?  
That way, the information can be discarded for those who don’t care about it, whereas others can store this info however they wish.

I suppose if raycasts (ie, _ **UWorld::LineTraceSingleByChannel** _) are more efficient than any other solution, then sadly, I’ll have to go with that.  
But I’ve read that they get expensive rather quickly, which is why I figured it was worth asking you if a better alternative was potentially present.

---

<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:** [June 27, 2017, 8:57am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/240 "2017-06-27T08:57:19Z")

</div>

> [@MichaelWion;728892](#):
>
> Just to clarify, I was hoping to do this in the game thread. Slopes aren’t super-important, just as long as I can return the (Z)-height of an (XY)-point from a _ **CGTile** _ to make it easy to place foliage on a tile’s surface.  
> An example of such a function would be: _**auto fSurfaceZ = myCGTile-\>GetHeightAtPoint(x, y); myTree-\>SetActorLocation(x, y, fSurfaceZ);**_  
> Is height information stored anywhere in your code, perhaps on a per-tile basis? Because then it should be as simple as exposing this information to other classes/blueprints.  
> Or maybe to coincide with what I’m doing, whilst keeping it thread-safe, perhaps a multicast delegate could be triggered once a tile’s height information is generated, passing out a copy of the data?  
> That way, the information can be discarded for those who don’t care about it, whereas others can store this info however they wish.
> 
> I suppose if raycasts (ie, _ **UWorld::LineTraceSingleByChannel** _) are more efficient than any other solution, then sadly, I’ll have to go with that.  
> But I’ve read that they get expensive rather quickly, which is why I figured it was worth asking you if a better alternative was potentially present.

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://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/1/a014a26e0d0bc130b47f9aa614a658534046cba8.jpeg "WIP Procedural Generation - 2016-09-03") ](https://www.youtube.com/watch?v=KyDR3Nim4cQ)

---

<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:** [June 27, 2017, 8:59am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/241 "2017-06-27T08:59:41Z")

</div>

> [@AinSophAur;728776](#):
>
> @mid_gen  
> Is there any plans of making the CGWorldFaces that’s created to be a child of the CGWorld that creates them?

Will be yes, have lots of tidying up to do still.

---

<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:** [June 27, 2017, 9:11am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/242 "2017-06-27T09:11:31Z")

</div>

Sweet. I know it’s early in the development, and it’s really fun to follow along and see it evolve even more.

---

<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:** [June 27, 2017, 4:47pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/243 "2017-06-27T16:47:30Z")

</div>

> [@mid\_gen;728516](#):
>
> Blueprints, tutorial video I posted covers it.
> 
> ![dec5f291682f3cd09110ecc7923f20a83ea12cf7.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

Does the CGWorld in this image have a little bit more than 4 subdivisions? Or how did you generate such a detailed planet?

---

<div class="post-metadata">

**Author:** ![honaj](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@honaj](https://forums.unrealengine.com/u/honaj)\
**Post date:** [June 27, 2017, 4:53pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/244 "2017-06-27T16:53:31Z")

</div>

Any plans for 4.16 support?

---

<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:** [June 27, 2017, 6:27pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/245 "2017-06-27T18:27:06Z")

</div>

> [@AinSophAur;729132](#):
>
> Does the CGWorld in this image have a little bit more than 4 subdivisions? Or how did you generate such a detailed planet?

If you pull from the branch again I’ve disabled the mega slow normal/tangent calculation. With that image I think I was running 21 subdivs with a 7 subdiv limit.

---

<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:** [June 27, 2017, 6:28pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/246 "2017-06-27T18:28:04Z")

</div>

> [@honaj;729135](#):
>
> Any plans for 4.16 support?

should be working fine with 4.16 with the appropriate RMC update.

---

<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:** [June 27, 2017, 6:57pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/247 "2017-06-27T18:57:55Z")

</div>

> [@mid\_gen;729181](#):
>
> If you pull from the branch again I’ve disabled the mega slow normal/tangent calculation. With that image I think I was running 21 subdivs with a 7 subdiv limit.

That’s really nice!  
And I can confirm that this works in 4.16.1 as well. I’ve pulled the CG-World branch tho. But as far as I know, also works in 4.16.1.

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

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