[WIP] Procedural mesh generation

I’ve been playing around with UE4 the last 3 days. Today I started on a procedural mesh generator blueprint written in c++ (Even though I’ve never written c++ before).
It’s still pretty basic, but I’m having fun and learning a ton!

Update 11.04.2015
Source code for the FoliageTileActor: Procedural foliage - Unreal Engine · GitHub
PS: Feel free to point out any bugs in it. No license, free to use :slight_smile:

I also ended up submitting a pull request to the engine. https://github.com/EpicGames/UnrealEngine/pull/1037

Looks like something similar to what is coming in 4.8 - they showed the BP in a video, it has a little more settings like a random seed for instance but great job!

The tree/grass features coming in 4.8 looks really awesome! Here is the video btw: https://www.youtube.com/watch?v=3ispyNxpRyg

Update: Added support for layer restrictions

10f9d9c03a36efd58585d3294e91c3611de80973.jpeg

I did this mostly to learn since it’s coming with 4.8. I must say I learned a ton of stuff the last few hours! :smiley:
I decided to start over and make my own ForestGenerator blueprint in c++ based on the one coming in 4.8.

  1. Spawn meshes based on a initial spawn radius.
  2. Add a spawn chance to make it more random
  3. Randomize the spawn within their area
  4. Spawn X children for Y number of steps around the parent mesh

1 child

5 children

3 children for 3 steps

  1. Change size based on age

  2. Add collision detection between trees

  3. Add PhysicalMaterial filtering so you can limit where they spawn

  4. Final result. The whole thing took about 4 hours to make. :slight_smile:
    2487e1921a35d634d0474cc3c9808ef697060dc7.jpeg

Hehe…looks exactly like the procedural foliage tool to me :wink: I had the chance to actually get my hands on it and this will really be a huge changer for how we populate large environments with stuff. So yeah…dont know all the specifics of your feature, but I would also suggest you check out the tech stream about procedural foliage to get a better feel for what it does. Maybe you dont want to invest loads of time into something Epic has already implemented in the next update :wink: Here is the stream Foliage | Live Training | Unreal Engine - YouTube

But anyways…I still like what I see here…a lot! :smiley:

Cheers!

I do it to learn c++ and the engine. I’ve never coded c++ before, and i picked up unreal 3 days ago. I’ve already watched the video multiple times. :slight_smile:

It looks great. What a fun idea to learn C++ from.

Added a “dead tree” property that lets the generator remove a certain percentage of the trees. This creates some interesting open areas and some variation to the forest. This is starting to look good! :slight_smile:

Hehe…yeah I guessed so. Sorry, wasnt meant in an offensive way! :slight_smile: Its nice to see people working on things like this as well :wink:

Keep up the good work and cheers!

I started on a second generator that does foliage. I must say I like the result! :slight_smile:

New iteration and testing out some resources from the kite demo :slight_smile:

Here is a breakdown of the steps taken: Test map - Album on Imgur
It’s 1 forest generator and 8 foliage generators that make up the scene. The whole thing took about 10 min to setup.

Great work guys!

Our premier game is going to have vast forests and foliage and we have yet to begin on populating these areas so it’s promising to see what can be done within BP and C++ already, not to mention the procedural trees coming in 4.8!

Nice, there could be some more smaller trees in between and some bushes, to improve the scene. What i noticed with the foliage tool, is that sometimes it adds small plants on top of trees, and when i use it, all the plants are one big instance. Would test your tool …

Started on v2 of the forest generation based on my tiling-work for the foliage.
The image is a set of rocks that are generated in a grid. You can see that it’s slightly square in the edges because it’s supposed to tile over. (Player is always in the center)

I think this method will rock for procedural landscapes! :smiley:

Almost done! :smiley:

3fc271c4976a30e1cb8868d2319f7de22f74214d.jpeg

Not sure if you want such input but why not modulate the floor grass when it is in the perimeter of a tree too? This would further improve realism and reduce time, which would otherwise be required to manually model each landscape part where trees/bushes are spawned. Thus a material with somewhat of grass and more sand-stone would be required (maybe even just blending in some gravel), or moss depending on the climate.

Just a quick update on the performance.

I forked the UnrealEngine source and look and behold! I now get no freezing when I update a lot of instances.
I wonder if my pull request will be accepted.

Current vs. modified source code. (Frametimes is how long it takes a frame to render. 17ms is about the same as 60 fps)

Updates!

Source code for the FoliageTileActor: Procedural foliage - Unreal Engine · GitHub
PS: Feel free to point out any bugs in it. No license, free to use :slight_smile:

I also ended up submitting a pull request to the engine. https://github.com/EpicGames/UnrealEngine/pull/1037

I did something similar. I add random foliage around trees. This is a early prototype.

719aa3f5872795242309f719c9c1651037ad4aa6.jpeg

Made it possible to add other meshes (foliage) around trees. Also tested out adding a slight depth of feel to the scene.