Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Bidir: avoid excessive brightness after render finishes and improve c…
Browse files Browse the repository at this point in the history
…ode readability.
  • Loading branch information
DavidBluecame committed Mar 21, 2017
1 parent 9bc8554 commit ea531cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions include/core_api/imagefilm.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class YAFRAYCORE_EXPORT imageFilm_t
//! Enables/Disables a light density estimation image
void setDensityEstimation(bool enable);
//! set number of samples for correct density estimation (if enabled)
void setNumSamples(int n){ numSamples = n; }
void setNumDensitySamples(int n){ numDensitySamples = n; }
/*! Sets the film color space and gamma correction */
void setColorSpace(colorSpaces_t color_space, float gammaVal);
/*! Sets the film color space and gamma correction for optional secondary file output */
Expand Down Expand Up @@ -221,8 +221,8 @@ class YAFRAYCORE_EXPORT imageFilm_t
std::mutex imageMutex, splitterMutex, outMutex, densityImageMutex;
bool split = true;
bool abort = false;
bool estimateDensity;
int numSamples;
bool estimateDensity = false;
int numDensitySamples = 0;
imageSpliter_t *splitter = nullptr;
progressBar_t *pbar = nullptr;
renderEnvironment_t *env;
Expand Down
2 changes: 1 addition & 1 deletion src/integrators/bidirpath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void biDirIntegrator_t::cleanup()
for(int i=0; i<MAX_PATH_LENGTH; ++i) free(pathData.lightPath[i].userdata);
for(int i=0; i<MAX_PATH_LENGTH; ++i) free(pathData.eyePath[i].userdata);
}
lightImage->setNumSamples(nPaths); //dirty hack...
lightImage->setNumDensitySamples(nPaths); //dirty hack...
}

/* ============================================================
Expand Down
9 changes: 5 additions & 4 deletions src/yafraycore/imagefilm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,9 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out)
Y_WARNING << "imageFilm: Text on the parameters badge won't be available." << yendl;
#endif

float multi = 0.f;
float densityFactor = 0.f;

if(estimateDensity) multi = (float) (w * h) / (float) numSamples;
if(estimateDensity && numDensitySamples > 0) densityFactor = (float) (w * h) / (float) numDensitySamples;

std::vector<colorA_t> colExtPasses(imagePasses.size(), colorA_t(0.f));

Expand Down Expand Up @@ -762,7 +762,8 @@ void imageFilm_t::flush(int numView, int flags, colorOutput_t *out)
else colExtPasses[idx] = colorA_t(0.f);
}

if(estimateDensity && (flags & IF_DENSITYIMAGE) && idx == 0) colExtPasses[idx] += (*densityImage)(i, j) * multi;
if(estimateDensity && (flags & IF_DENSITYIMAGE) && idx == 0 && densityFactor > 0.f) colExtPasses[idx] += colorA_t((*densityImage)(i, j) * densityFactor, 0.f);

colExtPasses[idx].clampRGB0();

if(out2) colExtPasses2[idx] = colExtPasses[idx];
Expand Down Expand Up @@ -1060,7 +1061,7 @@ void imageFilm_t::addDensitySample(const color_t& c, int x, int y, float dx, flo
}
}

++numSamples;
++numDensitySamples;

densityImageMutex.unlock();
}
Expand Down

0 comments on commit ea531cd

Please sign in to comment.