Announcement

Collapse
No announcement yet.

Runtime Mesh Component

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

  • replied
    Originally posted by Koderz View Post
    I was successful in reproducing it, but haven't been able to find the cause yet.
    That's good. I was worried it was just me! So hope you can find a fix for it as that bug is driving me crazy. I tried to have a look through the code myself to see if I could work out a fix, but unfortunately, I just couldn't grasp the architecture of it all enough to know where to look.

    Leave a comment:


  • replied
    Originally posted by wilberolive View Post
    [MENTION=141752]Koderz[/MENTION] Any luck reproducing the bug with translucency?
    I was successful in reproducing it, but haven't been able to find the cause yet.

    [MENTION=46051]alleysark[/MENTION] version 1.2 (the marketplace version and current release) doesn't have these parts yet. I hope to get v2 finished up here pretty quick, as it's mostly bugs left, then I'll update the marketplace.

    Leave a comment:


  • replied
    Originally posted by alleysark View Post
    By the way, is the market-place uploaded content version 1.2??
    Yes it is. v2.0 is still in the works but hopefully it is ready for the marketplace soon. You can test with v2.0 by following the instructions on GitHub to add it to your project. It might have bugs though.

    Leave a comment:


  • replied
    I really love you to make this awesome package!!
    This makes my whole problems easier.
    By the way, is the market-place uploaded content version 1.2??

    Leave a comment:


  • replied
    [MENTION=141752]Koderz[/MENTION] Any luck reproducing the bug with translucency?

    Leave a comment:


  • replied
    [MENTION=141752]Koderz[/MENTION]I figured out how to get the plugin installed and compiled into my project by poking through the UE4 docs.

    The navmesh issue I was having with it not updating seems to be fixed. The navmesh now updates every time without any problems. Was really exciting to see my AI actually walk around the objects instead of through them! However, I did have to delete the navmesh and recreate it for it to start working, but not a big deal.

    The issue with it not rendering with a translucent material still remains however. I have put together some information to help reproduce the problem.

    Firstly I created a new C++ actor called MyActor, added the following code to it, and compiled.

    MyActor.h
    Code:
    #pragma once
    
    #include "RuntimeMeshComponent.h"
    #include "MyActor.generated.h"
    
    UCLASS()
    class BLOCKHOSPITAL_API AMyActor : public AActor
    {
    	GENERATED_BODY()
    
    public:
    	AMyActor();
    
    	virtual void BeginPlay() override;
    	
    	virtual void Tick(float DeltaSeconds) override;
    
    	UFUNCTION(BlueprintCallable, Category = "Default")
    	void UpdateMesh();
    
    	UPROPERTY(BlueprintReadOnly, Meta = (ExposeOnSpawn = true))
    	UMaterialInterface* MeshMaterial;
    
    	URuntimeMeshComponent* RuntimeMesh;
    
    	float Size;
    };
    MyActor.cpp
    Code:
    #include "MyProject.h"
    #include "MyActor.h"
    #include "RuntimeMeshLibrary.h"
    
    AMyActor::AMyActor()
    {
    	PrimaryActorTick.bCanEverTick = true;
    
    	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("DefaultSceneRoot"));
    
    	Size = 10.0f;
    }
    
    void AMyActor::BeginPlay()
    {
    	Super::BeginPlay();
    
    	RuntimeMesh = NewObject<URuntimeMeshComponent>(this);
    	RuntimeMesh->SetupAttachment(RootComponent);
    	RuntimeMesh->SetMaterial(0, MeshMaterial);
    	RuntimeMesh->RegisterComponent();
    }
    
    void AMyActor::Tick(float DeltaTime)
    {
    	Super::Tick(DeltaTime);
    
    	Size += DeltaTime * 2.0f;
    }
    
    void AMyActor::UpdateMesh()
    {
    	FVector BoxRadius(Size, 100.0f, 100.0f);
    
    	TArray<FVector> Vertices;
    	TArray<int32> Triangles;
    	TArray<FVector> Normals;
    	TArray<FVector2D> UVs;
    	TArray<FColor> Colors;
    	TArray<FRuntimeMeshTangent> Tangents;
    
    	URuntimeMeshLibrary::CreateBoxMesh(BoxRadius, Vertices, Triangles, Normals, UVs, Tangents);
    
    	for (int32 i = 0; i < Vertices.Num(); ++i)
    		Colors.Add(FColor::White);
    
    	RuntimeMesh->CreateMeshSection(0, Vertices, Triangles, Normals, UVs, Colors, Tangents, true);
    }
    Then I created a material in the editor called NewMaterial and set it up like this.

    Click image for larger version

