Eevee: Shadows: Add UI buttons for size and method
authorClément Foucault <foucault.clem@gmail.com>
Fri, 1 Sep 2017 13:59:58 +0000 (15:59 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Sun, 10 Sep 2017 01:09:45 +0000 (03:09 +0200)
Only one method is available right now. VSM and PCF are comming.

release/scripts/startup/bl_ui/properties_render.py
release/scripts/startup/bl_ui/properties_render_layer.py
source/blender/makesrna/intern/rna_scene.c

index ce30256794f688a4e329ab25f867bd98c7f04460..49c3c9ad7c9dd3cd724075ddd5c734ef56559787 100644 (file)
@@ -746,6 +746,25 @@ class RENDER_PT_eevee_screen_space_reflections(RenderButtonsPanel, Panel):
         col.prop(props, "ssr_firefly_fac")
 
 
+class RENDER_PT_eevee_shadows(RenderButtonsPanel, Panel):
+    bl_label = "Shadows"
+    COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+    @classmethod
+    def poll(cls, context):
+        scene = context.scene
+        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+    def draw(self, context):
+        layout = self.layout
+        scene = context.scene
+        props = scene.layer_properties['BLENDER_EEVEE']
+
+        col = layout.column()
+        col.prop(props, "shadow_method")
+        col.prop(props, "shadow_size")
+
+
 classes = (
     RENDER_MT_presets,
     RENDER_MT_ffmpeg_presets,
@@ -767,6 +786,7 @@ classes = (
     RENDER_PT_eevee_screen_space_reflections,
     RENDER_PT_eevee_poststack_settings,
     RENDER_PT_eevee_postprocess_settings,
+    RENDER_PT_eevee_shadows,
 )
 
 if __name__ == "__main__":  # only for live edit.
index e43157171579f458f4466a67c6a9f206a43129e3..6c4ab256594d197e02cc32a68514506336b49768 100644 (file)
@@ -290,6 +290,27 @@ class RENDERLAYER_PT_eevee_screen_space_reflections(RenderLayerButtonsPanel, Pan
         col.template_override_property(layer_props, scene_props, "ssr_firefly_fac")
 
 
+class RENDERLAYER_PT_eevee_shadows(RenderLayerButtonsPanel, Panel):
+    bl_label = "Shadows"
+    COMPAT_ENGINES = {'BLENDER_EEVEE'}
+
+    @classmethod
+    def poll(cls, context):
+        scene = context.scene
+        return scene and (scene.render.engine in cls.COMPAT_ENGINES)
+
+    def draw(self, context):
+        layout = self.layout
+        scene = context.scene
+        scene_props = scene.layer_properties['BLENDER_EEVEE']
+        layer = bpy.context.render_layer
+        layer_props = layer.engine_overrides['BLENDER_EEVEE']
+
+        col = layout.column()
+        col.template_override_property(layer_props, scene_props, "shadow_method")
+        col.template_override_property(layer_props, scene_props, "shadow_size")
+
+
 classes = (
     RENDERLAYER_UL_renderlayers,
     RENDERLAYER_PT_layers,
index f61e0212f63daf5b8c9b4c2175a6a9c522bd7bda..3e744923d45e980339c1dbedc60601e204ea717c 100644 (file)
@@ -2658,6 +2658,8 @@ RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_max_roughness)
 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_thickness)
 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_border_fade)
 RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_firefly_fac)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_method)
+RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_size)
 
 /* object engine */
 RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(show_wire)
@@ -6205,6 +6207,26 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
 
+       /* Keep in sync with eevee_private.h */
+       static EnumPropertyItem eevee_shadow_method_items[] = {
+               {1, "ESM", 0, "ESM", "Exponential Shadow Mapping"},
+               /* TODO */
+               // {2, "VSM", 0, "VSM", "Variance Shadow Mapping"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
+       static EnumPropertyItem eevee_shadow_size_items[] = {
+               {64, "64", 0, "64px", ""},
+               {128, "128", 0, "128px", ""},
+               {256, "256", 0, "256px", ""},
+               {512, "512", 0, "512px", ""},
+               {1024, "1024", 0, "1024px", ""},
+               {2048, "2048", 0, "2048px", ""},
+               {4096, "4096", 0, "4096px", ""},
+               {8192, "8192", 0, "8192px", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        srna = RNA_def_struct(brna, "SceneLayerEngineSettingsEevee", "SceneLayerSettings");
        RNA_def_struct_ui_text(srna, "Eevee Scene Layer Settings", "Eevee Engine settings");
 
@@ -6532,6 +6554,21 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
        RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
        RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
 
+       /* Shadows */
+       prop = RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_method_get", "rna_LayerEngineSettings_Eevee_shadow_method_set", NULL);
+       RNA_def_property_enum_items(prop, eevee_shadow_method_items);
+       RNA_def_property_ui_text(prop, "Method", "Technique use to compute the shadows");
+       RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+       RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
+       prop = RNA_def_property(srna, "shadow_size", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_size_get", "rna_LayerEngineSettings_Eevee_shadow_size_set", NULL);
+       RNA_def_property_enum_items(prop, eevee_shadow_size_items);
+       RNA_def_property_ui_text(prop, "Size", "Size of every shadow maps");
+       RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
+       RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
+
        RNA_define_verify_sdna(1); /* not in sdna */
 }