• Stars
    star
    724
  • Rank 62,593 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A PBD fluid in unity running on the GPU

This is a position based dynamics particle fluid simulation running in Unity on the GPU. It uses the same math from the previous PBD project but adapted some what to run on the GPU.

The biggest difference is how finding the neighbouring particles is handled. This is more complicated on the GPU and I went with a grid hash using a Bitonic sort. Other sorting method are around (like Radix sort) and maybe faster but the Bitonic sort was simpler and works quite well. Profiling shows its not the bottle neck so a faster sort may not see much performance gain.

Its certainly not the fastest particle fluid around but can simulate 70K fluid particles and 30K boundary particles at 30fps on a GTX980 which is not too bad.

Fluid particles

The boundary conditions are handled by special particles that the fluid wont flow through. These are then added around the border. This does make it more costly than other methods but it also allows objects in the scene to interact with the fluid more easily. All you need is a method to voxlize a mesh to particles and you can then add them to the boundary.

Fluid boundary

To render the fluid I made a compute shader that fills a 3D texture with the particles densities. That volume can then be ray traced in a shader to render the fluid. Its just a unlit shader however so has no lighting. A method needs to be added to create normals from the volume to add lighting.

You need to use linear light space for the fluid to look like these images.

Fluid raytraced

Fluid raytraced

Fluid raytraced

Fluid raytraced

Fluid raytraced

Fluid raytraced

List of water projects.

Ceto
Phillips ocean.
Brunetons Ocean.
Tiled-directional flow.
PBD Fluid sim.

List of physics projects

Position-Based-Dynamics
PBD-Fluid-in-Unity
GPU-GEMS-NBody-Simulation
GPU-GEMS-2D-Fluid-Simulation
GPU-GEMS-3D-Fluid-Simulation
CyclonePhysicsEngine
2D-Deformable-body-in-Unity

More Repositories

1

Ceto

Ceto: Ocean system for Unity
C#
1,015
star
2

Marching-Cubes

Marching cubes in Unity
C#
462
star
3

Terrain-Topology-Algorithms

Terrain topology algorithms in Unity
C#
430
star
4

Hull-Delaunay-Voronoi

Hull, Delaunay and Voronoi algorithms in Unity
C#
411
star
5

Brunetons-Improved-Atmospheric-Scattering

A Unity port of Brunetons improved atmospheric scattering
HLSL
354
star
6

Position-Based-Dynamics

Position based dynamics in Unity
C#
299
star
7

Marching-Cubes-On-The-GPU

A implementation of the marching cubes algorithm on the GPU in Unity.
C#
291
star
8

GPU-GEMS-3D-Fluid-Simulation

3D fluid simulation on the in Unity
C#
278
star
9

Phillips-Ocean

A ocean using Phillips spectrum in Unity
C#
272
star
10

GPU-GEMS-2D-Fluid-Simulation

2D fluid simulation in Unity
C#
247
star
11

Mesh-Voxelization

Mesh voxelization in Unity
C#
231
star
12

CGALDotNet

C# wrapper for CGAL
C#
198
star
13

Interactive-Erosion

Interactive erosion in Unity
C#
170
star
14

2D-Deformable-body-in-Unity

A 2D Deformable body simulation in Unity using FEM
C#
142
star
15

Procedural-Noise

Simple examples of noise algorithms in Unity
C#
136
star
16

Brunetons-Ocean

Brunetons ocean in Unity
C#
127
star
17

Tiled-Directional-Flow

A shader to control the direction water flows based on a flow map in Unity.
ShaderLab
118
star
18

Proland-To-Unity

A port of Proland to Unity
C#
112
star
19

GPU-GEMS-Atmospheric-Scatter

Atmoshperic scatter in Unity
GLSL
73
star
20

AperiodicTexturing

A periodical texturing in Unity
C#
66
star
21

CGALDotNetUnity

CGALDotNet examples in Unity
C#
60
star
22

Brunetons-Atmospheric-Scatter

Brunetons procomputed atmospheric scatting in Unity
C#
55
star
23

GPU-Voronoi-Noise

GPU Voronoi noise in Unity
HLSL
48
star
24

CyclonePhysicsEngine

C# port of the Cylcone physics engine
C#
47
star
25

Wireframe-Shader

A wireframe material in Unity using the geometry shader.
ShaderLab
47
star
26

Simple-Procedural-Terrain

A simple example of how to create a Unity terrain from code using procedural noise.
C#
45
star
27

GPU-GEMS-NBody-Simulation

A NBody simulation in Unity
C#
43
star
28

GPU-GEMS-Improved-Perlin-Noise

Perlin noise on the GPU in Unity
GLSL
42
star
29

CGALDotNetGeometry

Geometry objects under MIT licence for CGALDotNet project
C#
28
star
30

ImageProcessing

A collection of code for processing images
C#
22
star
31

XAtlasDotNet

A c# wrapper around xatlas used to unwrap mesh uv’s.
C++
14
star
32

Common

Common code library
C#
9
star
33

OpenCLDotNet

A C# wrapper around OpenCL
C#
2
star