Tricks using barycentric coordinates on regular polyhedra

I found this sweet christmas ball (or rather circus ball?) pattern: https://eliashasle.github.io/christmas_ball.html

while experimenting with making a “golf ball” using a polyhedron: https://eliashasle.github.io/golf_ball.html (not very successful yet)

The principle is to vertex-color each triangular face R,G,B (that is 1,0,0, 0,1,0, 0,0,1) and use the interpolated values (effectively barycentric coordinates) in the fragment shader, in some symmetric way. In my case I have reused code intended for bumpmaps.

Using unindexed geometry makes the coloring very simple: rgb rgb rgb rgb …

Some details on so far unsuccessful experiments with indexing PolyhedronBufferGeoemtry and vertex-coloring it (demo) I did some experiments trying to make PolyhedronBufferGeometry generate indexed geometry, but did not succeed at making it bug-free. Some polyhedra can be three-colored on vertices, meaning that the indexed geometry can also be assigned R,G,B in some order. I began writing a coloring algorithm, but the coloring would terminate early. Either because of the bugs with indexing or because of wrong assumptions regarding always being able to fill the third vertex in some face, never having to branch the search. The indexing code is available at https://github.com/EliasHasle/EliasHasle.github.io/blob/master/js/Polyhedron_modification.js and the attempt at vertex-coloring it is available at https://github.com/EliasHasle/EliasHasle.github.io/blob/master/Modified_polyhedron.html and running at https://eliashasle.github.io/Modified_polyhedron.html I just share them in case anyone else can point out the error, or would like to try fixing them, or use them as inspiration for their own work/experiments.

(I have some more small demos on https://eliashasle.github.io)

2 Likes