cube

Defines the geometry of a cube. Use CUBE_PRIMITIVES vertex configuration with CUBE_VERTEX_COUNT vertices.

Get the coordinate of vertex i

vec3 cubeCoord(int i);

Get the normal vector of vertex i

vec3 cubeNormal(int i);

Get the texture coordinate of vertex i

vec2 cubeTexCoord(int i);

Get the tangent space transformation matrix of vertex i

mat3 cubeTangentSpace(int i);

The cubeVertex 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 = cubeCoord(index);
    normal = cubeNormal(index);
    coord = transformCoord(coord);
    normal = transformNormal(normal);
    return projectCoord(coord);
}

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

model Cube :
    fragment_data(vec3),
    vertex(vertexShader, CUBE_PRIMITIVES, CUBE_VERTEX_COUNT),
    fragment(fragmentShader);