# How can i make mesh surface smooth?

**URL:** <https://forum.babylonjs.com/t/how-can-i-make-mesh-surface-smooth/30869>\
**Category:** Questions\
**Tags:** mesh, vertex, normal\
**Created:** [May 30, 2022, 2:56pm UTC](https://forum.babylonjs.com/t/how-can-i-make-mesh-surface-smooth/30869 "2022-05-30T14:56:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kikoshoung](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kikoshoung/32/19308_2.png) [@kikoshoung](https://forum.babylonjs.com/u/kikoshoung)\
**Post date:** [May 30, 2022, 2:56pm UTC](https://forum.babylonjs.com/t/how-can-i-make-mesh-surface-smooth/30869/1 "2022-05-30T14:56:46Z")

</div>

I’m creating surface mesh from a sphere with csg functions, and i want to filter the vertex data to get the surface part.  
I made it, but the surface is not smooth like it before, have i lost something with vertex data？

Smooth but has other mesh faces: [https://playground.babylonjs.com/#07QQ27#2](https://playground.babylonjs.com/#07QQ27#2)  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/4/64b8f6f6dc88763be4fb84f50d97b748c2eb28e0.png)

Only surface but not smooth: [https://playground.babylonjs.com/#07QQ27#3](https://playground.babylonjs.com/#07QQ27#3)  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/c/bcabc6b8090a5a24b9644cbe968be3c148563d47.png)

**The difference is at line 413 to 417(filter the mesh or not).**

PS: Ignore the ugly filterMesh function part, cause i’m still researching. 😃

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 30, 2022, 3:13pm UTC](https://forum.babylonjs.com/t/how-can-i-make-mesh-surface-smooth/30869/2 "2022-05-30T15:13:11Z")

</div>

Not sure to get all the maths here, maybe @JohnK our maths artist 🙂 might know ?

---

<div class="post-metadata">

**Author:** ![kikoshoung](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kikoshoung/32/19308_2.png) [@kikoshoung](https://forum.babylonjs.com/u/kikoshoung)\
**Post date:** [May 31, 2022, 6:15am UTC](https://forum.babylonjs.com/t/how-can-i-make-mesh-surface-smooth/30869/3 "2022-05-31T06:15:59Z")

</div>

Inspired by this official doc([Updating Vertices | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/creation/custom/updatingVertices)) and this PG: [https://playground.babylonjs.com/#H05E9H#11](https://playground.babylonjs.com/#H05E9H#11), i figured it out.  
Use Vector.subtract(vertexPosition, sphere.position) as each vertex’s normal can solve it, PG: [https://playground.babylonjs.com/#07QQ27#7](https://playground.babylonjs.com/#07QQ27#7)
