Fluid Simulation For FX Artists

103  Download (0)

전체 글

(1)

Fluid Simulation

for FX Artists

Wanho choi

(2)

wanochoi.com

Fluid Simulation for FX Artists

Physical Quantity

물리량 (物理量) 측정 가능한 물리적 속성 (physical property) Examples - 길이, 면적, 부피, 질량, 밀도, 온도, 압력, … - 힘, 속도, 가속도, 운동량, …

(3)

wanochoi.com

Fluid Simulation for FX Artists

Scalar

vs

Vector

Scalar - 하나의 숫자로 표기가 가능한 물리량 - “크기”만을 가짐 Vector - N(=차원)개의 숫자로 표기가 가능한 물리량 - “크기”와 “방향”을 가짐

(4)

wanochoi.com

Fluid Simulation for FX Artists

Scalar

vs

Vector

Scalar

- 길이, 면적, 부피, 질량, 밀도, 온도, 압력, …

Vector

(5)

wanochoi.com

Fluid Simulation for FX Artists

Field (장,場)

모든 지점에서 어떠한 물리량이 존재하는 공간 Scalar field - Scalar 형식의 물리량이 정의되어 있는 공간 Vector field - Vector 형식의 물리량이 정의되어 있는 공간

(6)

wanochoi.com

Fluid Simulation for FX Artists

Field (장,場)

모든 지점에서 어떠한 물리량이 존재하는 공간 Scalar field - 밀도장, 온도장, 압력장, … Vector field - 중력장, 자기장, 속도장, …

(7)

wanochoi.com

Fluid Simulation for FX Artists

(8)

wanochoi.com

Fluid Simulation for FX Artists

Fields for Fluid Simulation

Gas (기체) - Velocity field - Divergence field - Pressure field - Density field - Temperature field Liquid (액체) - Velocity field - Divergence field - Pressure field

(9)

wanochoi.com

Fluid Simulation for FX Artists

Discrete Field

연속된 모든 지점에서 정의된 물리량을 이용하여 계산하는 것은 현실적으로 불가능 - 저장공간의 한계 (memory, HDD) - 계산 시간의 한계 (computational time) 대안: 대표점들을 이용하여 sampling

(10)

wanochoi.com

Fluid Simulation for FX Artists

How to sample

Eulerian approach

(격자 기반 방식)

Lagrangian approach

(입자 기반 방식)

(11)

wanochoi.com

Fluid Simulation for FX Artists

How to sample

Eulerian approach

(격자 기반 방식)

Lagrangian approach (입자 기반 방식)

(12)

wanochoi.com

Fluid Simulation for FX Artists

Voxel, Grid (격자)

Our grid = Uniform (Cartesian regular) grid

Resolution (해상도)

Quality (accurary) vs Time & Memory

(13)

wanochoi.com

Fluid Simulation for FX Artists

Pixel

vs

Voxel

voxel = volumetrix pixel

: volume data

Greyscale image

= 2D상에 정의된 scalar field

RGB image

(14)

wanochoi.com

Fluid Simulation for FX Artists

For the Fluid Simulation

Voxelization

- Surface data → Volume data It looks like Lego.

(15)

wanochoi.com

Fluid Simulation for FX Artists

Memory Layout

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

2D scalar field defined @ node

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

(16)

wanochoi.com

Fluid Simulation for FX Artists

Memory Layout

2D vector field defined @ node

1.0 1.0 2.0 1.0 1.0 2.0 1.0 3.0 2.0 (1.0,1.0) (2.0,1.0) (1.0,2.0) (1.0,3.0) (2.0,3.0) (1.0,1.0) (1.0,1.0) (1.0,1.0) (1.0,1.0)

(17)

wanochoi.com

Fluid Simulation for FX Artists

How much memory?

2D scalar field @ cell : sizeof(float)×5×5

(18)

wanochoi.com

Fluid Simulation for FX Artists

How much memory?

2D scalar field @ cell : sizeof(float)×5×5

= 100 bytes

2D scalar field @ node : sizeof(float)×6×6

(19)

wanochoi.com

Fluid Simulation for FX Artists

How much memory?

Scalar Field(1003)

: sizeof(float)×100×100×100

(20)

wanochoi.com

Fluid Simulation for FX Artists

