Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
BsdfEvalQuery.h
Go to the documentation of this file.
1#pragma once
2
5#include "Math/TVector3.h"
6#include "Core/SurfaceHit.h"
9
10#include <Common/assertion.h>
11
12#include <utility>
13
14namespace ph
15{
16
19class BsdfEvalInput final
20{
21public:
22 void set(const BsdfSampleQuery& sample);
23 void set(const BsdfSampleInput& sampleInput, const BsdfSampleOutput& sampleOutput);
24
25 void set(
26 const SurfaceHit& X,
27 const math::Vector3R& L,
28 const math::Vector3R& V);
29
30 const SurfaceHit& getX() const;
31 const math::Vector3R& getL() const;
32 const math::Vector3R& getV() const;
33
34private:
35 SurfaceHit m_X;
38#if PH_DEBUG
39 bool m_hasSet{false};
40#endif
41};
42
47{
48public:
53 void setBsdf(
54 const math::Spectrum& bsdf,
55 bool inferMeasurability = true);
56
60 const math::Spectrum& getBsdf() const;
61
68 bool isMeasurable() const;
69
72 void setMeasurability(bool measurability);
73
76 void setMeasurability(const math::Spectrum& reference);
77
80 operator bool () const;
81
82private:
83 math::Spectrum m_bsdf{0};
84 bool m_isMeasurable{false};
85};
86
102
103// In-header Implementations:
104
106 : BsdfEvalQuery()
107{
108 this->context = std::move(context);
109
110 // (rest of the fields are initialized via setters)
111}
112
114 const SurfaceHit& X,
115 const math::Vector3R& L,
116 const math::Vector3R& V)
117{
118 // Not querying from uninitialized surface hit
120
121 PH_ASSERT_IN_RANGE(L.lengthSquared(), 0.9_r, 1.1_r);
122 PH_ASSERT_IN_RANGE(V.lengthSquared(), 0.9_r, 1.1_r);
123
124 m_X = X;
125 m_L = L;
126 m_V = V;
127
128#if PH_DEBUG
129 m_hasSet = true;
130#endif
131}
132
133inline const SurfaceHit& BsdfEvalInput::getX() const
134{
135 PH_ASSERT(m_hasSet);
136
137 return m_X;
138}
139
141{
142 PH_ASSERT(m_hasSet);
143
144 return m_L;
145}
146
148{
149 PH_ASSERT(m_hasSet);
150
151 return m_V;
152}
153
155 const math::Spectrum& bsdf,
156 const bool inferMeasurabilityFromThis)
157{
158 m_bsdf = bsdf;
159
160 if(inferMeasurabilityFromThis)
161 {
162 setMeasurability(bsdf);
163 }
164}
165
167{
168 // When an evaluation report being measurable, it must not be some crazy values
169 PH_ASSERT(m_isMeasurable);
170 PH_ASSERT_MSG(m_bsdf.isFinite(), m_bsdf.toString());
171
172 return m_bsdf;
173}
174
176{
177 return m_isMeasurable;
178}
179
180inline void BsdfEvalOutput::setMeasurability(const bool measurability)
181{
182 m_isMeasurable = measurability;
183}
184
186{
187 setMeasurability(reference.isFinite());
188}
189
190inline BsdfEvalOutput::operator bool () const
191{
192 return isMeasurable();
193}
194
195}// end namespace ph
Input for BsdfEvalQuery.
Definition BsdfEvalQuery.h:20
void set(const BsdfSampleQuery &sample)
Definition BsdfEvalQuery.cpp:7
const SurfaceHit & getX() const
Definition BsdfEvalQuery.h:133
const math::Vector3R & getV() const
Definition BsdfEvalQuery.h:147
const math::Vector3R & getL() const
Definition BsdfEvalQuery.h:140
Output for BsdfEvalQuery.
Definition BsdfEvalQuery.h:47
void setMeasurability(bool measurability)
Set measurability directly.
Definition BsdfEvalQuery.h:180
const math::Spectrum & getBsdf() const
Definition BsdfEvalQuery.h:166
bool isMeasurable() const
Tells whether this evaluation has potential to contribute. All evaluated data should be usable if tru...
Definition BsdfEvalQuery.h:175
void setBsdf(const math::Spectrum &bsdf, bool inferMeasurability=true)
Definition BsdfEvalQuery.h:154
Information for obtaining a sample value from BSDF.
Definition BsdfEvalQuery.h:90
BsdfEvalQuery()=default
Input inputs
Definition BsdfEvalQuery.h:96
Output outputs
Definition BsdfEvalQuery.h:97
BsdfQueryContext context
Definition BsdfEvalQuery.h:95
The environment a BSDF query is performed under.
Definition BsdfQueryContext.h:13
Input for BsdfSampleQuery.
Definition BsdfSampleQuery.h:21
Output for BsdfSampleQuery.
Definition BsdfSampleQuery.h:45
Information for generating a BSDF sample.
Definition BsdfSampleQuery.h:141
General information about a ray-surface intersection event.
Definition SurfaceHit.h:59
SurfaceHitReason getReason() const
Definition SurfaceHit.h:164
constexpr bool hasExactly(const FlagsSet &flagsSet) const
Checks whether this instance contains exactly the specified flags. No more, no less.
Definition TBitFlags.ipp:99
std::string toString() const
Definition TArithmeticArrayBase.ipp:825
bool isFinite() const
Definition TArithmeticArrayBase.ipp:585
Definition TTristimulusSpectrum.h:11
T lengthSquared() const
Definition TVectorNBase.ipp:44
The root for all renderer implementations.
Definition EEngineProject.h:6