Code Monkey home page Code Monkey logo

gl-pic-fluid's Introduction

gl-pic-fluid

Realtime 3D particle-in-cell fluid simulation

Based on Robert Bridson's Fluid Simulation for Computer Graphics, 2nd ed.

Implements NVidia's "Screen Space Fluid Rendering for Games".

Video Demo

promo picture

Requirements

  • OpenGL >= 4.3
  • cmake >= 3.10
  • C++ compiler for version >= 17

Building

  1. git submodule update --init --recursive
  2. mkdir build
  3. cd build
  4. cmake ..
  5. Use generated build system

Running

  1. cd build
  2. bin/fluid

Controls:

  • Left click and drag to interact with fluid
  • Right click and drag to rotate the view
  • space - play/pause
  • s - step
  • r - reset
  • f - toggle screen space fluid rendering
  • p - toggle particle visibility (for viewing grid)
  • PIC/FLIP blending controls
    • home - set FLIP 0.9
    • end - set FLIP 0.0 (PIC)
    • page up - increase FLIP
    • page down - decrease FLIP
  • Grid visualization controls
    • g - toggle grid visualization
    • 1 - cell type
    • 2 - velocity
    • 3 - divergence
    • 4 - pressure solver A coefficients
    • 5 - pressure

Known Bugs

  • There is a lingering boundary condition bug which causes fluid to stick to positive direction walls.
    • The stickiness is patched in the pressure update shader, but a bias in the fluid pressures remains.
  • If fluid gathers in the +XYZ corner of the cube, it can cause the simulation to explode. I expect that this is related to or is a result of the previous bug.
    • Press r to restart the simulation if this happens

Development

  • Simulation code is split across src/Fluid.hpp and *.cs.glsl shaders in shader/
  • Make sure to list new source files in CMakeLists.txt!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.