Skip to content

Billboard

Camera-facing quad that always faces the active camera.

Billboard is a flat unit-sized quad oriented toward the camera at all times. It is usually textured and exposes the minimal Renderable interface so it can be submitted to the renderer. Common use cases include particles, labels, icons, and world-space markers.

cpp
MyNode::MyNode() {
  auto texture = LoadTexture("assets/billboard.png");
  if (texture.has_value()) {
    auto material = vglx::BillboardMaterial::Create({.texture_map = texture.value()});
    Add(vglx::Billboard::Create(material))->transform.SetScale(0.5f);
  } else {
    std::println(stderr, "{}", texture.error());
  }
}

INFO

Derives from Renderable and inherits all public properties and methods.

Construction

Constructors


Billboard()

Constructs a billboard.

If material is null a new instance of BillboardMaterial will be created.

cpp
Billboard::Billboard(std::shared_ptr<BillboardMaterial> material);
ParameterDescription
materialMaterial used to render the billboard.

Factories preferred


Billboard::Create() std::unique_ptr<Billboard>

Creates an instance of Billboard.

cpp
static std::unique_ptr<Billboard> Billboard::Create(std::shared_ptr<BillboardMaterial> material=nullptr);
ParameterDescription
materialShared billboard material.

Properties

anchor Vector2

Normalized anchor point inside the billboard.

Defines the pivot used for placement and rotation of the billboard.

  • lower-left corner of the billboard.
  • center of the billboard (default).
  • upper-right corner of the billboard.

The billboard's world-space position corresponds to this anchor point. Rotation is applied around this pivot.

cpp
Vector2 anchor {Vector2 {0.5f, 0.5f}};

rotation float

View-space rotation angle in radians applied to the billboard.

cpp
float rotation {0.0f};

Functions

GetMaterial() std::shared_ptr<Material> virtual

Returns the material associated with the billboard.

cpp
std::shared_ptr<Material> Billboard::GetMaterial() const override;

GetNodeType() Node::Type virtual

Identifies this node as.

cpp
Type vglx::Billboard::GetNodeType() const override;

SetMaterial() auto

Sets the material used to render the billboard.

cpp
auto Billboard::SetMaterial(std::shared_ptr<BillboardMaterial> material);
ParameterDescription
materialShared pointer to a billboard material.

Released under the MIT License.