Coding a Realtime Fluid Simulation in Unity

Sdílet
Vložit
  • čas přidán 26. 06. 2024
  • Got really curious about Realtime Fluid Simulations and I put together this video that will hopefully help you understand how it all works, the core technology used is Smoothed Particle Hydrodynamics, and everything is written from scratch in Unity using C# and Compute Shaders.
    If this video gains some interest I'll release a second part about optimization and making the fluid look cooler, just leave a comment down below if you're interested.
    Also tried a new editing style, and would love some feedback. It's been a while since I released a video so thanks to everyone who's supported me so far :)
    I'll see you all next time ✌
    ---
    Project Links
    ---
    GitHub: github.com/AJTech2002/SPH-Uni...
    Base Project: github.com/AJTech2002/SPH-Uni...
    FluidRayMarching.cs : github.com/AJTech2002/SPH-Uni...
    ---
    Information Links
    ---
    SPH Paper: matthias-research.github.io/p...
    Sebastian Lague Raymarching: • Coding Adventure: Ray ...
    Thread Groups Medium Article: / compute-shader-indices
    ---
    Timestamps
    ---
    Intro: (0:00)
    SPH Explanation: (0:45)
    Project Setup: (4:22)
    Initializing Particles: (5:03)
    Compute Shader Setup: (9:24)
    Integrate Function: (10:33)
    Linking Compute Shader: (12:09)
    Density & Pressure Calculation: (14:13)
    Force Calculations: (16:45)
    Testing: (20:25)
    External Forces: (21:07)
    Raymarching Setup: (21:48)
    Outro: (22:43)
  • Zábava

Komentáře • 36

  • @icantdrawhandss
    @icantdrawhandss Před rokem

    its nice to have you back!

  • @konka1906
    @konka1906 Před 11 měsíci +1

    really great video quality

  • @batchprogrammer108
    @batchprogrammer108  Před rokem +8

    Part 2 on Optimization (60,000 particles) : czcams.com/video/9M72KrGhYuE/video.html
    Hey everyone, hope you enjoyed the video! I'd love to help with any questions or issues you have with the video so just leave a comment if you need something :) If you are wondering about how to optimize this code I have a branch on the GitHub with the optimization implemented github.com/AJTech2002/Smoothed-Particle-Hydrodynamics/tree/feat/optimization

  • @evgeniipetrov2808
    @evgeniipetrov2808 Před rokem

    epic comeback!

  • @_yuri_n
    @_yuri_n Před rokem +1

    Thanks , I really learned a lot from your video,Looking forward to your next video

  • @venkatgopal2454
    @venkatgopal2454 Před rokem

    Very good video 👍

  • @pawartrader
    @pawartrader Před rokem

    The King is Back.

  • @monotone5402
    @monotone5402 Před 10 měsíci

    very nice

  • @swalscha
    @swalscha Před rokem +1

    Love the content, thanks for sharing your knowledge!
    Does the kernel also take surface tension into account ? From the poly6 representation I suppose it does but by the visualization only it doesn't seem to be the case 🧐

    • @batchprogrammer108
      @batchprogrammer108  Před rokem +1

      I actually didn't implement surface tension in this video because it's a little more difficult but I do plan to make a continuation tutorial for that 😁

    • @swalscha
      @swalscha Před rokem

      @@batchprogrammer108 nice! I'd love to watch that 👌😁

  • @user-mj3ll9hv6r
    @user-mj3ll9hv6r Před rokem

    OMG, extremely useful video. Please make a new one about optimization

  • @alejandrosainzmartinez9548
    @alejandrosainzmartinez9548 Před 9 měsíci +1

    Hi! I have an URP project and i don't know how can i adapt the shaders in the project to work properly. I tried to upgrade the shaders but apparently this can't be done in custom shaders. Can someone tell me where can i learn to do this? Or if someone can provide an URP version of the shaders it would be very helpful.

  • @shawnhoareau7137
    @shawnhoareau7137 Před 4 měsíci +2

    Is the fluid ray marching script responsible for making the particles look like water?

  • @bike_n_fish
    @bike_n_fish Před rokem

    Hey, thanks for this tutorial that was insane !
    11:36 nazi pro tip : if particleMass is constant, then 1f / particleMass is a constant too
    force * (1f / particleMass) will be faster to compute :P

  • @selimgonen
    @selimgonen Před rokem

    Very nice. Please create an optimization and shader video as well!

    • @batchprogrammer108
      @batchprogrammer108  Před rokem

      I've added optimization into the GitHub on this branch (github.com/AJTech2002/Smoothed-Particle-Hydrodynamics/tree/feat/optimization) incase you're interested, currently working on the video :)

    • @selimgonen
      @selimgonen Před rokem

      @@batchprogrammer108 glad to hear :)

    • @batchprogrammer108
      @batchprogrammer108  Před 11 měsíci

      As promised - czcams.com/video/9M72KrGhYuE/video.html

    • @selimgonen
      @selimgonen Před 11 měsíci

      @@batchprogrammer108 cool, added to my watchlist :)

  • @user-px5pj7ux5k
    @user-px5pj7ux5k Před 11 měsíci

    how did distance times mass become density?

  • @shawnhoareau7137
    @shawnhoareau7137 Před 4 měsíci

    Hi does this work with URP?

  • @benjamindameworth5351
    @benjamindameworth5351 Před 4 měsíci

    I downloaded the base project and it doesn't work in the sample scene

  • @tahaqazi376
    @tahaqazi376 Před 3 měsíci

    How we can enable this fluid to flow? actually i am working on a project "Fluid dynamics Experiment demonstration" where I am trying to create a environment where we can simulate fluid dynamics experiments like demonstration pf "water turbulence" or "Calculation of fluid flow". for that I need a realistic fluid simulation something similar to this video. Is there someone who can help me with this and guide me?

  • @monishdhayalan2552
    @monishdhayalan2552 Před 11 měsíci +1

    cant open you channel man, it says channel page is missing

    • @icantdrawhandss
      @icantdrawhandss Před 10 měsíci

      …but then how did you comment 🫣

    • @monishdhayalan2552
      @monishdhayalan2552 Před 10 měsíci

      @@icantdrawhandss just got this video on my recommendtions, I wanted to see the other videos but still cant able to see them

    • @icantdrawhandss
      @icantdrawhandss Před 10 měsíci

      @@monishdhayalan2552 ohhhh yeah right

  • @nimagames8639
    @nimagames8639 Před rokem

    Hey Can you tell me how to make a fps shooter controller??
    I really want to make an fps controller with everything.
    Thanks.