Implement transparent background for Storm delegate #21

Merged
Bogdan Nagirniak merged 4 commits from Vasyl-Pidhirskyi/blender-addons:BLEN-463 into storm-hydra-addon 2023-07-23 21:01:37 +02:00
3 changed files with 46 additions and 0 deletions
Showing only changes of commit a1fe1b31a4 - Show all commits

View File

@ -33,6 +33,14 @@ class StormHydraRenderEngine(bpy_hydra.HydraRenderEngine):
'maxLights': settings.max_lights, 'maxLights': settings.max_lights,
} }
def get_sync_settings(self, engine_type):
settings = bpy.context.scene.hydra_storm.viewport if engine_type == 'VIEWPORT' else \
bpy.context.scene.hydra_storm.final
return {
'enableAlpha': settings.enable_alpha,
}
register, unregister = bpy.utils.register_classes_factory(( register, unregister = bpy.utils.register_classes_factory((
StormHydraRenderEngine, StormHydraRenderEngine,
)) ))

View File

@ -48,6 +48,11 @@ class RenderProperties(bpy.types.PropertyGroup):
description="Limit maximum number of lights", description="Limit maximum number of lights",
default=16, min=0, max=16, default=16, min=0, max=16,
) )
enable_alpha: bpy.props.BoolProperty(
name="Enable Color Alpha",
description="World background is transparent, for compositing the render over another background",
default=False,
)
class SceneProperties(Properties): class SceneProperties(Properties):

View File

@ -58,6 +58,21 @@ class STORM_HYDRA_RENDER_PT_volume_final(bpy.types.Panel):
col.prop(settings, "volume_max_texture_memory_per_field") col.prop(settings, "volume_max_texture_memory_per_field")
class STORM_HYDRA_RENDER_PT_film_final(bpy.types.Panel):
bl_parent_id = STORM_HYDRA_RENDER_PT_final.bl_idname
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.hydra_storm.final, "enable_alpha", text="Transparent Background")
# #
# VIEWPORT RENDER SETTINGS # VIEWPORT RENDER SETTINGS
# #
@ -96,6 +111,21 @@ class STORM_HYDRA_RENDER_PT_volume_viewport(bpy.types.Panel):
col.prop(settings, "volume_max_texture_memory_per_field") col.prop(settings, "volume_max_texture_memory_per_field")
class STORM_HYDRA_RENDER_PT_film_viewport(bpy.types.Panel):
bl_parent_id = STORM_HYDRA_RENDER_PT_viewport.bl_idname
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.hydra_storm.viewport, "enable_alpha", text="Transparent Background")
class STORM_HYDRA_LIGHT_PT_light(Panel): class STORM_HYDRA_LIGHT_PT_light(Panel):
"""Physical light sources""" """Physical light sources"""
bl_label = "Light" bl_label = "Light"
@ -152,8 +182,11 @@ class STORM_HYDRA_LIGHT_PT_light(Panel):
register_classes, unregister_classes = bpy.utils.register_classes_factory(( register_classes, unregister_classes = bpy.utils.register_classes_factory((
STORM_HYDRA_RENDER_PT_final, STORM_HYDRA_RENDER_PT_final,
STORM_HYDRA_RENDER_PT_volume_final, STORM_HYDRA_RENDER_PT_volume_final,
STORM_HYDRA_RENDER_PT_film_final,
STORM_HYDRA_RENDER_PT_viewport, STORM_HYDRA_RENDER_PT_viewport,
STORM_HYDRA_RENDER_PT_volume_viewport, STORM_HYDRA_RENDER_PT_volume_viewport,
STORM_HYDRA_RENDER_PT_film_viewport,
STORM_HYDRA_LIGHT_PT_light, STORM_HYDRA_LIGHT_PT_light,
)) ))