13#include <Common/assertion.h>
18template<ES
idednessPolicy POLICY>
25template<ES
idednessPolicy POLICY>
29 const std::size_t pathLength,
32 const std::size_t rrBeginPathLength,
35 PH_ASSERT_GE(pathLength, 1);
45 std::size_t currentPathLength = 0;
46 while(currentPathLength < pathLength)
48 if(currentPathLength >= rrBeginPathLength)
53 pathThroughput *= 1.0_r / rrSurvivalProb;
67 if(currentPathLength + 1 == pathLength)
70 if(directLight.bsdfSamplePathWithNee(bsdfSample, sampleFlow, &Lo))
72 if(out_Lo) { *out_Lo = pathThroughput * Lo; }
80 if(!surfaceTracer.bsdfSampleNextSurface(bsdfSample, sampleFlow, &nextHit) ||
81 !bsdfSample.outputs.isMeasurable())
87 pathThroughput *= bsdfSample.outputs.getPdfAppliedBsdfCos();
90 rrScale /= bsdfSample.outputs.getRelativeIor2();
99template<ES
idednessPolicy POLICY>
103 const std::size_t minPathLength,
104 const std::size_t maxPathLength,
107 const std::size_t rrBeginPathLength,
110 PH_ASSERT_GE(minPathLength, 1);
111 PH_ASSERT_LE(minPathLength, maxPathLength);
120 real rrScale = 1.0_r;
122 std::size_t currentPathLength = 0;
123 while(currentPathLength < maxPathLength)
125 if(currentPathLength >= rrBeginPathLength)
130 pathThroughput *= 1.0_r / rrSurvivalProb;
144 PH_ASSERT_LE(currentPathLength + 1, maxPathLength);
145 if(currentPathLength + 1 >= minPathLength)
148 std::optional<SurfaceHit> nextHit;
149 if(!directLight.bsdfSamplePathWithNee(bsdfSample, sampleFlow, &Lo, &nextHit) ||
150 !bsdfSample.outputs.isMeasurable() ||
156 accuLo += pathThroughput * Lo;
157 currentHit = *nextHit;
163 if(!surfaceTracer.bsdfSampleNextSurface(bsdfSample, sampleFlow, &nextHit) ||
164 !bsdfSample.outputs.isMeasurable())
169 currentHit = nextHit;
172 pathThroughput *= bsdfSample.outputs.getPdfAppliedBsdfCos();
175 rrScale /= bsdfSample.outputs.getRelativeIor2();
180 if(out_Lo) { *out_Lo = accuLo; }
The environment a BSDF query is performed under.
Definition BsdfQueryContext.h:13
Information for generating a BSDF sample.
Definition BsdfSampleQuery.h:141
Input inputs
Definition BsdfSampleQuery.h:147
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
const Ray & getIncidentRay() const
Convenient method for getRay() where getReason() contains ESurfaceHitReason::IncidentRay.
Definition SurfaceHit.h:175
Russian roulette random termination scheme.
Definition RussianRoulette.h:16
bool surviveOnLuminance(const math::Spectrum &s, SampleFlow &sampleFlow, real *out_survivalProbability) const
Definition RussianRoulette.h:30
Common operations for surface tracing. This class also handles many subtle cases for surface tracing....
Definition SurfaceTracer.h:35
Estimate direct lighting for a surface point. This is a lightweight helper type for estimating direct...
Definition TDirectLightEstimator.h:31
TIndirectLightEstimator(const Scene *scene)
Definition TIndirectLightEstimator.ipp:19
bool bsdfSamplePathWithNee(const SurfaceHit &X, SampleFlow &sampleFlow, std::size_t pathLength, const RussianRoulette &rr, math::Spectrum *out_Lo=nullptr, std::size_t rrBeginPathLength=0, const math::Spectrum &initialPathWeight=math::Spectrum(1)) const
Constructing path with BSDF sampling and estimate lighting with both BSDF sampling and next-event est...
Definition TIndirectLightEstimator.ipp:26
Definition TTristimulusSpectrum.h:11
Derived mul(const Derived &rhs) const
Definition TArithmeticArrayBase.ipp:98
Light transport algorithms.
Definition enums.h:6