Merge branch 'blender-v4.0-release'
[blender-addons.git] / hydra_storm / ui.py
blob2ebe9b081aa839e9240e5ce5935b906a3a5fc747
1 # SPDX-FileCopyrightText: 2011-2022 Blender Foundation
3 # SPDX-License-Identifier: Apache-2.0
5 import bpy
7 from .engine import StormHydraRenderEngine
10 class Panel(bpy.types.Panel):
11 bl_space_type = 'PROPERTIES'
12 bl_region_type = 'WINDOW'
13 bl_context = 'render'
14 COMPAT_ENGINES = {StormHydraRenderEngine.bl_idname}
16 @classmethod
17 def poll(cls, context):
18 return context.engine in cls.COMPAT_ENGINES
22 # Quality render settings
24 class STORM_HYDRA_RENDER_PT_quality(Panel):
25 bl_label = "Quality"
27 def draw(self, layout):
28 pass
31 class STORM_HYDRA_RENDER_PT_quality_viewport(Panel):
32 bl_label = "Viewport"
33 bl_parent_id = "STORM_HYDRA_RENDER_PT_quality"
35 def draw(self, context):
36 layout = self.layout
37 layout.use_property_split = True
38 layout.use_property_decorate = False
40 settings = context.scene.hydra_storm.viewport
41 layout.prop(settings, 'max_lights')
42 layout.prop(settings, 'use_tiny_prim_culling')
45 class STORM_HYDRA_RENDER_PT_quality_render(Panel):
46 bl_label = "Render"
47 bl_parent_id = "STORM_HYDRA_RENDER_PT_quality"
49 def draw(self, context):
50 layout = self.layout
51 layout.use_property_split = True
52 layout.use_property_decorate = False
54 settings = context.scene.hydra_storm.final
55 layout.prop(settings, 'max_lights')
56 layout.prop(settings, 'use_tiny_prim_culling')
60 # Volume render settings
62 class STORM_HYDRA_RENDER_PT_volumes(Panel):
63 bl_label = "Volumes"
64 bl_options = {'DEFAULT_CLOSED'}
66 def draw(self, layout):
67 pass
70 class STORM_HYDRA_RENDER_PT_volumes_viewport(Panel):
71 bl_label = "Viewport"
72 bl_parent_id = "STORM_HYDRA_RENDER_PT_volumes"
74 def draw(self, context):
75 layout = self.layout
76 layout.use_property_split = True
77 layout.use_property_decorate = False
79 settings = context.scene.hydra_storm.viewport
81 col = layout.column(align=True)
82 col.prop(settings, "volume_raymarching_step_size", text="Step Size")
83 col.prop(settings, "volume_raymarching_step_size_lighting", text="Step Size Lightning")
84 col.prop(settings, "volume_max_texture_memory_per_field")
87 class STORM_HYDRA_RENDER_PT_volumes_render(Panel):
88 bl_label = "Render"
89 bl_parent_id = "STORM_HYDRA_RENDER_PT_volumes"
91 def draw(self, context):
92 layout = self.layout
93 layout.use_property_split = True
94 layout.use_property_decorate = False
96 settings = context.scene.hydra_storm.final
98 col = layout.column(align=True)
99 col.prop(settings, "volume_raymarching_step_size", text="Step Size")
100 col.prop(settings, "volume_raymarching_step_size_lighting", text="Step Size Lightning")
101 col.prop(settings, "volume_max_texture_memory_per_field")
105 # Film settings
107 class STORM_HYDRA_RENDER_PT_film(Panel):
108 bl_label = "Film"
109 bl_options = {'DEFAULT_CLOSED'}
111 def draw(self, context):
112 layout = self.layout
113 layout.use_property_split = True
114 layout.use_property_decorate = False
116 layout.prop(context.scene.render, "film_transparent", text="Transparent Background")
120 # View layer settings
122 class STORM_HYDRA_RENDER_PT_passes(Panel):
123 bl_label = "Passes"
124 bl_context = "view_layer"
126 def draw(self, context):
127 pass
130 class STORM_HYDRA_RENDER_PT_passes_data(Panel):
131 bl_label = "Data"
132 bl_context = "view_layer"
133 bl_parent_id = "STORM_HYDRA_RENDER_PT_passes"
135 def draw(self, context):
136 layout = self.layout
137 layout.use_property_split = True
138 layout.use_property_decorate = False
140 view_layer = context.view_layer
142 col = layout.column(heading="Include", align=True)
143 col.prop(view_layer, "use_pass_combined")
144 col.prop(view_layer, "use_pass_z")
148 # Light settings
150 class STORM_HYDRA_LIGHT_PT_light(Panel):
151 """Physical light sources"""
152 bl_label = "Light"
153 bl_context = 'data'
155 @classmethod
156 def poll(cls, context):
157 return super().poll(context) and context.light
159 def draw(self, context):
160 layout = self.layout
162 light = context.light
164 layout.prop(light, "type", expand=True)
166 layout.use_property_split = True
167 layout.use_property_decorate = False
169 main_col = layout.column()
171 main_col.prop(light, "color")
172 main_col.prop(light, "energy")
173 main_col.separator()
175 if light.type == 'POINT':
176 row = main_col.row(align=True)
177 row.prop(light, "shadow_soft_size", text="Radius")
179 elif light.type == 'SPOT':
180 col = main_col.column(align=True)
181 col.prop(light, 'spot_size', slider=True)
182 col.prop(light, 'spot_blend', slider=True)
184 main_col.prop(light, 'show_cone')
186 elif light.type == 'SUN':
187 main_col.prop(light, "angle")
189 elif light.type == 'AREA':
190 main_col.prop(light, "shape", text="Shape")
191 sub = main_col.column(align=True)
193 if light.shape in {'SQUARE', 'DISK'}:
194 sub.prop(light, "size")
195 elif light.shape in {'RECTANGLE', 'ELLIPSE'}:
196 sub.prop(light, "size", text="Size X")
197 sub.prop(light, "size_y", text="Y")
199 else:
200 main_col.prop(light, 'size')
203 register_classes, unregister_classes = bpy.utils.register_classes_factory((
204 STORM_HYDRA_RENDER_PT_quality,
205 STORM_HYDRA_RENDER_PT_quality_viewport,
206 STORM_HYDRA_RENDER_PT_quality_render,
207 STORM_HYDRA_RENDER_PT_volumes,
208 STORM_HYDRA_RENDER_PT_volumes_viewport,
209 STORM_HYDRA_RENDER_PT_volumes_render,
210 STORM_HYDRA_RENDER_PT_film,
211 STORM_HYDRA_LIGHT_PT_light,
212 STORM_HYDRA_RENDER_PT_passes,
213 STORM_HYDRA_RENDER_PT_passes_data,
217 def get_panels():
218 # Follow the Cycles model of excluding panels we don't want.
219 exclude_panels = {
220 'RENDER_PT_stamp',
221 'DATA_PT_light',
222 'DATA_PT_spot',
223 'NODE_DATA_PT_light',
224 'DATA_PT_falloff_curve',
225 'RENDER_PT_post_processing',
226 'RENDER_PT_simplify',
227 'SCENE_PT_audio',
228 'RENDER_PT_freestyle'
230 include_eevee_panels = {
231 'MATERIAL_PT_preview',
232 'EEVEE_MATERIAL_PT_context_material',
233 'EEVEE_MATERIAL_PT_surface',
234 'EEVEE_MATERIAL_PT_volume',
235 'EEVEE_MATERIAL_PT_settings',
236 'EEVEE_WORLD_PT_surface',
239 for panel_cls in bpy.types.Panel.__subclasses__():
240 if hasattr(panel_cls, 'COMPAT_ENGINES') and (
241 ('BLENDER_RENDER' in panel_cls.COMPAT_ENGINES and panel_cls.__name__ not in exclude_panels) or
242 ('BLENDER_EEVEE' in panel_cls.COMPAT_ENGINES and panel_cls.__name__ in include_eevee_panels)
244 yield panel_cls
247 def register():
248 register_classes()
250 for panel_cls in get_panels():
251 panel_cls.COMPAT_ENGINES.add(StormHydraRenderEngine.bl_idname)
254 def unregister():
255 unregister_classes()
257 for panel_cls in get_panels():
258 if StormHydraRenderEngine.bl_idname in panel_cls.COMPAT_ENGINES:
259 panel_cls.COMPAT_ENGINES.remove(StormHydraRenderEngine.bl_idname)