User Tag List

Page 1 of 7 123 ... LastLast
Results 1 to 40 of 270

Thread: Project: FluidSurface Plugin

  1. #1
    1
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    587

    Lightbulb Project: FluidSurface Plugin

    In UE2 we had a simple but fun feature called a FluidSurfaceInfo. This was a small, simulated fluid surface that you could place in your level, and would respond to the player running through it and shooting it. It was requested that we bring back this feature in UE4. So I am posting the original source from UE2, if anyone is interested in porting it to UE4 as a plugin! I made a page on the wiki with the source code here:

    https://wiki.unrealengine.com/FluidSurface_Plugin

    This is a CPU implementation. In UE3 we had a more sophisticated GPU-based fluid surface implementation, but I don't really know that code, and I thought this would be a simpler place to start. I would look at the CableComponent plugin to give an example of how to set up a plugin and render custom geometry each frame. This is _not_ intended to be an 'ocean surface' feature, but something useful for small pools of water (or, you know, toxic acid, lava, the usual...). This is UE2 source, back when we had .uc files, so the first job will be turning those into UE4 decorated C++ headers.

    I'm happy to try and answer any questions about here it here on the forums (if I can remember!) and I'm sorry for the lack of comments . If anyone makes some progress, please post your github branch here so others can check it out and contribute
    Lead Framework Programmer, UE4, Epic Games
    Twitter: @EpicJamesG

  2. #2
    0
    Just downloaded the code. Figured I would give it a shot as this would actually come in handy for my project. Will post if I have any breakthroughs.

  3. #3
    0
    The Rainbow Warrior



    Join Date
    Mar 2014
    Posts
    2,549
    I hope someone figures this out!

    I do miss those fluid surfaces!

    Thanks for bringing this up JamesG!



    Rama
    100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

  4. #4
    0
    That was amazing time, I remember my first 'OMG! AWESOME!' reaction to UT2003 water. And then water splashes were attached in UT2004... Still one of my fav VFX out there. Thanks, JamesG!

  5. #5
    0
    Samaritan
    Join Date
    Mar 2014
    Posts
    105
    I'll also take a look at it, see what I can do. Thanks for posting it James.

  6. #6
    0
    Supporter
    Join Date
    Apr 2014
    Posts
    4

    Need it badly

    As I'm the greatest Noob at the history of c++ xD

    I need this integration badly .....but how could I ? !!!!!

  7. #7
    0
    Quote Originally Posted by Omar Victoria View Post
    As I'm the greatest Noob at the history of c++ xD

    I need this integration badly .....but how could I ? !!!!!
    I've started writing the plugin based on the code from above. The first iteration will be a complete CPU based solution based on the above. Then I will improve it from there.

    EDIT: So far basic rendering of hex grid done.

    Name:  FluidSurfaceActor.JPG
Views: 16004
Size:  259.7 KB
    Last edited by Ehamloptiran; 04-26-2014 at 02:06 PM. Reason: Adding info

  8. #8
    0
    Samaritan
    Join Date
    Mar 2014
    Posts
    105
    Quote Originally Posted by Ehamloptiran View Post
    I've started writing the plugin based on the code from above. The first iteration will be a complete CPU based solution based on the above. Then I will improve it from there.

    EDIT: So far basic rendering of hex grid done.

    Name:  FluidSurfaceActor.JPG
