erebus

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/liberebus/src/brdf.h	Sun Apr 27 16:02:47 2014 +0300
     1.3 @@ -0,0 +1,67 @@
     1.4 +#ifndef BRDF_H_
     1.5 +#define BRDF_H_
     1.6 +
     1.7 +#include <map>
     1.8 +#include <string>
     1.9 +#include "color.h"
    1.10 +#include "texture.h"
    1.11 +
    1.12 +class ReflAttrib {
    1.13 +private:
    1.14 +	float value;
    1.15 +	Color color;
    1.16 +	Texture *map;
    1.17 +
    1.18 +public:
    1.19 +
    1.20 +	ReflAttrib();
    1.21 +	explicit ReflAttrib(const Color &color, Texture *tex = 0);
    1.22 +
    1.23 +	void set_value(float val);
    1.24 +	void set_color(const Color &col);
    1.25 +
    1.26 +	void set_map(Texture *tex);
    1.27 +	Texture *get_map() const;
    1.28 +
    1.29 +	float get_value() const;
    1.30 +	float get_value(float u, float v) const;
    1.31 +	const Color &get_color() const;
    1.32 +	Color get_color(float u, float v) const;
    1.33 +};
    1.34 +
    1.35 +
    1.36 +class Reflectance {
    1.37 +private:
    1.38 +	static ReflAttrib def_attrib;
    1.39 +	std::map<std::string, ReflAttrib> attrib;
    1.40 +
    1.41 +	virtual void set_default_attribs();
    1.42 +
    1.43 +public:
    1.44 +	Reflectance();
    1.45 +	virtual ~Reflectance() = default;
    1.46 +
    1.47 +	virtual void set_attrib(const char *name, const Color &color, Texture *tex = 0);
    1.48 +	virtual ReflAttrib &get_attrib(const char *name);
    1.49 +	virtual const ReflAttrib &get_attrib(const char *name) const;
    1.50 +
    1.51 +	virtual float get_attrib_value(const char *name) const;
    1.52 +	virtual float get_attrib_value(const char *name, float u, float v) const;
    1.53 +	virtual Color get_attrib_color(const char *name) const;
    1.54 +	virtual Color get_attrib_color(const char *name, float u, float v) const;
    1.55 +
    1.56 +	virtual Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const = 0;
    1.57 +	virtual float sample(const Vector3 &norm, const Vector3 &outdir, Vector3 *indir) const;
    1.58 +	virtual float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const = 0;
    1.59 +};
    1.60 +
    1.61 +class LambertRefl : public Reflectance {
    1.62 +private:
    1.63 +	void set_default_attribs() override;
    1.64 +
    1.65 +public:
    1.66 +	Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const override;
    1.67 +	float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const override;
    1.68 +};
    1.69 +
    1.70 +#endif	// BRDF_H_
    1.71 \ No newline at end of file