Name:	material.png
Views:	1
Size:	93.4 KB
ID:	1116924

    Finally I created a PlayerController in the editor and added the following to its blueprint.

    Click image for larger version

Name:	player.png
Views:	1
Size:	100.5 KB
ID:	1116925

    Now I run the project in the editor and turn on the navmesh rendering using the "show Navigation" console command. Then when I press the space bar, this is what I get.

    Click image for larger version

Name:	result.png
Views:	1
Size:	183.0 KB
ID:	1116926

    So you can clearly see that a mesh is being generated, added to the runtime mesh and affects the navmesh. However it just doesn't render.

    Now if I go back to the material and change its Blend Mode to Opaque, then It renders fine.

    Click image for larger version

Name:	result2.png
Views:	1
Size:	167.0 KB
ID:	1116927

    Also, if I change the code over in MyActor to use a UProceduralMeshComponent instead of a URuntimeMeshComponent then it also works fine. So it must be an issue with RMC and translucent materials.

    Leave a comment:


  • replied
    Originally posted by wilberolive View Post
    [MENTION=141752]Koderz[/MENTION] That is an impressive update. Really excited to get my hands on this. I'll try and figure out how to compile the plugin from GitHub so I can at least help with testing.

    From your little navmesh gif animation, does that mean the bug I was having with it not affecting navmeshs is now fixed in v2.0?


    It depends where you are adding the component. My understanding is that if you are doing it in the constructor, then you can skip registration as it happens automatically. However if you are adding the component at some other place, like OnConstruction, BeginPlay or Tick for example, then you need to register the component manually.

    I haven't updated these docs much in quite a while. I need to do that once v2 is finalized but this should be a decent starting point to getting setup from github. https://github.com/Koderz/UE4Runtime...MC-from-GitHub

    In theory all navigation bugs are now fixed. I've never really used the navigation system yet so I'm limited on my testing but it appears the navmesh updates correctly on all updates! If it doesn't, let me know as I want this to work as well as possible.

    It will be a while before all of this makes it to the marketplace as there's a few things that need to be finished, including collision, and also some serious testing needs to be done so it will likely be a few weeks at least before this makes it to the MP. The more people that can test over the next few days to a week the better. I should be around to fix them as they come up, as I'm building a brand new example project right now to test everything and show how everything works.

    Leave a comment:


  • replied
    [MENTION=141752]Koderz[/MENTION] That is an impressive update. Really excited to get my hands on this. I'll try and figure out how to compile the plugin from GitHub so I can at least help with testing.

    From your little navmesh gif animation, does that mean the bug I was having with it not affecting navmeshs is now fixed in v2.0?

    Originally posted by ambershee View Post
    Registering the component did the trick! I'm sure I've never had to do that with components before.
    It depends where you are adding the component. My understanding is that if you are doing it in the constructor, then you can skip registration as it happens automatically. However if you are adding the component at some other place, like OnConstruction, BeginPlay or Tick for example, then you need to register the component manually.

    Leave a comment:


  • replied
    Originally posted by Koderz View Post
    Looking at it, the only thing that stands out as potentially a problem is registration. You're not giving it a parent object or registering it.
    Registering the component did the trick! I'm sure I've never had to do that with components before.

    Leave a comment:


  • replied
    RMC V2.0 progress!

    Ok, this has been a long time coming, and every time I tried to set myself a date to have it done I would get slammed with another 'fun' time consuming project or problem, but I'm finally actually making real progress on the RMC again!

    So... The original list of things I wanted for V2.0...

    Version 2 Upcoming features! (List subject to change)
    • Normal/Tangent Calculation (Like the PMC's current helper, but hopefully faster)
    • RMC <-> StaticMeshComponent conversions. SMC -> RMC both in editor and runtime and RMC -> SMC in editor
    • Tessellation support
    • World origin shifting for infrequently updated sections (fixed already in github)
    • Hi-Precision Normals
    • Collision cooking speed improvements*


    Well I can finally say that almost all of that is done, and was pushed to github just before this post! As a qualification to that! This means that master branch of github is potentially unstable as I have not gone through and tested all of the new things as well as I want too, but decided I'd let some others at least try it and I'll try to fix everything that comes up as fast as possible!
    I DO NOT RECOMMEND GITHUB MASTER FOR REAL PROJECTS!!
    I would however like any feedback I can get about any issues encountered, and will attempt to fix them as they arise.


    Now, for more detail about what the current state is:
    • Normal/Tangent Calculation should be ported and up and working. This version does not have my speed improved version, so it's still very slow for large meshes. This I hope to get too soon after a few other things are finished.
    • Tessellation support is done! This means you can now use PN-Triangles and other tessellation on all platforms that support it provided that you either use the utility to calculate the adjacency information, or tell the RMC to calculate it internally when you Create/Update a section. This information will also be copied in a SMC->RMC conversion. (More details below)
    • Mesh Builder is operational, however not anywhere near finished and I'm not satisfied with its current design. (Feel free to pitch ideas if you have them)
    • Hi-Precision normals are supported throughout. This means like the SMC you can have higher fidelity normals/tangents on your meshes. These will also be copied correctly from a StaticMeshComponent.
    • SMC <->RMC conversions are done! This means you can convert a StaticMeshComponent to a RuntimeMeshComponent both in editor and at runtime. You can also convert a RMC to a SMC in editor as long as it's engine version 4.13+
    • Several bug fixes including world origin shifting, a shadowing bug, and a couple serialization issues.
    • Nav meshes now work correctly! By this I mean that nav meshes should always update correctly on any change. Until now both the RMC and PMC have required hacky workarounds to get this to work like moving the object to trigger a rebuild. Now it will automatically trigger a rebuild when it's needed! (More details below)



    Nav Meshes!!!


    Tessellation!!!




    Now the one major feature left for v2 that isn't in this list is the collision overhaul. I am sort of starting over with that due to several things, including the upgrade UE did to 3.4 as well as just a better understanding of what needs to happen. I'm going to refrain from giving a estimate as to when it will be done, as that hasn't worked well for me recently! Other than bug fixes which will take priority, this is the next thing I want to finish so hopefully it will get done pretty quick. I still expect it to have a dramatic impact on performance of projects with collision as I'm still going after complete threaded cooking to unblock the game thread and speed up cooking overall.

    Now, I won't be surprised if there's incompatibilities with older engine versions. This has only ever been vaguely tested against 4.14/master(4.15) so you have been warned about using it! I will try to test everything on 4.10-4.15 over the next day or two as I test the various new parts and update docs/examples to show these new things. If you're willing to test a likely highly unstable version, feel free and let me know what breaks! I will post here again when it's more ready for real use.


    Feel free to message me on discord if you have questions/comments/bug reports!

    Leave a comment:


  • replied
    Originally posted by wilberolive View Post
    I'm using UE 4.13.1 with the built in RMC 1.2.

    I would like to try out the GitHub version, but I'm not sure how. I'm assuming I need to download the code, compile it and then add it to the engine as a plugin? I just have no idea how to do that.

    On a side note, shadows now appear to be working with RMC. For a long time they didn't work, then today I noticed there was something different about my scene but couldn't put my finger on it until I realised there were shadows where there never used to be shadows. The only thing I've changed recently is upgrading from UE 4.12.5 to UE 4.13.1 about a week ago.

    However the issue with RMC not affecting the nav mesh still exists. I was hoping maybe that had fixed itself too after upgrading, but no. Have you had any luck with that bug as my game is completely broken because of it? My AI just walks through everything I place in the world like its not there. LOL.

    I'll look into that issue hopefully tomorrow. For now I have a surprise for everyone... stay tuned!

    Leave a comment:


  • replied
    Originally posted by Koderz View Post
    Which version are you using?
    I'm using UE 4.13.1 with the built in RMC 1.2.

    I would like to try out the GitHub version, but I'm not sure how. I'm assuming I need to download the code, compile it and then add it to the engine as a plugin? I just have no idea how to do that.

    On a side note, shadows now appear to be working with RMC. For a long time they didn't work, then today I noticed there was something different about my scene but couldn't put my finger on it until I realised there were shadows where there never used to be shadows. The only thing I've changed recently is upgrading from UE 4.12.5 to UE 4.13.1 about a week ago.

    However the issue with RMC not affecting the nav mesh still exists. I was hoping maybe that had fixed itself too after upgrading, but no. Have you had any luck with that bug as my game is completely broken because of it? My AI just walks through everything I place in the world like its not there. LOL.
    Last edited by wilberolive; 10-18-2016, 09:06 PM.

    Leave a comment:


  • replied
    Originally posted by wilberolive View Post
    [MENTION=141752]Koderz[/MENTION] Have run into another very strange issue with RMC. I'm trying to use a translucent material with my generated mesh. However, the first time I generate the mesh (at runtime), it is invisible. I've stepped through the code and it appears to be generating a mesh and adding it as a mesh section, but it just doesn't render on screen at all. However, if I clear that mesh section and then generate it again (while in runtime, not in the editor), it renders fine.

    So the issue seems to be that the first time you create a mesh section at runtime with a translucent material it doesn't render. You have to clear it once, then create it again for it to render.

    As a test, I just swapped the code over to use PMC instead and it works fine. The mesh renders first time every time with a translucent material. So it appears to be an issue with RMC.

    Well that's new...

    Which version are you using? Wondering since github master is a bit unstable atm, but I might be about to push a rather large update, so will look into it with this round.

    Leave a comment:


  • replied
    [MENTION=141752]Koderz[/MENTION] Have run into another very strange issue with RMC. I'm trying to use a translucent material with my generated mesh. However, the first time I generate the mesh (at runtime), it is invisible. I've stepped through the code and it appears to be generating a mesh and adding it as a mesh section, but it just doesn't render on screen at all. However, if I clear that mesh section and then generate it again (while in runtime, not in the editor), it renders fine.

    So the issue seems to be that the first time you create a mesh section at runtime with a translucent material it doesn't render. You have to clear it once, then create it again for it to render.

    As a test, I just swapped the code over to use PMC instead and it works fine. The mesh renders first time every time with a translucent material. So it appears to be an issue with RMC.

    Leave a comment:


  • replied
    Originally posted by rizzlewizzle View Post
    Ahh ok, thanks Koderz! I will look into it some more and see if I can come up with a new method of achieving what I am looking for.
    You're welcome! Good luck! My only suggestion would be to take world position in Z and localize it to a starting/ending height you want to blend between and then lerp between the two colors. There's probably a better way but that's a quick way to do it.




    Originally posted by ambershee View Post
    I've started playing with RMC today, have been backporting an example into C++, and I'm having some trouble actually generating something visible. As far as I can tell, everything I'm passing into CreateMeshSection is valid, and it isn't dropping out early, but I never see anything in the engine.

    Here's a snippet - am I missing something obvious / vital?
    Looking at it, the only thing that stands out as potentially a problem is registration. You're not giving it a parent object or registering it.



    Code:
    		
    		URuntimeMeshComponent* NewTile = NewObject<URuntimeMeshComponent>(this);
                    NewTile->RegisterComponent();
    		NewTile->SetupAttachment(RootComponent);
    but if you're in the constructor then the easier way is just
    Code:
    		
    		URuntimeMeshComponent* NewTile = CreateDefaultSubobject<URuntimeMeshComponent>(TEXT("TerrainTile"));
                    RootComponent = NewTile;

    (All of the above is done by memory, as I'm not at my desk atm, but I think it's right)

    Leave a comment:

Working...
X