Views: 16004
Size:  259.7 KB
    Wow that was fast, nice work buddy.

  9. #9

  10. #10
    0
    More water rippling. Actor interaction.

    https://drive.google.com/file/d/0Bzq...it?usp=sharing

  11. #11
    0
    Quote Originally Posted by Ehamloptiran View Post
    More water rippling. Actor interaction.

    https://drive.google.com/file/d/0Bzq...it?usp=sharing
    Nice one! Looks good so far.

  12. #12
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    481
    Wow that's looking awesome. Can't wait to see the whole thing.

  13. #13
    0
    You guyz need to hook up with these guyz: https://forums.unrealengine.com/show...Preview-Thread

  14. #14
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    587
    Quote Originally Posted by Ehamloptiran View Post
    More water rippling. Actor interaction.
    Wow, nice! Is your work on GitHub? Let me know if you'd like a review or anything.
    Lead Framework Programmer, UE4, Epic Games
    Twitter: @EpicJamesG

  15. #15
    0
    Quote Originally Posted by JamesG View Post
    Wow, nice! Is your work on GitHub? Let me know if you'd like a review or anything.
    Thanks James, not yet, just added oscillators and Hit/Touch effects. Just need to clean up the rendering code a bit then will upload to github

  16. #16

  17. #17
    0
    You need to put this inside plugin folder and compile again? Thanks.

  18. #18
    0

    FluidSurface Plugin Release v0.0.1

    FluidSurface Plugin Release v0.0.1

    Okay so I am not used to using GitHub, so I have uploaded the source code for the plugin to my private fork. You'll find it under the master branch in "Engine/Plugins/Runtime/FluidSurface/". Link is https://github.com/Ehamloptiran/UnrealEngine. The plugin contains the following:

    - CPU Based fluid simulation (Based on the UE2 code originally provided by JamesG) - Up to 255x255 grid, with variable spacing
    - Particle effects that play when surface receives damage or when overlapped by an actor supporting overlapping
    - Material Tessellation
    - A small Modifier framework (Can create new modifiers based off AFluidSurfaceModifier)
    - An oscillator modifier
    - An example rain effect modifier

    There is still plenty of work to be done, so this is purely still an alpha test release, use at your own risk. For now you will have to compile your own version (I will provide precompiled binaries later when the plugin is more stable).

    Here is a video that shows the features:
    https://drive.google.com/file/d/0Bzq...it?usp=sharing

    Wow, nice! Is your work on GitHub? Let me know if you'd like a review or anything.
    Now that the files are up on GitHub, feel free to review it, apologies in advance for the messy code.
    Last edited by Ehamloptiran; 05-04-2014 at 12:05 PM.

  19. #19
    0
    Nice work Ehamloptiran, that was really fast Looking forward to what you'll make out of it

  20. #20
    0
    Niiiice! What a cool example of "the New Epic!" I can't wait to see where all this goes

  21. #21
    0
    Thought I would just give an update. I am able now to create fluid surface's that are 3x greater than the previous version by making the vertex/index buffers static and updating via a texture in a custom vertex shader. The down side to this is it can no longer be a plugin and I have had to merge the code directly into the engine. (Seems you can't use IMPLEMENT_VERTEX_FACTORY_TYPE from a plugin as it has to have been initialized before Shader Core). Unless someone can tell me of another way. I won't be releasing the code at the moment as its a little unstable, plus I want to add in compute shader support for the algorithm. This should hopefully (Fingers crossed) allow surfaces up to 4096x4096 cells in size with little loss of speed.

    Anyways here is a screenshot showing the current size I hit before slow downs occur:
    Name:  LargeFluidSurface.jpg
