Skip to content

Material

Abstract base class for material types.

This class is not intended to be used directly. Use one of the concrete material types such as PhongMaterial, UnlitMaterial, ShaderMaterial, or derive your own material implementation from this class.

Types

Material::Blending enum

Enumerates blending modes used for compositing this material.

ValueDescription
NoneNo blending (default) fragments overwrite existing pixels.
NormalStandard alpha blending.
AdditiveAdds fragment color to the framebuffer color.
SubtractiveSubtracts fragment color from the framebuffer color.
MultiplyMultiplies fragment color by the framebuffer color.

Material::Type enum

Enumerates all supported material types.

ValueDescription
PhongMaterialImplements the Blinn–Phong lighting model.
ShaderMaterialUses a custom shader program for rendering.
SpriteMaterialSpecialized material for 2D sprites and billboards.
UnlitMaterialRenders without lighting; color appears as-is.
LengthSentinel value representing the number of material types.

Properties

blending Blending

Blending mode used when rendering this material.

cpp
Blending blending {Blending::Normal};

depth_test bool

Enables depth testing.

cpp
bool depth_test {true};

flat_shaded bool

Enables flat shading.

cpp
bool flat_shaded {false};

fog bool

Enables scene fog for this material.

cpp
bool fog {true};

opacity float

Value in the range indicating how transparent the material is. For opacity to have an effect, transparency must be enabled.

cpp
float opacity {1.0f};

polygon_offset_factor float

Polygon offset factor used to mitigate z-fighting.

cpp
float polygon_offset_factor {0.0f};

polygon_offset_units float

Polygon offset units used to mitigate z-fighting.

cpp
float polygon_offset_units {0.0f};

transparent bool

Enables transparency for this material.

cpp
bool transparent {false};

two_sided bool

Enables rendering both front and back faces of polygons.

cpp
bool two_sided {false};

visible bool

Controls whether this material is visible when rendering.

cpp
bool visible {true};

wireframe bool

Enables wireframe rendering.

cpp
bool wireframe {false};

Functions

GetType() Type pure virtual

Identifies the concrete Material::Type of this material.

cpp
virtual Type Material::GetType() const=0;

Material::TypeToString() std::string

Converts a material type value to a string.

Primarily intended for debugging and logging.

cpp
static std::string Material::TypeToString(Type type);
ParameterDescription
typeMaterial type enum value.

Released under the MIT License.