Commit: 60030d1511bd8e89bbca0e116d563ee1b8bd6674
Author: Alaska
Date:   Mon Aug 30 09:12:45 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB60030d1511bd8e89bbca0e116d563ee1b8bd6674

Cycles-X: Change viewport update system to be time based rather than sample 
based on fast devices

The viewport update speed when rendering with infinite samples has been changed 
to work based primarily on time since render start rather than sample count.

This change has been made because if you have a device fast enough to exceed 32 
samples in 0.1 seconds, then the next viewport update you'll observe is 2 
seconds after `render start` which can be annoying for anyone wishing to 
quickly iterate on fine details as `render start` is usually a 1 sample per 
pixel image meaning fine detail is lost in noise or overly blurred by a 
denoiser.

This change was made possible with help from Will Rusthon (a friend) and 
Blender developers.

Here is an example video of the issue (some of the "viewport changes" you see 
are due to compression artifacts to keep the video small):
{F10290321}

And here is my fix tested (the second demo with the caustics is there to show 
that the viewport updates reduce as time goes on. It's easier to see in the 
caustics scene due to the fireflies. This is important because reduced 
viewpoint updates means faster ray tracing. The difference is that with this 
patch the slow viewport update (once every 2 seconds) has been moved to after 
rendering for 8 seconds rather than occurring at 32 samples which could happen 
really quickly with simplistic sce [...]
{F10290508}

Reviewed By: sergey, leesonw

Differential Revision: https://developer.blender.org/D12265

===================================================================

M       intern/cycles/integrator/render_scheduler.cpp
M       intern/cycles/integrator/render_scheduler.h

===================================================================

diff --git a/intern/cycles/integrator/render_scheduler.cpp 
b/intern/cycles/integrator/render_scheduler.cpp
index b33c2068dc9..af16e8a0c59 100644
--- a/intern/cycles/integrator/render_scheduler.cpp
+++ b/intern/cycles/integrator/render_scheduler.cpp
@@ -630,17 +630,22 @@ double 
RenderScheduler::guess_display_update_interval_in_seconds_for_num_samples
     }
     return 2.0;
   }
-
-  if (num_rendered_samples < 4) {
+  
+  /* Render time and number of samples rendered are used to figure out the 
display update interval.
+  *  Render time is used to allow for fast display updates in the first few 
seconds of rendering
+  *  on fast devices. Number of samples rendered is used to allow for 
potentially quicker display
+  *  updates on slow devices during the first few samples. */
+  const double render_time = path_trace_time_.get_wall();
+  if (render_time < 1) {
     return 0.1;
   }
-  if (num_rendered_samples < 8) {
+  if (render_time < 2) {
     return 0.25;
   }
-  if (num_rendered_samples < 16) {
+  if (render_time < 4) {
     return 0.5;
   }
-  if (num_rendered_samples < 32) {
+  if (render_time < 8 || num_rendered_samples < 32) {
     return 1.0;
   }
   return 2.0;
@@ -649,7 +654,7 @@ double 
RenderScheduler::guess_display_update_interval_in_seconds_for_num_samples
 int RenderScheduler::calculate_num_samples_per_update() const
 {
   const double time_per_sample_average = path_trace_time_.get_average();
-  const double num_samples_in_second = 1.0 / time_per_sample_average;
+  const double num_samples_in_second = pixel_size_ * pixel_size_ / 
time_per_sample_average;
 
   const double update_interval_in_seconds = 
guess_display_update_interval_in_seconds();
 
@@ -810,9 +815,10 @@ bool RenderScheduler::work_need_denoise(bool &delayed)
     return false;
   }
 
-  /* Avoid excessive denoising in viewport after reaching a certain amount of 
samples. */
+  /* Avoid excessive denoising in viewport after reaching a certain sample 
count and render time. */
   /* TODO(sergey): Consider making time interval and sample configurable. */
-  delayed = (num_samples_finished >= 20 && (time_dt() - 
state_.last_display_update_time) < 1.0);
+  delayed = (path_trace_time_.get_wall() > 4 && num_samples_finished >= 20 &&
+      (time_dt() - state_.last_display_update_time) < 1.0);
 
   return !delayed;
 }
diff --git a/intern/cycles/integrator/render_scheduler.h 
b/intern/cycles/integrator/render_scheduler.h
index dc354737f6f..c58bcb20089 100644
--- a/intern/cycles/integrator/render_scheduler.h
+++ b/intern/cycles/integrator/render_scheduler.h
@@ -192,8 +192,9 @@ class RenderScheduler {
   bool is_denoise_active_during_update() const;
 
   /* Heuristic which aims to give perceptually pleasant update of display 
interval in a way that at
-   * lower samples updates happens more often, but with higher number of 
samples updates happens
-   * less often but the device occupancy goes higher. */
+   * lower samples and near the beginning of rendering, updates happen more 
often, but with higher 
+   * number of samples and later in the render, updates happen less often but 
device occupancy
+   * goes higher. */
   double guess_display_update_interval_in_seconds() const;
   double guess_display_update_interval_in_seconds_for_num_samples(int 
num_rendered_samples) const;
   double guess_display_update_interval_in_seconds_for_num_samples_no_limit(

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to