diff options
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 4 | ||||
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 28 | ||||
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 34 | ||||
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 1 |
5 files changed, 67 insertions, 3 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 0a3cffd5071..46a49f52de0 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -155,6 +155,10 @@ class CyclesWorldSettings(bpy.types.PropertyGroup): @classmethod def register(cls): bpy.types.World.cycles = PointerProperty(type=cls, name="Cycles World Settings", description="Cycles world settings") + cls.sample_as_light = BoolProperty(name="Sample as Lamp", description="Use direct light sampling for the environment, enabling for non-solid colors is recommended", + default=False) + cls.sample_map_resolution = IntProperty(name="Map Resolution", description="Importance map size is resolution x resolution; higher values potentially produce less noise, at the cost of memory and speed", + default=256, min=4, max=8096) @classmethod def unregister(cls): diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 70f38fa7e8c..67ff79a2037 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -453,10 +453,38 @@ class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel): layout = self.layout world = context.world + if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'): layout.prop(world, "horizon_color", text="Color") +class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel): + bl_label = "Settings" + bl_context = "world" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + return context.world and CyclesButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + + world = context.world + cworld = world.cycles + + split = layout.split() + col = split.column() + + col.prop(cworld, "sample_as_light") + row = col.row() + row.active = cworld.sample_as_light + row.prop(cworld, "sample_map_resolution") + + col = split.column() + col.label() + + class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel): bl_label = "Volume" bl_context = "world" diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 608cb33eadd..bc7868e0192 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -16,10 +16,13 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "graph.h" #include "light.h" #include "mesh.h" #include "object.h" #include "scene.h" +#include "nodes.h" +#include "shader.h" #include "blender_sync.h" #include "blender_util.h" @@ -152,6 +155,35 @@ void BlenderSync::sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, light->tag_update(scene); } +void BlenderSync::sync_background_light() +{ + BL::World b_world = b_scene.world(); + + PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles"); + bool sample_as_light = get_boolean(cworld, "sample_as_light"); + + if(sample_as_light) { + /* test if we need to sync */ + Light *light; + ObjectKey key(b_world, 0, b_world); + + if(light_map.sync(&light, b_world, b_world, key) || + world_recalc || + b_world.ptr.data != world_map) + { + light->type = LIGHT_BACKGROUND; + light->map_resolution = get_int(cworld, "sample_map_resolution"); + light->shader = scene->default_background; + + light->tag_update(scene); + light_map.set_recalc(b_world); + } + } + + world_map = b_world.ptr.data; + world_recalc = false; +} + /* Object */ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm, uint layer_flag) @@ -263,6 +295,8 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d) } } + sync_background_light(); + /* handle removed data and modified pointers */ if(light_map.post_sync()) scene->light_manager->tag_update(scene); diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index f5ffc321476..1ce134f3094 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -700,9 +700,6 @@ void BlenderSync::sync_world() if(background->modified(prevbackground)) background->tag_update(scene); - - world_map = b_world.ptr.data; - world_recalc = false; } /* Sync Lamps */ diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 7b65376bd84..5e76a0a0b1e 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -80,6 +80,7 @@ private: Mesh *sync_mesh(BL::Object b_ob, bool object_updated); void sync_object(BL::Object b_parent, int b_index, BL::Object b_object, Transform& tfm, uint layer_flag); void sync_light(BL::Object b_parent, int b_index, BL::Object b_ob, Transform& tfm); + void sync_background_light(); /* util */ void find_shader(BL::ID id, vector<uint>& used_shaders, int default_shader); |