erebus

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