23#include <Common/assertion.h>
31template<ES
idednessPolicy POLICY>
38template<ES
idednessPolicy POLICY>
43 std::optional<SurfaceHit>*
const out_X)
const
64 if(out_Le) { *out_Le = Le; }
65 if(out_X) { *out_X = foundNextX ? std::make_optional(nextX) : std::nullopt; }
70template<ES
idednessPolicy POLICY>
76 PH_ASSERT(isNeeSamplable(directSample.
inputs.
getX()));
82 getScene().genDirectSample(directSample, sampleFlow, probe);
91 if(!optVisibilityRay || getScene().isOccluding(*optVisibilityRay))
96 PH_ASSERT_IN_RANGE(optVisibilityRay->getDir().lengthSquared(), 0.9_r, 1.1_r);
99 if(out_Xe) { *out_Xe = Xe; }
104template<ES
idednessPolicy POLICY>
109 std::optional<SurfaceHit>*
const out_X)
const
121 std::optional<SurfaceHit> nextX;
122 if(bsdfSampleEmission(bsdfSample, sampleFlow, &bsdfLe, &nextX) &&
136 if(isNeeSamplable(X) && nextX->getSurfaceEmitter())
139 const real neePdfW = neeSamplePdfWUnoccluded(X, *nextX);
142 bsdfPdfQuery.inputs.set(bsdfSample);
147 if(bsdfPdfQuery.outputs)
149 const real bsdfSamplePdfW = bsdfPdfQuery.outputs.getSampleDirPdfW();
150 const real misWeighting = MIS{}.weight(bsdfSamplePdfW, neePdfW);
157 sampledLo += bsdfLe * weight;
163 sampledLo += bsdfLe * pdfAppliedBsdfCos;
169 if(out_X) { *out_X = nextX; }
173 if(isNeeSamplable(X))
177 if(neeSampleEmission(directSample, sampleFlow) &&
190 if(bsdfEval.outputs.isMeasurable())
193 bsdfPdfQuery.inputs.set(bsdfEval.inputs);
195 if(bsdfPdfQuery.outputs)
197 const auto L = bsdfEval.inputs.getL();
199 const real bsdfSamplePdfW = bsdfPdfQuery.outputs.getSampleDirPdfW();
200 const real misWeighting = MIS{}.weight(neePdfW, bsdfSamplePdfW);
213 if(out_Lo) { *out_Lo = sampledLo; }
218template<ES
idednessPolicy POLICY>
223 PH_ASSERT(isNeeSamplable(X));
228 getScene().calcDirectPdf(pdfQuery);
232template<ES
idednessPolicy POLICY>
239template<ES
idednessPolicy POLICY>
Information for obtaining a sample value from BSDF.
Definition BsdfEvalQuery.h:90
Information for the probability of generating a specific BSDF sample.
Definition BsdfPdfQuery.h:66
const math::Vector3R & getL() const
Definition BsdfSampleQuery.h:215
const math::Spectrum & getPdfAppliedBsdfCos() const
Definition BsdfSampleQuery.h:237
bool isMeasurable() const
Tells whether this sample has potential to contribute. All sampled data should be usable if true is r...
Definition BsdfSampleQuery.h:260
Information for generating a BSDF sample.
Definition BsdfSampleQuery.h:141
Input inputs
Definition BsdfSampleQuery.h:147
BsdfQueryContext context
Definition BsdfSampleQuery.h:146
Output outputs
Definition BsdfSampleQuery.h:148
real getPdfW() const
Definition DirectEnergyPdfQuery.h:149
Information for the probability of generating a specific sample for direct energy estimation.
Definition DirectEnergyPdfQuery.h:81
Output outputs
Definition DirectEnergyPdfQuery.h:87
Input inputs
Definition DirectEnergyPdfQuery.h:86
const math::Spectrum & getEmittedEnergy() const
The sampled emitted energy of. Does not contain any path weighting.
Definition DirectEnergySampleQuery.h:154
const Ray & getObservationRay() const
Get the ray from target position to sampled emitting position. If target position or emitting positio...
Definition DirectEnergySampleQuery.h:179
real getPdfW() const
Definition DirectEnergySampleQuery.h:160
Information for generating a sample for direct energy estimation.
Definition DirectEnergySampleQuery.h:89
math::Vector3R getTargetToEmit() const
Definition DirectEnergySampleQuery.h:190
Output outputs
Definition DirectEnergySampleQuery.h:95
Input inputs
Definition DirectEnergySampleQuery.h:94
An electromagnetic energy emitting source. The emitted energy can be captured by a Receiver.
Definition Emitter.h:68
EmitterFeatureSet getFeatureSet() const
Definition Emitter.h:129
virtual void evalEmittedEnergy(const SurfaceHit &Xe, math::Spectrum *out_energy) const =0
Evaluate emitted energy from a point on the surface.
Lightweight ray intersection testing and reporting object. If an intersection is found,...
Definition HitProbe.h:27
const math::Vector3R & getDir() const
Definition Ray.h:214
A sample with arbitrary dimensions with fine-grained sampling control.
Definition SampleFlow.h:19
A unified interface for accessing cooked content in a visual world.
Definition Scene.h:27
General information about a ray-surface intersection event.
Definition SurfaceHit.h:59
math::Vector3R getShadingNormal() const
Definition SurfaceHit.h:191
const Ray & getIncidentRay() const
Convenient method for getRay() where getReason() contains ESurfaceHitReason::IncidentRay.
Definition SurfaceHit.h:175
const Emitter * getSurfaceEmitter() const
Definition SurfaceHit.cpp:61
const SurfaceOptics * getSurfaceOptics() const
Definition SurfaceHit.cpp:67
Describes how light interacts with a surface.
Definition SurfaceOptics.h:17
void calcBsdf(BsdfEvalQuery &eval) const
Executes a BSDF evaluation query. Respects sidedness policy.
Definition SurfaceOptics.cpp:17
void calcBsdfPdf(BsdfPdfQuery &pdfQuery) const
Executes a BSDF sample PDF query. Respects sidedness policy.
Definition SurfaceOptics.cpp:54
SurfacePhenomena getAllPhenomena() const
Get all phenomena that exist in this surface.
Definition SurfaceOptics.h:94
Manipulate a value type where each bit is a binary flag.
Definition TBitFlags.h:17
constexpr bool has(Input singleFlag) const
Checks whether this single flag is fully contained.
Definition TBitFlags.ipp:133
constexpr bool hasNone(const FlagsSet &flagsSet) const
Checks whether this instance contains no specified flags.
Definition TBitFlags.ipp:81
Definition SidednessAgreement.h:32
Algorithms for various hit point adjustments. For surface escaping routines, the generated ray is not...
Definition SurfaceHitRefinery.h:31
Common operations for surface tracing. This class also handles many subtle cases for surface tracing....
Definition SurfaceTracer.h:35
bool bsdfSampleNextSurface(BsdfSampleQuery &bsdfSample, SampleFlow &sampleFlow, SurfaceHit *out_X) const
Uses BSDF sample to trace the next surface.
Definition SurfaceTracer.h:158
Estimate direct lighting for a surface point. This is a lightweight helper type for estimating direct...
Definition TDirectLightEstimator.h:31
bool bsdfSamplePathWithNee(BsdfSampleQuery &bsdfSample, SampleFlow &sampleFlow, math::Spectrum *out_Lo=nullptr, std::optional< SurfaceHit > *out_X=nullptr) const
Sample lighting by combining the techniques used by bsdfSample() and neeSample(). A light sampling te...
Definition TDirectLightEstimator.ipp:105
bool bsdfSampleEmission(BsdfSampleQuery &bsdfSample, SampleFlow &sampleFlow, math::Spectrum *out_Le=nullptr, std::optional< SurfaceHit > *out_X=nullptr) const
Sample lighting using BSDF's suggestion. A light sampling technique that is always valid.
Definition TDirectLightEstimator.ipp:39
TDirectLightEstimator(const Scene *scene)
Definition TDirectLightEstimator.ipp:32
bool isNeeSamplable(const SurfaceHit &X) const
Definition TDirectLightEstimator.ipp:233
bool neeSampleEmission(DirectEnergySampleQuery &directSample, SampleFlow &sampleFlow, SurfaceHit *out_Xe=nullptr) const
Sample lighting using next-event estimation. This light sampling technique may not always be valid....
Definition TDirectLightEstimator.ipp:71
real neeSamplePdfWUnoccluded(const SurfaceHit &X, const SurfaceHit &Xe) const
Get the solid angle domain PDF of an next-event estimation lighting sample. Surface occlusion is not ...
Definition TDirectLightEstimator.ipp:219
Static helper for Multiple Importance Sampling (MIS). See the paper by Veach et al....
Definition TMIS.h:18
Derived & safeClampLocal(T lowerBound, T upperBound)
Definition TArithmeticArrayBase.ipp:307
Definition TTristimulusSpectrum.h:11
Derived mul(const Derived &rhs) const
Definition TArithmeticArrayBase.ipp:98
Derived normalize() const
Normalize the vector. Notice that normalizing a integer typed vector will result in 0-vector most of ...
Definition TVectorNBase.ipp:50
T absDot(const Derived &rhs) const
Definition TVectorNBase.ipp:26
T lengthSquared() const
Definition TVectorNBase.ipp:44
Light transport algorithms.
Definition enums.h:6
constexpr ESurfacePhenomenon DELTA_SURFACE_PHENOMENA
Definition surface_optics_fwd.h:48