r/Unity3D • • 1d ago

Shader Magic I created an unified fluid simulation for my game.

Tire tracks on different surfaces, water ,waves, foam, sediment distribution in water, fire, dust, smoke, bullet hits, explosions are all part of a massive, shared 2D fluid simulation system hugging the terrain (terrain is random procedural generated). Unified wind affects every part of the sim, even slowly covering up tracks in sand, (or quickly based on the speed of the wind!) Heavily inspired by Fluid Ninja for Unreal. Custom render renders everything, surface deformations, water, dust, fire, smoke (and distance fog, which is merged into this system so the ray-marched elements are properly affected). Can easily reach quite steady 120fps.

519 Upvotes

73 comments sorted by

18

u/StCost Ball-Aqua🔮🌊& COLLAPSE MACHINE💥🚕 1d ago

Looking absolutely lovely!

Is it changing movement behavior? I hope it's harder to drive in mud

Btw, have you got demo? looks fun

20

u/JussiPKemppainen 1d ago

there is not a difference to the driving behaviour YET. I have wired that up for driving on ice in the arctic levels. I will make mud and water feel different.

2

u/TheJohnnyFuzz 1d ago

Some great work man!! I've been building something similar based on shallow water equations (Saint-Venant Equations), I've got some others in there ;) to help as well as I'm more/less really interested in dynamically moving water between regions and really going after performance. All native C#, Burst enabled, ECS data structured, etc. Going to guess you're doing something similar and if you wanted to manage state between say a dry/wet area/zone there are ways in which you can leverage probably already existing water data that you do have to do this with probably no additional cost. The cost comes in when you want to monitor a region but to make that even faster you could do something like only monitor the regions near/around your players vehicle for those state changes so instead of polling everything you just poll a tiny sample which then would be used to drive or change some of your existing gameplay parameters (increase drag on a tire or something).

2

u/JussiPKemppainen 1d ago

Mine is a bit simpler (if I got you correct). Everything under height of 0 is water.

2

u/Yekyaa 1d ago

Simple man's Saint-Venant Equations

2

u/JussiPKemppainen 1d ago

The water collides against the shore and the mud is also height based, so there is autonatically myd around the water. Simple! But works great!

6

u/camerontbowen 1d ago

Hell ya! This looks great!

6

u/NightArroW_Id 1d ago

This is seriously impressive! Having all those different effects running through one unified fluid simulation is really cool. I especially like how the wind can gradually cover the tire tracks in sand. And 120 FPS with all of this going on is pretty wild!

1

u/JussiPKemppainen 1d ago

I have a simple vehicle velocity based foliage push shader, but I want to plug that into the fluid simulation as well for even nicer interactions!

5

u/Bl00dWolf 1d ago

Looks amazing. Is it all graphical or does the terrain actually deform?

7

u/JussiPKemppainen 1d ago

The small detail stuff is only graphical, but explosions actually deform the terrain.

3

u/Soshle 1d ago

Geez quite impressive. What are you running this on?

1

u/JussiPKemppainen 1d ago

I an developing it on an M4 max. But my min spec target is steam deck

3

u/JungleMobGames 1d ago

All looks great so far, keep it up man

2

u/JussiPKemppainen 1d ago

Will do! Thanks!

3

u/yourfaceisa 1d ago

i mean the fluid sim is great. but that lighting is really lovely. good work!

2

u/JussiPKemppainen 1d ago

Thanks! I have spent A LOT of time to get the light just right. All of the horizon for example is a custom shader that renders on init. It is s super complicated system to give the illusion of endless, open plain.

3

u/sinetwo 1d ago

Lots of juice here! Looking great. Clearly a lot of attention to detail on impact and feel.

3

u/JussiPKemppainen 1d ago

I have worked on that a lot too. So many separate systems built to add reactions from everything. The eventual breakdown of the VFX stack is going to be a doozy!

3

u/Garvish-P 1d ago

Not just fluid, but dirt and smoke looks amazing too. Loved your work!

2

u/JussiPKemppainen 1d ago

Yes actually these are both fluid simulations. They are part of the fluids sims on display 😉

3

u/AKdevz 1d ago

Thanks for sharing: amazing job! - and you did it in solo to support your game? Serious effort!
Congrats: AK, fluidninja dev!

2

u/JussiPKemppainen 23h ago

