The spica renderer
photon_map.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_PHOTON_MAP_H_
6 #define _SPICA_PHOTON_MAP_H_
7 
8 #include "core/common.h"
9 
10 #include "core/spectrum.h"
11 #include "core/kdtree.h"
12 #include "core/uncopyable.h"
13 #include "core/stack.h"
14 
15 #include "core/vector3d.h"
16 #include "core/point3d.h"
17 #include "core/normal3d.h"
18 #include "core/random.h"
19 
20 namespace spica {
21 
22 // ------------------------------------------------------------------------
23 // Photon
24 // ------------------------------------------------------------------------
25 class SPICA_EXPORTS Photon {
26 public:
27  Photon();
28  Photon(const Point3d& pos, const Spectrum& beta,
29  const Vector3d& wi, const Normal3d& normal);
30  Photon(const Photon& photon);
31  ~Photon();
32 
33  Photon& operator=(const Photon& photon);
34  double operator[](int i) const;
35 
36  static double distance(const Photon& p1, const Photon& p2);
37 
38  inline Point3d pos() const { return pos_; }
39  inline Spectrum beta() const { return beta_; }
40  inline Vector3d wi() const { return wi_; }
41  inline Normal3d normal() const { return normal_; }
42  inline const Material* const material() const { return material_; }
43 
44 private:
45  Point3d pos_;
46  Spectrum beta_;
47  Vector3d wi_;
48  Normal3d normal_;
49  const Material* material_;
50 };
51 
52 // ------------------------------------------------------------------------
53 // Photon map
54 // ------------------------------------------------------------------------
55 class SPICA_EXPORTS PhotonMap : public Uncopyable {
56 public:
57  // Public methods
58  PhotonMap();
59  virtual ~PhotonMap();
60 
61  void clear();
62  virtual void construct(const Scene& scene,
63  RenderParams& params,
64  Sampler &sampler);
65 
69  virtual Spectrum evaluateL(const SurfaceInteraction& po,
70  int gatherPhotons, double gatherRadius) const;
71 
72  virtual Spectrum evaluateL(const MediumInteraction& mi,
73  int gatherPhotons, double gatherRadius) const;
74 
75 protected:
76  // Protected methods
77  void knnFind(const Photon& photon, std::vector<Photon>* photons,
78  int gatherPhotons, double gatherRadius) const;
79 
80  void tracePhoton(const Scene& scene,
81  RenderParams& params,
82  const Ray& r,
83  const Spectrum& b,
84  Sampler& sampler,
85  MemoryArena& arena,
86  std::vector<Photon>* photons);
87 
88  // Protected fields
89  KdTree<Photon> _kdtree;
90 };
91 
92 } // namespace spica
93 
94 #endif // _SPICA_PHOTON_MAP_H_
Definition: photon_map.h:55
Definition: interaction.h:68
Definition: kdtree.h:28
Random sampler class.
Definition: sampler.h:24
RGB spectrum.
Definition: spectrum.h:18
Ray class.
Definition: ray.h:24
Definition: renderparams.h:27
Definition: photon_map.h:25
Definition: interaction.h:126
Interface class which forbids copy and assignment.
Definition: uncopyable.h:15
Scene provides the interface for scene graph.
Definition: scene.h:23
Definition: material.h:30