diff --git a/hydra_storm/ui.py b/hydra_storm/ui.py index 0e375a959..01d4859c4 100644 --- a/hydra_storm/ui.py +++ b/hydra_storm/ui.py @@ -6,7 +6,6 @@ import bpy from .engine import StormHydraRenderEngine -from .preferences import addon_preferences class Panel(bpy.types.Panel): @@ -96,8 +95,63 @@ class STORM_HYDRA_RENDER_PT_volume_viewport(bpy.types.Panel): col.prop(settings, "volume_max_texture_memory_per_field") +class STORM_HYDRA_RENDER_PT_shadows(Panel): + bl_label = "Shadows" + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + props = context.scene.eevee + + col = layout.column() + col.prop(props, "shadow_cascade_size", text="Cascade Size") + + +class STORM_HYDRA_RENDER_PT_film(Panel): + bl_label = "Film" + bl_space_type = 'PROPERTIES' + bl_region_type = 'WINDOW' + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + layout.prop(context.scene.render, "film_transparent", text="Transparent Background") + + +class STORM_HYDRA_RENDER_PT_passes(Panel): + bl_label = "Passes" + bl_context = "view_layer" + + def draw(self, context): + pass + + +class STORM_HYDRA_RENDER_PT_passes_data(Panel): + bl_label = "Data" + bl_context = "view_layer" + bl_parent_id = "STORM_HYDRA_RENDER_PT_passes" + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + view_layer = context.view_layer + + col = layout.column(heading="Include", align=True) + col.prop(view_layer, "use_pass_z") + + class STORM_HYDRA_LIGHT_PT_light(Panel): """Physical light sources""" + bl_idname = 'STORM_HYDRA_LIGHT_PT_light' bl_label = "Light" bl_context = 'data' @@ -149,42 +203,37 @@ class STORM_HYDRA_LIGHT_PT_light(Panel): main_col.prop(light, 'size') -class STORM_HYDRA_RENDER_PT_film(Panel): - bl_label = "Film" +class STORM_HYDRA_LIGHT_PT_shadows(Panel): + bl_parent_id = STORM_HYDRA_LIGHT_PT_light.bl_idname + bl_label = "Shadow" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_options = {'DEFAULT_CLOSED'} - def draw(self, context): - layout = self.layout - layout.use_property_split = True - layout.use_property_decorate = False + @classmethod + def poll(cls, context): + light = context.light + return ( + (light and light.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) + ) - layout.prop(context.scene.render, "film_transparent", text="Transparent Background") - - -class STORM_HYDRA_RENDER_PT_passes(Panel): - bl_label = "Passes" - bl_context = "view_layer" - - def draw(self, context): - pass - - -class STORM_HYDRA_RENDER_PT_passes_data(Panel): - bl_label = "Data" - bl_context = "view_layer" - bl_parent_id = "STORM_HYDRA_RENDER_PT_passes" + def draw_header(self, context): + light = context.light + self.layout.prop(light, "use_shadow", text="") def draw(self, context): layout = self.layout layout.use_property_split = True - layout.use_property_decorate = False - view_layer = context.view_layer + light = context.light - col = layout.column(heading="Include", align=True) - col.prop(view_layer, "use_pass_z") + layout.active = light.use_shadow + + if light.type == 'SUN': + col = layout.column() + col.prop(light, "shadow_buffer_bias", text="Bias") + col.prop(light, "shadow_cascade_max_distance", text="Max Distance") + col.prop(light, "shadow_cascade_fade", text="Fade") register_classes, unregister_classes = bpy.utils.register_classes_factory(( @@ -192,10 +241,12 @@ register_classes, unregister_classes = bpy.utils.register_classes_factory(( STORM_HYDRA_RENDER_PT_volume_final, STORM_HYDRA_RENDER_PT_viewport, STORM_HYDRA_RENDER_PT_volume_viewport, + STORM_HYDRA_RENDER_PT_shadows, STORM_HYDRA_RENDER_PT_film, - STORM_HYDRA_LIGHT_PT_light, STORM_HYDRA_RENDER_PT_passes, STORM_HYDRA_RENDER_PT_passes_data, + STORM_HYDRA_LIGHT_PT_light, + STORM_HYDRA_LIGHT_PT_shadows, ))