How much memory?

Scalar Field(1003) : sizeof(float)×100×100×100 = 4,000,000 bytes = 4 Mb Scalar Field(2563) : sizeof(float)×256×256×256 = 67,108,864 bytes = 67 Mb

(21)

wanochoi.com

Fluid Simulation for FX Artists

How much memory?

Scalar Field(1003) : sizeof(float)×100×100×100 = 4,000,000 bytes = 4 Mb Scalar Field(2563) : sizeof(float)×256×256×256 = 67,108,864 bytes = 67 Mb Scalar Field(5123) : sizeof(float)×512×512×512 = 536,870,912 bytes = 536 Mb

(22)

wanochoi.com

Fluid Simulation for FX Artists

How much memory?

Scalar Field(1003) : sizeof(float)×100×100×100 = 4,000,000 bytes = 4 Mb Scalar Field(2563) : sizeof(float)×256×256×256 = 67,108,864 bytes = 67 Mb Scalar Field(5123) : sizeof(float)×512×512×512 = 536,870,912 bytes = 536 Mb Vector Field(1003) : sizeof(float)×3×100×100×100 = 12,000,000 bytes = 12 Mb

(23)

wanochoi.com

Fluid Simulation for FX Artists

How much memory?

Scalar Field(1003) : sizeof(float)×100×100×100 = 4,000,000 bytes = 4 Mb Scalar Field(2563) : sizeof(float)×256×256×256 = 67,108,864 bytes = 67 Mb Scalar Field(5123) : sizeof(float)×512×512×512 = 536,870,912 bytes = 536 Mb Vector Field(1003) : sizeof(float)×3×100×100×100 = 12,000,000 bytes = 12 Mb Vector Field(2563) : sizeof(float)×3×256×256×256 = 201,326,592 bytes = 201 Mb

(24)

wanochoi.com

Fluid Simulation for FX Artists

How much memory?

Scalar Field(1003) : sizeof(float)×100×100×100 = 4,000,000 bytes = 4 Mb Scalar Field(2563) : sizeof(float)×256×256×256 = 67,108,864 bytes = 67 Mb Scalar Field(5123) : sizeof(float)×512×512×512 = 536,870,912 bytes = 536 Mb Vector Field(1003) : sizeof(float)×3×100×100×100 = 12,000,000 bytes = 12 Mb Vector Field(2563) : sizeof(float)×3×256×256×256 = 201,326,592 bytes = 201 Mb Vector Field(5123) : sizeof(float)×3×512×512×512 = 1,610,612,736 bytes = 1.6 Gb

(25)

wanochoi.com

Fluid Simulation for FX Artists

How to get a value

(26)

wanochoi.com

Fluid Simulation for FX Artists

How to get a value

Interpolation

(27)

wanochoi.com

Fluid Simulation for FX Artists

How to get a value

Interpolation

- 1D (linear): by length - 2D (bi-linear): by area

(28)

wanochoi.com

Fluid Simulation for FX Artists

How to get a value

Interpolation

- 1D (linear): by length - 2D (bi-linear): by area

(29)

wanochoi.com

Fluid Simulation for FX Artists

2D Density Field Visualization

0.0 0.0 0.0 0.0 0.5 0.5 0.5 0.5 1.0 1.0 1.0 1.0 0.0 0.0 0.0 1.0 0.0 1.0 0.0 1.0 0.5 0.5 0.0 0.0 A cell

(30)

wanochoi.com

Fluid Simulation for FX Artists

0.0 0.0 0.0 0.0 0.5 0.5 0.5 0.5 1.0 1.0 1.0 1.0 0.0 0.0 0.0 1.0 0.0 1.0 0.0 1.0 0.5 0.5 0.0 0.0 A cell

(31)

wanochoi.com

Fluid Simulation for FX Artists

All cells together

(32)

wanochoi.com

Fluid Simulation for FX Artists

??!?

from) http://physbam.stanford.edu/~fedkiw/

(33)

wanochoi.com

Fluid Simulation for FX Artists

Ray marching algorithm

(34)

wanochoi.com

Fluid Simulation for FX Artists

How to animate it

유체의 유동(fluid flow)에 의해서 - Velocity field

(35)

wanochoi.com

