20#include <Common/assertion.h>
21#include <Common/primitive_type.h>
27namespace ph {
class Scene; }
36template<CPhoton Photon>
45 if constexpr(Photon::template has<EPhotonData::GeometryNormal>())
47 const math::Vector3R photonNg = photon.template get<EPhotonData::GeometryNormal>();
48 if(photonNg.
dot(Ng) < 0.1_r ||
49 photonNg.
dot(Ns) < 0.2_r ||
73template<CPhoton Photon>
75 const std::size_t viewPathLength,
80 const std::size_t minFullPathLength = 1,
91 PH_ASSERT_GE(viewPathLength, 1);
92 PH_ASSERT_GE(minFullPathLength, 1);
93 PH_ASSERT_LE(minFullPathLength, maxFullPathLength);
104 PH_ASSERT_IN_RANGE_INCLUSIVE(viewPathLength, minFullPathLength, maxFullPathLength);
108 lostEnergy += viewPathThroughput * viewRadiance;
112 const auto minPathLengthWithPhotonMap = photonMapInfo.
minPathLength + 1;
115 if(viewPathLength + 1 < minPathLengthWithPhotonMap &&
116 minFullPathLength <= viewPathLength + 1 && viewPathLength + 1 <= maxFullPathLength)
123 if(DirectLight{scene}.bsdfSamplePathWithNee(
128 lostEnergy += viewPathThroughput * viewRadiance;
150template<CPhoton Photon>
152 const std::size_t viewPathLength,
157 const std::size_t minFullPathLength = 1,
168 PH_ASSERT_GE(viewPathLength, 1);
169 PH_ASSERT_GE(minFullPathLength, 1);
170 PH_ASSERT_LE(minFullPathLength, maxFullPathLength);
182 if(minFullPathLength <= viewPathLength + photonMapInfo.
minPathLength &&
183 viewPathLength + photonMapInfo.
minPathLength <= maxFullPathLength)
187 if(IndirectLight{scene}.bsdfSamplePathWithNee(
196 lostEnergy += viewRadiance;
217template<CPhoton Photon>
219 const std::size_t viewPathLength,
224 const std::size_t minFullPathLength = 1,
235 PH_ASSERT_GE(viewPathLength, 1);
236 PH_ASSERT_GE(minFullPathLength, 1);
237 PH_ASSERT_LE(minFullPathLength, maxFullPathLength);
248 const auto minLostFullPathLength = viewPathLength + photonMapInfo.
maxPathLength + 1;
251 const bool isAlreadyEnoughBounces =
254 if(!isAlreadyEnoughBounces && minLostFullPathLength <= maxFullPathLength)
256 const auto minLostFullPathLengthClipped = std::max(
257 minFullPathLength, minLostFullPathLength);
258 PH_ASSERT_GE(minLostFullPathLengthClipped, viewPathLength);
262 if(IndirectLight{scene}.bsdfSamplePathWithNee(
265 minLostFullPathLengthClipped - viewPathLength,
266 std::numeric_limits<std::size_t>::max(),
272 lostEnergy += viewRadiance;
Information for generating a BSDF sample.
Definition BsdfSampleQuery.h:141
Input inputs
Definition BsdfSampleQuery.h:147
virtual void evalEmittedEnergy(const SurfaceHit &Xe, math::Spectrum *out_energy) const =0
Evaluate emitted energy from a point on the surface.
static constexpr uint32 DEFAULT_MAX_PATH_LENGTH
Definition PMCommonParams.h:15
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
const Emitter * getSurfaceEmitter() const
Definition SurfaceHit.cpp:61
const SurfaceOptics * getSurfaceOptics() const
Definition SurfaceHit.cpp:67
Carries common informatiom for a photon map.
Definition TPhotonMap.h:24
uint32 minPathLength
Definition TPhotonMap.h:27
uint32 maxPathLength
Definition TPhotonMap.h:28
Russian roulette random termination scheme.
Definition RussianRoulette.h:16
Definition SidednessAgreement.h:32
bool isSidednessAgreed(const math::Vector3R &Ng, const math::Vector3R &Ns, const math::Vector3R &vec) const
Definition SidednessAgreement.h:104
Estimate direct lighting for a surface point. This is a lightweight helper type for estimating direct...
Definition TDirectLightEstimator.h:31
Estimate indirect lighting for a surface point.
Definition TIndirectLightEstimator.h:23
Definition TTristimulusSpectrum.h:11
T dot(const Derived &rhs) const
Definition TVectorNBase.ipp:14
The root for all renderer implementations.
Definition EEngineProject.h:6
math::Spectrum estimate_lost_energy_for_extending(const std::size_t viewPathLength, const SurfaceHit &X, const math::Spectrum &viewPathThroughput, const TPhotonMapInfo< Photon > &photonMapInfo, const Scene *scene, const std::size_t minFullPathLength=1, const std::size_t maxFullPathLength=PMCommonParams::DEFAULT_MAX_PATH_LENGTH)
Estimate the energy that is otherwise lost forever if the path is extended. The estimation is for the...
Definition photon_map_light_transport.h:151
math::Spectrum estimate_lost_energy_for_merging(const std::size_t viewPathLength, const SurfaceHit &X, const math::Spectrum &viewPathThroughput, const TPhotonMapInfo< Photon > &photonMapInfo, const Scene *scene, const std::size_t minFullPathLength=1, const std::size_t maxFullPathLength=PMCommonParams::DEFAULT_MAX_PATH_LENGTH)
Estimate the energy that is otherwise lost forever if the path is merged. The estimation is for the c...
Definition photon_map_light_transport.h:218
math::Spectrum estimate_certainly_lost_energy(const std::size_t viewPathLength, const SurfaceHit &X, const math::Spectrum &viewPathThroughput, const TPhotonMapInfo< Photon > &photonMapInfo, const Scene *scene, const std::size_t minFullPathLength=1, const std::size_t maxFullPathLength=PMCommonParams::DEFAULT_MAX_PATH_LENGTH)
Estimate the energy that can never be obtained by utilizing a photon map. The estimation is for the c...
Definition photon_map_light_transport.h:74
bool accept_photon_by_surface_topology(const Photon &photon, const math::Vector3R &Ng, const math::Vector3R &Ns, const math::Vector3R &L, const math::Vector3R &V, const lta::SidednessAgreement &sidedness)
Definition photon_map_light_transport.h:37