| Attached Files | fix_sppm_light_group_radiance_estimation.diff [^] (4,789 bytes) 2011-05-10 10:56 [Show Content] [Hide Content]# HG changeset patch
# User Guillaume Bouchard <guillaume.bouchard@liris.cnrs.fr>
# Parent 493247cf7205a94f6ab6f66818b76cc82fa40460
Fix sppm light group normalisation error
The density estimation in hitpoints.cpp must use the total number of photon and not the number of photon traced by light group. Other diff are cleaning because of unneeded statics of how much photons per light group.
diff -r 493247cf7205 renderers/sppm/hitpoints.cpp
--- a/renderers/sppm/hitpoints.cpp Tue May 10 19:45:27 2011 +0200
+++ b/renderers/sppm/hitpoints.cpp Tue May 10 19:48:22 2011 +0200
@@ -209,7 +209,7 @@
}
}
-void HitPoints::AccumulateFlux(const vector<unsigned long long> &photonTracedByLightGroup,
+void HitPoints::AccumulateFlux(unsigned long long total_photons,
const u_int index, const u_int count) {
const unsigned int workSize = hitPoints->size() / count;
const unsigned int first = workSize * index;
@@ -277,7 +277,7 @@
for(u_int j = 0; j < lightGroupsNumber; ++j) {
const u_int hitCount = hp->lightGroupData[j].constantHitsCount + hp->lightGroupData[j].surfaceHitsCount;
if (hitCount > 0) {
- const double k = 1.0 / (M_PI * hp->accumPhotonRadius2 * photonTracedByLightGroup[j]);
+ const double k = 1.0 / (M_PI * hp->accumPhotonRadius2 * total_photons);
const XYZColor newRadiance = (hp->lightGroupData[j].accumRadiance +
hp->lightGroupData[j].surfaceHitsCount * hp->lightGroupData[j].reflectedFlux * k) / hitCount;
diff -r 493247cf7205 renderers/sppm/hitpoints.h
--- a/renderers/sppm/hitpoints.h Tue May 10 19:45:27 2011 +0200
+++ b/renderers/sppm/hitpoints.h Tue May 10 19:48:22 2011 +0200
@@ -135,7 +135,7 @@
lookUpAccel[passIndex]->AddFlux(hitPoint, passIndex, bsdf, wi, sw, photonFlux, light_group);
}
- void AccumulateFlux(const vector<unsigned long long> &photonTracedByLightGroup,
+ void AccumulateFlux(unsigned long long const total_photons,
const u_int index, const u_int count);
void SetHitPoints(RandomGenerator *rng, const u_int index, const u_int count);
diff -r 493247cf7205 renderers/sppmrenderer.cpp
--- a/renderers/sppmrenderer.cpp Tue May 10 19:45:27 2011 +0200
+++ b/renderers/sppmrenderer.cpp Tue May 10 19:48:22 2011 +0200
@@ -186,9 +186,8 @@
exitBarrier = new boost::barrier(threadCount);
// initialise
- photonTracedTotal.resize(scene->lightGroups.size(), 0);
- photonTracedPass.resize(scene->lightGroups.size(), 0);
- photonTracedPassNoLightGroup = 0;
+ photonTracedTotal = 0;
+ photonTracedPass = 0;
photonHitEfficiency = 0;
// start the timer
@@ -303,10 +302,7 @@
else if (statName == "pass") {
return (hitPoints) ? double(hitPoints->GetPhotonPassCount()) : 0.0;
} else if (statName == "photonCount") {
- unsigned long long total = 0;
- for (size_t i = 0; i < photonTracedTotal.size(); ++i)
- total += photonTracedTotal[i] + photonTracedPass[i];
- return double(total);
+ return double(photonTracedTotal);
} else if (statName == "hitPointsUpdateEfficiency") {
return photonHitEfficiency;
} else {
@@ -563,11 +559,8 @@
renderer->photonHitEfficiency = renderer->hitPoints->GetPhotonHitEfficency();
// First thread only tasks
- for(u_int i = 0; i < renderer->photonTracedTotal.size(); ++i) {
- renderer->photonTracedTotal[i] += renderer->photonTracedPass[i];
- renderer->photonTracedPass[i] = 0;
- }
- renderer->photonTracedPassNoLightGroup = 0;
+ renderer->photonTracedTotal += renderer->photonTracedPass;
+ renderer->photonTracedPass = 0;
}
// Wait for other threads
@@ -613,7 +606,7 @@
for (u_int photonCount = 0;; ++photonCount) {
// Check if it is time to do an eye pass
- if (renderer->photonTracedPassNoLightGroup > renderer->sppmi->photonPerPass) {
+ if (renderer->photonTracedPass > renderer->sppmi->photonPerPass) {
// Ok, time to stop
return;
}
@@ -641,8 +634,7 @@
u_int lightNum = lightCDF->SampleDiscrete(u[6], &lightPdf);
const Light *light = scene.lights[lightNum];
- osAtomicInc(&(renderer->photonTracedPass[light->group]));
- osAtomicInc(&(renderer->photonTracedPassNoLightGroup));
+ osAtomicInc(&renderer->photonTracedPass);
// Generate _photonRay_ from light source and initialize _alpha_
BSDF *bsdf;
diff -r 493247cf7205 renderers/sppmrenderer.h
--- a/renderers/sppmrenderer.h Tue May 10 19:45:27 2011 +0200
+++ b/renderers/sppmrenderer.h Tue May 10 19:48:22 2011 +0200
@@ -183,11 +183,8 @@
double photonHitEfficiency;
// Store number of photon traced by lightgroup
- vector<unsigned long long> photonTracedTotal;
- vector<u_int> photonTracedPass;
-
- // Store number of photon traced this pass, regardless of lightgroup
- u_int photonTracedPassNoLightGroup;
+ unsigned long long photonTracedTotal;
+ u_int photonTracedPass;
fast_mutex sampPosMutex;
u_int sampPos;
|