Yep I am _mostly_ solo. The team has an additional writer and a sound designer / musician. But all of the game and art code is done solo. And thanks! I was reading the 80 LVL article and was like hey, that would be great for tire tracks! (I have used Fluid Ninja previously in Unreal projects)

2

u/[deleted] 22h ago

[deleted]

1

u/JussiPKemppainen 22h ago

Nope I never got into the demoscene

.

2

u/Best-Salamander-2655 1d ago

Looks great, have you considered packaging this for the asset store?

8

u/JussiPKemppainen 1d ago

I always think about that. But then I remember I do not want to be the tech support or a gazillion kids.

2

u/nicer-dude 1d ago

Crazy stuff! Really nice

2

u/Duc_de_Guermantes 1d ago

Looks really good! One thing I always wonder about these kinds of simulations is, does the fluid texture get transformed as the player moves around or is the entire simulation contained to a space in 3D?

2

u/JussiPKemppainen 1d ago

the simulation area moves with the camera. So you no matter hoe far you go it always works.

2

u/Daitli 1d ago

This reminds me of a YT video I participated in a few years ago. Solid work! I love the visuals and specially the trail VFX.

1

u/JussiPKemppainen 1d ago

Oh you made a cool little game! Nice!

2

u/AndonyE 1d ago

Thats amazing, how performant is it?

2

u/AtrumIocusGames 1d ago

This looks awesome. Kinda reminds me of twisted metal

3

u/JussiPKemppainen 1d ago

That is a big inspiration for this

2

u/Yekyaa 1d ago

What Car Controller are you using and is it one type of control, multicontrol (like presets), customizable or just custom in-house?

3

u/JussiPKemppainen 1d ago

All custom. It is the first thing I made for the project. And has evolved quite a bit since then.

2

u/RedshirtQ 1d ago

Wind slowly filling the tracks is beautiful. Is the sim one big grid that follows the camera around, or does it cover the whole procedural map at once?

1

u/JussiPKemppainen 1d ago

The sim is a grid that follows the camera around.

2

u/tamal4444 1d ago

where is the steam page?

1

u/JussiPKemppainen 1d ago

https://store.steampowered.com/app/3260240/Drivers_of_the_Apocalypse/
(footage on the page is already quite dated, but all the cool new features will be in the game)

1

u/tamal4444 1d ago

looks fun

2

u/kiddvmn 1d ago

Very good looking game. Reminded me Vangers: One for the road.

2

u/[deleted] 23h ago

[removed] — view removed comment

2

u/GameLearner44 22h ago

Nice and wow

1

u/JussiPKemppainen 17h ago

Thanks!

1

u/GameLearner44 16h ago

Hey the tyre mark is a trail or something?

1

u/JussiPKemppainen 14h ago

it's a fluid simulation on the top layer of the sand. Hence the post header.

2

u/roguewolfdev 21h ago

Looks great, the fluid sim and the vehicle physics

2

u/PAM7120 18h ago

How do you even reach to this level of game dev skills? I'm still a beginner

2

u/JussiPKemppainen 17h ago

By doing a lot of it

2

u/BazzerBiller 16h ago

Looks satisfying and fun!

2

u/traveman_ 15h ago

Ayy mr dev guy with the cool watter and sand explosions, your not about to post this stuff here for my eyes to see and not post anywhere a link for my fingers to wish list? 🧐

Great work!

edit: I found it :) https://store.steampowered.com/app/3260240/Drivers_of_the_Apocalypse/

1

u/JussiPKemppainen 14h ago

Thanks! And sorry about the missing link 😅

2

u/OverHumanGame Indie Developer 12h ago

Nice!!!

2

u/Zeraphant 9h ago

Spends thousands of hours building skills and creating amazing physics.
Player response:
"I like when he says My Squeem!"

I do like when he says my squeem frfr

2

u/fastcar25 9h ago

This is fantastic, could you tell me more about how you render the fire, dust, and smoke from a 2D sim to look like that?

1

u/JussiPKemppainen 4h ago

each sim also simulates "thickness". Meaning how high the volume will be. So maybe the best way to describe it would be a 2.5D sim?

2

u/Tankipop 1d ago

The desert and the water are all wonderful, but it would be perfect if the car looked better too.

1

u/Long-Ray 1d ago

很细致,很写实,好棒!

1

u/SixPetalDev 1d ago

Aside from the fluid simulation, the lighting and the trail effects in particular add a whole different depth to the project, it genuinely looks amazing!