diff --git a/export/light.py b/export/light.py index dca490a9..49826e7f 100644 --- a/export/light.py +++ b/export/light.py @@ -196,6 +196,10 @@ def convert_world(world, scene): if world.luxcore.sun: definitions["dir"] = _calc_sun_dir(world.luxcore.sun) + if world.luxcore.use_sun_gain_for_sky: + gain = [x * world.luxcore.sun.data.luxcore.gain for x in world.luxcore.rgb_gain] + definitions["gain"] = gain + if world.luxcore.sun and world.luxcore.sun.data: # Use sun turbidity so the user does not have to keep two values in sync definitions["turbidity"] = world.luxcore.sun.data.luxcore.turbidity diff --git a/properties/light.py b/properties/light.py index 36a6c2fa..2e06d8a9 100644 --- a/properties/light.py +++ b/properties/light.py @@ -70,7 +70,7 @@ def update_is_laser(self, context): ############################################## # BlendLuxCore specific properties needed to translate LuxCore light concepts to Blender sun_types = [ - ("sun", "Sun", "Sun", 0), + ("sun", "Sun", "Physically correct sun that emits parallel light rays and changes color with elevation", 0), ("distant", "Distant", "Distant star without atmosphere simulation (emits parallel light)", 1), ] sun_type = EnumProperty(name="Sun Type", items=sun_types, default="sun") diff --git a/properties/world.py b/properties/world.py index 8f252c7e..a7009170 100644 --- a/properties/world.py +++ b/properties/world.py @@ -10,6 +10,10 @@ VISIBILITYMAP_ENABLE_DESC, ) +USE_SUN_GAIN_FOR_SKY_DESC = ( + "Use the gain setting of the attached sun " + "(so you adjust both sun and sky gain at the same time)" +) def init(): bpy.types.World.luxcore = PointerProperty(type=LuxCoreWorldProps) @@ -33,6 +37,9 @@ class LuxCoreWorldProps(bpy.types.PropertyGroup): # sky2 settings sun = PointerProperty(name="Sun", type=bpy.types.Object, description="Used to specify the sun direction") + # Only shown in UI when light is sky2 and a sun is attached + use_sun_gain_for_sky = BoolProperty(name="Use Sun Gain", default=True, + description=USE_SUN_GAIN_FOR_SKY_DESC) turbidity = FloatProperty(name="Turbidity", default=2.2, min=0, max=30) groundalbedo = FloatVectorProperty(name="Ground Albedo", default=(0.5, 0.5, 0.5), min=0, max=1, subtype="COLOR") ground_enable = BoolProperty(name="Use Ground Color", default=False) diff --git a/ui/world.py b/ui/world.py index d907f71f..8a962c07 100644 --- a/ui/world.py +++ b/ui/world.py @@ -23,10 +23,20 @@ def draw(self, context): layout.prop(world.luxcore, "light", expand=True) if world.luxcore.light != "none": + # TODO: id (light group) split = layout.split(percentage=0.33) split.prop(world.luxcore, "rgb_gain", text="") - split.prop(world.luxcore, "gain") - # TODO: id (light group) + + is_sky = world.luxcore.light == "sky2" + has_sun = world.luxcore.sun and world.luxcore.sun.type == "LAMP" + + if is_sky and has_sun and world.luxcore.use_sun_gain_for_sky: + split.prop(world.luxcore.sun.data.luxcore, "gain") + else: + split.prop(world.luxcore, "gain") + + if is_sky and has_sun: + split.prop(world.luxcore, "use_sun_gain_for_sky") layout.label("Default Volume (used on materials without attached volume):") utils_ui.template_node_tree(layout, world.luxcore, "volume", ICON_VOLUME, @@ -54,10 +64,15 @@ def draw(self, context): world = context.world layout.prop(world.luxcore, "sun") - sun_obj = world.luxcore.sun - if sun_obj and sun_obj.data and sun_obj.data.type == "SUN": - layout.label("Using turbidity of sun light:", icon="INFO") - layout.prop(sun_obj.data.luxcore, "turbidity") + sun = world.luxcore.sun + if sun: + is_really_a_sun = sun.type == "LAMP" and sun.data and sun.data.type == "SUN" + + if is_really_a_sun: + layout.label("Using turbidity of sun light:", icon="INFO") + layout.prop(sun.data.luxcore, "turbidity") + else: + layout.label("Not a sun lamp", icon="ERROR") else: layout.prop(world.luxcore, "turbidity")