icosahedron

Defines the geometry of a regular icosahedron. Use ICOSAHEDRON_PRIMITIVES vertex configuration with ICOSAHEDRON_VERTEX_COUNT vertices.

Get the coordinate of vertex i

vec3 icosahedronCoord(int i);

Get the normal vector of vertex i

vec3 icosahedronNormal(int i);

The icosahedronVertex function can be used directly as the vertex shader if no coordinate transformation is needed.

Example

vec4 vertexShader(out vec3 normal, int index) {
    vec3 coord = icosahedronCoord(index);
    normal = icosahedronNormal(index);
    coord = transformCoord(coord);
    normal = transformNormal(normal);
    return projectCoord(coord);
}

vec4 fragmentShader(in vec3 normal) {
    return computeLighting(normal);
}

model Icosahedron :
    fragment_data(vec3),
    vertex(vertexShader, ICOSAHEDRON_PRIMITIVES, ICOSAHEDRON_VERTEX_COUNT),
    fragment(fragmentShader);