# Fluid boundary collision bug?

**URL:** <https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740>\
**Category:** Questions\
**Tags:** water\
**Created:** [May 30, 2025, 7:38am UTC](https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740 "2025-05-30T07:38:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![WREQI](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wreqi/32/46073_2.png) [@WREQI](https://forum.babylonjs.com/u/WREQI)\
**Post date:** [May 30, 2025, 7:38am UTC](https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740/1 "2025-05-30T07:38:59Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/5/15ef0bd20111462b04a64f9783d13afb925ea6b6.jpeg)  
As you can see from the diagram, the boundary collision is wrong, why is that? Is the SDF boundary mesh inaccurate with the actual 3D mesh? Is it a bug with the SDF generator or a bug with the fluid renderer?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 30, 2025, 2:54pm UTC](https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740/2 "2025-05-30T14:54:45Z")

</div>

cc @Evgeni_Popov (please be patient, our forum master is on well deserved vacation)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 2, 2025, 9:36am UTC](https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740/3 "2025-06-02T09:36:08Z")

</div>

Because of [Fix obj loader and exporter to support handedness correctly by bghgary · Pull Request #14884 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/14884), there was a breaking change introduced in the way .obj files are loaded, which makes this demo fail.

A simple fix is to set `scene.useRightHandedSystem = true`:

> **[Babylon.js Playground](https://playground.babylonjs.com/#XMXDAA%23165)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

A more complicated fix would be to change how the SDF generator loads .obj files…

[EDIT] I’ve updated the doc page:

> <https://github.com/BabylonJS/Documentation/pull/1371>

---

<div class="post-metadata">

**Author:** ![WREQI](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wreqi/32/46073_2.png) [@WREQI](https://forum.babylonjs.com/u/WREQI)\
**Post date:** [June 3, 2025, 8:40am UTC](https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740/4 "2025-06-03T08:40:24Z")

</div>

SDF is a pre-computed generated 3D texture, and can the 3D texture be moved and updated in a 3D scene? Can I see how to update the 3D texture calculation?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 3, 2025, 10:17am UTC](https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740/5 "2025-06-03T10:17:07Z")

</div>

We don’t use a 3D texture because we do everything (fluid simulation + SDF calculation) on the GPU (hence why it’s slow).

The parsing of SDF data is done in `_ParseSDFData` (the SDF files are in [FluidRendering/src/assets/sdf at main · Popov72/FluidRendering · GitHub](https://github.com/Popov72/FluidRendering/tree/main/src/assets/sdf)), which fills a `SDFArray`, which is then used in `SDMesh` to calculate the distance to the mesh.

---

<div class="post-metadata">

**Author:** ![WREQI](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wreqi/32/46073_2.png) [@WREQI](https://forum.babylonjs.com/u/WREQI)\
**Post date:** [June 5, 2025, 10:24am UTC](https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740/6 "2025-06-05T10:24:24Z")

</div>

> [@Evgeni\_Popov](#):
>
> SDF calculation

Thanks for the answer, can you take a screenshot and tell me which file the GPU SDF calculation collision detection code is in? I didn’t find it

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 5, 2025, 11:05am UTC](https://forum.babylonjs.com/t/fluid-boundary-collision-bug/58740/7 "2025-06-05T11:05:40Z")

</div>

We don’t do anything on the GPU, everything is done on CPU side. The SDF calculation for SDF meshes is done in `SDFHelper.SDMesh`. The collision handling code is in `FluidSimulationDemoBase._checkCollisions`.
