Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

WebGL Fluid Experiment

Discussion in 'General Discussion' started by Korindian, Nov 20, 2014.

  1. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Not sure if this has been posted here before, but I found this cool demo of a WebGL Fluid Experiement posted on another forum, and spent some time playing around with it with my kid. Thought some people here would find it interesting as well.

    http://haxiomic.github.io/GPU-Fluid-Experiments/html5/
     
  2. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Nice sandbox sim.

    Q: Would this be easy to do in Unity 5?
     
  3. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    My buddy was asking me how to do it the other day, looks awesome. It's using glsl so I'd imagine it could be ported to Unity...?

    This is a unity fluid sim nowhere near that one but might be similar setup. I've tweaked the shader so you could move the white circle around to push the fluid around: http://scrawkunity.netau.net/GPU_GEMS_2DFluidSim/GPU_GEMS_2DFluidSim.html
     
  4. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Imbarns, that's pretty cool... is the demo you posted the tweaked version where you can move the white circle? Can't figure out how to do it.
     
  5. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    No that's the starting example. That guy has tons of cool stuff and gives the project files for everything.

    Bottom of this page: http://scrawkblog.com/category/fluid/

    You have to pass the mouse coordinates to the shader to make it move the white thing and you can also scale it in the shader.

    If you open up the shader somewhere in there are parameters to see how it's drawn. Then add a vector2 property that you can set from script with .SetVector("propertyname", value);