Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
BsdfPdfQuery.h
Go to the documentation of this file.
1#pragma once
2
5#include "Math/TVector3.h"
6#include "Core/SurfaceHit.h"
7#include "Core/LTA/PDF.h"
8
9#include <Common/assertion.h>
10
11#include <string>
12
13namespace ph
14{
15
18class BsdfPdfInput final
19{
20public:
21 void set(const BsdfEvalInput& evalInput);
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
45class BsdfPdfOutput final
46{
47public:
48 void setSampleDirPdf(const lta::PDF& pdf);
49
50 real getSampleDirPdfW() const;
51
55 const lta::PDF& getSampleDirPdf() const;
56
57 operator bool () const;
58
59private:
60 lta::PDF m_sampleDirPdf{};
61};
62
78
79// In-header Implementations:
80
82 : BsdfPdfQuery()
83{
84 this->context = std::move(context);
85
86 // (rest of the fields are initialized via setters)
87}
88
90 const SurfaceHit& X,
91 const math::Vector3R& L,
92 const math::Vector3R& V)
93{
94 // Not querying from uninitialized surface hit
96
97 PH_ASSERT_IN_RANGE(L.lengthSquared(), 0.9_r, 1.1_r);
98 PH_ASSERT_IN_RANGE(V.lengthSquared(), 0.9_r, 1.1_r);
99
100 m_X = X;
101 m_L = L;
102 m_V = V;
103
104#if PH_DEBUG
105 m_hasSet = true;
106#endif
107}
108
109inline const SurfaceHit& BsdfPdfInput::getX() const
110{
111 PH_ASSERT(m_hasSet);
112
113 return m_X;
114}
115
117{
118 PH_ASSERT(m_hasSet);
119
120 return m_L;
121}
122
124{
125 PH_ASSERT(m_hasSet);
126
127 return m_V;
128}
129
131{
132 m_sampleDirPdf = pdf;
133}
134
136{
137 return getSampleDirPdf().getPdfW();
138}
139
141{
142 PH_ASSERT(*this);
143
144 return m_sampleDirPdf;
145}
146
147inline BsdfPdfOutput::operator bool () const
148{
149 return m_sampleDirPdf;
150}
151
152}// end namespace ph
Input for BsdfEvalQuery.
Definition BsdfEvalQuery.h:20
Input for BsdfPdfQuery.
Definition BsdfPdfQuery.h:19
void set(const BsdfEvalInput &evalInput)
Definition BsdfPdfQuery.cpp:8
const math::Vector3R & getV() const
Definition BsdfPdfQuery.h:123
const SurfaceHit & getX() const
Definition BsdfPdfQuery.h:109
const math::Vector3R & getL() const
Definition BsdfPdfQuery.h:116
Output for BsdfPdfQuery.
Definition BsdfPdfQuery.h:46
void setSampleDirPdf(const lta::PDF &pdf)
Definition BsdfPdfQuery.h:130
real getSampleDirPdfW() const
Definition BsdfPdfQuery.h:135
const lta::PDF & getSampleDirPdf() const
Definition BsdfPdfQuery.h:140
Information for the probability of generating a specific BSDF sample.
Definition BsdfPdfQuery.h:66
BsdfPdfQuery()=default
Output outputs
Definition BsdfPdfQuery.h:73
Input inputs
Definition BsdfPdfQuery.h:72
BsdfQueryContext context
Definition BsdfPdfQuery.h:71
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
A sample from a Probability Density Function (PDF).
Definition PDF.h:14
real getPdfW() const
Definition PDF.h:87
T lengthSquared() const
Definition TVectorNBase.ipp:44
The root for all renderer implementations.
Definition EEngineProject.h:6