Lightmetrica  0.0.1.50dbee3 (yosakoi)
 All Classes Functions Variables Typedefs Enumerations Enumerator
bpt.subpath.h
1 /*
2  Lightmetrica : A research-oriented renderer
3 
4  Copyright (c) 2014 Hisanari Otsu
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 #ifndef LIB_LIGHTMETRICA_BPT_SUBPATH_H
22 #define LIB_LIGHTMETRICA_BPT_SUBPATH_H
23 
24 #include "bpt.common.h"
25 #include "math.types.h"
26 #include "surfacegeometry.h"
27 #include "transportdirection.h"
28 #include "align.h"
29 #include <vector>
30 
31 LM_NAMESPACE_BEGIN
32 
33 class GeneralizedBSDF;
34 class Emitter;
35 class Light;
36 class Camera;
37 
42 enum class BPTPathVertexType
43 {
44  None,
45  EndPoint,
46  IntermediatePoint,
47 };
48 
55 {
56 public:
57 
58  LM_PUBLIC_API BPTPathVertex();
59 
60 private:
61 
62  LM_DISABLE_COPY_AND_MOVE(BPTPathVertex);
63 
64 public:
65 
72  bool Degenerated() const;
73 
78  void DebugPrint() const;
79 
80 public:
81 
82  // # General information
83  // --------------------------------------------------
84  BPTPathVertexType type;
86 
87  // # Variables associated with Emitter.
88  // \a type is EndPoint
89  // --------------------------------------------------
90  Math::PDFEval pdfP;
91  const Emitter* emitter;
92 
93  // # Variables associated with generalized BSDF.
94  // \a type is either EndPoint or IntermediatePoint
95  // --------------------------------------------------
96  Math::Vec3 weight[2];
97  Math::PDFEval pdfD[2];
98  Math::PDFEval pdfRR;
99  TransportDirection transportDir;
102  const Light* areaL;
103  const Camera* areaE;
104  Math::Vec3 wi;
105  Math::Vec3 wo;
106 
107 };
108 
109 class BPTPathVertexPool;
110 class Scene;
111 class Sampler;
112 
118 {
119 public:
120 
121  LM_PUBLIC_API BPTSubpath(TransportDirection transportDir);
122 
123 private:
124 
125  LM_DISABLE_COPY_AND_MOVE(BPTSubpath);
126 
127 public:
128 
133  LM_PUBLIC_API void Clear();
134 
139  LM_PUBLIC_API void DebugPrint() const;
140 
146  LM_PUBLIC_API void DebugPrint(size_t n) const;
147 
157  LM_PUBLIC_API void Sample(const Scene& scene, Sampler& sampler, BPTPathVertexPool& pool, int rrDepth, int maxPathVertices);
158 
166  Math::Vec3 EvaluateSubpathAlpha(int vs, Math::Vec2& rasterPosition) const;
167 
173  Math::Float SubpathSelectionProbability(int vs) const;
174 
180  LM_PUBLIC_API int NumVertices() const;
181 
188  LM_PUBLIC_API BPTPathVertex* Vertex(int i) const;
189 
190 public:
191 
192  TransportDirection transportDir;
193  std::vector<BPTPathVertex*> vertices;
194 
195 };
196 
197 LM_NAMESPACE_END
198 
199 #endif // LIB_LIGHTMETRICA_BPT_SUBPATH_H
LM_PUBLIC_API void DebugPrint() const
Definition: bpt.subpath.cpp:130
Definition: bpt.pool.h:34
BPTPathVertexType type
Vertex type.
Definition: bpt.subpath.h:84
Definition: align.h:84
Definition: generalizedbsdf.h:168
Definition: light.h:32
const Camera * areaE
Camera associated with surface.
Definition: bpt.subpath.h:103
Math::PDFEval pdfP
PDF evaluation for positional component.
Definition: bpt.subpath.h:90
LM_PUBLIC_API void Clear()
Definition: bpt.subpath.cpp:125
bool Degenerated() const
Definition: bpt.subpath.cpp:48
LM_PUBLIC_API BPTPathVertex * Vertex(int i) const
Definition: bpt.subpath.cpp:150
Definition: camera.h:35
const Light * areaL
Light associated with surface.
Definition: bpt.subpath.h:102
LM_PUBLIC_API void Sample(const Scene &scene, Sampler &sampler, BPTPathVertexPool &pool, int rrDepth, int maxPathVertices)
Definition: bpt.subpath.cpp:155
SurfaceGeometry geom
Surface geometry information.
Definition: bpt.subpath.h:85
Math::Vec3 weight[2]
Value of f_s / p_{^} for each transport direction.
Definition: bpt.subpath.h:96
Definition: scene.h:47
LM_PUBLIC_API int NumVertices() const
Definition: bpt.subpath.cpp:145
Definition: sampler.h:37
Math::PDFEval pdfD[2]
PDF evaluation for directional component for each transport direction.
Definition: bpt.subpath.h:97
Definition: surfacegeometry.h:36
Math::Float SubpathSelectionProbability(int vs) const
Definition: bpt.subpath.cpp:386
Math::Vec3 wi
Incoming ray direction.
Definition: bpt.subpath.h:104
Math::Vec3 wo
Outgoing ray direction.
Definition: bpt.subpath.h:105
const GeneralizedBSDF * bsdf
Generalized BSDF (note that BSDF and light or camera can point to different instances).
Definition: bpt.subpath.h:101
Definition: bpt.subpath.h:54
int componentType
Sampled component type.
Definition: bpt.subpath.h:100
TransportDirection transportDir
Transport direction.
Definition: bpt.subpath.h:99
Math::Vec3 EvaluateSubpathAlpha(int vs, Math::Vec2 &rasterPosition) const
Definition: bpt.subpath.cpp:337
Definition: bpt.subpath.h:117
const Emitter * emitter
Emitter. The entry is required because of area light or camera.
Definition: bpt.subpath.h:91
Math::PDFEval pdfRR
PDF evaluation for Russian roulette.
Definition: bpt.subpath.h:98
void DebugPrint() const
Definition: bpt.subpath.cpp:53
Definition: emitter.h:38