Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OLM R&D祭 2020 11/26 プロダクションのための流体シミュレーション / matsuri2020-Fluid

OLM R&D祭 2020 11/26 プロダクションのための流体シミュレーション / matsuri2020-Fluid

撮影作業の中でエフェクトを短時間に作成しなくてはならい状況が発生します。そこでR&Dでは、流体エフェクト用のAfter Effectsツールの開発を進めています。現在の開発状況および技術詳細を紹介いたします。(辛口)

OLM Digital R&D
PRO

December 15, 2020
Tweet

More Decks by OLM Digital R&D

Other Decks in Technology

Transcript

  1. プロダクションのための流体シミュレーション
    伊東 浩太
    © OLM Digital, Inc. 1

    View Slide

  2. OLM Fluid とは
    • 流体シミュレーションツール
    • 開発中
    © OLM Digital, Inc. 2

    View Slide

  3. 背景
    © OLM Digital, Inc. 3

    View Slide

  4. 撮影部
    素材の合成・エフェクトの適用をするチーム
    © OLM Digital, Inc. 4
    絵コンテ
    作画 美術
    3D
    撮影

    View Slide

  5. 撮影部
    素材の合成・エフェクトの適用をするチーム
    © OLM Digital, Inc. 5
    絵コンテ
    作画 美術
    3D
    撮影
    大きなリテイクコスト

    View Slide

  6. 撮影部
    素材の合成・エフェクトの適用をするチーム
    © OLM Digital, Inc. 6
    絵コンテ
    作画 美術
    3D
    撮影
    大きなリテイクコスト
    撮影部で作ります

    View Slide

  7. • 3ds Max・Fume FX を使用
    簡単なシミュレーションの対応
    • 撮影部で作成
    © OLM Digital, Inc. 7

    View Slide

  8. 懸念点
    © OLM Digital, Inc. 8
    • ソフトウェアへの習熟が必要
    • ライセンス料
    • 開発が止まると使用不能に

    View Slide

  9. 目的
    • 簡単に使える
    © OLM Digital, Inc. 9

    View Slide

  10. 目的
    • 簡単に使える
    © OLM Digital, Inc. 10
    • After Effects で完結する

    View Slide

  11. 目的
    • 簡単に使える
    © OLM Digital, Inc. 11
    • After Effects で完結する
    • 知見を積み重ねる(R&D)

    View Slide

  12. 目的
    • 簡単に使える
    © OLM Digital, Inc. 12
    • After Effects で完結する
    • 知見を積み重ねる(R&D) 内製しましょう

    View Slide

  13. 本発表の内容
    © OLM Digital, Inc. 13
    • 流体シミュレーションの基礎
    • 右の結果を作るまでにやったこと
    • 初学者向け

    View Slide

  14. 参考資料
    © OLM Digital, Inc. 14
    https://github.com/tunabrain/incremental-fluids
    『github incremental-fluid』で検索
    • 上記の本の内容に沿った実装
    https://developer.nvidia.com/gpugems/gpugems3/part-
    v-physics-simulation/chapter-30-real-time-simulation-
    and-rendering-3d-fluids
    『nvidia 3d-fluid simulation』で検索
    • NVIDIA のページ
    • Fluid Simulation for Computer Graphics [1]
    気体から液体まで流体シミュレーションの基礎的な部分の解説
    2015年に第2版が出版されている
    [1] Bridson, Robert. Fluid simulation for computer graphics. CRC press, 2008.

    View Slide

  15. CG流体シミュレーションの基礎
    © OLM Digital, Inc. 15

    View Slide

  16. Navier-Stokes方程式
    © OLM Digital, Inc. 16
    • 流体の速度 の方程式
    • 解析的には解けない


    = − ∙ ∇ −
    1

    ∇ + ∇2 +

    View Slide

  17. シミュレーションの流れ
    © OLM Digital, Inc. 17
    時間
    速度場
    その他物理量
    (質量・熱 etc)
    ・・・
    ・・・
    +1 +2
    +1 +2

    View Slide

  18. 空間の離散化
    © OLM Digital, Inc. 18

    +1,
    − −1,
    2
    ,
    ,+1
    − ,−1
    2


    View Slide

  19. Staggered Grid (Marker And Cell Grid)
    © OLM Digital, Inc. 19
    • 速度場とその他の物理量でデータの位置をずらす
    • 相互に微分が必要な時に有効
    ,


    1
    2
    ,

    +
    1
    2
    ,

    ,+
    1
    2

    ,−
    1
    2
    ,
    ,
    ,

    View Slide

  20. Stam [2]
    の手法
    • 4ステップに分割して方程式を解く
    • 最終ステップ以外は速度以外にも適用
    © OLM Digital, Inc. 20
    [2] Stam, Jos. "Stable fluids." Proceedings of the 26th annual conference on Computer graphics and interactive techniques. 1999.
    ∇ ∙ = 0


    = − ∙ ∇ −
    1

    ∇ + ∇2 +

    View Slide

  21. © OLM Digital, Inc. 21
    [2] Stam, Jos. "Stable fluids." Proceedings of the 26th annual conference on Computer graphics and interactive techniques. 1999.
    External Force
    ∇ ∙ = 0


    = − ∙ ∇ −
    1

    ∇ + ∇2 +
    Stam [2]
    の手法
    • 4ステップに分割して方程式を解く
    • 最終ステップ以外は速度以外にも適用

    View Slide

  22. © OLM Digital, Inc. 22
    [2] Stam, Jos. "Stable fluids." Proceedings of the 26th annual conference on Computer graphics and interactive techniques. 1999.
    Advection
    External Force
    ∇ ∙ = 0


    = − ∙ ∇ −
    1

    ∇ + ∇2 +
    Stam [2]
    の手法
    • 4ステップに分割して方程式を解く
    • 最終ステップ以外は速度以外にも適用

    View Slide

  23. © OLM Digital, Inc. 23
    [2] Stam, Jos. "Stable fluids." Proceedings of the 26th annual conference on Computer graphics and interactive techniques. 1999.
    Diffusion
    Advection
    External Force
    ∇ ∙ = 0


    = − ∙ ∇ −
    1

    ∇ + ∇2 +
    Stam [2]
    の手法
    • 4ステップに分割して方程式を解く
    • 最終ステップ以外は速度以外にも適用

    View Slide

  24. © OLM Digital, Inc. 24
    [2] Stam, Jos. "Stable fluids." Proceedings of the 26th annual conference on Computer graphics and interactive techniques. 1999.
    Projection
    ∇ ∙ = 0


    = − ∙ ∇ −
    1

    ∇ + ∇2 +
    Diffusion
    Advection
    External Force
    Stam [2]
    の手法
    • 4ステップに分割して方程式を解く
    • 最終ステップ以外は速度以外にも適用

    View Slide

  25. External Force
    物理量(質量、温度、速度等)をグリッドに追加する
    © OLM Digital, Inc. 25


    =


    =

    View Slide

  26. External Force
    物理量(質量、温度、速度等)をグリッドに追加する
    © OLM Digital, Inc. 26
    : 物理量
    : 速度場


    =


    =

    View Slide

  27. Advection
    物理量を速度場に沿って移動させる
    © OLM Digital, Inc. 27


    = − ∙ ∇q


    +1


    = − ∙ ∇

    View Slide

  28. Forward Euler 法
    © OLM Digital, Inc. 28


    = − ∙ ∇q

    ,
    +1 − ,

    Δ
    = − ∙ (
    +1,
    − −1,

    2
    ,
    ,+1
    − ,−1

    2
    )
    • 解が発散しやすい
    • 離散値の微分による問題あり

    View Slide

  29. Semi Lagrangian 法
    © OLM Digital, Inc. 29
    パーティクルの移動として考える
    +1
    前の値を使って補間

    View Slide

  30. Diffusion
    • 物理量を拡散させる
    © OLM Digital, Inc. 30
    • ガウスブラーなどで代用も可


    = ∇2


    = ∇2q

    View Slide

  31. Projection
    © OLM Digital, Inc. 31
    ∇ ∙ = 0


    = − ∙ ∇ −
    1

    ∇ + ∇2 +
    Diffusion
    Advection
    External Force

    View Slide

  32. Projection
    © OLM Digital, Inc. 32
    Projection
    ∇ ∙ = 0


    = − ∙ ∇ −
    1

    ∇ + ∇2 +

    View Slide

  33. Projection
    © OLM Digital, Inc. 33
    1. 圧力()の連立一次方程式を解く
    2. 圧力から速度場を求める
    Projection
    ∇ ∙ = 0


    = − ∙ ∇ −
    1

    ∇ + ∇2 +

    View Slide

  34. 基本の結果
    © OLM Digital, Inc. 34

    View Slide

  35. Diffusion の影響
    © OLM Digital, Inc. 35
    w/diffusion wo/diffusion

    View Slide

  36. Diffusion の影響
    © OLM Digital, Inc. 36
    w/diffusion wo/diffusion

    View Slide

  37. 問題点
    1. 解法による誤差の蓄積
    © OLM Digital, Inc. 37
    2. 計算時間
    • サブピクセルの補間方法
    • Advection による誤差

    View Slide

  38. サブピクセルの補間方法
    Linear 補間 → Cubic 補間
    © OLM Digital, Inc. 38
    Linear Cubic

    View Slide

  39. Mac Cormack法
    [3]
    Advectionの誤差を補正する
    © OLM Digital, Inc. 39
    [3] Selle, Andrew, et al. "An unconditionally stable MacCormack method." Journal of Scientific Computing 35.2-3 (2008): 350-371.

    真の値
    +1

    View Slide

  40. Mac Cormack法
    [3]
    Advectionの誤差を補正する
    © OLM Digital, Inc. 40
    [3] Selle, Andrew, et al. "An unconditionally stable MacCormack method." Journal of Scientific Computing 35.2-3 (2008): 350-371.


    +1
    真の値
    +1
    Advection

    +1 = (, ∆)

    View Slide

  41. Mac Cormack法
    [3]
    Advectionの誤差を補正する
    © OLM Digital, Inc. 41
    [3] Selle, Andrew, et al. "An unconditionally stable MacCormack method." Journal of Scientific Computing 35.2-3 (2008): 350-371.


    +1
    真の値
    +1
    Advection
    誤差

    +1 = (, ∆)

    View Slide

  42. Mac Cormack法
    [3]
    Advectionの誤差を補正する
    © OLM Digital, Inc. 42
    [3] Selle, Andrew, et al. "An unconditionally stable MacCormack method." Journal of Scientific Computing 35.2-3 (2008): 350-371.


    +1
    真の値
    +1
    誤差


    逆向きにAdvection

    +1 = (, ∆)

    = (ෝ
    +, −∆)

    View Slide

  43. Mac Cormack法
    [3]
    Advectionの誤差を補正する
    © OLM Digital, Inc. 43
    [3] Selle, Andrew, et al. "An unconditionally stable MacCormack method." Journal of Scientific Computing 35.2-3 (2008): 350-371.

    +1 = (, ∆)


    +1
    真の値
    +1
    誤差

    = (ෝ
    +, −∆)


    Advection
    誤差2

    View Slide

  44. Mac Cormack法
    [3]
    Advectionの誤差を補正する
    © OLM Digital, Inc. 44
    [3] Selle, Andrew, et al. "An unconditionally stable MacCormack method." Journal of Scientific Computing 35.2-3 (2008): 350-371.

    +1 = (, ∆)


    +1
    真の値
    +1
    =
    1
    2
    ( − ෝ
    )

    = (ෝ
    +, −∆)


    Advection
    誤差2
    +1 = ෝ
    +1 +
    1
    2
    ( − ෝ
    )

    View Slide

  45. Mac Cormack法
    [3]
    Advectionの誤差を補正する
    © OLM Digital, Inc. 45
    [3] Selle, Andrew, et al. "An unconditionally stable MacCormack method." Journal of Scientific Computing 35.2-3 (2008): 350-371.
    • 計算量はSemi Lagrangianの2回分
    • タイムステップに制約がつく

    +1 = (, ∆)

    = (ෝ
    +, −∆)
    +1 = ෝ
    +1 +
    1
    2
    ( − ෝ
    )

    View Slide

  46. Mac Cormack法
    [3]
    © OLM Digital, Inc. 46
    wo/Mac Cormack w/Mac Cormack

    View Slide

  47. 比較
    © OLM Digital, Inc. 47
    Linear補間 Cubic補間 Linear補間
    +
    Mac Cormack
    Cubic補間
    +
    Mac Cormack

    View Slide

  48. 計算速度の向上
    © OLM Digital, Inc. 48
    128×128 256×256 512×512 1024×1024
    Advection 78 311 1244 5081
    Projection 106 371 1574 7746
    シングルスレッド
    単位:ms

    View Slide

  49. 計算速度の向上
    © OLM Digital, Inc. 49
    128×128 256×256 512×512 1024×1024
    Advection 78 311 1244 5081
    Projection 106 371 1574 7746
    シングルスレッド
    128×128 256×256 512×512 1024×1024
    Advection 28 85 320 1263
    Projection 19 28 102 855
    4スレッド+SSE
    サブサンプルが重い
    単位:ms
    単位:ms

    View Slide

  50. 計算速度の向上
    速度場のみ解像度を落とす
    © OLM Digital, Inc. 50
    煙の解像度512に対して速度場の解像度を変化させたときの違い
    64×64 128×128 256×256 512×512

    View Slide

  51. 煙から炎へ
    © OLM Digital, Inc. 51

    View Slide

  52. 燃料の拡散・燃焼
    © OLM Digital, Inc. 52
    - 燃料
    - 熱
    - 煙
    燃料と熱を扱う

    View Slide

  53. 燃料の拡散・燃焼
    © OLM Digital, Inc. 53
    - 燃料
    - 熱
    - 煙
    燃料と熱を扱う
    1. エミッターから燃料を追加

    View Slide

  54. 燃料の拡散・燃焼
    © OLM Digital, Inc. 54
    - 燃料
    - 熱
    - 煙
    燃料と熱を扱う
    1. エミッターから燃料を追加
    2. 物理量を Advection

    View Slide

  55. 燃料の拡散・燃焼
    © OLM Digital, Inc. 55
    - 燃料
    - 熱
    - 煙
    1. エミッターから燃料を追加
    燃料と熱を扱う
    2. 物理量を Advection
    3. 燃料を消費。熱と煙を追加

    View Slide

  56. 燃料の拡散・燃焼
    © OLM Digital, Inc. 56
    - 燃料
    - 熱
    - 煙
    1. エミッターから燃料を追加
    燃料と熱を扱う
    2. 物理量を Advection
    3. 燃料を消費。熱と煙を追加

    View Slide

  57. 燃料の拡散・燃焼
    © OLM Digital, Inc. 57
    - 燃料
    - 熱
    - 煙
    1. エミッターから燃料を追加
    燃料と熱を扱う
    2. 物理量を Advection
    3. 燃料を消費。熱と煙を追加

    View Slide

  58. 燃料の拡散・燃焼
    © OLM Digital, Inc. 58
    - 燃料
    - 熱
    - 煙
    1. エミッターから燃料を追加
    燃料と熱を扱う
    2. 物理量を Advection
    3. 燃料を消費。熱と煙を追加

    View Slide


  59. © OLM Digital, Inc. 59
    燃料の残量に応じてマッピングを行う
    0.6
    0.5 0.6 0.5
    0.5 0.6 0.7 0.6 0.5
    0.6 0.7 0.7 0.7 0.6
    0.6 0.7 0.8 0.8 0.8 0.7 0.6
    0.7 0.8 0.9 0.9 0.9 0.8 0.7
    0.9 1 1 1 0.9
    1 1

    View Slide

  60. 浮力
    燃焼による大きな熱で発生
    © OLM Digital, Inc. 60
    浮力なし 浮力あり

    View Slide

  61. ノイズ
    エミッターにノイズを乗せることでより炎らしくする
    © OLM Digital, Inc. 61
    ノイズなし ノイズあり

    View Slide

  62. Divergence Term
    • 可燃性気体の体積の膨張の調整
    © OLM Digital, Inc. 62
    • 圧力計算時に影響を加味する
    燃焼の外向きの速度が増す、はず

    View Slide

  63. Divergence Term
    • 可燃性気体の体積の膨張の調整
    © OLM Digital, Inc. 63
    • 圧力計算時に影響を加味する
    燃焼の外向きの速度が増す、はず

    View Slide

  64. 結果
    © OLM Digital, Inc. 64
    煙 燃料

    View Slide

  65. 今後
    © OLM Digital, Inc. 65

    View Slide

  66. 今後の方針
    • Particle 法との併合(FLIP)
    © OLM Digital, Inc. 66
    • GPU での実装
    • アップレゾリューションの手法の実装
    • 2D 版の AE への実装

    View Slide