Download

Fluid simulation demo from GDC

If you look at this video Twitch from 5:35 hours to 6 hours they show a ton of really cool 2d and 3d fluid simulation stuff.

The speaker said there was also some demo content for this currently in the launcher but I couldn’t find that.

Does anyone know of any good tutorials or examples that are using this? I understand most of the math and individual parts but am having trouble combining things to work. I also am having trouble understanding how the materials are applied and to what. Mostly my difficulty comes from implementing this in the engine, I understand the simulation aspect.

Any thoughts or further reading suggestions would be appreciated. :slight_smile:

The map I was talking about in ContentExamples is called BlueprintRenderToTarget.umap. You may have to update your project since it was only added in 4.13.

It inlcudes a heightmap painter and ripple solver 2d fluid sim. These examples were created by Daniel Wright, who is the programmer who made the Draw to RT nodes in BP.

I also have a different version of the 2d fluid sim that is a bit more fully featured and includes hookups for gameplay and material FX like rain. This is the project I shared with Sam Dieter that was used in his 2d fluid sim talk at the booth (although for some reason ZakP asked him not to credit me which is a bit weird). I am planning to release that at some point soon.

Also I do plan to release the 2d and 3d advection simulations at some point soon.

Awesome thank you @RyanB. I was looking for a separate sample project.

They were probably just looking to keep solidarity of representing UE4 at the conference.

Very cool, I’ll keep an eye out for it.

I wish I had a chance to go to the booths but I was in my own booth most of the time :slight_smile:

Do you know what they were applying the 3D fluid simulation material too? Was it a cube or some kind of deformable static mesh? I think that is the part that is confusing me the most. I see they have 3 static meshes in the details panel. It looks like two are for showing layers of the effect and another one called inside out box. Is that the special technical part? :slight_smile:

Yes I think that is exactly it.

Understood. I too wish I could have seen more at GDC but the rehearsals and setup ended up taking most of my time.

I was applying the material using a volume raymarch material. You are correct about the other two layers. One was showing the density volume slices and the other was showing the velocity slices. The ray march material was on the ‘inside out box’. The inside out box part is how I enable the camera to go inside of the volume. To do that, you have to then use a Ray-Box intersection in order to still start the trace on the outside edge of the box when the camera is not inside. Then when its inside, it just starts at camera position which is achieved by clamping time along the ray intersection to 0. All the details on that part of it are in the ray marching tutorial I wrote here:

http://shaderbits.com/blog/creating-volumetric-ray-marcher

Awesome thank you. I have a new blog to read now :slight_smile:

That talk was really great as well!

I was inspired by @RyanB GDC talk and made my 2d fluid sim as a coffee break project. It is pretty cool, but I ran into several issues.

**1) Bounds. **

If I understood the paper](http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html) correctly, it is proposed to have a bounds texture, that stores offset to the closest pixel inside.
This texture is sampled once per stage and the result is added to UVs that are used throughout the stage.
Then for pressure, value just inside the border is used as is, and for velocity, the value is inverted.
My first complication is how to efficiently apply it to borders of arbitrary shape(or to be more precise, how to efficiently generate a texture, that stores offset to the closest pixel inside or outside of the border) ?

And the second issue here is how to deal with moving bounds. Simply having moving objects looks surprisingly acceptable, but they tend to eat up fluid instead of displacing it.
Injecting some of the velocity from moving object into velocity texture helps, but it is still quite fake.
I Imagine that velocity change should be a function of existing velocity, moving object’s surface normal and moving object’s velocity.
I’m frankly not sure how to implement that, while maintaining moving object’s boundaries(and do we need boundary condition for moving object at all, provided that we are doing velocity change? ).

[SPOILER]https://youtube.com/watch?v=_n_Y_6KWyhU[/SPOILER]

2) Looping

After seeing fluid sim in action, I’m quite eager to extend what I have a to a system for baking FX into flipbooks.
It is possible to loop the animation by blending two flipbooks with an offset in time, but is there a way to loop the sim itself?

Thanks for any assistance rendered in advance.

Ryan, did you ever happen to release your 2D fluid sim somewhere?

Found it. :slight_smile:

https://docs.unrealengine.com/en-us/Videos/PLZlv_N0_O1ga0aV9jVqJgog0VWz1cLL5f/CWzPP5FAYAg
https://forums.unrealengine.com/showthread.php?143821

Looks like it still works in 4.20.2 too!