erebus

view liberebus/src/brdf.h @ 2:474a0244f57d

fixed specialization mistake fixed line endings added makefiles
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 28 Apr 2014 06:31:10 +0300
parents 4abdce1361b9
children 93894c232d65
line source
1 #ifndef BRDF_H_
2 #define BRDF_H_
4 #include <map>
5 #include <string>
6 #include "color.h"
7 #include "texture.h"
9 class ReflAttrib {
10 private:
11 float value;
12 Color color;
13 Texture *map;
15 public:
17 ReflAttrib();
18 explicit ReflAttrib(const Color &color, Texture *tex = 0);
20 void set_value(float val);
21 void set_color(const Color &col);
23 void set_map(Texture *tex);
24 Texture *get_map() const;
26 float get_value() const;
27 float get_value(float u, float v) const;
28 const Color &get_color() const;
29 Color get_color(float u, float v) const;
30 };
33 class Reflectance {
34 private:
35 static ReflAttrib def_attrib;
36 std::map<std::string, ReflAttrib> attrib;
38 virtual void set_default_attribs();
40 public:
41 Reflectance();
42 virtual ~Reflectance() = default;
44 virtual void set_attrib(const char *name, const Color &color, Texture *tex = 0);
45 virtual ReflAttrib &get_attrib(const char *name);
46 virtual const ReflAttrib &get_attrib(const char *name) const;
48 virtual float get_attrib_value(const char *name) const;
49 virtual float get_attrib_value(const char *name, float u, float v) const;
50 virtual Color get_attrib_color(const char *name) const;
51 virtual Color get_attrib_color(const char *name, float u, float v) const;
53 virtual Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const = 0;
54 virtual float sample(const Vector3 &norm, const Vector3 &outdir, Vector3 *indir) const;
55 virtual float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const = 0;
56 };
58 class LambertRefl : public Reflectance {
59 private:
60 void set_default_attribs() override;
62 public:
63 Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const override;
64 float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const override;
65 };
67 #endif // BRDF_H_