Cycles: seed value to get different noise values from renders, there was a patch
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 29 Oct 2011 14:27:24 +0000 (14:27 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 29 Oct 2011 14:27:24 +0000 (14:27 +0000)
for this but I've implemented it differently.

intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_sync.cpp
intern/cycles/kernel/kernel_random.h
intern/cycles/kernel/kernel_types.h
intern/cycles/render/integrator.cpp
intern/cycles/render/integrator.h
intern/cycles/util/util_hash.h

index 6fab3ecaa688f518ad4a656dafdd21cf34741cd7..0d30307fc73d68e2bf5ab0335dd4f4fba0c27085 100644 (file)
@@ -78,6 +78,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
         cls.filter_width = FloatProperty(name="Filter Width", description="Pixel filter width",
             default=1.5, min=0.01, max=10.0)
 
+        cls.seed = IntProperty(name="Seed", description="Seed value for integrator to get different noise patterns",
+            default=0, min=0, max=2147483647)
+
         cls.debug_tile_size = IntProperty(name="Tile Size", description="",
             default=1024, min=1, max=4096)
         cls.debug_min_size = IntProperty(name="Min Size", description="",
index f9e178a2d3aaf143423cd2bf6bf5156abecb0782..ca077a50ad6d1ccdb11cfe31aae8068cadba256e 100644 (file)
@@ -62,13 +62,13 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
         sub.label(text="Samples:")
         sub.prop(cscene, "samples", text="Render")
         sub.prop(cscene, "preview_samples", text="Preview")
+        sub.prop(cscene, "seed")
 
         sub = col.column(align=True)
         sub.label("Transparency:")
         sub.prop(cscene, "transparent_max_bounces", text="Max")
         sub.prop(cscene, "transparent_min_bounces", text="Min")
         sub.prop(cscene, "use_transparent_shadows", text="Shadows")
-        sub.prop(cscene, "no_caustics")
 
         col = split.column()
 
@@ -82,6 +82,7 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
         sub.prop(cscene, "diffuse_bounces", text="Diffuse")
         sub.prop(cscene, "glossy_bounces", text="Glossy")
         sub.prop(cscene, "transmission_bounces", text="Transmission")
+        sub.prop(cscene, "no_caustics")
 
         #row = col.row()
         #row.prop(cscene, "blur_caustics")
index 4babb612bdd9fb240a196ac8ef43a50f848b1cf7..3a9514efa3cbc6b5f1a5e8e7ca106a62a82bb4f7 100644 (file)
@@ -151,6 +151,8 @@ void BlenderSync::sync_integrator()
        integrator->no_caustics = get_boolean(cscene, "no_caustics");
        integrator->blur_caustics = get_float(cscene, "blur_caustics");
 
+       integrator->seed = get_int(cscene, "seed");
+
        if(integrator->modified(previntegrator))
                integrator->tag_update(scene);
 }
index 13cf4df8b8c4dc1314837afdd80845cfe61391b2..df876e6f72611263d6f155fedbc3328709c57216 100644 (file)
@@ -128,11 +128,15 @@ __device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state,
 
        *rng = sobol_lookup(bits, frame, x, y, &px, &py);
 
+       *rng ^= kernel_data.integrator.seed;
+
        *fx = size * (float)px * (1.0f/(float)0xFFFFFFFF) - x;
        *fy = size * (float)py * (1.0f/(float)0xFFFFFFFF) - y;
 #else
        *rng = rng_state[x + y*kernel_data.cam.width];
 
+       *rng ^= kernel_data.integrator.seed;
+
        *fx = path_rng(kg, rng, sample, PRNG_FILTER_U);
        *fy = path_rng(kg, rng, sample, PRNG_FILTER_V);
 #endif
@@ -159,6 +163,8 @@ __device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sam
        /* load state */
        *rng = rng_state[x + y*kernel_data.cam.width];
 
+       *rng ^= kernel_data.integrator.seed;
+
        *fx = path_rng(kg, rng, sample, PRNG_FILTER_U);
        *fy = path_rng(kg, rng, sample, PRNG_FILTER_V);
 }
index d8270b2cd718214b4d5e3defa226ec92d0d0584c..46cdcd1151e1f67ea0f19264713704576d49ec24 100644 (file)
@@ -362,7 +362,6 @@ typedef struct KernelIntegrator {
        int num_all_lights;
        float pdf_triangles;
        float pdf_lights;
-       float pdf_pad;
 
        /* bounces */
        int min_bounce;
@@ -380,6 +379,9 @@ typedef struct KernelIntegrator {
        /* caustics */
        int no_caustics;
        float blur_caustics;
+
+       /* seed */
+       int seed;
 } KernelIntegrator;
 
 typedef struct KernelBVH {
index 78ea464d836d0fa66ae0a70d5b3a95d132bbced5..9d129d8e8db07f1c48076845fbe7fa8f5b73e12e 100644 (file)
@@ -21,6 +21,8 @@
 #include "scene.h"
 #include "sobol.h"
 
+#include "util_hash.h"
+
 CCL_NAMESPACE_BEGIN
 
 Integrator::Integrator()
@@ -41,6 +43,8 @@ Integrator::Integrator()
        no_caustics = false;
        blur_caustics = 0.0f;
 
+       seed = 0;
+
        need_update = true;
 }
 
@@ -79,6 +83,8 @@ void Integrator::device_update(Device *device, DeviceScene *dscene)
        kintegrator->no_caustics = no_caustics;
        kintegrator->blur_caustics = blur_caustics;
 
+       kintegrator->seed = hash_int(seed);
+
        /* sobol directions table */
        int dimensions = PRNG_BASE_NUM + (max_bounce + transparent_max_bounce + 2)*PRNG_BOUNCE_NUM;
        uint *directions = dscene->sobol_directions.resize(SOBOL_BITS*dimensions);
@@ -109,7 +115,8 @@ bool Integrator::modified(const Integrator& integrator)
                transparent_probalistic == integrator.transparent_probalistic &&
                transparent_shadows == integrator.transparent_shadows &&
                no_caustics == integrator.no_caustics &&
-               blur_caustics == integrator.blur_caustics);
+               blur_caustics == integrator.blur_caustics &&
+               seed == integrator.seed);
 }
 
 void Integrator::tag_update(Scene *scene)
index 5bab4470089e004e53d444035551eecf35e2043b..52032fa1a261714c582ca17ab796942ac10ea2ec 100644 (file)
@@ -42,6 +42,9 @@ public:
 
        bool no_caustics;
        float blur_caustics;
+
+       int seed;
+
        bool need_update;
 
        Integrator();
index 0b7164403f2be1c3e551423e13ea66bd2b7f9207..af7ad7e06a12a4f9debd3591adc3d2bcdf02f861 100644 (file)
@@ -44,6 +44,11 @@ static unsigned int hash_int_2d(unsigned int kx, unsigned int ky)
        #undef rot
 }
 
+static unsigned int hash_int(unsigned int k)
+{
+       return hash_int_2d(k, 0);
+}
+
 CCL_NAMESPACE_END
 
 #endif /* __UTIL_HASH_H__ */