Fluid Simulation for FX Artists

How to animate it

유체의 유동(fluid flow)에 의해서 - Velocity field Advection - 어떠한 물리량이 유체의 속도장에 의해서 이동하는 현상 (밀도, 온도, 속도, …)

(36)

wanochoi.com

Fluid Simulation for FX Artists

Density Field Advection의 예

(37)

wanochoi.com

Fluid Simulation for FX Artists

(n+1) frame

(38)

wanochoi.com

Fluid Simulation for FX Artists

(n+2) frame

(39)

wanochoi.com

Fluid Simulation for FX Artists

(n+3) frame

(40)

wanochoi.com

Fluid Simulation for FX Artists

(n+4) frame

(41)

wanochoi.com

Fluid Simulation for FX Artists

Lagrangian Advection

(42)

wanochoi.com

Fluid Simulation for FX Artists

Lagrangian Advection

0.5

(43)

wanochoi.com

Fluid Simulation for FX Artists

Lagrangian Advection

n frame

0.5

(44)

wanochoi.com

Fluid Simulation for FX Artists

Lagrangian Advection

0.5

Next frame

(45)

wanochoi.com

Fluid Simulation for FX Artists

Lagrangian Advection

0.5

And next frame

(46)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

Velocity field @ n frame

△x = 6.0 △t = 2.0 (2,2) (2,2) (2,2) (2,2) (2,2) (2,2) (2,2) (2,2) (2,2)

(47)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 △x = 6.0 △t = 2.0

(48)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

? ? ? ? ? ? ? ? ? △x = 6.0 △t = 2.0

(49)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 △x = 6.0 △t = 2.0

(50)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 △x = 6.0 △t = 2.0

Nodal velocity of (1,1) node @ n frame

(51)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 △x = 6.0 △t = 2.0 Streamline (2,2)

(52)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 △x = 6.0 △t = 2.0 Back-tracking by △t (2,2)

(53)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 △x = 6.0 △t = 2.0

Get a value @ back-tracked position

(54)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

0.0 0.0 0.0

0.0 0.0

1.0 0.0 0.0

Update nodal density of (1,1) node

(55)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

△x = 6.0 △t = 2.0

Same procedure for the other nodes

1.0 0.444 0.0 0.0 0.0 0.0 0.0 0.667 0.667

(56)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

△x = 6.0 △t = 2.0 Visualization (rendering) 1.0 0.444 0.0 0.0 0.0 0.0 0.0 0.667 0.667

(57)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

It’s animated!

(N+1) frame N frame

(58)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

More plausible example

(59)

wanochoi.com

Fluid Simulation for FX Artists

Eulerian Advection

Field 당 2개의 저장 공간이 필요함

- Previous (=old) field - Current (=new) field

ρn+1 = Advect( Vn, ρn )

(60)

wanochoi.com

Fluid Simulation for FX Artists

Unconditionally stable Numerical diffusion

Eulerian Advection

(61)

wanochoi.com

Fluid Simulation for FX Artists

Semi-Lagrangian Advection

Actually,

(62)

wanochoi.com

Fluid Simulation for FX Artists

v

Semi-Lagrangian Advection

Actually,

(63)

wanochoi.com

Fluid Simulation for FX Artists

v

dt × v

Semi-Lagrangian Advection

Actually,

(64)

wanochoi.com

Fluid Simulation for FX Artists

v

dt × v

Semi-Lagrangian Advection

Actually,

(65)

wanochoi.com

Fluid Simulation for FX Artists

Semi-Lagrangian Advection

More accurate with sub-time step

v

(66)

wanochoi.com

Fluid Simulation for FX Artists

More accurate with sub-time step

v

dt/3 × v v1

(67)

wanochoi.com

Fluid Simulation for FX Artists

More accurate with sub-time step

v

dt/3 × v dt/3 × v1

(68)

wanochoi.com

Fluid Simulation for FX Artists

More accurate with sub-time step

v

dt/3 × v dt/3 × v1 v2

(69)

wanochoi.com

Fluid Simulation for FX Artists

More accurate with sub-time step

v

dt/3 × v dt/3 × v1

dt/3 × v2

(70)

wanochoi.com

Fluid Simulation for FX Artists

More accurate with sub-time step

v

