9#ifndef AVARA3D_VISUAL_MATERIAL_MATERIAL_H
10#define AVARA3D_VISUAL_MATERIAL_MATERIAL_H
21#include "a3d/util/Bitmask.h"
40 using Property = std::variant<std::monostate, std::shared_ptr<Texture>,
Color>;
116 const std::optional<std::string>&
name()
const;
231 using PropertyList = std::vector<std::pair<const Property*, PropertyType>>;
233 enum class DirtyMask : uint32_t {
240 static std::shared_ptr<Material> MissingTextureMaterial();
241 static Property MissingTextureProperty();
245 PropertyList properties()
const;
247 MaterialId id() const noexcept;
249 DirtyMask dirtyMask() const;
250 void dirtyMask(DirtyMask mask);
256 std::optional<std::
string> _name;
261 float _specularExponent;
262 bool _locksAmbientWithDiffuse;
269 bool _depthTestEnabled;
270 bool _depthWriteEnabled;
271 DirtyMask _dirtyMask;
274 namespace util::bitmask {
277 struct enable_ops<
Material::DirtyMask> : std::true_type {};
Represents a normalized RGBA color.
Describes the surface appearance and render state of Mesh geometry.
void doubleSided(bool flag)
Sets whether both sides of polygons are rendered.
Material()
Creates a Material with no lighting properties and default render state.
const Property & emission() const
Returns the self-emissive material property.
void ambient(const Property &ambient)
Sets the ambient material property.
FillMode
Selects polygon rasterization mode.
const Property & specular() const
Returns the specular material property.
const Property & diffuse() const
Returns the diffuse material property.
static std::shared_ptr< Material > EmissionMaterial(Property property)
Creates a Material containing only the supplied emission property.
void alphaCutoff(float v)
Sets the stored alpha-mask cutoff; the renderer does not currently consume this value.
void blendFunction(BlendFunction function)
Sets the requested transparent blending function.
void diffuse(const Property &diffuse)
Sets the diffuse material property.
void depthWriteEnabled(bool enabled)
Enables or disables depth-buffer writes for the material.
AlphaMode alphaMode() const
Returns the alpha render mode.
BlendFunction blendFunction() const
Returns the requested transparent blending function.
void fillMode(FillMode mode)
Sets the polygon rasterization mode.
bool locksAmbientWithDiffuse() const
Returns whether diffuse content replaces ambient content during lighting.
const std::optional< std::string > & name() const
Returns the optional material name.
FillMode fillMode() const
Returns the polygon rasterization mode.
BlendFunction
Selects the blending function used for transparent materials.
void emission(const Property &emission)
Sets the self-emissive material property.
PropertyType
Identifies one of the material's lighting properties.
void name(const std::string &name)
Sets the material name.
Material(const Property &ambient, const Property &diffuse, const Property &specular)
Creates a Material with the supplied ambient, diffuse, and specular properties.
float alphaCutoff() const
Returns the stored alpha-mask cutoff; the renderer does not currently consume this value.
void uvScale(float scale)
Sets the uniform texture-coordinate scale.
void alphaMode(AlphaMode mode)
Sets the alpha render mode.
AlphaMode
Selects how material alpha participates in render-pass selection.
bool depthTestEnabled() const
Returns whether depth testing is enabled for the material.
static std::shared_ptr< Material > DefaultMaterial()
Returns the shared mutable fallback Material used for geometry without a usable material.
void specularExponent(float exponent)
Sets the Phong specular exponent controlling highlight sharpness.
static std::shared_ptr< Material > DiffuseMaterial(Property property)
Creates a Material containing only the supplied diffuse property.
void specular(const Property &specular)
Sets the specular material property.
float uvScale() const
Returns the uniform texture-coordinate scale.
Material(const Property &ambient, const Property &diffuse, const Property &specular, const Property &emission)
Creates a Material with the supplied lighting properties.
bool doubleSided() const
Returns whether both sides of polygons are rendered.
std::variant< std::monostate, std::shared_ptr< Texture >, Color > Property
Material property contents: absent, a shared Texture, or a constant Color.
float specularExponent() const
Returns the Phong specular exponent controlling highlight sharpness.
const Property & ambient() const
Returns the ambient material property.
bool depthWriteEnabled() const
Returns whether rendering the material writes to the depth buffer.
void depthTestEnabled(bool enabled)
Enables or disables depth testing for the material.
void locksAmbientWithDiffuse(bool flag)
Sets whether diffuse content replaces ambient content during lighting.