The spica renderer
microfacet.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_MICROFACET_H_
6 #define _SPICA_MICROFACET_H_
7 
8 #include "core/common.h"
9 #include "core/core.hpp"
10 
11 namespace spica {
12 
16 class SPICA_EXPORTS MicrofacetDistribution {
17 public:
18  MicrofacetDistribution(double alphax, double alphay, bool sampleVisibleArea);
19  virtual ~MicrofacetDistribution();
20  virtual double D(const Vector3d& wh) const = 0;
21  virtual double lambda(const Vector3d& w) const = 0;
22  double G1(const Vector3d& w, const Vector3d &wh) const;
23  double G(const Vector3d& wo, const Vector3d& wi, const Vector3d &wh) const;
24 
26  virtual Vector3d sample(const Vector3d &wo, const Point2d& rands) const = 0;
27 
28  double pdf(const Vector3d& wo, const Vector3d& wh) const;
29  inline double alphax() const { return alphax_; }
30  inline double alphay() const { return alphay_; }
31 
32 protected:
33  const bool sampleVisibleArea_;
34  const double alphax_, alphay_;
35 };
36 
41 public:
42  TrowbridgeReitzDistribution(double alphax, double alphay,
43  bool samplevis = true);
44 
45  double D(const Vector3d& wh) const override;
46  Vector3d sample(const Vector3d& wo, const Point2d& rands) const override;
47 
48  static double roughnessToAlpha(double rough);
49 
50 private:
51  // Private methods
52  double lambda(const Vector3d& w) const override;
53 };
54 
58 class SPICA_EXPORTS BeckmannDistribution : public MicrofacetDistribution {
59 public:
60  BeckmannDistribution(double alphax, double alphay, bool sampleVis = true);
61 
62  double D(const Vector3d &wh) const override;
63  Vector3d sample(const Vector3d &wo, const Point2d &rands) const override;
64 
65  static double roughnessToAlpha(double rough);
66 
67 private:
68  // Private methods
69  double lambda(const Vector3d &w) const override;
70 };
71 
72 } // namespace spica
73 
74 #endif // _SPICA_MICROFACET_H_
The base class for microfacet distributions.
Definition: microfacet.h:16
Beckmann microfacet distribution.
Definition: microfacet.h:58
Trowbridge and Reitz's microfacet distribution (GGX)
Definition: microfacet.h:40