Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Material.hpp
1#pragma once
2
3#include "resources/ResourcesManager.hpp"
4#include "system/Codable.hpp"
5#include "Common.hpp"
6
72class Material {
73
74public:
76 enum Type : int {
77 None = 0,
88 };
89
91 Material() = default;
92
97
101 void addTexture(const Texture * infos);
102
106 void addParameter(const glm::vec4& param);
107
111 const std::vector<const Texture *> & textures() const { return _textures; }
112
116 const std::vector<glm::vec4> & parameters() const { return _parameters; }
117
122 const Type & type() const { return _material; }
123
127 bool twoSided() const { return _twoSided; }
128
132 bool masked() const { return _masked; }
133
135 const std::string& name() const { return _name; }
136
153 bool decode(const KeyValues & params, Storage options);
154
158 virtual KeyValues encode() const;
159
161 virtual ~Material() = default;
162
164 Material(const Material &) = delete;
165
169 Material & operator=(const Material &) = delete;
170
172 Material(Material &&) = default;
173
177 Material & operator=(Material &&) = default;
178
179protected:
180
181 std::vector<const Texture *> _textures;
182 std::vector<glm::vec4> _parameters;
183 std::string _name;
185 bool _twoSided = false;
186 bool _masked = false;
187
188};
189
190STD_HASH(Material::Type);
Represent a surface material, including textures describing the surface parameters.
Definition: Material.hpp:72
virtual ~Material()=default
Material(const Material &)=delete
bool decode(const KeyValues &params, Storage options)
Definition: Material.cpp:41
Material()=default
void addParameter(const glm::vec4 &param)
Definition: Material.cpp:131
bool masked() const
Definition: Material.hpp:132
const std::vector< glm::vec4 > & parameters() const
Definition: Material.hpp:116
Material(Material &&)=default
std::vector< const Texture * > _textures
Textures used by the material.
Definition: Material.hpp:181
void addTexture(const Texture *infos)
Definition: Material.cpp:126
Material & operator=(Material &&)=default
Type _material
The material type.
Definition: Material.hpp:184
const std::string & name() const
Definition: Material.hpp:135
std::string _name
The material name.
Definition: Material.hpp:183
Type
Type of shading/effects.
Definition: Material.hpp:76
@ Regular
PBR shading.
Definition: Material.hpp:78
@ Clearcoat
PBR shading with an additional clear coat specular layer.
Definition: Material.hpp:80
@ TransparentIrid
Transparent object with iridescent Fresnel.
Definition: Material.hpp:87
@ Subsurface
PBR shading with subsurface scattering.
Definition: Material.hpp:84
@ Iridescent
PBR shading with iridescent Fresnel.
Definition: Material.hpp:83
@ Sheen
PBR shading with a sheen BRDF.
Definition: Material.hpp:82
@ Parallax
PBR with parallax mapping.
Definition: Material.hpp:79
@ Emissive
Emissive objects (no diffuse shading).
Definition: Material.hpp:85
@ Anisotropic
PBR shading with an anisotropic BRDF.
Definition: Material.hpp:81
@ Transparent
Transparent object.
Definition: Material.hpp:86
@ None
Any type of shading.
Definition: Material.hpp:77
Material & operator=(const Material &)=delete
const Type & type() const
Definition: Material.hpp:122
bool _twoSided
Should faces of objects be visible from the two sides.
Definition: Material.hpp:185
bool _masked
The material uses alpha cutout.
Definition: Material.hpp:186
virtual KeyValues encode() const
Definition: Material.cpp:88
bool twoSided() const
Definition: Material.hpp:127
const std::vector< const Texture * > & textures() const
Definition: Material.hpp:111
std::vector< glm::vec4 > _parameters
Parameters used by the material.
Definition: Material.hpp:182
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12
Storage
Storage and loading options.
Definition: ResourcesManager.hpp:14
Represent a key-values tuple.
Definition: Config.hpp:9