Nefertiti [wireframe shader]

Hi community!

We all know this example of wireframe: three.js examples
It uses a custom attribute center, that contains repetitive data for vertices of each face, like this:

...
1, 0, 0,
0, 1, 0,
0, 0, 1,
...

My thought was: to have precomputed values is good, but can we make the same thing in vertex shader?
I tried this:

vCenter = vec3(0);
vCenter[int(mod(float(gl_VertexID), 3.))] = 1.;

And it worked.

The result of experiment is here:
Picture

Video:

Demo: https://codepen.io/prisoner849/full/VYPMaVv

9 Likes

Nefertiti would be proud!

1 Like