Add traverse_transparent property to control sun light traversal through transparent objects

This commit is contained in:
falken10
2025-03-10 14:44:11 +01:00
committed by Dion Moult
parent 6517cafd98
commit 4cff2f1fc1
2 changed files with 37 additions and 0 deletions
@@ -73,6 +73,8 @@ def update_sun_path_size(self, context):
def update_display_shadows(self, context):
if self.display_shadows:
if context.scene.BIMSolarProperties.traverse_transparent:
context.scene.BIMSolarProperties.traverse_transparent = False
update_sun_path(self)
context.scene.render.engine = "BLENDER_WORKBENCH"
context.scene.display.shading.light = "FLAT"
@@ -86,6 +88,27 @@ def update_display_shadows(self, context):
space = tool.Blender.get_view3d_space()
space.shading.type = "SOLID"
def update_traverse_transparent(self, context):
if self.traverse_transparent:
if context.scene.BIMSolarProperties.display_shadows:
context.scene.BIMSolarProperties.display_shadows = False
if context.scene.sun_pos_properties.sun_object is None:
bpy.ops.object.light_add(type="SUN", radius=1, align="WORLD", location=(0, 0, 0), scale=(1, 1, 1))
bpy.ops.object.move_to_collection(collection_index=0)
context.scene.sun_pos_properties.sun_object = bpy.context.active_object
update_sun_path(self)
context.scene.render.engine = "BLENDER_EEVEE_NEXT"
context.scene.display.shading.light = "FLAT"
context.scene.display.shading.show_shadows = True
context.scene.display.shading.show_object_outline = True
context.scene.display.shadow_focus = 1.0
context.scene.view_settings.view_transform = "Standard" # Preserve shading colours
space = tool.Blender.get_view3d_space()
space.shading.type = "RENDERED"
else:
context.scene.render.engine = "BLENDER_WORKBENCH"
space = tool.Blender.get_view3d_space()
space.shading.type = "SOLID"
def update_display_sun_path(self, context):
if self.display_sun_path:
@@ -400,6 +423,14 @@ class BIMSolarProperties(PropertyGroup):
description="Enables a visual style to display shadows easily",
update=update_display_shadows,
)
traverse_transparent: BoolProperty(
name="Enable Sun: Shadows and Light traversal of transparent objects",
default=False,
description="Enables a visual style so Sun light can traverse transparent objects and cast shadows (it toggles the render engine to EEVEE)",
update=update_traverse_transparent,
)
display_sun_path: BoolProperty(
name="Display Sun Path",
default=False,
+6
View File
@@ -239,5 +239,11 @@ class BIM_PT_solar(bpy.types.Panel):
row.prop(props, "display_shadows", icon="SHADING_RENDERED")
row.prop(context.scene.display.shading, "shadow_intensity", text="Shadow Intensity")
row = self.layout.row(align=True)
row.prop(props, "traverse_transparent", icon="SHADING_RENDERED")
if props.traverse_transparent:
row = self.layout.row(align=True)
row.prop(context.scene.sun_pos_properties.sun_object.data , "energy", text="Sun Intensity")
row = self.layout.row(align=True)
row.operator("bim.view_from_sun", icon="LIGHT_HEMI")