Generate Procedural Mesh

I’ve been playing around with procedural mesh generation for a few weekends now, and having tons of fun!

This weekend I converted over to using Golding’s new ProceduralMeshComponent from 4.8. While I had to adjust my code a bit the results are better than before and faster too!

I’m working on a hobby project that involves fractals, and also just wanted to learn more about mesh generation.

Quick question - What’s the easiest way to not save the mesh data along with the map? I have a repeatable seed and would rather not serialize all the data to disk, it can become quite big! :slight_smile: I’ve tried marking the component as Transient, but that doesn’t seem to be enough.

Here is a quick screengrab from earlier today.

And a more traditional fractal. This one is constructed from cylinders, working on a solid version now.

Wow those are awesome! Transient should work, if not just don’t make the component a UPROPERTY and it won’t get serialised. It also won’t get GC’d though so it’s not an ideal situation.

Yeah I’m aware of the GC issue, been burnt by that before :slight_smile: Will continue to explore options, need to figure this out as well as how to create a static mesh “snap shot” asset from the component.

[=Taces;283067]
I have exactly the same problem. Although I haven’t looked into it, might this occur as on the borders there isn’t a real face which is blocking the light?
[/]

I have found the solution; change the directional light to movable (and rebuild it). Not optimal for rendering but better than the artefacts.

[=Meessen;289794]
I have found the solution; change the directional light to movable (and rebuild it). Not optimal for rendering but better than the artefacts.
[/]

I can confirm that this does work for me too, that’s great!
Also I can’t notice any drawbacks regarding FPS, so at least at the moment it’s not much more expensive to have the directional light movable than stationary.

The only way I’ve found to not make ProceduralMeshComponent serialize all it’s data to disk, is to mark the ProcMeshSections UPROPERTY as Transient.

Simply marking the UPROPERTY in my class that holds the ProceduralMeshComponent as Transient isn’t enough.

[=SiggiG;289324]
Yeah I’m aware of the GC issue, been burnt by that before :slight_smile: Will continue to explore options, need to figure this out as well as how to create a static mesh “snap shot” asset from the component.
[/]

Could you share if you figure this out? Saving as an asset would be a neat feature.

[=Meessen;290239]
Could you share if you figure this out? Saving as an asset would be a neat feature.
[/]

Hey I’m working on a to save procedurally generated meshes as an asset at the moment. I haven’t got much so far but I have an asset type and an editor which you can create lathes in:

It’s still very much a WIP but I’ve got some big plans for the such as being able to edit meshes in world and their editor as well as being able to save them back to a static mesh for efficiency. I’ll probably make a thread about once I have something ready to share but it’s too basic at the moment.

It might not look like much but it took over 2000 lines of code just to get that much!

[=JamesG;282933]
I just wanted to give an update on something I have been working on for 4.8. Way more people than expected were using the CustomMeshComponent - it was only intended as an example of creating geometry! Anyway, there is clearly a lot of interest in creating geometry using Blueprints, so I’ve added a new ProceduralMeshComponent. This has a very different API, and some new features. I tried to just add features to CMC, but it just wasn’t feasible whilst still maintaining backwards compat. The new API is based on arrays of positions, indices, normals etc, rather than an array of ‘triangle’ structs. I’ve also added a new ProcMesh library of useful functions, and tried to keep the component fairly simple. The big new features are collision support, vertex UVs and colors, and automatic normal/tangent generation. Here is a screenshot of what it looks like in BP:


[/]

Can you explain how the create grid mesh triangles works?

If I have a quad verts at 0-(0,0,0), 1-(1,0,0), 2-(0,1,0), 3-(1,1,0)
What would be the appropriate setting for the grid mesh?

@JamesG, thanks for adding the new UProceduralMeshComponent! Unfortunately I can’t build my level in 4.8p2 with the editor built from source. I posted this question with a stack trace to AnswerHub: Crash on build in editor with UProceduralMeshComponent 4.8p2 - World Creation - Unreal Engine Forums

[=;290656]
Hey I’m working on a to save procedurally generated meshes as an asset at the moment. I haven’t got much so far but I have an asset type and an editor which you can create lathes in:

It’s still very much a WIP but I’ve got some big plans for the such as being able to edit meshes in world and their editor as well as being able to save them back to a static mesh for efficiency. I’ll probably make a thread about once I have something ready to share but it’s too basic at the moment.

It might not look like much but it took over 2000 lines of code just to get that much!
[/]

This is pretty cool!
Do you plan to open source your work with that? I’d like to help if you do! :smiley:

[=;291687]
So do you plan to open source your work with that? :slight_smile:
[/]

I’m kinda going two ways about it at the moment. I’d like to get it to the point where I can sell it as a on the marketplace at some stage but I think I’ll at least have a basic version I put out for free.

It would be good to give back to the community but I also don’t have a job at the moment and I’m pretty much working on this full time!

Either way I’d like to get it to get it to a level of quality that I’m happy with before I release anything.

So why is noone interrested in getting the new procedural mesh component work in construct script? any idea’s ?

Basically it works, but somehow the map cannot be saved. but if i would save the blueprint afterwards and reopen the map it works though…

[=BulleTime;293712]
So why is noone interrested in getting the new procedural mesh component work in construct script? any idea’s ?

Basically it works, but somehow the map cannot be saved. but if i would save the blueprint afterwards and reopen the map it works though…
[/]

I think this is the fix you need: https://.com/EpicGames/UnrealEngine/commit/bbac812cdac40b5e7936801753378c6f1d7cc623

[=JamesG;294100]
I think this is the fix you need: https://.com/EpicGames/UnrealEngine/commit/bbac812cdac40b5e7936801753378c6f1d7cc623
[/]

Thanks for making this fix !

:slight_smile:

[=JamesG;294100]
I think this is the fix you need: https://.com/EpicGames/UnrealEngine/commit/bbac812cdac40b5e7936801753378c6f1d7cc623
[/]

Nice, its within preview3 . Thanks!

So, I’m starting to research using the custom mesh component as a way to make terrain tiles and such for Z’s map generator. Alas, I have no C++ skills so I’ve been trying to use blueprint. I have been able to create a hex tile, assign a material, etc. I even made a subdivision function in anticipation of generating mountains and such. Alas, I’m beginning to suspect from what I have and haven’t been able to find in regards to functions that work with this node that this is basically a pipe dream. I can find no way of assigning UVs to the mesh vertices, no way to computing or setting the bounds of the component. Not to mention, for reasons I do not understand, while the mesh I have created displays in the editor just fine, as soon as I hit play, it vanishes. I have no idea why. So, I am forced into the assumption that this component, as it stands, is not really ready for general usage, at least for a non-programmer. Does this sound accurate to you all?

J^2

Digging around even more just adds to my confusion. I see a custom mesh component and a procedural mesh component. The custom mesh at least has the ability to make an array of triangles and assign that array as the mesh. The procedural mesh has no such functionality. In fact I can find no docs on the procedural mesh component at all. However, the procedural mesh component seems to have a great deal more work put into it, such as info in its vertex struct that seem useful and apropos like normal, UV, tangent, color, etc. Alas, I can’t seem to make a variable of that struct. It’s just not an option. I can’t even promote the output of the makeProcMeshVertex function to a variable. What’s going on with that? And since I can’t make an array of the proc mesh vertices, I can’t define an array of triangles. I don’t even see a procMesh triangle struct. Only thing I can find that seems even close for the proc mesh comp is a CreateSection function, which instead of taking an array of procMeshTriangle structs, you have to use some completely different approach using arrays of vertices, integers, etc. If I could at least find any sort of documentation, I could try and work something out, but as it stands now it’s just a brick wall.

So, why the two different components that seem to do the same thing, both of which seem only partially implemented in wildly different ways and poorly documented, if at all. Is this a WIP that I stumbled upon by accident? Or is this an accidentally exposed functionality that really should not be seen let alone used by non-programmers. It feels as if someone started on making a way to create procedural meshes via blueprint only to give up or get sidetracked after barely getting started. It’s very frustrating to find what looks like the solution I’m looking for only to discover it doesn’t seem to work properly if at all and have absolutely no documentation on it.

I’m just trying to find a viable way to taking the amazing work that is doing and make it into a more functional base for an actual game. The approach I have taken so far, making the tile meshes by hand, just does not seem viable for the long term if we want to be able to do anything like add rivers, canyons, deformable terrain, evolving climates, etc. Is the take away from this just that I have to suck it up and learn C++?

J^2

[=J. J. ]
Digging around even more just adds to my confusion. I see a custom mesh component and a procedural mesh component. The custom mesh at least has the ability to make an array of triangles and assign that array as the mesh. The procedural mesh has no such functionality. In fact I can find no docs on the procedural mesh component at all. However, the procedural mesh component seems to have a great deal more work put into it, such as info in its vertex struct that seem useful and apropos like normal, UV, tangent, color, etc. Alas, I can’t seem to make a variable of that struct. It’s just not an option. I can’t even promote the output of the makeProcMeshVertex function to a variable. What’s going on with that? And since I can’t make an array of the proc mesh vertices, I can’t define an array of triangles. I don’t even see a procMesh triangle struct. Only thing I can find that seems even close for the proc mesh comp is a CreateSection function, which instead of taking an array of procMeshTriangle structs, you have to use some completely different approach using arrays of vertices, integers, etc. If I could at least find any sort of documentation, I could try and work something out, but as it stands now it’s just a brick wall.

So, why the two different components that seem to do the same thing, both of which seem only partially implemented in wildly different ways and poorly documented, if at all. Is this a WIP that I stumbled upon by accident? Or is this an accidentally exposed functionality that really should not be seen let alone used by non-programmers. It feels as if someone started on making a way to create procedural meshes via blueprint only to give up or get sidetracked after barely getting started. It’s very frustrating to find what looks like the solution I’m looking for only to discover it doesn’t seem to work properly if at all and have absolutely no documentation on it.

I’m just trying to find a viable way to taking the amazing work that is doing and make it into a more functional base for an actual game. The approach I have taken so far, making the tile meshes by hand, just does not seem viable for the long term if we want to be able to do anything like add rivers, canyons, deformable terrain, evolving climates, etc. Is the take away from this just that I have to suck it up and learn C++?

J^2
[/]

Make sure to read the rest of the thread, since it does explain the difference between CustomMeshComponent and ProceduralMeshComponent and also why theres no doco on the latter (hint: Its brand new for 4.8 and still WIP). Here is a from an Epic Dev:

[=JamesG;282933]
I just wanted to give an update on something I have been working on for 4.8. Way more people than expected were using the CustomMeshComponent - it was only intended as an example of creating geometry! Anyway, there is clearly a lot of interest in creating geometry using Blueprints, so I’ve added a new ProceduralMeshComponent. This has a very different API, and some new features. I tried to just add features to CMC, but it just wasn’t feasible whilst still maintaining backwards compat. The new API is based on arrays of positions, indices, normals etc, rather than an array of ‘triangle’ structs. I’ve also added a new ProcMesh library of useful functions, and tried to keep the component fairly simple. The big new features are collision support, vertex UVs and colors, and automatic normal/tangent generation. Here is a screenshot of what it looks like in BP:


[/]

There should be more info regarding how to use the ProceduralMeshComponent following that.