Fix more bugs

This commit is contained in:
hal8174 2024-06-27 08:54:09 +02:00
parent 9e328cf9e3
commit ef6013ce4f
4 changed files with 18 additions and 15 deletions

View file

@ -1,7 +1,8 @@
#include "Application3.h" #include "Application3.h"
#include "math/vec3fa.h" #include "math/vec3fa.h"
#define EPS 0.01f #define EPS 0.001f
void Application3::initScene() { void Application3::initScene() {
Data_Constructor(&data, 1, 8); Data_Constructor(&data, 1, 8);

View file

@ -115,13 +115,15 @@ void ApplicationIntegrator::mltRender(int *pixels, int width, int height,
if ((last_l[i] == 0.0 && l > 0.0) || (last_l[i] > 0.0 && RandomSampler_get1D(chains[i].sampler) < l / last_l[i])) { 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); data.film.addSplat(x_pixel, y_pixel, f / l);
// printf("accept %d\n", chains[i].is_large_step()); // 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(); chains[i].accept();
accepted.fetch_add(1, std::memory_order_relaxed); accepted.fetch_add(1, std::memory_order_relaxed);
last_l[i] = l; last_l[i] = l;
} }
} }
large_luminance_outer_sum += large_luminance_sum; large_luminance_outer_sum += large_luminance_sum;
} }
std::lock_guard<std::mutex> guard(large_step_global_luminance_mutex); std::lock_guard<std::mutex> guard(large_step_global_luminance_mutex);
@ -135,7 +137,7 @@ void ApplicationIntegrator::mltRender(int *pixels, int width, int height,
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 / (accepted.load(std::memory_order_relaxed) * luminance_count.load(std::memory_order_relaxed));
printf("%f\n", data.film.scalar); 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);
} }
void ApplicationIntegrator::mcRender(int *pixels, int width, int height, void ApplicationIntegrator::mcRender(int *pixels, int width, int height,

View file

@ -3,7 +3,7 @@
#include "distribution.hpp" #include "distribution.hpp"
#include "sampler.h" #include "sampler.h"
#define NUM_CHAINS 20 #define NUM_CHAINS 12
class ApplicationIntegrator: public Application { class ApplicationIntegrator: public Application {
public: public:

View file

@ -50,30 +50,29 @@ public:
} }
if (large_step) if (large_step)
last_large_step = time; last_large_step = time;
index = 0;
new_data.clear();
} }
void new_ray(bool l) { void new_ray(bool l) {
index = 0;
new_data.clear();
large_step = l; large_step = l;
} }
bool is_large_step() { return large_step; } bool is_large_step() { return large_step; }
float get1D() override { float get1D() override {
float result;
if (is_large_step()) { if (is_large_step()) {
float r = RandomSampler_get1D(sampler); float r = RandomSampler_get1D(sampler);
new_data.push_back(r); new_data.push_back(r);
index++; result = r;
return r;
} else { } else {
if (index >= data.size()) { if (index >= data.size()) {
float r = RandomSampler_get1D(sampler); float r = RandomSampler_get1D(sampler);
data.push_back(r); data.push_back(r);
last_changed.push_back(time); last_changed.push_back(time);
new_data.push_back(r); new_data.push_back(r);
index++; result = r;
return r;
} }
// printf("%d, %d\n", index, last_large_step); // printf("%d, %d\n", index, last_large_step);
if (last_changed.at(index) < last_large_step) { if (last_changed.at(index) < last_large_step) {
@ -81,8 +80,7 @@ public:
data.at(index) = r; data.at(index) = r;
last_changed.at(index) = time; last_changed.at(index) = time;
new_data.push_back(r); new_data.push_back(r);
index++; result = r;
return r;
} else { } else {
size_t steps = time - last_changed.at(index); size_t steps = time - last_changed.at(index);
float d = data.at(index); float d = data.at(index);
@ -99,11 +97,13 @@ public:
d = normalize(d + o); d = normalize(d + o);
new_data.push_back(d); new_data.push_back(d);
// printf("%f, %f\n", data.at(index), d); // printf("%zu, %zu, %f, %f\n", index, steps, data.at(index), d);
index++; result = d;
return d;
} }
} }
// printf("%zu, %f\n", index, result);
index++;
return result;
} }
embree::Vec2f get2D() override { return embree::Vec2f(get1D(), get1D()); } embree::Vec2f get2D() override { return embree::Vec2f(get1D(), get1D()); }