1#ifndef OE_SCENE_MATERIAL_H
2#define OE_SCENE_MATERIAL_H
10#include <glm/mat4x4.hpp>
78 float attenuation_distance = 0.0f;
79 glm::vec3 attenuation_color = glm::vec3(1.0f);
97 std::shared_ptr<oe::render::ShaderBase>
shader =
nullptr;
162 void setTexture(
const std::string& name, std::shared_ptr<oe::render::Texture> texture,
const int32_t layer = -1);
167 std::shared_ptr<oe::render::Texture>
getTexture(
const uint32_t& layer)
const noexcept;
193 template <
typename T>
201 template <
typename T>
208 std::map<std::string, std::pair<uint32_t, std::shared_ptr<oe::render::Texture>>> _textures;
209 std::map<uint32_t, std::shared_ptr<oe::render::Texture>> _textures_layers;
214 #define OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(TYPE, PROPERTY) \
215 std::map<const std::string, TYPE> _prop_ ## PROPERTY; \
216 std::map<const std::string, std::vector<TYPE>> _prop_ ## PROPERTY ## _arrays; \
218 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(
bool,
bool)
219 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(int32_t, int32_t)
220 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(uint32_t, uint32_t)
221 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(
float,
float)
222 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(
double,
double)
223 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::ivec2, ivec2)
224 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::vec2, vec2)
225 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::vec3, vec3)
226 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::vec4, vec4)
227 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::mat4, mat4)
229 #undef OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY
261 #define OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(TYPE, PROPERTY) \
262 template <> inline Material* Material::setProperty(const std::string& name, const TYPE& value) \
264 _prop_ ## PROPERTY[name] = value; \
267 template <> inline Material* Material::setArray(const std::string& name, const std::vector<TYPE>& value) \
269 _prop_ ## PROPERTY ## _arrays[name] = value; \
273 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(int32_t, int32_t)
274 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(uint32_t, uint32_t)
275 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(
float,
float)
276 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(
double,
double)
277 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::ivec2, ivec2)
278 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::vec2, vec2)
279 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::vec3, vec3)
280 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::vec4, vec4)
281 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::mat4, mat4)
285 return setProperty<int32_t>(name, value);
291 return setProperty<uint32_t>(name, value);
294 template <>
inline Material*
Material::setArray(
const std::string& name,
const std::vector<bool>& values)
296 std::vector<uint32_t> result(values.begin(), values.end());
297 return setArray<uint32_t>(name, result);
300 #undef OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER
Shader class.
Definition shader_base.h:33
Render agnostic material.
Definition material.h:26
bool double_sided
Draws two sides of faces.
Definition material.h:102
void setTexture(const std::string &name, std::shared_ptr< oe::render::Texture > texture, const int32_t layer=-1)
Set Texture at specified layer.
Material * parent
Material source where properties/textures should be inherited from.
Definition material.h:143
const auto & getTextures() const
Get all material textures.
Definition material.h:183
uint32_t getNextAvailableTextureLayer(const uint32_t start=0) const
Get an available texture layer for this material.
bool inherit_properties
Check if Material properties should be inherited from parent Material.
Definition material.h:148
glm::vec2 texture_tiling
Apply a tiling to the texture UV.
Definition material.h:115
float alpha_threshold
Texture with alpha below this value will be considered completely transparent.
Definition material.h:138
Material * setProperty(const std::string &name, const T &value)=delete
Set a property on a material.
uint32_t flags
General purpose user flags, may be used for collisions / sounds / etc...
Definition material.h:92
std::shared_ptr< oe::render::Texture > getTexture(const uint32_t &layer) const noexcept
Get Texture stored at specified layer.
std::shared_ptr< oe::render::ShaderBase > shader
Shader to use to render this material.
Definition material.h:97
Material * setArray(const std::string &name, const std::vector< T > &value)=delete
Set a array of properties on a material.
TransmissiveProperties transmissive_properties
Physically-based transmission properties.
Definition material.h:133
bool is_blend
This material need blending (transparency, effects, ...)
Definition material.h:128
DrawMode draw_mode
Describe how the mesh should be drawn.
Definition material.h:85
bool invert_faces
If not double sided, draws back faces instead of front ones.
Definition material.h:107
glm::vec2 texture_offset
Apply an offset to the texture UV.
Definition material.h:123
bool inherit_textures
Check if Material textures should be inherited from parent Material.
Definition material.h:153
DrawMode
Specify how the mesh vertices will be rendered.
Definition material.h:34
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures)
Definition opengl.h:10
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19
Material properties related to physically-based transparency related effects.
Definition material.h:61
float transmission
Percentage of light transmitted through the surface between 0.0f (opaque) and 1.0f (transparent)
Definition material.h:69
float thickness
Thickness of the volume of the material between 0.0f (thin) and +Infinite (transparent)
Definition material.h:76
Common properties/textures tied to a PBR material.
Definition material.h:238
glm::vec3 emissiveColor
Definition material.h:243
std::shared_ptr< oe::render::Texture > rouMetAoTexture
Definition material.h:258
glm::vec3 rouMetAoColor
Definition material.h:246
std::shared_ptr< oe::render::Texture > albedoTexture
Definition material.h:249
glm::vec4 albedoColor
Definition material.h:240
std::shared_ptr< oe::render::Texture > normalTexture
Definition material.h:255
std::shared_ptr< oe::render::Texture > emissiveTexture
Definition material.h:252