Commit 43c0d37c authored by TheNumbat's avatar TheNumbat
Browse files

Release more changes

Features
- Button to add samples to current render

Fixes
- Don't draw emitter arrows when rendering with rasterization
- (Previous commit) deal with non-uniform ray hit distance scaling
  systematically instead of deferring it to hit functions.
parent 3c95c936
......@@ -761,7 +761,6 @@ bool Widget_Render::UI(Scene& scene, Widget_Camera& cam, Camera& user_cam, std::
if(ImGui::Button("Cancel")) {
pathtracer.cancel();
has_rendered = false;
}
ImGui::SameLine();
......@@ -812,6 +811,13 @@ bool Widget_Render::UI(Scene& scene, Widget_Camera& cam, Camera& user_cam, std::
}
}
if(method == 1 && has_rendered) {
ImGui::SameLine();
if(ImGui::Button("Add Samples")) {
pathtracer.begin_render(scene, cam.get(), true);
}
}
float avail = ImGui::GetContentRegionAvail().x;
float w = std::min(avail, (float)out_w);
float h = (w / out_w) * out_h;
......
......@@ -233,21 +233,23 @@ size_t Pathtracer::visualize_bvh(GL::Lines& lines, GL::Lines& active, size_t dep
return scene.visualize(lines, active, depth, Mat4::I);
}
void Pathtracer::begin_render(Scene& layout_scene, const Camera& cam) {
void Pathtracer::begin_render(Scene& layout_scene, const Camera& cam, bool add_samples) {
size_t n_threads = std::thread::hardware_concurrency();
size_t samples_per_epoch = std::max(size_t(1), n_samples / (n_threads * 10));
cancel();
accumulator.clear({});
total_epochs = n_samples / samples_per_epoch + !!(n_samples % samples_per_epoch);
build_time = SDL_GetPerformanceCounter();
build_scene(layout_scene);
if(!add_samples) {
accumulator.clear({});
accumulator_samples = 0;
build_time = SDL_GetPerformanceCounter();
build_scene(layout_scene);
build_time = SDL_GetPerformanceCounter() - build_time;
}
render_time = SDL_GetPerformanceCounter();
build_time = render_time - build_time;
camera = cam;
for(size_t s = 0; s < n_samples; s += samples_per_epoch) {
......@@ -266,12 +268,11 @@ void Pathtracer::begin_render(Scene& layout_scene, const Camera& cam) {
void Pathtracer::cancel() {
cancel_flag = true;
thread_pool.clear();
render_time = 0;
build_time = 0;
accumulator_samples = 0;
completed_epochs = 0;
total_epochs = 0;
cancel_flag = false;
build_time = 0;
render_time = SDL_GetPerformanceCounter() - render_time;
}
const HDR_Image& Pathtracer::get_output() {
......
......@@ -32,7 +32,7 @@ public:
const GL::Tex2D& get_output_texture(float exposure);
size_t visualize_bvh(GL::Lines& lines, GL::Lines& active, size_t level);
void begin_render(Scene& scene, const Camera& camera);
void begin_render(Scene& scene, const Camera& camera, bool add_samples = false);
void cancel();
bool in_progress() const;
float progress() const;
......
......@@ -50,7 +50,7 @@ const GL::Mesh& Scene_Particles::mesh() const {
return particle_instances.mesh();
}
void Scene_Particles::render(const Mat4& view, bool depth_only, bool posed) {
void Scene_Particles::render(const Mat4& view, bool depth_only, bool posed, bool particles_only) {
Renderer& renderer = Renderer::get();
......@@ -62,7 +62,10 @@ void Scene_Particles::render(const Mat4& view, bool depth_only, bool posed) {
opts.solid_color = true;
opts.depth_only = depth_only;
opts.color = opt.color.to_vec();
renderer.mesh(arrow, opts);
if(!particles_only) {
renderer.mesh(arrow, opts);
}
if(opt.enabled && !depth_only) {
opts.modelview = view;
......
......@@ -42,7 +42,7 @@ public:
const std::vector<Particle>& get_particles() const;
BBox bbox() const;
void render(const Mat4& view, bool depth_only = false, bool posed = true);
void render(const Mat4& view, bool depth_only = false, bool posed = true, bool particles_only = false);
Scene_ID id() const;
void set_time(float time);
......
......@@ -90,7 +90,12 @@ void Renderer::save(Scene& scene, const Camera& cam, int w, int h, int s) {
Scene_Light& light = item.get<Scene_Light>();
if(!light.is_env()) return;
}
item.render(view);
if(item.is<Scene_Particles>()) {
item.get<Scene_Particles>().render(view, false, true, true);
} else {
item.render(view);
}
});
save_buffer.blit_to(0, save_output, true);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment