Announcement

Collapse
No announcement yet.

Procedural Mesh Examples - free!

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • started a topic [PLUGIN] Procedural Mesh Examples - free!

    Procedural Mesh Examples - free!

    Hi everyone!

    Last year I wanted to learn how to procedurally generate meshes in Unreal, so I put together a few quick tests of my own. This got some interest from people here so I decided to clean it up and release it for free!

    I really hope this will be useful to others who also want to play with geometry generation in Unreal.

    Download and source code: https://github.com/SiggiG/ProceduralMeshDemos/

    NOTE: All the current code is for Unreal 4.22!

    Click image for larger version  Name:	ProcExamples.jpg Views:	1 Size:	116.0 KB ID:	1182663

    The purpose of this project is to provide examples on how to generate geometry in code, from simple cubes to more complex geometry generated from fractal algorithms.

    I would love for this to become a community project, so I will accept pull requests for new samples as well as any corrections to my code. I'm also willing to add contributors directly if anyone is interested!

    Please note that I wrote the code to be readable, trying my best to explain each step along the way. There are many ways this code could be optimized to run better, but I wanted to keep things simple in the first few examples.

    There is a lot of code duplication between the different examples which I felt was OK for the first few classes, but I will refactor some of the common functions into a utility class soon.

    Update: I recently converted the example from using Epic's ProceduralMeshComponent to Koderz's excellent RuntimeMeshComponent.


    All corrections, contributions etc are of course welcome! I'm still new to rendering in UE4 and ultimately want to convert some of this to using RHI calls myself (UPrimitiveComponent, PrimitiveSceneProxy etc).
    Last edited by SiggiG; 04-10-2019, 02:13 PM.

  • replied
    Originally posted by SiggiG View Post
    Hey Virtew sorry I didnt see this message until now. I havent taken a look at the examples for a while, so not sure whats going on or if its a problem with the Runtime Mesh plugin or not. Did you update all the submodules?
    Sorry for the late reply you too... we abandoned that project soon after, not because of the plugin anyway. Didn't check anymore, maybe we'll have a try with the latest update! Thanks for the feedback.

    Leave a comment:


  • replied
    Updated to UE 4.22.

    Because of confusion for some users, I merged the submodules all into a single project.

    Leave a comment:


  • replied
    Hey Virtew sorry I didnt see this message until now. I havent taken a look at the examples for a while, so not sure whats going on or if its a problem with the Runtime Mesh plugin or not. Did you update all the submodules?

    Leave a comment:


  • replied
    SiggiG
    some serious issues with the plugin... I cannot save the level map anymore! I used the branching tree class, create a blueprint with it and have some duplicates on the level... Any ideas?
    Attached Files

    Leave a comment:


  • replied
    Updated for 4.20 and latest ProceduralMeshComponent. Sorry how long it took!

    Leave a comment:


  • replied
    Updated with a new sample that is a (non line-based) Sierpinski mesh to showcase a more advanced UV mapping scheme.

    Leave a comment:


  • replied
    Project updated for UE 4.16. Going back to working on this to add more samples and adapt to the latest changes in the Runtime Mesh Component.

    Leave a comment:


  • replied
    I love it! Especially the sky thing. It would be an awesome addition to many games.

    My initial idea was to make it so that the player could surf/snowboard on the sound wave, though making it fun to play while keeping the real-time aspect would be a challenge. Just as a visualization it might be cool though.
    Last edited by Tsarpf; 01-13-2017, 09:15 AM.

    Leave a comment:


  • replied
    Oh my gosh, those are amazing. Thinking of picking this plugin up if it works with 4.14., I'd like to attempt procedural buildings

    Leave a comment:


  • replied
    Originally posted by Tsarpf View Post
    Thank you very much for the tutorial / example project!

    The procedural mesh examples I tried before this one came out didn't get me too far in getting anything actually working, but this made everything crystal clear!

    Anyway, what I did is a thing that updates a mesh procedurally according to audio playing on the OS (eg. from Spotify/Foobar/Youtube/anything). My thing is bit of a mess though and not very stable. And it especially does *not* work out of the editor (yet?).

    Here's a longer description: https://rabid.prototyping.xyz/2017/0...real-engine-4/
    and the source code: https://github.com/Tsarpf/UE4-Procedural-Audio

    I've stopped developing this for now, so I thought I'd post it here if someone else wants to give it a go, or maybe someone comes up with something even better!

    Adding collision for one might be cool.
    Very cool! I was playing around with very similar things last year, including eXi's plugin

    I got bogged down with real work, but will pick this up again later

    Two examples of what I was doing:


    (very compressed on youtube but the sky has a full grid moving)



    (a bit crude)

    Leave a comment:


  • replied
    Collision in UE4 involves the PhysX cooker which isn't the fastest thing around. The RMC is getting a slight upgrade to collision probably today actually as long as you're on UE4.14 preview or above. I'm working on some potentially major upgrades and talking with Epic on the possibilities of this coming to mainline UE4 as to go beyond where the RMC is currently will require engine changes.
    Does that mean we can hope for faster collision processing?

    Leave a comment:


  • replied
    Thank you very much for the tutorial / example project!

    The procedural mesh examples I tried before this one came out didn't get me too far in getting anything actually working, but this made everything crystal clear!

    Anyway, what I did is a thing that updates a mesh procedurally according to audio playing on the OS (eg. from Spotify/Foobar/Youtube/anything). My thing is bit of a mess though and not very stable. And it especially does *not* work out of the editor (yet?).

    Here's a longer description: https://rabid.prototyping.xyz/2017/0...real-engine-4/
    and the source code: https://github.com/Tsarpf/UE4-Procedural-Audio

    I've stopped developing this for now, so I thought I'd post it here if someone else wants to give it a go, or maybe someone comes up with something even better!

    Adding collision for one might be cool.

    Leave a comment:


  • replied
    Originally posted by iontom View Post
    I was using the pre-built 1.2 libraries. I did get static collisions enabled for the cube actor - but for some reason the same rules didn't work for the noise-field terrain.

    I'm still struggling to understand how Unreal deals with collision meshes in general - but here's the configuration that worked for me. It would be nice to have physics turned on and collisions enabled, but I'm guessing you'd have to build the collision mesh in RMC by hand.

    MeshComponent->SetSimulatePhysics(false);
    MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
    MeshComponent->CreateMeshSection(0, Vertices, Triangles, BoundingBox, false, EUpdateFrequency::Infrequent);
    MeshComponent->SetMaterial(0, Material);
    MeshComponent->SetMeshSectionCollisionEnabled(0, true);

    I just came across your question.

    Most of the time if you only want static collision, in other words the RMC itself is not moving, you just need to tell the section to enable collsion either by the flag in CreateMeshSection, or using SetMeshSectionCollisionEnabled like you have here. The one problem with this is don't expect it to be super fast. Collision in UE4 involves the PhysX cooker which isn't the fastest thing around. The RMC is getting a slight upgrade to collision probably today actually as long as you're on UE4.14 preview or above. I'm working on some potentially major upgrades and talking with Epic on the possibilities of this coming to mainline UE4 as to go beyond where the RMC is currently will require engine changes.

    Now, if you're wanting the RMC to have collision and physics enabled where it can move and bounce off things it gets more interesting. The above part with the cooker still applies but there's another factor. By default the mesh sections use the triangular mesh you supply as the collision surface. The problem is PhysX doesn't support moving triangular meshes for a list of reasons, and so the only way to get moving collision is using convex collision. Convex collision works fundamentally different, where the triangular mesh is mostly poly perfect collision and can handle convex/concave shapes, convex can only handle convex shapes. The way this is commonly handled for concave objects is to decompose it into multiple convex shapes to approximate the object. That is another slow thing to do usually, so in this case you'd have to probably generate those yourself from whatever is generating the shape.

    Hope that helps even though it's a month late!

    Leave a comment:


  • replied
    Originally posted by SiggiG View Post
    I believe Koderz's latest version of PMC has proper support for collisions. I'll try to get my code updated to his latest plugin soon (tm).
    I was using the pre-built 1.2 libraries. I did get static collisions enabled for the cube actor - but for some reason the same rules didn't work for the noise-field terrain.

    I'm still struggling to understand how Unreal deals with collision meshes in general - but here's the configuration that worked for me. It would be nice to have physics turned on and collisions enabled, but I'm guessing you'd have to build the collision mesh in RMC by hand.

    MeshComponent->SetSimulatePhysics(false);
    MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
    MeshComponent->CreateMeshSection(0, Vertices, Triangles, BoundingBox, false, EUpdateFrequency::Infrequent);
    MeshComponent->SetMaterial(0, Material);
    MeshComponent->SetMeshSectionCollisionEnabled(0, true);
    Last edited by iontom; 09-22-2016, 09:20 PM.

    Leave a comment:

Working...
X