8 Commits
Author SHA1 Message Date
西风逍遥游 5758297ab7 Merge pull request #398 from EVEngine/codex/fluid3d
feat(fluids): add Fluid3D simulation and rendering
2026-09-15 15:45:41 +08:00
西风逍遥游 92109ae643 feat(fluids): add Fluid3D simulation and rendering 2026-09-14 23:28:26 +08:00
西风逍遥游 7d513f767f test: replace redundant work with representative behavioral checks 2026-09-10 15:34:01 +08:00
sunxfancy 6bdf4ef00c feat(fluids): support droplets on dynamic surfaces 2026-08-23 18:01:13 +08:00
西风逍遥游 071d3250f8 fix(fluids): upload SDF before GPU init and clamp PBF corrections
Two stability fixes found while rendering surface-fluid frames:

- FluidSimulator::ensureGpu set gpuOk_ only after uploadSdf(), whose guard
  early-returned on !gpuOk_, so the GPU SDF buffer was never filled. The
  compute kernels then saw an all-zero field: projection used the fallback
  normal (0,1,0) and pushed every particle off the model by one particle
  radius per frame. Upload now happens after gpuOk_ is set.
- PBF position corrections were unbounded: overlapping particles amplify the
  spiky gradient and got flung apart. Both the CPU reference and the GLSL
  apply-delta kernel now clamp the correction to 0.05 * support radius.
- Regression guard: fluids.gpu.surfaceFlow asserts particles stay within
  |p| < 3 of the model origin (the zero-SDF path drifted to |p| ~ 7).
2026-08-23 11:04:33 +08:00
西风逍遥游 203c2a21e9 feat(fluids): Bingham yield stress and screen-space surface reconstruction
Phase 3 of the surface fluid simulation:
- Bingham yield stress in the CPU solver and integrate kernel: effective
  viscosity grows as local shear rate drops, so mud piles up and freezes
  instead of spreading like water.
- FluidSurfaceRenderer: screen-space fluid rendering pipeline (splat depth+
  thickness with atomic min/add, bilateral depth smoothing, view-space normal
  reconstruction from depth gradients, water/mud shading), mirrored 1:1 in
  FluidSsfKernels.h and driven through the gpgpu compute queue with a CPU
  fallback and PPM debug output.
- Script API: Fluids.newSurfaceRenderer + FluidSurface (render/setCamera/
  setMode/writePpm).
- Design + usage spec under docs/dev/specs.
- Tests: yield-stress freeze, SSF single-particle depth/normal/thickness,
  water-vs-mud shading, GPU SSF pipeline with PPM artifact (17 fluids cases).
2026-08-23 00:17:00 +08:00
西风逍遥游 601a94143b feat(fluids): PBF density constraints with cohesion/adhesion for droplets
Phase 2 of the surface fluid simulation:
- PBF density constraint: per-substep lambda/gradient accumulation and
  position corrections (3 passes on GPU: density+lambda, delta, apply),
  mirrored exactly in the CPU reference solver.
- Akinci-style cohesion kernel (fluid-fluid surface tension) and SDF-based
  adhesion (fluid-solid contact), so scattered films pull into droplets and
  drops stick to model undersides.
- Script API: setCohesion/setAdhesion/setPbfIterations on FluidSim.
- New tests: compressed-cloud relaxation, cohesion clumping, underside
  adhesion, and a GPU PBF+cohesion cluster run (13 fluids cases total).
2026-08-22 23:52:34 +08:00
西风逍遥游 c53ec6c6cc feat(fluids): surface fluid module with mesh SDF and GPU surface flow
Phase 1 of the interactive surface fluid simulation:
- New 'fluids' module (LAYER 5, deps gpgpu/graphics), registered in the
  module manifest with Squirrel binding (Fluids + FluidSim classes).
- MeshSdf: voxelized signed distance fields (analytic sphere/plane plus a
  closed-triangle-mesh baker) with trilinear sampling and gradient queries.
- FluidSimulation: CPU reference solver — uniform-grid neighbor search, SPH
  density, XSPH viscosity, gravity, and SDF surface projection so water
  sticks to the model and only flows tangentially downhill.
- FluidGpuKernels: GLSL compute kernels (clear/build grid, density,
  integrate+project) mirroring the CPU reference 1:1, driven through the
  gpgpu module with a CPU fallback.
- Tests: SPH kernels, sphere + triangle-mesh SDFs, CPU surface flow,
  viscosity damping, density, module wiring, and a headless GPU surface
  flow run (9 cases).
2026-08-22 23:47:23 +08:00