Skip to content

Commit

Permalink
remove finalGathering flag, add finalGatheringDepth instead
Browse files Browse the repository at this point in the history
  • Loading branch information
yumcyaWiz committed Nov 22, 2021
1 parent 1d6dde7 commit 4668125
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ int main() {
const int n_estimation_global = 100;
const float n_photons_caustics_multiplier = 100;
const int n_estimation_caustics = 100;
const bool final_gathering = true;
const int strict_calc_depth = 3;
const int final_gathering_depth = 3;
const int max_depth = 100;

Image image(width, height);
Expand All @@ -26,7 +25,7 @@ int main() {
// photon tracing and build photon map
PhotonMapping integrator(n_photons, n_estimation_global,
n_photons_caustics_multiplier, n_estimation_caustics,
strict_calc_depth, final_gathering, max_depth);
final_gathering_depth, max_depth);
UniformSampler sampler;
integrator.build(scene, sampler);

Expand Down
12 changes: 5 additions & 7 deletions include/integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ class PhotonMapping : public Integrator {
const int nEstimationGlobal;
const int nPhotonsCaustics;
const int nEstimationCaustics;
const int strictCalcDepth;
const int finalGatheringDepth;
const int maxDepth;
bool finalGathering;

PhotonMap globalPhotonMap;
PhotonMap causticsPhotonMap;
Expand Down Expand Up @@ -259,7 +258,7 @@ class PhotonMapping : public Integrator {
// if hitting diffuse surface, computed reflected radiance with photon
// map
if (bxdf_type == BxDFType::DIFFUSE) {
if (!finalGathering || depth > strictCalcDepth) {
if (depth >= finalGatheringDepth) {
return computeRadianceWithPhotonMap(-ray.direction, info);
} else {
// compute direct illumination by explicit light sampling
Expand Down Expand Up @@ -331,13 +330,12 @@ class PhotonMapping : public Integrator {
public:
PhotonMapping(int nPhotonsGlobal, int nEstimationGlobal,
float nPhotonsCausticsMultiplier, int nEstimationCaustics,
int strictCalcDepth, bool finalGathering, int maxDepth)
int strictCalcDepth, int maxDepth)
: nPhotonsGlobal(nPhotonsGlobal),
nEstimationGlobal(nEstimationGlobal),
nPhotonsCaustics(nPhotonsGlobal * nPhotonsCausticsMultiplier),
nEstimationCaustics(nEstimationCaustics),
strictCalcDepth(strictCalcDepth),
finalGathering(finalGathering),
finalGatheringDepth(strictCalcDepth),
maxDepth(maxDepth) {}

const PhotonMap* getPhotonMapPtr() const { return &globalPhotonMap; }
Expand Down Expand Up @@ -425,7 +423,7 @@ class PhotonMapping : public Integrator {
globalPhotonMap.build();

// build caustics photon map
if (finalGathering) {
if (finalGatheringDepth > 0) {
photons.clear();

// photon tracing
Expand Down
2 changes: 1 addition & 1 deletion tests/visualize_photon_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main() {
scene.build();

// photon tracing and build photon map
PhotonMapping integrator(n_photons, 1, 0, 0, 0, false, max_depth);
PhotonMapping integrator(n_photons, 1, 0, 0, 0, max_depth);
UniformSampler sampler;
integrator.build(scene, sampler);

Expand Down

0 comments on commit 4668125

Please sign in to comment.