dt/3 × v dt/3 × v1

dt/3 × v2

(71)

wanochoi.com

Fluid Simulation for FX Artists

Time Step Size

△t ↓

- Accuracy ↑, but Computations ↑

△t ↑

(72)

wanochoi.com

Fluid Simulation for FX Artists

CFL condition

Courant-Friedrichs-Lewy

(CFL>1) is unphysical.

(73)

wanochoi.com

Fluid Simulation for FX Artists

Adaptive Time Step

0 frame 4 sub-steps 0000.tif 1 frame 3 sub-steps 0001.tif 2 frame 2 sub-steps 0002.tif 3 frame 2 sub-steps 0003.tif 4 frame 3 sub-steps 0004.tif 5 frame 0005.tif 0000.den 0001.den 0002.den 0003.den 0004.den 0005.den

Cache

(74)

wanochoi.com

Fluid Simulation for FX Artists

Velocity Advection

(75)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

(76)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

(77)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

(78)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

- 모든 cell에서 입,출력 양의 합이 0이어야함!

(79)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

- 모든 cell에서 입,출력 양의 합이 0이어야함!

(80)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

- 모든 cell에서 입,출력 양의 합이 0이어야함!

(81)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output) - 모든 cell에서 입,출력 양의 합이 0이어야함! 2D 0.5 0.5 1.1 2.1

(82)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

(83)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

(84)

wanochoi.com

Fluid Simulation for FX Artists

What makes fluid flows

Incompressibility (비압축성, 非壓縮性)

Conservation of mass (volume) : (input) = (output)

(85)

wanochoi.com

Fluid Simulation for FX Artists

Pressure Projection

A velocity field decomposition

(86)

wanochoi.com

Fluid Simulation for FX Artists

Pressure Projection

Helmholtz-Hodge decomposition

from) Real-Time Fluid Dynamics for Games (by Jos Stam)

divergence-free vel. field (unknown) divergence-free vel. field (unknown) messed-up vel. field (given) messed-up vel. field (given)

(87)

wanochoi.com

Fluid Simulation for FX Artists

Simulation Update

messed-up

(88)

wanochoi.com

Fluid Simulation for FX Artists

Simulation Update

messed-up

vel. field

pressure projection

(89)

wanochoi.com

Fluid Simulation for FX Artists

Simulation Update

divergence-free vel. field messed-up vel. field pressure projection

(90)

wanochoi.com

Fluid Simulation for FX Artists

Simulation Update

divergence-free vel. field messed-up vel. field pressure projection advection

(91)

wanochoi.com

Fluid Simulation for FX Artists

Simulation Update

divergence-free vel. field messed-up vel. field pressure projection advection adding external forces

(92)

wanochoi.com

Fluid Simulation for FX Artists

Simulation Update

divergence-free vel. field messed-up vel. field pressure projection advection adding external forces

one step

(93)

wanochoi.com

Fluid Simulation for FX Artists

Forces Swirls

(94)

wanochoi.com

Fluid Simulation for FX Artists

Forces Swirls

(95)

wanochoi.com

Fluid Simulation for FX Artists

Swirly Motion

(96)

wanochoi.com

Fluid Simulation for FX Artists

Swirly Motion

(97)

wanochoi.com

Fluid Simulation for FX Artists

Swirly Motion

(98)

wanochoi.com

Fluid Simulation for FX Artists

Smoke Simulation

Add external forces

(99)

wanochoi.com

Fluid Simulation for FX Artists

Smoke Simulation

Add external forces

- Gravity, buoyancy, …

Make incompressible flow

(100)

wanochoi.com

Fluid Simulation for FX Artists

Smoke Simulation

Add external forces

- Gravity, buoyancy, …

Make incompressible flow

- Very heavy computation

Advect

(101)

wanochoi.com

Fluid Simulation for FX Artists

Smoke Simulation

Diffusion(확산,擴散)이 필요할 때도 있음 - 분자간의 운동에서 기인함

- Viscosity(점성,粘性)에 비례함

(102)

wanochoi.com

Fluid Simulation for FX Artists

Now, can you make it?

http://users.skynet.be/fquake/

(103)

wanochoi.com

Fluid Simulation for FX Artists

수치

Updating...

참조

Updating...

관련 주제 :