1#ifndef OE_SCENE_MATERIAL_H
2#define OE_SCENE_MATERIAL_H
7#include <glm/mat4x4.hpp>
80 float attenuation_distance = 0.0f;
81 glm::vec3 attenuation_color = glm::vec3(1.0f);
92 std::vector<TextureProperty> textures;
203 template <
typename T>
211 template <
typename T>
224 #define OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(TYPE, PROPERTY) \
225 std::map<const std::string, TYPE> _prop_ ## PROPERTY; \
226 std::map<const std::string, std::vector<TYPE>> _prop_ ## PROPERTY ## _arrays; \
228 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(
bool,
bool)
229 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(int32_t, int32_t)
230 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(uint32_t, uint32_t)
231 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(
float,
float)
232 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(
double,
double)
233 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::ivec2, ivec2)
234 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::vec2, vec2)
235 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::vec3, vec3)
236 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::vec4, vec4)
237 OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY(glm::mat4, mat4)
239 #undef OE_ENGINE_SCENE_MATERIAL_GENERATE_PROPERTY
242 #define OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(TYPE, PROPERTY) \
243 template <> inline Material* Material::setProperty(const std::string& name, const TYPE& value) \
245 _prop_ ## PROPERTY[name] = value; \
248 template <> inline Material* Material::setArray(const std::string& name, const std::vector<TYPE>& value) \
250 _prop_ ## PROPERTY ## _arrays[name] = value; \
254 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(int32_t, int32_t)
255 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(uint32_t, uint32_t)
256 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(
float,
float)
257 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(
double,
double)
258 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::ivec2, ivec2)
259 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::vec2, vec2)
260 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::vec3, vec3)
261 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::vec4, vec4)
262 OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER(glm::mat4, mat4)
266 return setProperty<int32_t>(name, value);
272 return setProperty<uint32_t>(name, value);
275 template <>
inline Material*
Material::setArray(
const std::string& name,
const std::vector<bool>& values)
277 std::vector<uint32_t> result(values.begin(), values.end());
278 return setArray<uint32_t>(name, result);
281 #undef OE_ENGINE_SCENE_MATERIAL_GENERATE_SETTER
Shader class.
Definition shader_base.h:32
Render agnostic material.
Definition material.h:90
TextureCoordinatesTransform texture_coordinates_1
Second texture coordinates transformation set.
Definition material.h:102
bool double_sided
Draws two sides of faces.
Definition material.h:119
Material * parent
Material source where properties/textures should be inherited from.
Definition material.h:146
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:151
float alpha_threshold
Texture with alpha below this value will be considered completely transparent.
Definition material.h:141
TextureCoordinatesTransform texture_coordinates_0
First texture coordinates transformation set.
Definition material.h:97
Material * setProperty(const std::string &name, const T &value)=delete
Get all material textures.
uint32_t flags
General purpose user flags, may be used for collisions / sounds / etc...
Definition material.h:109
Material * setArray(const std::string &name, const std::vector< T > &value)=delete
Set a array of properties on a material.
oe::render::ShaderBase * shader
Shader to use to render this material.
Definition material.h:114
TransmissiveProperties transmissive_properties
Physically-based transmission properties.
Definition material.h:136
bool is_blend
This material need blending (transparency, effects, ...)
Definition material.h:131
bool invert_faces
If not double sided, draws back faces instead of front ones.
Definition material.h:124
bool inherit_textures
Check if Material textures should be inherited from parent Material.
Definition material.h:156
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures)
Definition opengl.h:10
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19
Material property defining texture coordinates set transformation.
Definition material.h:41
glm::vec2 offset
Apply an offset to the texture UV.
Definition material.h:54
glm::vec2 tiling
Apply a tiling to the texture UV.
Definition material.h:48
Material property defining texture settings.
Definition material.h:21
std::string name
Texture uniform name.
Definition material.h:25
render::Texture * texture
Texture pointer.
Definition material.h:32
Material properties related to physically-based transparency related effects.
Definition material.h:63
float thickness
Thickness of the volume of the material between 0.0f (thin) and +Infinite (thick)
Definition material.h:78
float transmission
Percentage of light transmitted through the surface between 0.0f (opaque) and 1.0f (transparent)
Definition material.h:71