]> git.tdb.fi Git - libs/gl.git/blob - source/materials/pbrmaterial.h
Check the flat qualifier from the correct member
[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 /**
12 A physically-based material using the Cook-Torrance BRDF.
13
14 The material is characterized by base color, metalness and roughness.  Fully
15 metallic materials have no diffuse reflection and their specular reflection is
16 tinted by the base color.  For fully dielectric materials base color determines
17 the color of the diffuse reflection; specular reflection is untinted.
18 Roughness affects how blurry specular reflections are.
19 */
20 class PbrMaterial: public Material
21 {
22 public:
23         class Loader: public DataFile::DerivedObjectLoader<PbrMaterial, Material::PropertyLoader<PbrMaterial> >
24         {
25         private:
26                 static ActionMap shared_actions;
27
28         public:
29                 Loader(PbrMaterial &, Collection &);
30
31         private:
32                 virtual void init_actions();
33         };
34         
35 private:
36         Property<Color> base_color;
37         Property<Vector3> normal;
38         Property<float> metalness;
39         Property<float> roughness;
40         Property<float> occlusion;
41         Property<Color> emission;
42         const Texture2D &fresnel_lookup;
43         const Sampler &fresnel_sampler;
44
45         static const Tag texture_tags[];
46
47 public:
48         PbrMaterial();
49
50 private:
51         static const Texture2D &get_or_create_fresnel_lookup();
52
53 protected:
54         virtual void fill_program_info(std::string &, std::map<std::string, int> &) const;
55
56 public:
57         virtual const Tag *get_texture_tags() const { return texture_tags; }
58         virtual const Texture *get_texture(Tag) const;
59         virtual const Sampler *get_sampler(Tag) const;
60
61         void set_base_color(const Color &);
62         void set_base_color_map(const Texture *);
63         void set_normal_map(const Texture *);
64         void set_metalness(float);
65         void set_metalness_map(const Texture *);
66         void set_roughness(float);
67         void set_roughness_map(const Texture *);
68         void set_occlusion_map(const Texture *);
69         void set_emission(const Color &);
70         void set_emission_map(const Texture *);
71 };
72
73 } // namespace GL
74 } // namespace Msp
75
76 #endif