Views: 15278
Size:  135.7 KB

  22. #22
    0
    The Rainbow Warrior



    Join Date
    Mar 2014
    Posts
    2,549
    Quote Originally Posted by Ehamloptiran View Post
    This should hopefully (Fingers crossed) allow surfaces up to 4096x4096 cells in size with little loss of speed.
    Oooh wow very nice!

    I really missed the fluid surfaces, I am glad you are bringing them back!



    Rama
    100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

  23. #23
    0
    Quote Originally Posted by Ehamloptiran View Post
    surfaces up to 4096x4096 cells in size with little loss of speed
    It's hearing things like this which make my day as a game developer. Well done.

  24. #24
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    1,002
    Hi Ehamloptiran,

    Very cool progress!

    RE: the IMPLEMENT_VERTEX_FACTORY_TYPE issue, you might be able to make another module in your plugin with that code in it, and set the loading phase to "PostConfigInit". I'm not sure if this is early enough or not, but it's much earlier than the default phase for plugin modules.

    Cheers,
    Michael Noland

  25. #25
    0
    Quote Originally Posted by Michael Noland View Post
    RE: the IMPLEMENT_VERTEX_FACTORY_TYPE issue, you might be able to make another module in your plugin with that code in it, and set the loading phase to "PostConfigInit". I'm not sure if this is early enough or not, but it's much earlier than the default phase for plugin modules.
    Yes, it will work "PostConfigInit" is good for custom shader plugin.
    Developer. Bass player. Cats owner. Unreal Engine addicted. Check my.alyamkin.com
    [Plugin] VaRest - REST API with blueprintable JSON plugin
    [Plugin] VaTexAltas - simple way to use texture atlases for UMG

  26. #26
    0
    Quote Originally Posted by Michael Noland View Post
    Hi Ehamloptiran,

    Very cool progress!

    RE: the IMPLEMENT_VERTEX_FACTORY_TYPE issue, you might be able to make another module in your plugin with that code in it, and set the loading phase to "PostConfigInit". I'm not sure if this is early enough or not, but it's much earlier than the default phase for plugin modules.

    Cheers,
    Michael Noland
    Quote Originally Posted by ufna View Post
    Yes, it will work "PostConfigInit" is good for custom shader plugin.
    Sweet I will try that out thanks, it'll be good to be able to keep this as a plugin.

  27. #27
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    164
    Thanks for picking up the torch, Ehamloptiran! Can't wait to play with it all :-)

  28. #28
    0
    Quote Originally Posted by Daniel Vogel View Post
    Thanks for picking up the torch, Ehamloptiran! Can't wait to play with it all :-)
    No worries, it has been an exciting trip into the deepest and darkest sections of the engine, learning about the rendering. On that note I have created a Compute Shader and moved the simulation on to the GPU. Now I can create surfaces at 2048x2048 cells with very little performance hit. Thats about an 11x increase from the original if anyone is keeping score.

  29. #29
    0
    The Rainbow Warrior



    Join Date
    Mar 2014
    Posts
    2,549
    Quote Originally Posted by Ehamloptiran View Post
    I have created a Compute Shader and moved the simulation on to the GPU. Now I can create surfaces at 2048x2048 cells with very little performance hit. Thats about an 11x increase from the original if anyone is keeping score.
    Oh wow!

    Quote Originally Posted by Ehamloptiran View Post
    and moved the simulation on to the GPU.
    !
    Quote Originally Posted by Ehamloptiran View Post
    and moved the simulation on to the GPU.
    !!!!!!
    Quote Originally Posted by Ehamloptiran View Post
    and moved the simulation on to the GPU.
    Amazing work Ehamloptiran!

    You just made this better than UE3 version (better at the very least cause its in UE4 hee hee)!

    You just outperformed JamesG's request!



    Rama
    Last edited by Rama; 05-01-2014 at 11:19 AM.
    100+ UE4 C++ Tutorials on the UE4 Code Wiki, including UE4 Multi-Threading!

    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    Visit www.ue4code.com to see lots of videos about my C++ Creations! ♥ Rama

  30. #30
    0
    Unreal Engine Developer
    Join Date
    Mar 2014
    Posts
    587
    Quote Originally Posted by Ehamloptiran View Post
    I have created a Compute Shader and moved the simulation on to the GPU. Now I can create surfaces at 2048x2048 cells with very little performance hit. Thats about an 11x increase from the original if anyone is keeping score.
    Woah, that sounds amazing! I was actually about to ask if you had thought about going down that path Do let me know if there is anything I can do to help get it into shape to review.

    How are you doing collision at the moment? I would think just treating it as a thin box for collision purposes would be fine.
    Lead Framework Programmer, UE4, Epic Games
    Twitter: @EpicJamesG

  31. #31
    0
    Quote Originally Posted by JamesG View Post
    Woah, that sounds amazing! I was actually about to ask if you had thought about going down that path Do let me know if there is anything I can do to help get it into shape to review.
    At the moment the code is very unoptimized and a mess, but afterwards I wouldn't mind a review on the rendering process, like am I doing it correctly, or are there better ways, etc.

    Quote Originally Posted by JamesG View Post
    How are you doing collision at the moment? I would think just treating it as a thin box for collision purposes would be fine.
    For now I have created an AggGeom box based on the bounds (Its about 5 or 10 units thick) which is used for tracing, otherwise I check overlapping actors per tick (Probably not very efficient).

  32. #32
    0

    FluidSurface Plugin Release v0.0.2

    FluidSurface Plugin Release v0.0.2

    Link: Fluid Surface Plugin v0.0.2

    Version 0.0.2 has been released to github. I have a new branch "FluidSurface" which contains the source code. You'll need the following files/folders for it to work:

    - Engine/Plugins/Runtime/FluidSurface/* - Main plugin code
    - Engine/Shaders/FluidSurfaceShader.usf - Compute shader to perform simulation
    - Engine/Shaders/FluidSurfaceVertexFactory.usf - Vertex factory shader for FluidSurface rendering
    - Engine/Shaders/FluidSurfaceVertexFactoryCommon.usf - Common code for vertex factory
    - Engine/Shaders/FlatTessellation.usf - Had to make a small change to this to allow the FluidSurfaceVertexFactory to modify the world displacement prior to the material (Will explain further down why)
    - Engine/Shaders/PNTriangles.usf - Same as above.

    It is very important to get the shaders. The plugin will not work without them.

    The plugin contains the following new features:

    GPU based simulation
    The simulation has moved from the CPU to a Compute Shader and vertex shader/domain shader additions. This allows for larger areas to be calculated quicker. I have been able to run up to 2048x2048 tiles (About 491m wide with standard grid spacing) at realtime.

    New tessellation modifications
    If you enable tessellation, it will actually reduce the number of vertices/indices in needs to store in the buffers, and then uses the tessellation world displacement to offset the fluid surface (Rather than vertex world offset). It actually runs faster on larger surfaces to have tessellation enabled. New options have been added to the editor:

    - Build Tessellation data: This will tell the component to use the new algorithm to build the surface. If you don't apply a tessellation material, you will see a very low quality simulation, this is because of the reduced triangle count.
    - Tessellation Ratio: This allows you to tweak the amount of triangles to use for tessellation, the value can go from 0.1 - 2.0 (Max is twice the normal tessellated resolution, not recommended. The recommended value is 0.125)

    As stated above, I had to add some code to both FlatTessellation.usf and PNTriangles.usf (So these are mandatory for execution) which can be found wrapped within the USE_FLUIDSURFACE macro to allow the Vertex factory to apply displacement prior to the material.

  33. #33
    0

    FluidSurface Plugin Release v0.0.2

    FluidSurface Plugin Release v0.0.3

    Link: FluidSurface Plugin v0.0.3

    Version 0.0.3 has been released to github. Moved pling calculations onto GPU and increased compute shader thread count. With tessellation and the right material setup, can now render 4096x4096 cells at realtime. Speed of all other cell counts should be increased.

    Material used to blend tessellation by distance:
    Name:  DistanceTess.jpg
Views: 15468
Size:  132.0 KB

    Credit goes to DaveTheFreak aka David Scholze for the material setup. Can be found here Distance Based DX11 Tesselation - Video
    Last edited by Ehamloptiran; 05-04-2014 at 10:12 PM. Reason: Giving credit

  34. #34
    0
    Quote Originally Posted by Ehamloptiran View Post
    FluidSurface Plugin Release v0.0.3

    Link: FluidSurface Plugin v0.0.3

    Version 0.0.3 has been released to github. Moved pling calculations onto GPU and increased compute shader thread count. With tessellation and the right material setup, can now render 4096x4096 cells at realtime. Speed of all other cell counts should be increased.

    Material used to blend tessellation by distance:
    Name:  DistanceTess.jpg
Views: 15468
Size:  132.0 KB

    Credit goes to DaveTheFreak aka David Scholze for the material setup. Can be found here Distance Based DX11 Tesselation - Video
    Download link returns 404.

  35. #35
    0
    Quote Originally Posted by Ray Jones 312 View Post
    Download link returns 404.
    You need to be logged into your Git hub account to access it.

  36. #36
    0
    As per ufna's advise. I have moved the code to a new repository, it can now be located at <Link Removed>. All future updates will be to here.

    UPDATE: Due to the fact that this plugin contains original code from the engine, I have removed the public repo. All future updates will remain in https://github.com/Ehamloptiran/Unre...e/FluidSurface

    Please refer to the following AnswerHub topic for information: https://answers.unrealengine.com/que...ored-in-a.html

    I apologise for the confusion.
    Last edited by Ehamloptiran; 05-07-2014 at 11:08 AM.

  37. #37
    0
    Samaritan
    Join Date
    Mar 2014
    Posts
    112
    Absolutely great work Ehamloptiran, a great plugin already and would really be awesome if integrated in ue4 (i think thats what is meant by pull request, im a bit of a noob when it comes to development nomenclature)

  38. #38
    0
    Does it work with 4.1.1? Because when I copied this to my UE4 folder, when trying to generate visual studio project to compile the engine, I got many errors in CMD command.
    Please an installtaion tutorial would be appreciated. Thanks.

  39. #39
    0
    Quote Originally Posted by DarkInfiktrator View Post
    Does it work with 4.1.1? Because when I copied this to my UE4 folder, when trying to generate visual studio project to compile the engine, I got many errors in CMD command.
    Please an installtaion tutorial would be appreciated. Thanks.
    Hi, I have had no issues running it with 4.1.1. Are you able to post some of the error messages? Also yes I am working on a more thorough installation tutorial, I will also provide some prebuilt binaries for the more common engine versions at some point.

  40. #40
    0
    Quote Originally Posted by Ehamloptiran View Post
    Hi, I have had no issues running it with 4.1.1. Are you able to post some of the error messages? Also yes I am working on a more thorough installation tutorial, I will also provide some prebuilt binaries for the more common engine versions at some point.
    When I put 4.1.1 files and everything required, then I place into /Engine/Plugins/Runtime directory and I place shaders into /Engine/Shaders directory
    Then I compile, I get those errors:

    Erreur 3 error : Failed to produce item: C:\UnrealEngine\Engine\Plugins\Runtime\CableComponent\Binaries\Win64\UE4Editor-CableComponent.dll C:\UnrealEngine\Engine\Intermediate\ProjectFiles\ERROR UE4
    Erreur 2 error LNK1120: 1 externes non rÚsolus C:\UnrealEngine\Engine\Plugins\Runtime\CableComponent\Binaries\Win64\UE4Editor-CableComponent.dll UE4
    Erreur 1 error LNK2019: symbole externe non rÚsolu "private: static class UClass * __cdecl UCableComponent::GetPrivateStaticClass(wchar_t const *)" (?GetPrivateStaticClass@UCableComponent@@CAPEAVUClass@@PEB_W@Z) rÚfÚrencÚ dans la fonction "public: class UCableComponent * __cdecl FPostConstructInitializeProperties::CreateDefaultSubobject<class UCableComponent,class UCableComponent>(class UObject *,class FName,bool,bool,bool)const " (??$CreateDefaultSubobject@VUCableComponent@@V1@@FPostConstructInitializeProperties@@QEBAPEAVUCableComponent@@PEAVUObject@@VFName@@_N22@Z) C:\UnrealEngine\Engine\Intermediate\ProjectFiles\Module.CableComponent.cpp.obj UE4
    Erreur 4 error MSB3073: La commande "..\..\Build\BatchFiles\Build.bat UE4Editor Win64 Development" s'est arrêtée avec le code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 UE4

Page 1 of 7 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •