icosphere
Defines the geometry of an approximate sphere, whose mesh is constructed as a tesselation of the regular icosahedron, where each original edge is divided into LOD segments. Use ICOSPHERE_PRIMITIVES vertex configuration with ICOSPHERE_VERTEX_COUNT(LOD) vertices.
Get the coordinate of vertex i
template <LOD>
vec3 icosphereCoord(int i);
Get the normal vector of vertex i
template <LOD>
vec3 icosphereNormal(int i);
The icosphereVertex 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 = icosphereCoord<32>(index);
normal = icosphereNormal<32>(index);
coord = transformCoord(coord);
normal = transformNormal(normal);
return projectCoord(coord);
}
vec4 fragmentShader(in vec3 normal) {
return computeLighting(normal);
}
model Icosphere :
fragment_data(vec3),
vertex(vertexShader, ICOSPHERE_PRIMITIVES, ICOSPHERE_VERTEX_COUNT(32)),
fragment(fragmentShader);