# Mesh Edge render as line?

**URL:** <https://forum.babylonjs.com/t/mesh-edge-render-as-line/43267>\
**Category:** Questions\
**Created:** [August 12, 2023, 9:12am UTC](https://forum.babylonjs.com/t/mesh-edge-render-as-line/43267 "2023-08-12T09:12:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccc159](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ccc159/32/11452_2.png) [@ccc159](https://forum.babylonjs.com/u/ccc159)\
**Post date:** [August 12, 2023, 9:12am UTC](https://forum.babylonjs.com/t/mesh-edge-render-as-line/43267/1 "2023-08-12T09:12:50Z")

</div>

Hi all,

I tried to find resources in the forum regarding render edges as simple line but without success.

Basically I have a model that needs to render the edges. So far I used the `enableEdgesRendering` function. But this edge renderer draws triangles instead of lines, making the edge of the mesh barely visible from far and too thick when close. Also the edges are jittering a lot.

 ![localhost_3000_ (1)](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/7/f7a8e5be7775ea8ea1c956156bad3c2266d996ee.jpeg)  
_from far the edges are barely seen._

 ![localhost_3000_](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/c/3/c35c78f9d29fe2de12f98a182489601a6e30aaea.jpeg)  
_from close they are too thick and not even_

I would like to instead render the edges as line so they have a constant look. (Something like below but this is an example from threejs)

 ![www.sema-soft.com_docs_webviewer_holzbau.html](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/4/040db6cafe3c602dfefebd44116f4192a5ac58d3.jpeg)

I noticed that the boundingbox edge renderer draws line, which is something I need. But I tried to attach the boundingboxrender’s shader material to the edgeRenderer’s lineshader `mesh.edgesRenderer.lineShader = _colorShader;` which does not really work.

I am not familar with the shader material. So I wonder if there’s an instruction on how I can achieve line renderer for the mesh edges. And if I have to stay with the default edgeRender, how can I fixed the jittering issue at least?

Thanks!

---

<div class="post-metadata">

**Author:** ![CodingCrusader](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/codingcrusader/32/29857_2.png) [@CodingCrusader](https://forum.babylonjs.com/u/CodingCrusader)\
**Post date:** [August 13, 2023, 5:51pm UTC](https://forum.babylonjs.com/t/mesh-edge-render-as-line/43267/3 "2023-08-13T17:51:59Z")

</div>

Maybe this example can give you the right direction how to draw a lot of thin lines:

[Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#XDJ6CZ)

---

<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:** [August 13, 2023, 10:11pm UTC](https://forum.babylonjs.com/t/mesh-edge-render-as-line/43267/4 "2023-08-13T22:11:55Z")

</div>

You can reuse the data created by the edge renderer to generate the lines yourself (either as a line mesh or with the thin wire plugin linked by @CodingCrusader). See this post and related PG:

> [@Create mesh from edgesRenderer](https://forum.babylonjs.com/t/create-mesh-from-edgesrenderer/16464/5):
>
> The lines are really triangles, so linesIndices gives you the indices of the 3 vertices of each triangle. Also, the triangles are degenerated in the linesPositions array: for each line between P1 and P2 you can see on screen you have in fact 4 vertices V0/V1/V2/V3 where V0=V1=P1 and V2=V3=P2 the first triangle is V0/V1/V2 and the second one is V0/V2/V3. As V0=V1 and V2=V3, those two triangles are degenerated (so if displayed “as is” you won’t see anything) It’s the shader used by the edge re…

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [August 13, 2023, 11:44pm UTC](https://forum.babylonjs.com/t/mesh-edge-render-as-line/43267/5 "2023-08-13T23:44:13Z")

</div>

> [@Barycentric Generation?](https://forum.babylonjs.com/t/barycentric-generation/9994):
>
> So do we have a way to include Barycentric coordinates in the vertexData just inherently? Currently I parse the data and replace the normal buffer with barycentric info, but it would be nice to keep both. I think I might just have to make a custom Buffer with step for the extra two values.

> [@Trying to get my Barycentric Shader working as a custom material?](https://forum.babylonjs.com/t/trying-to-get-my-barycentric-shader-working-as-a-custom-material/12468):
>
> [https://playground.babylonjs.com/#LFZ3QM](https://playground.babylonjs.com/#LFZ3QM) I am struggling trying to get this to work like I did in this example: [https://www.babylonjs-playground.com/#G3GZA1#162](https://www.babylonjs-playground.com/#G3GZA1#162) Any ideas how to get this working anyone? I was hoping to draw the quad of the ground plane without doing a whole customShader

There is also Barycentric stuff you could do.

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#G3GZA1%23162)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes
