GDC2023 Photon Water System Reading Note

It is an reading note of Photon Water System in GDC2023, related about usage of flow map baking, shallow water equation solving for water surface propagation.

The article can’t cover all details, it just a reading note. Implementation details are so complex that it is recommended to have a look on original source.

GDCVault Photon Water System

Outline

Water System:

  1. Procedural tools for river, lake, and ocean

  2. Offline flow map baking

  3. Runtime fluid simulation

  4. Buoyancy and boat physics

  5. Underwater volumetric lighting

  6. Adaptive water mesh tessellation

Fluid simulation

Offline Flow map baking

Flowmap is pre-computed texture using physical-based simulation tool in existing third party software, such as Houdini.

Details about usage see:

Water Flow in Portal 2

The velocity field is stored as a 2d vector map and fetch at runtime.

However, the existing tool is still inconvenience for artists to use and cannot support turbulent flow.

LightSpeed use lattice Boltzmann method for the solution of shallow water equations (LBMSWE) to bake the flow map. The method has severval advantages:

  1. Support turbulence flow

  2. Simple to implement

  3. Highly parallelizable

  4. Conservative

Details about LBM see other tutorial.

Solving

The basic LBMSWE algorithm has four steps:

  1. Update the equilibrium distribution f α e q f_{\alpha}^{eq} fαeq

  2. Streaming and collision

  3. Boundary handling

  4. Compute macroscopic variables

In fact, after reading, I just review the theroy of LBM but have no idea about baking.

Summarize

To summarize, LBMSWE:

Pros:

  1. Support turbulence flow turbulent flow

  2. Simple to implement

  3. Highly parallelizable

  4. Conservative

Cons:

  1. Large memory usage

    Each cell needs to store 3 distribution values for nine directions

  2. Not good for real-time waterfront propagation

Runtime fluid simulation

LightSpeed uses Shallow Water Equation (SWE) to implement height-field based 2.5D fluid simulation.

To solve classic NS equation based on the shallow water assumption:

D h D t + h ∇ ⋅ u = 0 D u D t = − g ∇ ( h + H ) \begin{aligned} & \dfrac{Dh}{Dt}+h\nabla \cdot u = 0 \\ & \dfrac{Du}{Dt} = -g \nabla (h+H) \end{aligned} DtDh+hu=0DtDu=g(h+H)

Fig: Height Field

They split world into grid. Water depth h h h are stored at cell centers, velocities are stored at edge centers.

Fig: SWE Grid
Solving

The solving is split into 3 steps:

  1. Height integration ∂ h ∂ t = − h ∇ ⋅ u \frac{\partial{h}}{\partial{t}} = -h\nabla \cdot u th=hu

  2. Velocity advection ∂ u ∂ t = − u ⋅ ∇ u \frac{\partial{u}}{\partial{t}} = -u \cdot \nabla u tu=uu

  3. Apply water pressure ∂ u ∂ t = − g ∇ ( h + H ) \frac{\partial{u}}{\partial{t}} = -g \nabla (h+H) tu=g(h+H)

step 1 and step 3 are using discrete format of first order differential.

step 2 uses classic idea of Semi-Lagrangian Method, which see center of grid as particle, backtrace this particle position p l a s t p_{last} plast at last time, sample at p l a s t p_{last} plast and set it as field value at next time.

The way to get p l a s t p_{last} plast is simply regarding velocity doesn’t change over time, so p l a s t = p c u r r − v c u r r Δ t p_{last} = p_{curr} - v_{curr} \Delta t plast=pcurrvcurrΔt

To summarize: A n e w ( p c u r r ) = A c u r r ( p l a s t ) A_{new}(p_{curr}) = A_{curr}(p_{last}) Anew(pcurr)=Acurr(plast)

It is just my personal conclusion, you can see famous paper Stable Fluid to get more details.

Stable Fluid

And the paper author also gave details about implementation of Stable Fluid:

Real-Time Fluid Dynamics for Games

SWE + Particles System

Problem: SWE does not support discontinuous terrain, such as waterfall

Solution: additional particle system, in which each particle carries water
mass and velocity

Steps:

1. Create particles

Go over all edges to determine whether and how many water particles
needs to be created.

  1. Determine whether should create waterfall edge based on the difference between neighboring terrain heights and water levels

  2. Determine the particle number

    Flux Φ = u i + 1 / 2 ,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值