]> git.tdb.fi Git - libs/gl.git/blob - source/materials/pbrmaterial.h
dadda9b52358c0b029f46971fcf4d2da73d088f1
[libs/gl.git] / source / materials / pbrmaterial.h
1 #ifndef MSP_GL_PBRMATERIAL_H_
2 #define MSP_GL_PBRMATERIAL_H_
3
4 #include "material.h"
5
6 namespace Msp {
7 namespace GL {
8
9 class Texture2D;
10
11 class PbrMaterial: public Material
12 {
13 public:
14         class Loader: public DataFile::DerivedObjectLoader<PbrMaterial, Material::PropertyLoader<PbrMaterial> >
15         {
16         private:
17                 static ActionMap shared_actions;
18
19         public:
20                 Loader(PbrMaterial &);
21                 Loader(PbrMaterial &, Collection &);
22
23         private:
24                 virtual void init_actions();
25         };
26         
27 private:
28         Property<Color> base_color;
29         Property<Vector3> normal;
30         Property<float> metalness;
31         Property<float> roughness;
32         Property<float> occlusion;
33         Property<Color> emission;
34         const Texture2D &fresnel_lookup;
35
36         static const Tag texture_tags[];
37
38 public:
39         PbrMaterial();
40
41 private:
42         static const Texture2D &get_or_create_fresnel_lookup();
43
44 protected:
45         virtual void fill_program_info(std::string &, std::map<std::string, int> &) const;
46
47 public:
48         virtual const Tag *get_texture_tags() const { return texture_tags; }
49         virtual const Texture *get_texture(Tag) const;
50
51         void set_base_color(const Color &);
52         void set_base_color_map(const Texture *);
53         void set_normal_map(const Texture *);
54         void set_metalness(float);
55         void set_metalness_map(const Texture *);
56         void set_roughness(float);
57         void set_roughness_map(const Texture *);
58         void set_occlusion_map(const Texture *);
59         void set_emission(const Color &);
60         void set_emission_map(const Texture *);
61 };
62
63 } // namespace GL
64 } // namespace Msp
65
66 #endif