Fix T57138: Cycles CMJ failing with viewport samples set to 0.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 14 Mar 2019 16:29:18 +0000 (17:29 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 14 Mar 2019 16:39:00 +0000 (17:39 +0100)
Can't use INT_MAX, CMJ runs into precision/overflow issues before that.

intern/cycles/blender/addon/properties.py
intern/cycles/blender/blender_sync.cpp
intern/cycles/render/integrator.h
intern/cycles/render/session.h

index 04b0cf75e820bbd2a9e7a9c35dc071ea5709fe0c..950a0b5f08fc9b7a05c90ae710bd7c14642d6b99 100644 (file)
@@ -194,13 +194,13 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
         cls.samples = IntProperty(
             name="Samples",
             description="Number of samples to render for each pixel",
-            min=1, max=2147483647,
+            min=1, max=(1 << 24),
             default=128,
         )
         cls.preview_samples = IntProperty(
             name="Preview Samples",
             description="Number of samples to render in the viewport, unlimited if 0",
-            min=0, max=2147483647,
+            min=0, max=(1 << 24),
             default=32,
         )
         cls.preview_pause = BoolProperty(
index 05979fa4f574859dd85656760774b8ab0b49a323..a1202cbbad4ffb706fef9b9d4132d34b1f390964 100644 (file)
@@ -794,6 +794,9 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
                }
        }
 
+       /* Clamp samples. */
+       params.samples = min(params.samples, Integrator::MAX_SAMPLES);
+
        /* tiles */
        const bool is_cpu = (params.device.type == DEVICE_CPU);
        if(!is_cpu && !background) {
index 6a7e20568519d3878280a7f8bfc534e5829547aa..da4e61d8153cfc0b8564bb33e8a8d2c13d04de7a 100644 (file)
@@ -55,6 +55,10 @@ public:
        float sample_clamp_indirect;
        bool motion_blur;
 
+       /* Maximum number of samples, beyond which we are likely to run into
+        * precision issues for sampling patterns. */
+       static const int MAX_SAMPLES = (1 << 24);
+
        int aa_samples;
        int diffuse_samples;
        int glossy_samples;
index e3cccbb9fcf95f3e46c45f4c2532d037aee78f39..cbdfc75a9052cfce06f9838f04c3c9b4925e8d28 100644 (file)
@@ -84,7 +84,7 @@ public:
 
                progressive = false;
                experimental = false;
-               samples = INT_MAX;
+               samples = 1024;
                tile_size = make_int2(64, 64);
                start_resolution = INT_MAX;
                pixel_size = 1;