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 "math/vec3fa.h"
#define EPS 0.01f
#define EPS 0.001f
void Application3::initScene() {
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])) {
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();
accepted.fetch_add(1, std::memory_order_relaxed);
last_l[i] = l;
}
}
large_luminance_outer_sum += large_luminance_sum;
}
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));
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,

View file

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

View file

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