I’ve been working on and off on a multipurpose 2.5D fluid simulator. It allows you to simulate fire, ink, oil, fog, mud, and magic-like VFX stuff. It’s cheap enough to be used liberally in a project.
Simulation is performed in a 2D plane, that can optionally face the camera. Objects in the scene are projected to the plane and can affect fluid density/velocity, 3D forces/accelerations are converted to a 2D representation. This makes the fluid look 3D-ish, though it’s only 2D.
It all works on regular vertex/fragment shaders, shader model 3.0. No compute buffer support required. Works in Unity 2019.3 and up. For now it only supports the built-in render pipeline, though URP support will be there by launch.
Features:
Advection, buoyancy, viscosity, turbulence and dissipation.
Rectangular fluid containers with periodic, solid or open boundary conditions at the edges.
3D external forces/accelerations are converted to 2D space.
Objects can be projected onto the simulation container and affect fluid velocity and/or density.
Inertial forces.
Multicolored fluids (eg you can mix red, green and pink fluid in a single simulation).
Parallel solving of up to 16 different containers. This reduces the amount of CPU work to a minimum, as single Blit() can update all 16 containers at once.
LOD. Distant containers use lower-resolution buffers. A single memory pool can be shared by multiple containers, and their sizes adjusted depending on their relative level of detail to ensure constant memory usage.
Different resolution for velocity and density buffers.
A wonderful tool! Very similar to Fluid Ninga FX from Unreal Engine Marketplace. Ideal for simulating volumetric smoke or creating magic effects, when, for example, two wizards throw different colored fire into each other, the fire is mixed and extinguished. There are a lot of ideas, but there are not enough volumetric simulations. If you will add volumetric smoke, then this asset will become super useful and wonderful!
Thanks! It’s indeed basically the same as Fluid Ninja, as far as physics simulation goes. I think FN was also inspired by the same talk (see the above post).
Latest FluXY version allows for tessellated meshes and integration with ShaderGraph. It comes with a couple URP sample shaders for liquids (ponds, lakes, etc), which makes certain use cases simpler and easier:
Rendering-wise it’s a lot less spectacular than anything in Unreal, mainly due to Unity’s fragmented rendering system and limited support for volumetrics. Volumetrics are only supported in HDRP and only allow for very low-resolution 3D textures.
For this reason I’m working on a custom volumetric renderer for both URP and HDRP, so volumetric rendering is definitely coming in the future (probably still not as nicely integrated with lightning as Unreal’s though).
No compute, only vanilla vertex/fragment under SM3. So yes, should work for WebGL 2.0. Untested though! Let me know if there’s any issues, I will look into it.
Been working on some really cool stuff lately: arbitrary mesh support for containers, tangent space simulation, adhesion, surface tension, gravity maps and normal map support. This will be available in the next update, at no extra performance - or economic- cost :).
Hi, I found a small bug in the FluxyTarget script. When you calculate the aspect ratio, you need to cast one of the values to float, otherwise it always returns 1.
It’s really shaping up and looking exciting, I look forward to trying Fluxy out more in-depth… Do you think features such as the volumetrics will be brought to all pipeline ? (I’m specifically wondering about HDRP)
HDRP already has volumetrics, although they use “froxels” and the resolution isn’t great.
URP volumetrics are implemented in Fluxy using ShaderGraph, so simply setting the graph target to HDRP should work. Only missing part is getting the main directional light from HDRP, which should also be doable.
Well, volumetrics are pretty much finished. Only polishing UI stuff/parameter sets now. Hoping to upload it to the store early next week :).
Containers now support 3 different shapes: flat, custom mesh, and volume. In volume mode, the mesh generated is a rectangular prism with inwards-pointing normals, set up for ray marching shaders. This allows the camera to get inside volumes.
The 2D density buffer (only X and Y axis) is ray marched in 3D by offsetting and extruding it in the Z axis. This gives the impression of a fully 3D volumetric fluid sim.
There’s a single ShaderGraph volumetric shader included, with several variants: unlit, point light, and directional light, all 3 with optional support for 3D noise. Unlit/no-noise being the cheapest, and point/noise the most expensive one. You can target them to both URP and HDRP. Here’s how the volumetric material inspector looks like:
Video time! (excuse the crappy frame rate, without video capture going on it runs much smoother).
Volumetrics are pretty neat it 1.3! Appreciate the update. Wish it had an HDRP version setup out of the box for them though, but other than it’s impressive how much has been added to this asset already.
For next updates please setup samples for HDRP, I got that we can copy the URP graph, adjust a bit and make HDRP version, but for ignorant users they will give you low star because they see the volumetric samples are just pink.
I’m not too sure how fluxy works, but do you think it would be possible to use your asset to create smoke from a destruction effect that follows a rigid body? Something sort of like this video? If it’s already possible excuse my ignorant I’m a newb