erebus

annotate liberebus/src/brdf.h @ 21:e49f4d7ad04c

started adding BRDFs
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 28 May 2014 07:06:29 +0300
parents 93894c232d65
children 4a0a288ffb27
rev   line source
nuclear@2 1 #ifndef BRDF_H_
nuclear@2 2 #define BRDF_H_
nuclear@2 3
nuclear@21 4 #include <vector>
nuclear@2 5 #include "texture.h"
nuclear@2 6
nuclear@2 7 class Reflectance {
nuclear@2 8 public:
nuclear@2 9 Reflectance();
nuclear@2 10 virtual ~Reflectance() = default;
nuclear@2 11
nuclear@2 12 virtual Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const = 0;
nuclear@2 13 virtual float sample(const Vector3 &norm, const Vector3 &outdir, Vector3 *indir) const;
nuclear@2 14 virtual float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const = 0;
nuclear@2 15 };
nuclear@2 16
nuclear@21 17 typedef float (*CompReflWeightFunc)(const Vector3 &norm, const Vector3 &outdir);
nuclear@21 18
nuclear@21 19 class CompositeRefl : public Reflectance {
nuclear@21 20 private:
nuclear@21 21 struct SubRefl {
nuclear@21 22 Reflectance *brdf;
nuclear@21 23 float weight;
nuclear@21 24 CompReflWeightFunc weight_func; // if null, use static weight above
nuclear@21 25 };
nuclear@21 26 std::vector<SubRefl> sub_brdf;
nuclear@21 27 mutable bool valid_checked;
nuclear@21 28
nuclear@21 29 int pick_brdf(const Vector3 &norm, const Vector3 &outdir) const;
nuclear@21 30
nuclear@21 31 public:
nuclear@21 32 CompositeRefl();
nuclear@21 33
nuclear@21 34 virtual void add_brdf(Reflectance *brdf, float weight);
nuclear@21 35 virtual void add_brdf(Reflectance *brdf, CompReflWeightFunc weight_func);
nuclear@21 36
nuclear@21 37 bool check_valid() const;
nuclear@21 38
nuclear@21 39 Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const override;
nuclear@21 40 float sample(const Vector3 &norm, const Vector3 &outdir, Vector3 *indir) const override;
nuclear@21 41 float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const override;
nuclear@21 42 };
nuclear@21 43
nuclear@2 44 class LambertRefl : public Reflectance {
nuclear@2 45 public:
nuclear@2 46 Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const override;
nuclear@2 47 float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const override;
nuclear@2 48 };
nuclear@2 49
nuclear@21 50 class MirrorRefl : public Reflectance {
nuclear@21 51 public:
nuclear@21 52 Vector3 sample_dir(const Vector3 &norm, const Vector3 &outdir) const override;
nuclear@21 53 float eval(const Vector3 &norm, const Vector3 &outdir, const Vector3 &indir) const override;
nuclear@21 54 };
nuclear@21 55
nuclear@2 56 #endif // BRDF_H_