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:: ...@@ -761,7 +761,6 @@ bool Widget_Render::UI(Scene& scene, Widget_Camera& cam, Camera& user_cam, std::
if(ImGui::Button("Cancel")) { if(ImGui::Button("Cancel")) {
pathtracer.cancel(); pathtracer.cancel();
has_rendered = false;
} }
ImGui::SameLine(); ImGui::SameLine();
...@@ -812,6 +811,13 @@ bool Widget_Render::UI(Scene& scene, Widget_Camera& cam, Camera& user_cam, std:: ...@@ -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 avail = ImGui::GetContentRegionAvail().x;
float w = std::min(avail, (float)out_w); float w = std::min(avail, (float)out_w);
float h = (w / out_w) * out_h; float h = (w / out_w) * out_h;
......
...@@ -233,20 +233,22 @@ size_t Pathtracer::visualize_bvh(GL::Lines& lines, GL::Lines& active, size_t dep ...@@ -233,20 +233,22 @@ size_t Pathtracer::visualize_bvh(GL::Lines& lines, GL::Lines& active, size_t dep
return scene.visualize(lines, active, depth, Mat4::I); 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 n_threads = std::thread::hardware_concurrency();
size_t samples_per_epoch = std::max(size_t(1), n_samples / (n_threads * 10)); size_t samples_per_epoch = std::max(size_t(1), n_samples / (n_threads * 10));
cancel(); cancel();
accumulator.clear({});
total_epochs = n_samples / samples_per_epoch + !!(n_samples % samples_per_epoch); total_epochs = n_samples / samples_per_epoch + !!(n_samples % samples_per_epoch);
if(!add_samples) {
accumulator.clear({});
accumulator_samples = 0;
build_time = SDL_GetPerformanceCounter(); build_time = SDL_GetPerformanceCounter();
build_scene(layout_scene); build_scene(layout_scene);
build_time = SDL_GetPerformanceCounter() - build_time;
}
render_time = SDL_GetPerformanceCounter(); render_time = SDL_GetPerformanceCounter();
build_time = render_time - build_time;
camera = cam; camera = cam;
...@@ -266,12 +268,11 @@ void Pathtracer::begin_render(Scene& layout_scene, const Camera& cam) { ...@@ -266,12 +268,11 @@ void Pathtracer::begin_render(Scene& layout_scene, const Camera& cam) {
void Pathtracer::cancel() { void Pathtracer::cancel() {
cancel_flag = true; cancel_flag = true;
thread_pool.clear(); thread_pool.clear();
render_time = 0;
build_time = 0;
accumulator_samples = 0;
completed_epochs = 0; completed_epochs = 0;
total_epochs = 0; total_epochs = 0;
cancel_flag = false; cancel_flag = false;
build_time = 0;
render_time = SDL_GetPerformanceCounter() - render_time;
} }
const HDR_Image& Pathtracer::get_output() { const HDR_Image& Pathtracer::get_output() {
......
...@@ -32,7 +32,7 @@ public: ...@@ -32,7 +32,7 @@ public:
const GL::Tex2D& get_output_texture(float exposure); const GL::Tex2D& get_output_texture(float exposure);
size_t visualize_bvh(GL::Lines& lines, GL::Lines& active, size_t level); 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(); void cancel();
bool in_progress() const; bool in_progress() const;
float progress() const; float progress() const;
......
...@@ -50,7 +50,7 @@ const GL::Mesh& Scene_Particles::mesh() const { ...@@ -50,7 +50,7 @@ const GL::Mesh& Scene_Particles::mesh() const {
return particle_instances.mesh(); 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(); Renderer& renderer = Renderer::get();
...@@ -62,7 +62,10 @@ void Scene_Particles::render(const Mat4& view, bool depth_only, bool posed) { ...@@ -62,7 +62,10 @@ void Scene_Particles::render(const Mat4& view, bool depth_only, bool posed) {
opts.solid_color = true; opts.solid_color = true;
opts.depth_only = depth_only; opts.depth_only = depth_only;
opts.color = opt.color.to_vec(); opts.color = opt.color.to_vec();
if(!particles_only) {
renderer.mesh(arrow, opts); renderer.mesh(arrow, opts);
}
if(opt.enabled && !depth_only) { if(opt.enabled && !depth_only) {
opts.modelview = view; opts.modelview = view;
......
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
const std::vector<Particle>& get_particles() const; const std::vector<Particle>& get_particles() const;
BBox bbox() 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; Scene_ID id() const;
void set_time(float time); void set_time(float time);
......
...@@ -90,7 +90,12 @@ void Renderer::save(Scene& scene, const Camera& cam, int w, int h, int s) { ...@@ -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>(); Scene_Light& light = item.get<Scene_Light>();
if(!light.is_env()) return; if(!light.is_env()) return;
} }
if(item.is<Scene_Particles>()) {
item.get<Scene_Particles>().render(view, false, true, true);
} else {
item.render(view); item.render(view);
}
}); });
save_buffer.blit_to(0, save_output, true); 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