The spica renderer
bsdf.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_BSDF_H_
6 #define _SPICA_BSDF_H_
7 
8 #include <array>
9 
10 #include "core/core.hpp"
11 #include "core/common.h"
12 #include "core/vector3d.h"
13 #include "core/normal3d.h"
14 
15 #include "core/render.hpp"
16 #include "core/bxdf.h"
17 
18 namespace spica {
19 
20 class SPICA_EXPORTS BSDF {
21 public:
22  // Public methods
23  BSDF(const SurfaceInteraction& isect, double eta = 1.0);
24 
25  void add(BxDF* b);
26  int numComponents(BxDFType type = BxDFType::All) const;
27 
28  Spectrum f(const Vector3d& woWorld, const Vector3d& wiWorld,
29  BxDFType type = BxDFType::All) const;
30 
31  Spectrum sample(const Vector3d& woWorld, Vector3d* wiWorld, const Point2d& rands,
32  double* pdf, BxDFType type = BxDFType::All,
33  BxDFType* sampledType = nullptr) const;
34  double pdf(const Vector3d& wo, const Vector3d& wi,
35  BxDFType type = BxDFType::All) const;
36 
37  bool hasType(BxDFType type) const;
38 
39  inline double eta() const { return eta_; }
40 
41 private:
42  // Private methods
43  Vector3d worldToLocal(const Vector3d& v) const;
44  Vector3d localToWorld(const Vector3d& v) const;
45 
46  // Private fields
47  const double eta_;
48  const Normal3d normal_;
49  const Vector3d tangent_, binormal_;
50  int nBxDFs_ = 0;
51  static constexpr int maxBxDFs_ = 8;
52  std::array<BxDF*, maxBxDFs_> bxdfs_;
53 
54 }; // class BSDF
55 
56 } // namespace spica
57 
58 #endif // _SPICA_BSDF_H_
Definition: interaction.h:68
RGB spectrum.
Definition: spectrum.h:18
The base class of BxDFs.
Definition: bxdf.h:45
Definition: bsdf.h:20