Skip to content

SpriteMaterial

Represents a material for 2D sprites.

[SpriteMaterial](/reference/materials/sprite_material) is a lightweight material optimized for rendering camera-facing quads such as UI elements, particles, or font glyphs. It supports a solid color, an optional albedo map, and an optional alpha map for per-pixel transparency.

Unlike physically-based or Phong materials, [SpriteMaterial](/reference/materials/sprite_material) is rendered without lighting by default, making it efficient for 2D overlays and screen-space elements.

cpp
auto material = vglx::SpriteMaterial::Create(0xFFFFFF);
material->albedo_map = texture;

auto sprite = vglx::Sprite::Create(material);
scene->Add(sprite);

INFO

Derives from Material and inherits all public properties and methods.

Construction

Constructors


SpriteMaterial()

cpp
vglx::SpriteMaterial::SpriteMaterial(const Color &color)
ParameterDescription
colorColor of the material.

Constructs a SpriteMaterial object.

Factories preferred


SpriteMaterial::Create() auto

cpp
static auto vglx::SpriteMaterial::Create(const Color &color=0xFFFFFF)
ParameterDescription
colorColor of the material.

Creates a shared pointer to a SpriteMaterial object.

Properties

albedo_map std::shared_ptr<Texture2D>

cpp
std::shared_ptr<Texture2D> albedo_map { nullptr }

Albedo (base color) map, optionally containing an alpha channel.

alpha_map std::shared_ptr<Texture2D>

cpp
std::shared_ptr<Texture2D> alpha_map { nullptr }

Alpha map that controls the opacity across the surface.

color Color

cpp
Color color { 0xFFFFFF }

Color of the material.

Functions

GetType() MaterialType virtual

cpp
MaterialType vglx::SpriteMaterial::GetType() const override

Returns material type.

Released under the MIT License.