]> git.tdb.fi Git - libs/gl.git/blobdiff - source/pbrmaterial.h
Add a PBR material type and corresponding shader
[libs/gl.git] / source / pbrmaterial.h
diff --git a/source/pbrmaterial.h b/source/pbrmaterial.h
new file mode 100644 (file)
index 0000000..0002888
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef MSP_GL_PBRMATERIAL_H_
+#define MSP_GL_PBRMATERIAL_H_
+
+#include "material.h"
+
+namespace Msp {
+namespace GL {
+
+class PbrMaterial: public Material
+{
+public:
+       class Loader: public DataFile::DerivedObjectLoader<PbrMaterial, Material::LoaderBase<PbrMaterial> >
+       {
+       private:
+               static ActionMap shared_actions;
+
+       public:
+               Loader(PbrMaterial &);
+               Loader(PbrMaterial &, Collection &);
+
+       private:
+               virtual void init_actions();
+       };
+       
+private:
+       Property<Color> base_color;
+       Property<Vector3> normal;
+       Property<float> metalness;
+       Property<float> roughness;
+       Property<float> occlusion;
+       Property<Color> emission;
+       bool receive_shadows;
+
+public:
+       PbrMaterial();
+
+protected:
+       virtual std::string create_program_source() const;
+
+public:
+       virtual void attach_textures_to(Texturing &, ProgramData &) const;
+
+       void set_base_color(const Color &);
+       void set_base_color_map(const Texture *);
+       void set_normal_map(const Texture *);
+       void set_metalness(float);
+       void set_metalness_map(const Texture *);
+       void set_roughness(float);
+       void set_roughness_map(const Texture *);
+       void set_occlusion_map(const Texture *);
+       void set_emission(const Color &);
+       void set_emission_map(const Texture *);
+       void set_receive_shadows(bool);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif