Is it possible to use the wireframe of a sphere as a material?

Hi everyone,

I’m trying to use a sphere as my “world container” (the camera will be inside of it) and I want to have this sphere look like a glowing spherical cage. As I was thinking about it the most simple way seemed to create a sphere, activate wireframe and color it using emisive color but that doesn’t seems to be possible.

Am I trying to do what I want the wrong way ? :sweat_smile:

1 Like

This example uses the sphere’s geometry points to create a “cage” with animated faces:
https://www.babylonjs-playground.com/#1LIVJD#9

The glow layer does not work on wireframe geometries.

You can try something like this, which draws the edges of each triangles through a custom vertex/shader and makes the edge thickness pulsates over time:

https://playground.babylonjs.com/#T1EAE3

This is based on:

You can change the method in the fragment shader:

#define METHOD 1

Note that:

mesh.convertToFlatShadedMesh();

is very important, as it ensures that each triangle has its 3 own vertices and that no vertex are shared by triangles. You need this because each vertex of a triangle has a new attribute barycentric that can’t be shared because its value may be different for two vertices at the same location if they are not in the same triangle.

3 Likes

In fact … glow layer doesn’t work on wireframes! :slight_smile: … but I found out this morning a nice effect for an opening scene with two spheres combined. If you move the camera the glow vanishes and the grid appears:
https://www.babylonjs-playground.com/#7A3KZH#1

Thank you all for your replies.
I finally found another way by using Torus https://playground.babylonjs.com/#ABRQMN#6

For the moment I found my solution inelegant but I think I’m getting closer of what I want to do :sweat_smile:

Now I need to figure out how to draw the wireframe using those torus.

I took a look at your methods Evgeni_Popov but I think I’m not enough good at math to make a successful implementation of them

Even if it is not what I’m trying to do I love you shown Necips https://www.babylonjs-playground.com/#1LIVJD#9. Looking like a sort of alien techno sphere :alien: Love it !

Again, thanks a lot for your answers !

1 Like

Note that the glow layer can be used with my PG:

https://playground.babylonjs.com/#T1EAE3#1

2 Likes