nuclear@2: #ifndef BRDF_H_ nuclear@2: #define BRDF_H_ nuclear@2: nuclear@2: #include nuclear@2: #include nuclear@2: #include "color.h" nuclear@2: #include "texture.h" nuclear@2: nuclear@2: class ReflAttrib { nuclear@2: private: nuclear@2: float value; nuclear@2: Color color; nuclear@2: Texture *map; nuclear@2: nuclear@2: public: nuclear@2: nuclear@2: ReflAttrib(); nuclear@2: explicit ReflAttrib(const Color &color, Texture *tex = 0); nuclear@2: nuclear@2: void set_value(float val); nuclear@2: void set_color(const Color &col); nuclear@2: nuclear@2: void set_map(Texture *tex); nuclear@2: Texture *get_map() const; nuclear@2: nuclear@2: float get_value() const; nuclear@2: float get_value(float u, float v) const; nuclear@2: const Color &get_color() const; nuclear@2: Color get_color(float u, float v) const; nuclear@2: }; nuclear@2: nuclear@2: nuclear@2: class Reflectance { nuclear@2: private: nuclear@2: static ReflAttrib def_attrib; nuclear@2: std::map attrib; nuclear@2: nuclear@2: virtual void set_default_attribs(); nuclear@2: nuclear@2: public: nuclear@2: Reflectance(); nuclear@2: virtual ~Reflectance() = default; nuclear@2: nuclear@2: virtual void set_attrib(const char *name, const Color &color, Texture *tex = 0); nuclear@2: virtual ReflAttrib &get_attrib(const char *name); nuclear@2: virtual const ReflAttrib &get_attrib(const char *name) const; nuclear@2: nuclear@2: virtual float get_attrib_value(const char *name) const; nuclear@2: virtual float get_attrib_value(const char *name, float u, float v) const; nuclear@2: virtual Color get_attrib_color(const char *name) const; nuclear@2: virtual Color get_attrib_color(const char *name, float u, float v) const; nuclear@2: nuclear@2: virtual Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const = 0; nuclear@2: virtual float sample(const Vector3 &norm, const Vector3 &outdir, Vector3 *indir) const; nuclear@2: virtual float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const = 0; nuclear@2: }; nuclear@2: nuclear@2: class LambertRefl : public Reflectance { nuclear@2: private: nuclear@2: void set_default_attribs() override; nuclear@2: nuclear@2: public: nuclear@2: Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const override; nuclear@2: float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const override; nuclear@2: }; nuclear@2: nuclear@2: #endif // BRDF_H_