All Projects → bwiberg → Position Based Fluids

bwiberg / Position Based Fluids

Licence: wtfpl
Real-time Position-Based Fluids in OpenCL, homework in Stanford's CS348C

Projects that are alternatives of or similar to Position Based Fluids

Gl Rs
An OpenGL function pointer loader for Rust
Stars: ✭ 539 (+1638.71%)
Mutual labels:  computer-graphics
Cgmath
A linear algebra and mathematics library for computer graphics.
Stars: ✭ 773 (+2393.55%)
Mutual labels:  computer-graphics
Geometric Textures
Stars: ✭ 27 (-12.9%)
Mutual labels:  computer-graphics
Pix2pixhd
Synthesizing and manipulating 2048x1024 images with conditional GANs
Stars: ✭ 5,553 (+17812.9%)
Mutual labels:  computer-graphics
Softras
Project page of paper "Soft Rasterizer: A Differentiable Renderer for Image-based 3D Reasoning"
Stars: ✭ 715 (+2206.45%)
Mutual labels:  computer-graphics
Contrastive Unpaired Translation
Contrastive unpaired image-to-image translation, faster and lighter training than cyclegan (ECCV 2020, in PyTorch)
Stars: ✭ 822 (+2551.61%)
Mutual labels:  computer-graphics
3dworld
3D Procedural Game Engine Using OpenGL
Stars: ✭ 527 (+1600%)
Mutual labels:  computer-graphics
R1b
A thermal-printer-oriented, 1-bit graphics rasterizer for 2D and 3D
Stars: ✭ 29 (-6.45%)
Mutual labels:  computer-graphics
Context Encoder
[CVPR 2016] Unsupervised Feature Learning by Image Inpainting using GANs
Stars: ✭ 731 (+2258.06%)
Mutual labels:  computer-graphics
Catpapers
Cool vision, learning, and graphics papers on Cats!
Stars: ✭ 918 (+2861.29%)
Mutual labels:  computer-graphics
Deep Motion Editing
An end-to-end library for editing and rendering motion of 3D characters with deep learning [SIGGRAPH 2020]
Stars: ✭ 620 (+1900%)
Mutual labels:  computer-graphics
Materialx
MaterialX is an open standard for transfer of rich material and look-development content between applications and renderers.
Stars: ✭ 679 (+2090.32%)
Mutual labels:  computer-graphics
Anime4kcpp
A high performance anime upscaler
Stars: ✭ 887 (+2761.29%)
Mutual labels:  computer-graphics
Pytorch Cyclegan
A clean and readable Pytorch implementation of CycleGAN
Stars: ✭ 558 (+1700%)
Mutual labels:  computer-graphics
Scannet
Stars: ✭ 860 (+2674.19%)
Mutual labels:  computer-graphics
Awesome Glsl
🎇 Compilation of the best resources to learn programming OpenGL Shaders
Stars: ✭ 530 (+1609.68%)
Mutual labels:  computer-graphics
Opengraphic
Graphic Engine & Game Engine lists
Stars: ✭ 772 (+2390.32%)
Mutual labels:  computer-graphics
Computeshader Unity Macos
Stars: ✭ 31 (+0%)
Mutual labels:  computer-graphics
St Cgan
Dataset and Code for our CVPR'18 paper ST-CGAN: "Stacked Conditional Generative Adversarial Networks for Jointly Learning Shadow Detection and Shadow Removal"
Stars: ✭ 13 (-58.06%)
Mutual labels:  computer-graphics
Fssgi
Exploratory Project on Fast Screen Space Global Illumination
Stars: ✭ 22 (-29.03%)
Mutual labels:  computer-graphics

Real-time Position-Based Fluids in OpenCL

Course assignment for CS 348C: Animation and Simulation, Fall 2016. Based on the paper Position-Based Fluids by Macklin and Müller.

Libraries

  • Based on the cl-gl-bootstrap template for C++ project with OpenCL-OpenGL interoperability, written by me.
  • Uses my simple OpenGL-wrapper BWGL
  • Uses NanoGUI for the UI, which in turn depends on GLFW, Eigen and NanoVG
  • Uses GLM for vector- and matrix operations

Instructions

The idea with the cl-gl-bootstrap template is to allow for multiple simulation demos to be run in the same executable. This is accomplished by having multiple "scenes" available on startup. To start the PBF-simulation scene, press the "LOAD" button in the "General Controls" UI pane and select the only available scene.

The UI displays the average time for a simulation frame (not the rendering) in the Scene Controls UI, as well as the current average FPS (which takes into account both simulation and rendering).

Recordings created by pressing the button with the record symbol are exported through FFMPEG and saved as .mp4-files in the /output folder. Beware, the average simulation time will be incorrect when recording (don't know why yet).

To load a specific fluid setup, use the buttons in the interface on the left ("Scene Controls"). The "Fluid Parameters" UI to the right can be used to adjust the fluids properties, and parameter configurations can be loaded/saved using the provided buttons. The provided file "dam-break-3.txt" works well for the fluid setups available currently.

Parameters

  • kernelRadius - The radius of influence of a particle (0.1 to 0.2 works good)
  • numSubSteps - How many times the position-correction step should be done each frame (1-4 works good)
  • restDensity - The density of the fluid (6000-8000 works good)
  • deltaTime - The size if the timestep for each frame, in seconds (0.0083s works well, yielding 120 frames per second of simulation)
  • epsilon - Constraint Force Mixing (CFM) relaxation parameter
  • k - Artificial pressure strength
  • delta_q Artificial pressure radius
  • n - Artificial pressure power
  • c - Artificial viscosity (should be <0.05)
  • k_vc - Vorticity confinement strength
  • kBoundsDensity - Contribution of boundaries to a particle's density

Controls

  • SPACE (hold) - spawn particles
  • Arrows - move position of spawner on the wall
  • WASD - rotate camera constant amount each update (good for recordings)
  • Left-click and mouse - rotate camera freely

Build instructions

The program has only been tested on MacOS so far, so it will probably not run on Linux or Windows without modifications to the CMake configuration and some parts of the source dode.

The only dependency which is not included in the source code is GLM (which is found by CMake and must be installed on the machine), the rest are included as git submodules.

  1. Get the source code using git clone https://github.com/bwiberg/position-based-fluids.git
  2. Fetch all submodules using git submodule update --init --recursive
  3. Create a subdirectory named e.g. /build
  4. Run cmake -DCMAKE_BUILD_TYPE=Debug .. and then make from that directoy (NOTE: the program will crash with the output "illegal hardware instruction" on MacOS if using the release configuration, I will have to investigate why)
  5. Run the program using ./pbf. Optional program flags and arguments are:
    • -w 1280 720 Opens the window with a resolution of 1280x270.
    • -f Causes the program to run in fullscreen. Overrides the -w flag. (NOTE: must specify the -cl flag when using the -f flag)
    • -cl 0 1 Automatically selects the OpenCL context as alternative 0 and the OpenCL device as alternative 1.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].