The spica renderer
sppm.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_SPPM_H_
6 #define _SPICA_SPPM_H_
7 
8 #include "core/common.h"
9 #include "core/cobject.h"
10 #include "core/hash_grid.h"
11 #include "core/render.hpp"
12 #include "core/integrator.h"
13 
14 namespace spica {
15 
19 class SPICA_EXPORTS SPPMIntegrator : public Integrator {
20 public:
21  // Public methods
22  SPPMIntegrator(const std::shared_ptr<Sampler>& sampler);
23 
25 
26  ~SPPMIntegrator();
27 
28  void render(const std::shared_ptr<const Camera>& camera,
29  const Scene& scene,
30  RenderParams& params) override;
31 
32 private:
33  // Private internal class
34  struct SPPMPixel;
35 
36  // 1st pass: Trace rays from camera
37  void traceRays(const std::shared_ptr<const Camera> &camera,
38  const Scene& scene,
39  RenderParams& params,
40  const std::vector<std::unique_ptr<Sampler>>& samplers,
41  std::vector<MemoryArena>& arenas,
42  std::vector<SPPMPixel>& hpoints) const;
43 
44  // 2nd pass: Trace photons from lights
45  void tracePhotons(const Scene& scene,
46  RenderParams& params,
47  const std::vector<std::unique_ptr<Sampler>>& samplers,
48  std::vector<MemoryArena>& arenas,
49  const Distribution1D& lightDistrib,
50  const int numPhotons) const;
51 
52  void tracePhotonsSub(const Scene& scene,
53  RenderParams& params,
54  const Ray& r,
55  const Spectrum& b,
56  Sampler& sampler,
57  MemoryArena& arena) const;
58 
59  void pathTrace(const Scene& scene,
60  RenderParams& params,
61  const Ray& ray,
62  Sampler& sampler,
63  MemoryArena& arena,
64  SPPMPixel* hp) const;
65 
66  void constructHashGrid(std::vector<SPPMPixel>& hpoints,
67  int imageW, int imageH) const;
68 
69  // Private fields
70  std::shared_ptr<Sampler> sampler_;
71  mutable HashGrid<SPPMPixel*> hashgrid_;
72  static const double kAlpha_;
73 
74 }; // class SPPMIntegrator
75 
76 SPICA_EXPORT_PLUGIN(SPPMIntegrator, "Stochastic progressive photon mapping");
77 
78 } // namespace spica
79 
80 #endif // _SPICA_SPPM_H_
Definition: sppm.cc:27
Random sampler class.
Definition: sampler.h:24
RGB spectrum.
Definition: spectrum.h:18
The integrator interface.
Definition: integrator.h:29
Ray class.
Definition: ray.h:24
Definition: renderparams.h:27
Stochastic progressive photon mapping.
Definition: sppm.h:19
Definition: hash_grid.h:12
Scene provides the interface for scene graph.
Definition: scene.h:23
Definition: sampling.h:17