Lightmetrica  0.0.1.50dbee3 (yosakoi)
 All Classes Functions Variables Typedefs Enumerations Enumerator
generalizedbsdf.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_GENERALIZED_BSDF_H
22 #define LIB_LIGHTMETRICA_GENERALIZED_BSDF_H
23 
24 #include "asset.h"
25 #include "math.types.h"
26 #include "transportdirection.h"
27 
28 LM_NAMESPACE_BEGIN
29 
34 enum GeneralizedBSDFType
35 {
36 
37  // Uninitialized value
38  None = 0,
39 
40  // Primitive BSDF types
41  DiffuseReflection = 1<<0,
42  DiffuseTransmission = 1<<1,
43  SpecularReflection = 1<<2,
44  SpecularTransmission = 1<<3,
45  GlossyReflection = 1<<4,
46  GlossyTransmission = 1<<5,
47 
48  // Emitter primitive types
49  DeltaLightDirection = 1<<6,
50  NonDeltaLightDirection = 1<<7,
51  DeltaEyeDirection = 1<<8,
52  NonDeltaEyeDirection = 1<<9,
53 
54  // Material type flags for BSDF types
55  Diffuse = DiffuseReflection | DiffuseTransmission,
56  Specular = SpecularReflection | SpecularTransmission,
57  Glossy = GlossyReflection | GlossyTransmission,
58  Reflection = DiffuseReflection | SpecularReflection | GlossyReflection,
59  Transmission = DiffuseTransmission | SpecularTransmission | GlossyTransmission,
60 
61  // Emitter type flags
62  LightDirection = DeltaLightDirection | NonDeltaLightDirection,
63  EyeDirection = DeltaEyeDirection | NonDeltaEyeDirection,
64 
65  // Useful type flags
66  AllEmitter = LightDirection | EyeDirection,
67  AllBSDF = Diffuse | Specular | Glossy,
68  All = AllEmitter | AllBSDF,
69 
70  // Delta or non-delta
71  Delta = Specular | DeltaLightDirection | DeltaEyeDirection,
72  NonDelta = All & ~Delta
73 
74 };
75 
81 {
82 
83  int type;
84  Math::Vec2 sample;
85  Math::Float uComp;
86  TransportDirection transportDir;
87  Math::Vec3 wi;
88 
89 };
90 
96 {
97 
99  Math::Vec3 wo;
100  Math::PDFEval pdf;
101 
102 };
103 
109 {
110 
112  Math::Vec3 wo;
113  Math::Vec3 weight[2];
114  Math::PDFEval pdf[2];
115 
116 };
117 
123 {
124 
125  int type;
126  TransportDirection transportDir;
127  Math::Vec3 wi;
128  Math::Vec3 wo;
129  bool forced;
130 
131 public:
132 
134  {
135 
136  }
137 
139  : type(result.sampledType)
140  , transportDir(query.transportDir)
141  , wi(query.wi)
142  , wo(result.wo)
143  , forced(false)
144  {
145 
146  }
147 
148  GeneralizedBSDFEvaluateQuery(int type, TransportDirection transportDir, const Math::Vec3& wi, const Math::Vec3& wo)
149  : type(type)
150  , transportDir(transportDir)
151  , wi(wi)
152  , wo(wo)
153  , forced(false)
154  {
155 
156  }
157 
158 };
159 
160 struct SurfaceGeometry;
161 
168 class GeneralizedBSDF : public Asset
169 {
170 public:
171 
172  GeneralizedBSDF() {}
173  virtual ~GeneralizedBSDF() {}
174 
175 public:
176 
187  virtual bool SampleDirection(const GeneralizedBSDFSampleQuery& query, const SurfaceGeometry& geom, GeneralizedBSDFSampleResult& result) const = 0;
188 
197  virtual Math::Vec3 SampleAndEstimateDirection(const GeneralizedBSDFSampleQuery& query, const SurfaceGeometry& geom, GeneralizedBSDFSampleResult& result) const = 0;
198 
210  virtual bool SampleAndEstimateDirectionBidir(const GeneralizedBSDFSampleQuery& query, const SurfaceGeometry& geom, GeneralizedBSDFSampleBidirResult& result) const = 0;
211 
218  virtual Math::Vec3 EvaluateDirection(const GeneralizedBSDFEvaluateQuery& query, const SurfaceGeometry& geom) const = 0;
219 
226  virtual Math::PDFEval EvaluateDirectionPDF(const GeneralizedBSDFEvaluateQuery& query, const SurfaceGeometry& geom) const = 0;
227 
234  //virtual bool Degenerated() const = 0;
235 
236  //virtual bool Connectable() const = 0;
237 
244  virtual int BSDFTypes() const = 0;
245 
246 };
247 
248 LM_NAMESPACE_END
249 
250 #endif // LIB_LIGHTMETRICA_GENERALIZED_BSDF_H
Math::Vec3 wo
Sampled outgoing direction in world coordinates.
Definition: generalizedbsdf.h:112
Math::Vec3 wo
Outgoing direction in shading coordinates.
Definition: generalizedbsdf.h:128
Definition: generalizedbsdf.h:168
virtual Math::Vec3 EvaluateDirection(const GeneralizedBSDFEvaluateQuery &query, const SurfaceGeometry &geom) const =0
Definition: generalizedbsdf.h:80
Math::Vec3 wi
Input direction in world coordinates.
Definition: generalizedbsdf.h:87
Math::Vec3 weight[2]
Evaluated weights.
Definition: generalizedbsdf.h:113
Math::PDFEval pdf[2]
Evaluated PDFs.
Definition: generalizedbsdf.h:114
Math::PDFEval pdf
Evaluated PDF. We note that some BSDFs, the PDF cannot be explicitly evaluated.
Definition: generalizedbsdf.h:100
TransportDirection transportDir
Transport direction.
Definition: generalizedbsdf.h:126
virtual bool SampleAndEstimateDirectionBidir(const GeneralizedBSDFSampleQuery &query, const SurfaceGeometry &geom, GeneralizedBSDFSampleBidirResult &result) const =0
virtual bool SampleDirection(const GeneralizedBSDFSampleQuery &query, const SurfaceGeometry &geom, GeneralizedBSDFSampleResult &result) const =0
virtual Math::Vec3 SampleAndEstimateDirection(const GeneralizedBSDFSampleQuery &query, const SurfaceGeometry &geom, GeneralizedBSDFSampleResult &result) const =0
Math::Float uComp
Uniform random number for component selection.
Definition: generalizedbsdf.h:85
Definition: generalizedbsdf.h:95
Definition: surfacegeometry.h:36
int type
Requested BSDF type(s).
Definition: generalizedbsdf.h:83
virtual Math::PDFEval EvaluateDirectionPDF(const GeneralizedBSDFEvaluateQuery &query, const SurfaceGeometry &geom) const =0
Math::Vec2 sample
Uniform random numbers for sampling BSDF.
Definition: generalizedbsdf.h:84
int sampledType
Sampled BSDF type.
Definition: generalizedbsdf.h:98
Definition: asset.h:35
virtual int BSDFTypes() const =0
Math::Vec3 wo
Sampled outgoing direction in world coordinates.
Definition: generalizedbsdf.h:99
int type
Requested BSDF type.
Definition: generalizedbsdf.h:125
Math::Vec3 wi
Input direction in shading coordinates.
Definition: generalizedbsdf.h:127
bool forced
Forces to evaluate values regardless of wi or wo. This is valid only when type is Specular...
Definition: generalizedbsdf.h:129
Definition: generalizedbsdf.h:108
int sampledType
Sampled BSDF type.
Definition: generalizedbsdf.h:111
Definition: generalizedbsdf.h:122
TransportDirection transportDir
Transport direction.
Definition: generalizedbsdf.h:86