erebus

annotate liberebus/src/brdf.h @ 0:4abdce1361b9

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