20 #ifndef ANTKEEPER_RENDER_MATERIAL_HPP
21 #define ANTKEEPER_RENDER_MATERIAL_HPP
29 #include <unordered_map>
93 void set_flags(std::uint32_t flags) noexcept;
114 [[nodiscard]]
inline std::uint32_t
get_flags() const noexcept
136 return shader_template;
161 [[nodiscard]]
inline const std::unordered_map<hash::fnv1a32_t, std::shared_ptr<material_variable_base>>&
get_variables() const noexcept
179 [[nodiscard]]
inline std::size_t
hash() const noexcept
188 void rehash() noexcept;
190 bool two_sided{
false};
193 std::uint32_t flags{0};
194 std::shared_ptr<gl::shader_template> shader_template;
195 std::unordered_map<hash::fnv1a32_t, std::shared_ptr<material_variable_base>> variable_map;
196 std::size_t m_hash{0};
A material is associated with exactly one shader program and contains a set of material properties wh...
const std::shared_ptr< gl::shader_template > & get_shader_template() const noexcept
Returns the shader template with which this material is associated.
void set_variable(hash::fnv1a32_t key, std::shared_ptr< material_variable_base > value)
Sets the value of a material variable with the given name.
material()=default
Constructs a material.
std::uint32_t get_flags() const noexcept
Returns the material flags.
~material()=default
Destroys a material.
material_shadow_mode get_shadow_mode() const noexcept
Returns the material shadow mode.
void set_two_sided(bool two_sided) noexcept
Enables or disables back-face culling of the material surface.
std::size_t hash() const noexcept
Returns a hash of the material state.
std::shared_ptr< material_variable_base > get_variable(hash::fnv1a32_t key) const
Returns a shared pointer to the material variable with the given name, or nullptr if not found.
material & operator=(const material &other)
Makes this material a copy of aother material.
const std::unordered_map< hash::fnv1a32_t, std::shared_ptr< material_variable_base > > & get_variables() const noexcept
Returns all material variables.
void set_flags(std::uint32_t flags) noexcept
Sets the material flags.
bool is_two_sided() const noexcept
Returns true if the material surface is two-sided, and false otherwise.
void set_blend_mode(material_blend_mode mode) noexcept
Sets the material blend mode.
void set_shadow_mode(material_shadow_mode mode) noexcept
Sets the material shadow mode.
material_blend_mode get_blend_mode() const noexcept
Returns the material blend mode.
void set_shader_template(std::shared_ptr< gl::shader_template > shader_template)
Sets the material's shader template.
material_blend_mode
Material blend modes.
@ opaque
Material is fully opaque.
material_shadow_mode
Material shadow casting modes.
@ opaque
Material casts fully opaque shadows.
32-bit FNV-1a hash value.