{
 "id": "flip-pic-fluids",
 "title": "FLIP/PIC fluids",
 "aliases": [
  "FLIP",
  "PIC",
  "PIC/FLIP"
 ],
 "domain": "simulation",
 "subdomain": "hybrid particle-grid fluids",
 "stage": "simulation",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "cuda",
  "houdini",
  "blender",
  "desktop-gpu"
 ],
 "year_introduced": 2005,
 "inputs": [
  "particles",
  "voxels"
 ],
 "outputs": [
  "particles",
  "volume-density"
 ],
 "style": "photoreal",
 "dynamic": "dynamic",
 "summary": "Hybrid fluid method: particles carry mass and velocity, a grid solves pressure, and FLIP-style delta transfer gives splashy, low-dissipation liquid motion.",
 "how_it_works": "Each step: transfer particle velocities to a staggered MAC grid, add gravity, enforce boundary conditions, project the velocity field to be divergence-free with a pressure solve (PCG or multigrid), then transfer back. PIC copies the new grid velocity to particles, which is stable but very viscous. FLIP transfers only the change in grid velocity, preserving detail but noisy. Production solvers blend them (for example 95-99% FLIP). Particles are advected with the grid velocity, and re-seeded to keep about 8 per fluid cell. Sand and granular media can be modelled by adding a friction-based yield model on top. The surface is extracted from particles via a level-set or anisotropic kernel.",
 "when_to_use": "Choose it when you want film-quality liquids with energetic splashes and little numerical dissipation. Prefer `sph-fluids` or `position-based-fluids` for realtime GPU liquids, `mpm-snow` when you also need elastoplastic solids (snow, sand, mud) in the same solver, and `stable-fluids` for smoke on a pure grid.",
 "cost": {
  "class": "offline",
  "notes": "Pressure solve on the grid dominates; production solvers are offline or interactive at modest resolution."
 },
 "failure_modes": [
  "FLIP noise: high-frequency velocity jitter and splash 'fizz' when blend ratio is too high",
  "Volume drift or loss without particle-count-per-cell maintenance and volume correction",
  "Thin features below the grid resolution are lost or turn into clumps",
  "Pressure solve with free-surface and solid boundaries is sensitive to bad Neumann/Dirichlet setups"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/1073204.1073298",
   "type": "paper",
   "title": "Animating sand as a fluid",
   "authors": [
    "Yongning Zhu",
    "Robert Bridson"
   ],
   "year": 2005,
   "venue": "ACM Transactions on Graphics",
   "url": "https://doi.org/10.1145/1073204.1073298",
   "ids": {
    "doi": "10.1145/1073204.1073298"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1073204.1073298",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1073204.1073298",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1073204.1073298",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1073204.1073298",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1073204.1073298",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "zhu2005animating"
  },
  {
   "role": "tutorial",
   "key": "url:https://matthias-research.github.io/pages/tenMinutePhysics",
   "type": "tutorial",
   "title": "Ten Minute Physics",
   "authors": [
    "Matthias Müller"
   ],
   "year": null,
   "venue": "matthias-research.github.io",
   "url": "https://matthias-research.github.io/pages/tenMinutePhysics",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20260924155100/https://matthias-research.github.io/pages/tenMinutePhysics/",
     "timestamp": "20260924155100"
    },
    "page_title": "Ten Minute Physics",
    "host": "matthias-research.github.io",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://matthias-research.github.io/pages/tenMinutePhysics → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://matthias-research.github.io/pages/tenMinutePhysics → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://matthias-research.github.io/pages/tenMinutePhysics → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "mllerminute"
  }
 ],
 "presets": [
  {
   "id": "flip-pic-fluids-live",
   "title": "FLIP/PIC Fluids — damped PIC grid transfer (left) vs energetic FLIP velocity-delta blend (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_FLIP_RATIO": 0.95,
    "P_GRID_RES": 10,
    "P_WAVE_AMP": 1,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_FLIP_RATIO = 0.95; // P FLIP Blend Beta [0.0, 1.0, 0.02]\nconst float P_GRID_RES = 10.0; // P MAC Grid Cells [6.0, 18.0, 1.0]\nconst float P_WAVE_AMP = 1.0; // P Splash Energy [0.3, 1.8, 0.05]\nconst float P_SPLIT = 0.48; // P PIC / FLIP Split [0.0, 1.0, 0.02]\n\nvec2 hash21(float p) {\n  vec3 p3 = fract(vec3(p) * vec3(0.1031, 0.1030, 0.0973));\n  p3 += dot(p3, p3.yzx + 33.33);\n  return fract((p3.xx + p3.yz) * p3.zy);\n}\n\n// Divergence-free MAC grid velocity field u(x,y) = curl(psi)\nvec2 macVelocity(vec2 p, float t, float flipBeta) {\n  float k = 4.2;\n  float vx = cos(p.y * k + t * 1.4) * sin(p.x * 3.1 - t * 0.9);\n  float vy = -sin(p.y * k + t * 1.4) * cos(p.x * 3.1 - t * 0.9) * 0.72;\n  // FLIP preserves fine high-frequency sub-grid vorticity that PIC diffuses away\n  float sub = flipBeta * 0.55;\n  vx += sub * sin(p.y * 11.5 - t * 2.8) * cos(p.x * 9.2 + t * 1.9);\n  vy += sub * cos(p.y * 11.5 - t * 2.8) * sin(p.x * 9.2 + t * 1.9);\n  return vec2(vx, vy);\n}\n\nfloat sdArrow(vec2 p, vec2 a, vec2 b) {\n  vec2 pa = p - a;\n  vec2 ba = b - a;\n  float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);\n  return length(pa - ba * h);\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float px = 1.0 / max(iResolution.y, 1.0);\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  bool isFlip = screenX >= split;\n  float beta = isFlip ? clamp(P_FLIP_RATIO, 0.0, 1.0) : 0.04;\n  float res = clamp(floor(P_GRID_RES + 0.5), 6.0, 18.0);\n  float amp = clamp(P_WAVE_AMP, 0.2, 2.0);\n  float t = iTime;\n\n  vec3 col = mix(vec3(0.022, 0.032, 0.052), vec3(0.052, 0.072, 0.112), smoothstep(-0.5, 0.5, uv.y));\n\n  // Tank domain\n  vec2 tankBox = abs(uv) - vec2(0.68, 0.39);\n  float dTank = length(max(tankBox, 0.0)) + min(max(tankBox.x, tankBox.y), 0.0);\n  float inTank = step(dTank, 0.0);\n\n  // Background staggered MAC pressure/velocity grid\n  vec2 cellUV = uv * res;\n  vec2 cellId = floor(cellUV);\n  vec2 cellF = fract(cellUV) - 0.5;\n  vec2 cellCenter = (cellId + 0.5) / res;\n\n  float gridLine = smoothstep(0.045, 0.01, min(abs(cellF.x - 0.5), abs(cellF.y - 0.5)));\n  gridLine = max(gridLine, smoothstep(0.045, 0.01, min(abs(cellF.x + 0.5), abs(cellF.y + 0.5))));\n  col += vec3(0.045, 0.075, 0.125) * gridLine * inTank;\n\n  // Draw MAC velocity vectors inside each grid cell\n  vec2 vCell = macVelocity(cellCenter, t, beta);\n  float vMag = length(vCell);\n  vec2 arrowEnd = (vCell / max(vMag, 1e-4)) * min(vMag * 0.24, 0.38);\n  float dArr = sdArrow(cellF, -arrowEnd * 0.35, arrowEnd);\n  col += mix(vec3(0.14, 0.38, 0.62), vec3(0.28, 0.85, 0.92), clamp(vMag * 0.7, 0.0, 1.0)) *\n         smoothstep(0.055, 0.015, dArr) * 0.42 * inTank;\n\n  // Evaluate 36 Lagrangian fluid particles transferring velocity with MAC grid\n  float fluidField = 0.0;\n  float speedSum = 0.0;\n  float minP = 1e5;\n  float splashMask = 0.0;\n\n  for (int i = 0; i < 36; i++) {\n    float fi = float(i);\n    vec2 h = hash21(fi * 13.7 + 1.9);\n    float colI = mod(fi, 9.0);\n    float rowI = floor(fi / 9.0);\n\n    // Base wave + PIC viscous damping vs FLIP ballistic cresting\n    float bx = (colI - 4.0) * 0.142 + 0.05 * sin(t * 1.4 + rowI * 0.8);\n    float crest = sin(bx * 4.2 - t * 2.1) * 0.095 * amp * (0.35 + 0.65 * beta);\n    float by = -0.27 + rowI * 0.102 + crest;\n\n    // FLIP retains sharp sub-grid spray arcs above the wave crest\n    vec2 vLocal = macVelocity(vec2(bx, by), t, beta);\n    float lift = (rowI > 2.5) ? (beta * 0.115 * amp * pow(max(0.5 + 0.5 * sin(t * 2.4 + fi * 1.3), 0.0), 2.0)) : 0.0;\n    vec2 pPos = vec2(bx, by + lift) + vLocal * (0.022 + 0.055 * beta) * amp;\n    pPos.x = clamp(pPos.x, -0.63, 0.63);\n    pPos.y = clamp(pPos.y, -0.35, 0.34);\n\n    float d = length(uv - pPos);\n    minP = min(minP, d);\n    float rK = 0.135;\n    if (d < rK) {\n      float q = 1.0 - d / rK;\n      float w = q * q * q;\n      fluidField += w;\n      speedSum += w * (length(vLocal) + lift * 6.0);\n    }\n    if (rowI > 2.5 && beta > 0.3) {\n      splashMask = max(splashMask, smoothstep(0.024, 0.008, d) * beta);\n    }\n  }\n\n  float mask = smoothstep(0.42, 0.58, fluidField) * inTank;\n  if (mask > 0.005) {\n    float avgSpd = speedSum / max(fluidField, 1e-4);\n    vec3 picCol = mix(vec3(0.08, 0.28, 0.56), vec3(0.22, 0.52, 0.74), clamp(avgSpd * 0.5, 0.0, 1.0));\n    vec3 flipCol = mix(vec3(0.05, 0.42, 0.78), vec3(0.18, 0.92, 0.88), clamp(avgSpd * 0.65, 0.0, 1.0));\n    flipCol = mix(flipCol, vec3(0.95, 0.98, 1.0), smoothstep(1.1, 2.0, avgSpd) * 0.65);\n    vec3 water = mix(picCol, flipCol, beta);\n    float edgeFoam = smoothstep(0.75, 0.44, fluidField);\n    water += vec3(0.85, 0.96, 1.0) * edgeFoam * (0.18 + 0.38 * beta);\n    col = mix(col, water, mask * 0.88);\n  }\n\n  // Particle dots + ballistic FLIP spray droplets\n  col = mix(col, vec3(0.88, 0.96, 1.0), smoothstep(0.015, 0.006, minP) * 0.72 * inTank);\n  col += vec3(0.82, 0.97, 1.0) * splashMask * 0.75 * inTank;\n\n  // Border and split bar\n  col = mix(col, vec3(0.68, 0.84, 0.98), smoothstep(0.009, 0.002, abs(dTank)) * 0.85);\n  col = mix(col, vec3(0.95, 0.97, 1.0), smoothstep(0.0035, 0.0008, abs(screenX - split)));\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "flip-pic-fluids",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:53:26.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.3466,
      "std": 0.1949,
      "min": 0.1727,
      "max": 0.942
     },
     "image": "/specimens/flip-pic-fluids-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "stable-fluids",
  "sph-fluids",
  "position-based-fluids",
  "mpm-snow"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/simulation/flip-pic-fluids.json"
 },
 "solves": [
  "water simulation looks too damped and viscous",
  "splashy liquid with lots of detail and particles",
  "pure grid fluid loses small scale motion",
  "simulate liquid pouring and splashing for vfx"
 ],
 "authority": "Zhu & Bridson, 2005",
 "url": "https://texelatlas.vercel.app/t/flip-pic-fluids/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 44.69,
  "tier": "heavy",
  "p50_ms": 1.3855,
  "p95_ms": 1.4413,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 36,
  "preset_id": "flip-pic-fluids-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 43.97,
   "tier": "heavy",
   "p50_ms": 0.6991,
   "p95_ms": 0.7037,
   "speedup_x": 1.98,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 31,
   "tier": "heavy",
   "p50_ms": 0.8929,
   "p95_ms": 0.8934,
   "speedup_x": 1.55,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}