Icosahedronal symmetry

29 views
Skip to first unread message

Tom Sirgedas

unread,
Jan 7, 2023, 11:36:47 PM1/7/23
to ShaderToy
Snag_29ea27e.png

Shane created Asymmetric Spherical Jigsaw Map
https://www.shadertoy.com/view/7ldfzS

It's another great creation, but Shane mentioned that the setting up the geometry was a big pain (and he's written a few shaders with icosahedronal symmetry). I only partially understand what his code is doing, but it seems overly complicated. So, I'm attempting to create a similar shader (geometry-wise) and make the code as elegant/concise/fast/re-usable as possible.

Tom Sirgedas

unread,
Jan 8, 2023, 12:10:17 AM1/8/23
to ShaderToy
Snag_2a8fe98.png

Here's my initial proof-of-concept shader: https://www.shadertoy.com/view/4ltBDH

Snag_2ad24d9.png
(in this image, the 15 cells with positive X, Y, and Z coordinates are highlighted.)

Determining which sector (the ico_id) a point lies in
The idea is to detect which of the 120 "sectors" a point is in. The sign of the x/y/z coordinates indicated which of the 8 octants the point is in.
Then the absolute values of the coordinates can be taken, and only 15 sectors remain. Then we check all half-planes that separate sectors (this is just involves taking a dot product with the point and a normal to the plane, and checking if the result is positive). Then it's possible to take a weighted sum of the results of these tests to assign an "id" to the sector. The weights are chose such that each sector has a unique integer "id" in the set {0, 1, 2, ..., 14}. Combining the id with the octant can provide an "ico_id" to all 120 sectors with values {0, 1, ..., 119}.

The ico_id allows easy lookup of sector information
The attributes unique to each sector (like "matrix", neighbors, which icosahedron face it belongs to, which dodecahedron face it belongs to) are stored in hard-coded look-up tables.

Snag_2bc0969.png

The sector with ico_id == 58 is the "identity" sector. The "matrix" for each sector will transform that sector to coincide with sector 58. For example, sector 59's matrix is just a reflection on the X axis (see image above).

That's the basic idea so far. I plan to work on some example shaders and evolve the "API" from there.


Reply all
Reply to author
Forward
0 new messages