# Using applyDisplacementMap then CSG to subtract mesh

**URL:** <https://forum.babylonjs.com/t/using-applydisplacementmap-then-csg-to-subtract-mesh/26820>\
**Category:** Questions\
**Created:** [January 16, 2022, 9:02pm UTC](https://forum.babylonjs.com/t/using-applydisplacementmap-then-csg-to-subtract-mesh/26820 "2022-01-16T21:02:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![supershwa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/supershwa/32/7039_2.png) [@supershwa](https://forum.babylonjs.com/u/supershwa)\
**Post date:** [January 16, 2022, 9:02pm UTC](https://forum.babylonjs.com/t/using-applydisplacementmap-then-csg-to-subtract-mesh/26820/1 "2022-01-16T21:02:22Z")

</div>

I’m trying to apply a displacement map to a mesh, then use CSG to subtract another mesh from it, but unfortunately the displacement map isn’t retained in the boolean/CSG operation. Is there a way to “render” or clone the mesh and keep the displacement data before using CSG to subtract another mesh?

Attempted here: [https://www.babylonjs-playground.com/#WUYDVT#31](https://www.babylonjs-playground.com/#WUYDVT#31)

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [January 17, 2022, 11:55am UTC](https://forum.babylonjs.com/t/using-applydisplacementmap-then-csg-to-subtract-mesh/26820/2 "2022-01-17T11:55:33Z")

</div>

Due to the way displacement map works, it is an asynchronous process. Meaning, running code right after calling the function won’t work.

You will need to use the onSuccess callback to get that to work correctly:

[Displacement Map + CSG test | Babylon.js Playground (babylonjs-playground.com)](https://www.babylonjs-playground.com/#WUYDVT#33)

---

<div class="post-metadata">

**Author:** ![supershwa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/supershwa/32/7039_2.png) [@supershwa](https://forum.babylonjs.com/u/supershwa)\
**Post date:** [January 17, 2022, 4:34pm UTC](https://forum.babylonjs.com/t/using-applydisplacementmap-then-csg-to-subtract-mesh/26820/3 "2022-01-17T16:34:28Z")

</div>

Perfect! Thank you for the help!
