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

<div class="post-metadata">

**Author:** ![unit23](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/unit23/32/1146013_2.png) [@unit23](https://forums.unrealengine.com/u/unit23)\
**Post date:** [November 23, 2016, 6:44pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/103 "2016-11-23T18:44:18Z")

</div>

As a LAM user i can say that it is important to have the option to assign different themes for a landscape. In LAM i extended the existing material with additional layers, but it was always a very time consuming task, because of shader compilation and then updating the existing landscape parts.

---

<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:** [November 25, 2016, 9:02am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/104 "2016-11-25T09:02:11Z")

</div>

> [@unit23;627888](#):
>
> As a LAM user i can say that it is important to have the option to assign different themes for a landscape. In LAM i extended the existing material with additional layers, but it was always a very time consuming task, because of shader compilation and then updating the existing landscape parts.

Different biomes is part of the design, although obviously needs to be all procedurally generated which makes things trickier. I think the approach I will take is :

2 different biomes  
Each biome has a unique:

- Terrain heighmap noise generator
- Material
- HISM mesh spawn parameters

The two biomes will be blended using a noise generator mask.

Anyway, the V10\_REFACTOR branch is up to 4.14 and very nearly finished. It’s a side-by-side refactor so the original WorldManager with foliage spawning etc is all still in place.

To use the all new, much faster and more efficient terrain, you’ll want to place a CGTerrainManager in the world. Call the SetupTiles method as you would have the old SpawnZones.

I think there’s still some edge case bugs in the LOD system I need to work out before I merge into .

---

<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:** [November 27, 2016, 12:02pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/105 "2016-11-27T12:02:00Z")

</div>

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/8/9/1892a36b6cb10889037785d9b8a8de00c54dc142.jpeg "Procedural Generation Update 2016-11-27") ](https://www.youtube.com/watch?v=vhHaVw4UdmQ)

V10\_REFACTOR branch in action.

It’s on 4.14 now and I’ve included the 4.14 compatible OceanPlugin.

---

<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:** [November 28, 2016, 8:20am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/106 "2016-11-28T08:20:34Z")

</div>

Some ease of use improvements this morning, most parameters are now set in the defaults panel. Noise modules still need to be built in the blueprint.

 ![70160d16a47543d0ac7172f313c78b67.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/f/0/3f0501f7595cd0962f01db0945c5d6aa03a88f17.png)

> **[GitHub - midgen/cashgenUE at V10\_REFACTOR](https://github.com/midgen/cashgenUE/tree/V10_REFACTOR)**
>
> V10\_REFACTOR

Still not quite ready to merge to . I’m still to make the LOD levels fully configurable.

---

<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:** [November 28, 2016, 7:12pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/107 "2016-11-28T19:12:26Z")

</div>

![2eb9644758e648a0976c9c6164d297fd.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/5/d/5da163bf23f4b831068f4e5c70e494237b8dee2d.png)

Fully configurage LODs added 🙂

Now you can define how many LODs, collision enabling, distance and the resolution divisor per LOD.

If your standard tile width is 32 units, a LOD divisor or 8 will only use 4…and so on.

---

<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:** [November 29, 2016, 3:34am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/108 "2016-11-29T03:34:22Z")

</div>

Hey @Mid_Gen this looks awesome so far.

I got to ask tho what is the Biome Blend Module?

What are your plans for Biome generation?

---

<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:** [November 29, 2016, 9:07am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/109 "2016-11-29T09:07:04Z")

</div>

> [@HeadClot;630155](#):
>
> Hey @Mid_Gen this looks awesome so far.
> 
> I got to ask tho what is the Biome Blend Module?
> 
> What are your plans for Biome generation?

Well I’ve been mulling over what to do about biomes. To create a decent looking terrain you need several different noise types and blend between them with a mask from another noise generator. The idea was to use that mask as a weighting for biomes. I’m not sure that’s going to be much use though.

I’m going to keep the terrain with the fairly basic material as is, shoreline, grass, snow/rock, with slope blending for a bit of variation.

The foliage spawning I’m splitting off into a standalone plugin. It’ll track the player pawn and position instanced foliage meshes around the player as required, and use it’s own noise generator to add variation.

---

<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:** [November 29, 2016, 9:07am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/110 "2016-11-29T09:07:43Z")

</div>

In the meantime, I’ve put together a better sample scene and got a decent capture finally. :

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/a/15a1373eb3ca0141d0cff34c7289bb6410d45d5f.jpeg "CashGen - Procedural Realtime Terrain Generation Plugin for UE4") ](https://www.youtube.com/watch?v=4a6NH3rz6AU)

I’d really like to make the heightmap for Oceanplugin work but I wasn’t having much luck last time I tried. I’ll have another look.

---

<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:** [November 29, 2016, 9:16am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/111 "2016-11-29T09:16:02Z")

</div>

> [@mid\_gen;630241](#):
>
> Well I’ve been mulling over what to do about biomes. To create a decent looking terrain you need several different noise types and blend between them with a mask from another noise generator. The idea was to use that mask as a weighting for biomes. I’m not sure that’s going to be much use though.
> 
> I’m going to keep the terrain with the fairly basic material as is, shoreline, grass, snow/rock, with slope blending for a bit of variation.
> 
> The foliage spawning I’m splitting off into a standalone plugin. It’ll track the player pawn and position instanced foliage meshes around the player as required, and use it’s own noise generator to add variation.

Interesting - Cannot wait to see the results of the biome plugin 🙂

> [@mid\_gen;630242](#):
>
> In the meantime, I’ve put together a better sample scene and got a decent capture finally. :
> 
> [https://youtube.com/watch?v=4a6NH3rz6AU](https://youtube.com/watch?v=4a6NH3rz6AU)
> 
> I’d really like to make the heightmap for Oceanplugin work but I wasn’t having much luck last time I tried. I’ll have another look.

That video looks really good so far 🙂

---

<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:** [November 29, 2016, 2:10pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/112 "2016-11-29T14:10:11Z")

</div>

Thanks 🙂

Small push to branch, tesselation is now working.

Just working on some heightmap supersampling to clean up the jaggies on ridges.

---

<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:** [November 30, 2016, 9:08am UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/113 "2016-11-30T09:08:17Z")

</div>

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/9/4/89422773c0cc1b114f6a1b9910aa3bee1700f2da.jpeg "CashGen - Procedural Realtime Terrain Generation Plugin for UE4 - Update2016-11-30") ](https://www.youtube.com/watch?v=iSCJt5ww8cA)

Changed the material and tesselation settings to be per LOD now. Little demo of tesselation in action.

---

<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:** [December 5, 2016, 2:59pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/114 "2016-12-05T14:59:50Z")

</div>

Refactoring work has been merged back into now, 4.14 ready!

Getting back to work on the foliage system.

---

<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:** [December 6, 2016, 2:35pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/115 "2016-12-06T14:35:15Z")

</div>

Thought I’d have a go at some erosion…didn’t think it would work well with the tiling but to my surprise it looks pretty good!

[http://image.prntscr.com/image/efcf2bf3419645d6938fb377a3bca96b.png](http://image.prntscr.com/image/efcf2bf3419645d6938fb377a3bca96b.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_395b899c1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_395b899c1](https://forums.unrealengine.com/u/anonymous_user_395b899c1)\
**Post date:** [December 6, 2016, 6:09pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/116 "2016-12-06T18:09:40Z")

</div>

The erosion is looking better! I’ve been tracking the progress on this for a couple months now. Great work!

UE4 could really use something like this.

Curious, and not sure if this has been answered already.  
Is this a plane based system? for example, is it all one giant plane? It does seem to appear that way; or does this plugin possess the capabilities to create a game where the it can generate a procedural world, but on a spherical-like planet, capable of views this distance and relationship from afar, for example the moon?

I would suspect not but it would be interesting to see something like I described.

Either way, great work!

---

<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:** [December 7, 2016, 4:35pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/117 "2016-12-07T16:35:07Z")

</div>

The erosion looks really good so far 😃

---

<div class="post-metadata">

**Author:** ![sivan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sivan](https://forums.unrealengine.com/u/sivan)\
**Post date:** [December 8, 2016, 1:56pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/118 "2016-12-08T13:56:51Z")

</div>

erosion looks great!

---

<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:** [December 9, 2016, 4:01pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/119 "2016-12-09T16:01:50Z")

</div>

> [@nolea94;633943](#):
>
> The erosion is looking better! I’ve been tracking the progress on this for a couple months now. Great work!
> 
> UE4 could really use something like this.
> 
> Curious, and not sure if this has been answered already.  
> Is this a plane based system? for example, is it all one giant plane? It does seem to appear that way; or does this plugin possess the capabilities to create a game where the it can generate a procedural world, but on a spherical-like planet, capable of views this distance and relationship from afar, for example the moon?
> 
> I would suspect not but it would be interesting to see something like I described.
> 
> Either way, great work!

Sorry thought I’d already replied!

It’s just plane based so no good for a planet in it’s current state…although my analysis of No Man’s Sky leads me to believe it is the same system they use when on-planet…and then change to a sphere-based planet during the atmospheric transition .

Been super ill all week, but have tinkered with erosion settings a bit.

---

<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:** [December 9, 2016, 5:15pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/120 "2016-12-09T17:15:48Z")

</div>

Video of the hydraulic erosion :

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/9/4/e94d6e401a0d86816ade2440329aef458a065955.jpeg "CashGen - Procedural Realtime Terrain Generation Plugin for UE4 - Update2016-12") ](https://www.youtube.com/watch?v=lH-3WCOXv-c)

Code is on this branch that has become a staging branch of sorts :

> **[GitHub - midgen/cashgenUE at V10\_REFACTOR](https://github.com/midgen/cashgenUE/tree/V10_REFACTOR)**
>
> V10\_REFACTOR

Erosion on the mountains I’m pretty happy with, but I want it to behave better on the flatter sections…it’s very crude at the moment. In fact, here it is…in it’s totally unoptimised state. That’s running 200,000 times per tile in the demo IIRC

```auto

void FCGTerrainGeneratorWorker::ProcessSingleDropletErosion()
{
	int32 XUnits = GetNumberOfNoiseSamplePoints();
	int32 YUnits = XUnits;

	// Pick a random start point that isn't on an edge
	int32 cX = FMath::RandRange(1, XUnits - 1);
	int32 cY = FMath::RandRange(1, YUnits - 1);

	float sedimentAmount = 0.0f;
	float waterAmount = 1.0f;
	FVector velocity = FVector(0.0f, 0.0f, 1.0f);
	

	while (waterAmount > 0.0f && cX > 0 && cX < XUnits - 1 && cY > 0 && cY < YUnits - 1)
	{
		FVector origin = (*pHeightMap)[cX + (XUnits * cY)];
		FVector up = ((*pHeightMap)[cX + (XUnits * (cY + 1))] - origin).GetSafeNormal();
		FVector down = ((*pHeightMap)[cX + (XUnits * (cY - 1))] - origin).GetSafeNormal();
		FVector left = ((*pHeightMap)[cX + 1 + (XUnits * (cY))] - origin).GetSafeNormal();
		FVector right = ((*pHeightMap)[cX - 1 + (XUnits * (cY))] - origin).GetSafeNormal();
		
		FVector upleft = ((*pHeightMap)[cX + 1 + (XUnits * (cY + 1))] - origin).GetSafeNormal();
		FVector downleft = ((*pHeightMap)[cX + 1 + (XUnits * (cY - 1))] - origin).GetSafeNormal();
		FVector upright = ((*pHeightMap)[cX - 1 + (XUnits * (cY + 1))] - origin).GetSafeNormal();
		FVector downright = ((*pHeightMap)[cX - 1 + (XUnits * (cY - 1))] - origin).GetSafeNormal();

		FVector lowestRoute = FVector(0.0f);

		int32 newCx = cX;
		int32 newCy = cY;

		if (up.Z < lowestRoute.Z) { lowestRoute = up; newCy++; }
		if (down.Z < lowestRoute.Z) { lowestRoute = down; newCy--; }
		if (left.Z < lowestRoute.Z) { lowestRoute = left; newCx++; }
		if (right.Z < lowestRoute.Z) { lowestRoute = right; newCx--; }
		if (upleft.Z < lowestRoute.Z) { lowestRoute = upleft; newCy++; newCx++; }
		if (upright.Z < lowestRoute.Z) { lowestRoute = upright; newCy++; newCx--; }
		if (downleft.Z < lowestRoute.Z) { lowestRoute = downleft; newCy--; newCx++; }
		if (downright.Z < lowestRoute.Z) { lowestRoute = downright; newCy--; newCx--; }

		// The amount of sediment to pick up depends on if we are hitting an obstacle
		float sedimentUptake = pTerrainConfig->DropletErosionMultiplier * FVector::DotProduct(velocity, lowestRoute);
		if (sedimentUptake < 0.0f) { sedimentUptake = 0.0f; }

		sedimentAmount += sedimentUptake;

		float sedimentDeposit = 0.0f;
		// Deposit sediment if we are carrying too much
		if (sedimentAmount > pTerrainConfig->DropletSedimentCapacity)
		{
			sedimentDeposit = (sedimentAmount - pTerrainConfig->DropletSedimentCapacity) * pTerrainConfig->DropletDespositionMultiplier;
		}

		// Deposit based on slope
		sedimentDeposit += sedimentAmount * FMath::Clamp(1.0f + lowestRoute.Z, 0.0f, 1.0f);

		sedimentAmount -= sedimentDeposit;
		

		velocity = lowestRoute;

		//(*pHeightMap)[cX + (XUnits * cY)].Z -= sedimentUptake + (sedimentDeposit * -1.0f);
		erodeHeightMapAtIndex(cX,cY, (sedimentUptake + (sedimentDeposit * -1.0f)));
		
		waterAmount -= pTerrainConfig->DropletEvaporationRate;

		cX = newCx;
		cY = newCy;

	}

}

```

---

<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:** [December 9, 2016, 5:17pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/121 "2016-12-09T17:17:01Z")

</div>

Man I really need to get rid of that OceanPlugin water for something that works with this project properly!

Great asset but I need something that I can integrate with the heightmap to smooth out the displacement on shorelines.

---

<div class="post-metadata">

**Author:** ![n00854180t](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@n00854180t](https://forums.unrealengine.com/u/n00854180t)\
**Post date:** [December 9, 2016, 6:14pm UTC](https://forums.unrealengine.com/t/cashgen-kinda-infinite-procedural-world-generator/63131/122 "2016-12-09T18:14:37Z")

</div>

> [@mid\_gen;635637](#):
>
> Man I really need to get rid of that OceanPlugin water for something that works with this project properly!
> 
> Great asset but I need something that I can integrate with the heightmap to smooth out the displacement on shorelines.

AFAIK there’s some stuff for that either in the thread for the OceanPlugin, or in another thread related to it. Not sure how it worked, though, but for the needs of this project specifically I’m not sure what would work best since you need some sort of data about the terrain elevation to do it - distance fields, height map in the material, etc., which of course is an when the terrain is created at runtime.

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

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