Rendering edges of a cylinder

Hi
I’m pretty new to babylonjs, so first thanks for all the great work you’ve done : )

I wanna draw a hexagon and display its outline. Here’s an example using createCylinder :https://www.babylonjs-playground.com/#CWPN2T#150

I tried with enableEdges Rendering, but there is a “red line” going from an edge to center of hexagon : /
What I’m doing wrong ? Is there any way to display only outline ?

Thanks

Hi @gabriel ,

Have you tried renderOutline?

https://www.babylonjs-playground.com/#CWPN2T#152

1 Like

That looks great ! Thank you.
Is there anyway to render outline for each face ? I wanna have outline around top face.

1 Like

It should be possible to define submeshes and render only their outline, but when seen from the side, flat faces show no outline.

For your original question, apparently setting the checkVerticesInsteadOfIndices of enableEdgesRendering works for the cylinder, perhaps it will work for the hexagon as well:

https://www.babylonjs-playground.com/#CWPN2T#153

That looks fine to me. Thanks a lot !

Le ven. 8 nov. 2019 à 18:16, Gijs Schenk via Babylon.js babylonjs@discoursemail.com a écrit :

Is it also possible to draw the sides of the cylinder?
Like this:

Hi,
You can add a HighlightLayer:
https://www.babylonjs-playground.com/#CWPN2T#372
(But this is probably not the best way to do it :grimacing: )

2 Likes

I’m not sure how to do this, but I think this can be done using How To use the Node Material - Babylon.js Documentation.

1 Like

Is there a way to make the lines smoother / higher res?

with cylinder.renderOutline = true the lines are smoother but you get artifacts in some angle:
https://www.babylonjs-playground.com/#CWPN2T#373

This page is pretty heavy and out of my skills.
Do you have some tips or ressources how I could tackle this problem?

@Browork, these video guides by the Babylon team are amazing: https://www.youtube.com/results?search_query=node+material+editor

I’m not a Node Material or shader expert, though I think these are powerful approaches, since they offer so much customization flexibility.

Found some resources below on possible starting points when creating an outline shader or Node Material:

https://alexanderameye.github.io/outlineshader.html

Even though the Node setups in the resources above were created outside of Babylon, there is much to learn from these when implementing your own in https://nme.babylonjs.com/

The Babylon community was extremely helpful when I first tried learning Node Materials (Node Material: Dissolve Effect). If you have questions when creating your own custom material or shader, I’m sure the community would be happy to help :smiley:

3 Likes

@sebavan will soon add support for an even better technique:))

2 Likes