Clean up
This commit is contained in:
parent
ef6013ce4f
commit
42f8bd8a40
2 changed files with 11 additions and 9 deletions
|
|
@ -46,10 +46,10 @@ inline float luminance(Vec3fa v) {
|
|||
void ApplicationIntegrator::resetRender() {
|
||||
Application::resetRender();
|
||||
|
||||
accepted.store(0, std::memory_order_relaxed);
|
||||
luminance_count.store(0, std::memory_order_relaxed);
|
||||
std::lock_guard<std::mutex> guard(large_step_global_luminance_mutex);
|
||||
large_step_global_luminance = 0.0;
|
||||
frame_count = 0;
|
||||
|
||||
for (size_t i = 0; i < NUM_CHAINS; i++) {
|
||||
chains[i] = MLTRandomSampler(small_step_size, large_step_probability);
|
||||
|
|
@ -86,8 +86,7 @@ void ApplicationIntegrator::mltRender(int *pixels, int width, int height,
|
|||
// d = Distribution1D(float* bis_values, num_bins)
|
||||
// float integral = d.funcInt;
|
||||
// int index_of_the_sampled_bin = d.SampleDiscrete(rng.get1D());
|
||||
|
||||
|
||||
|
||||
parallel_for(size_t(0), size_t(NUM_CHAINS), [&](const range<size_t> &range) {
|
||||
const int threadIndex = (int)TaskScheduler::threadIndex();
|
||||
float large_luminance_outer_sum = 0.0;
|
||||
|
|
@ -113,12 +112,14 @@ void ApplicationIntegrator::mltRender(int *pixels, int width, int height,
|
|||
luminance_count.fetch_add(1, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
|
||||
if (l > 0.0) {
|
||||
data.film.addSplat(x_pixel, y_pixel, (f / l) * std::fmin(l / last_l[i], 1.0));
|
||||
}
|
||||
if ((last_l[i] == 0.0 && l > 0.0) || (last_l[i] > 0.0 && RandomSampler_get1D(chains[i].sampler) < l / last_l[i])) {
|
||||
data.film.addSplat(x_pixel, y_pixel, f / l);
|
||||
// if (i == 0)
|
||||
// printf("%d accept %d %f %f %f\n", i, chains[i].is_large_step(), last_l[i], l, l / last_l[i]);
|
||||
chains[i].accept();
|
||||
accepted.fetch_add(1, std::memory_order_relaxed);
|
||||
last_l[i] = l;
|
||||
}
|
||||
|
||||
|
|
@ -132,12 +133,13 @@ void ApplicationIntegrator::mltRender(int *pixels, int width, int height,
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
frame_count++;
|
||||
std::lock_guard<std::mutex> guard(large_step_global_luminance_mutex);
|
||||
data.film.scalar = (float)(width * height) * large_step_global_luminance / (accepted.load(std::memory_order_relaxed) * luminance_count.load(std::memory_order_relaxed));
|
||||
data.film.scalar = (float)(width * height) * large_step_global_luminance / ((NUM_CHAINS * frame_count * chain_lengths) * luminance_count.load(std::memory_order_relaxed));
|
||||
|
||||
|
||||
printf("%f, %f, %zu, %d\n", data.film.scalar, large_step_global_luminance / luminance_count.load(std::memory_order_relaxed), luminance_count.load(std::memory_order_relaxed), NUM_CHAINS);
|
||||
printf("%zu, %f, %f, %zu, %d\n", frame_count, data.film.scalar, large_step_global_luminance / luminance_count.load(std::memory_order_relaxed), luminance_count.load(std::memory_order_relaxed), NUM_CHAINS);
|
||||
}
|
||||
|
||||
void ApplicationIntegrator::mcRender(int *pixels, int width, int height,
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ protected:
|
|||
const unsigned int height, const float time, const ISPCCamera& camera, const int numTilesX,
|
||||
const int numTilesY);
|
||||
|
||||
std::atomic<size_t> accepted = 0;
|
||||
std::atomic<size_t> luminance_count = 0;
|
||||
float large_step_global_luminance = 0.0;
|
||||
std::mutex large_step_global_luminance_mutex;
|
||||
MLTRandomSampler chains[NUM_CHAINS];
|
||||
float last_l[NUM_CHAINS];
|
||||
size_t frame_count = 0;
|
||||
int chain_lengths = 100000;
|
||||
float small_step_size = 0.01;
|
||||
float large_step_probability = 0.02;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue