billboard

Defines the geometry of a billboard – a flat square in 3D space. Use BILLBOARD_PRIMITIVES vertex configuration with BILLBOARD_VERTEX_COUNT vertices.

Get the coordinate of vertex i

vec3 billboardCoord(int i);

Get the normal vector of vertex i

vec3 billboardNormal(int i);

Get the texture coordinate of vertex i

vec2 billboardTexCoord(int i);

Get the tangent space transformation matrix of vertex i

mat3 billboardTangentSpace(int i);

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

Example

vec4 vertexShader(out vec2 texCoord, int index) {
    vec3 coord = billboardCoord(index);
    texCoord = billboardTexCoord(index);
    coord = transformCoord(coord);
    return projectCoord(coord);
}

vec4 fragmentShader(in vec2 texCoord) {
    return texture(BillboardTexture, texCoord);
}

model Billboard :
    fragment_data(vec2),
    vertex(vertexShader, BILLBOARD_PRIMITIVES, BILLBOARD_VERTEX_COUNT),
    fragment(fragmentShader);