2022-02-10 22:07:11 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2018-06-27 12:41:53 +00:00
|
|
|
import bpy
|
2023-02-23 21:00:57 +00:00
|
|
|
from bpy.app.translations import contexts as i18n_contexts
|
2019-03-14 04:14:43 +00:00
|
|
|
from bpy.types import Panel
|
2018-06-27 12:41:53 +00:00
|
|
|
from rna_prop_ui import PropertyPanel
|
|
|
|
|
|
|
|
|
|
|
|
class DataButtonsPanel:
|
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "data"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
engine = context.engine
|
|
|
|
return context.light and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_context_light(DataButtonsPanel, Panel):
|
|
|
|
bl_label = ""
|
|
|
|
bl_options = {'HIDE_HEADER'}
|
2023-01-24 16:58:58 +00:00
|
|
|
COMPAT_ENGINES = {
|
|
|
|
'BLENDER_RENDER',
|
|
|
|
'BLENDER_EEVEE_NEXT',
|
|
|
|
'BLENDER_EEVEE',
|
|
|
|
'BLENDER_WORKBENCH',
|
|
|
|
'BLENDER_WORKBENCH_NEXT'}
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
light = context.light
|
|
|
|
space = context.space_data
|
|
|
|
|
|
|
|
if ob:
|
2018-07-14 23:15:32 +00:00
|
|
|
layout.template_ID(ob, "data")
|
2018-06-27 12:41:53 +00:00
|
|
|
elif light:
|
2018-07-14 23:15:32 +00:00
|
|
|
layout.template_ID(space, "pin_id")
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_preview(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Preview"
|
2018-07-14 23:15:32 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2022-08-11 06:13:47 +00:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE_NEXT', 'BLENDER_EEVEE'}
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
self.layout.template_preview(context.light)
|
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_light(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Light"
|
2023-01-24 16:58:58 +00:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_WORKBENCH', 'BLENDER_WORKBENCH_NEXT'}
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
light = context.light
|
|
|
|
|
2019-03-17 16:52:05 +00:00
|
|
|
# Compact layout for node editor.
|
|
|
|
if self.bl_space_type == 'PROPERTIES':
|
|
|
|
layout.row().prop(light, "type", expand=True)
|
|
|
|
layout.use_property_split = True
|
|
|
|
else:
|
|
|
|
layout.use_property_split = True
|
|
|
|
layout.row().prop(light, "type")
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_EEVEE_light(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Light"
|
2022-08-11 06:13:47 +00:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT', 'BLENDER_EEVEE'}
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
light = context.light
|
|
|
|
|
2019-03-17 16:52:05 +00:00
|
|
|
# Compact layout for node editor.
|
|
|
|
if self.bl_space_type == 'PROPERTIES':
|
|
|
|
layout.row().prop(light, "type", expand=True)
|
|
|
|
layout.use_property_split = True
|
|
|
|
else:
|
|
|
|
layout.use_property_split = True
|
|
|
|
layout.row().prop(light, "type")
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
col.prop(light, "color")
|
|
|
|
col.prop(light, "energy")
|
2021-03-19 11:07:23 +00:00
|
|
|
|
|
|
|
col.separator()
|
|
|
|
|
|
|
|
col.prop(light, "diffuse_factor", text="Diffuse")
|
2018-06-27 12:41:53 +00:00
|
|
|
col.prop(light, "specular_factor", text="Specular")
|
2023-02-23 21:00:57 +00:00
|
|
|
col.prop(light, "volume_factor", text="Volume", text_ctxt=i18n_contexts.id_id)
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
col.separator()
|
|
|
|
|
2019-05-15 12:45:33 +00:00
|
|
|
if light.type in {'POINT', 'SPOT'}:
|
2018-06-27 12:41:53 +00:00
|
|
|
col.prop(light, "shadow_soft_size", text="Radius")
|
2019-05-15 12:45:33 +00:00
|
|
|
elif light.type == 'SUN':
|
|
|
|
col.prop(light, "angle")
|
2018-06-27 12:41:53 +00:00
|
|
|
elif light.type == 'AREA':
|
|
|
|
col.prop(light, "shape")
|
|
|
|
|
|
|
|
sub = col.column(align=True)
|
|
|
|
|
|
|
|
if light.shape in {'SQUARE', 'DISK'}:
|
|
|
|
sub.prop(light, "size")
|
|
|
|
elif light.shape in {'RECTANGLE', 'ELLIPSE'}:
|
|
|
|
sub.prop(light, "size", text="Size X")
|
|
|
|
sub.prop(light, "size_y", text="Y")
|
|
|
|
|
|
|
|
|
2018-11-15 13:44:45 +00:00
|
|
|
class DATA_PT_EEVEE_light_distance(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Custom Distance"
|
|
|
|
bl_parent_id = "DATA_PT_EEVEE_light"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2022-08-11 06:13:47 +00:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE_NEXT', 'BLENDER_EEVEE'}
|
2018-11-15 13:44:45 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
light = context.light
|
|
|
|
engine = context.engine
|
|
|
|
|
|
|
|
return (light and light.type != 'SUN') and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
light = context.light
|
|
|
|
|
|
|
|
layout = self.layout
|
|
|
|
layout.prop(light, "use_custom_distance", text="")
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
light = context.light
|
2020-01-21 08:59:22 +00:00
|
|
|
layout.active = light.use_custom_distance
|
2018-11-15 13:44:45 +00:00
|
|
|
layout.use_property_split = True
|
|
|
|
|
2020-01-21 08:59:22 +00:00
|
|
|
layout.prop(light, "cutoff_distance", text="Distance")
|
2018-11-15 13:44:45 +00:00
|
|
|
|
|
|
|
|
2018-06-27 12:41:53 +00:00
|
|
|
class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Shadow"
|
2018-10-18 10:13:06 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2023-02-08 20:08:54 +00:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT'}
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
light = context.light
|
|
|
|
engine = context.engine
|
2019-03-19 23:44:13 +00:00
|
|
|
return (
|
|
|
|
(light and light.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and
|
|
|
|
(engine in cls.COMPAT_ENGINES)
|
|
|
|
)
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
light = context.light
|
|
|
|
|
|
|
|
layout.active = light.use_shadow
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
sub = col.column(align=True)
|
2019-08-22 14:04:25 +00:00
|
|
|
if light.type != 'SUN':
|
|
|
|
sub.prop(light, "shadow_buffer_clip_start", text="Clip Start")
|
2018-06-27 12:41:53 +00:00
|
|
|
|
2023-02-08 20:08:54 +00:00
|
|
|
if context.engine != 'BLENDER_EEVEE_NEXT':
|
|
|
|
col.prop(light, "shadow_buffer_bias", text="Bias")
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_EEVEE_shadow_cascaded_shadow_map(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Cascaded Shadow Map"
|
|
|
|
bl_parent_id = "DATA_PT_EEVEE_shadow"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
light = context.light
|
|
|
|
engine = context.engine
|
|
|
|
|
|
|
|
return (light and light.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
light = context.light
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
|
|
|
|
col.prop(light, "shadow_cascade_count", text="Count")
|
|
|
|
col.prop(light, "shadow_cascade_fade", text="Fade")
|
|
|
|
|
|
|
|
col.prop(light, "shadow_cascade_max_distance", text="Max Distance")
|
|
|
|
col.prop(light, "shadow_cascade_exponent", text="Distribution")
|
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Contact Shadows"
|
|
|
|
bl_parent_id = "DATA_PT_EEVEE_shadow"
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
light = context.light
|
|
|
|
engine = context.engine
|
2019-03-19 23:44:13 +00:00
|
|
|
return (
|
|
|
|
(light and light.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and
|
|
|
|
(engine in cls.COMPAT_ENGINES)
|
|
|
|
)
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
light = context.light
|
|
|
|
|
|
|
|
layout = self.layout
|
|
|
|
layout.active = light.use_shadow
|
|
|
|
layout.prop(light, "use_contact_shadow", text="")
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
light = context.light
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
col.active = light.use_shadow and light.use_contact_shadow
|
|
|
|
|
|
|
|
col.prop(light, "contact_shadow_distance", text="Distance")
|
|
|
|
col.prop(light, "contact_shadow_bias", text="Bias")
|
|
|
|
col.prop(light, "contact_shadow_thickness", text="Thickness")
|
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_spot(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Spot Shape"
|
|
|
|
bl_parent_id = "DATA_PT_EEVEE_light"
|
2023-01-24 16:58:58 +00:00
|
|
|
COMPAT_ENGINES = {
|
|
|
|
'BLENDER_RENDER',
|
|
|
|
'BLENDER_EEVEE_NEXT',
|
|
|
|
'BLENDER_EEVEE',
|
|
|
|
'BLENDER_WORKBENCH',
|
|
|
|
'BLENDER_WORKBENCH_NEXT'}
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
light = context.light
|
|
|
|
engine = context.engine
|
|
|
|
return (light and light.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
|
|
|
|
light = context.light
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
|
|
|
|
col.prop(light, "spot_size", text="Size")
|
|
|
|
col.prop(light, "spot_blend", text="Blend", slider=True)
|
|
|
|
|
|
|
|
col.prop(light, "show_cone")
|
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
|
|
|
|
bl_label = "Falloff Curve"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
light = context.light
|
|
|
|
engine = context.engine
|
|
|
|
|
2019-03-19 23:44:13 +00:00
|
|
|
return (
|
|
|
|
(light and light.type in {'POINT', 'SPOT'} and light.falloff_type == 'CUSTOM_CURVE') and
|
|
|
|
(engine in cls.COMPAT_ENGINES)
|
|
|
|
)
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
light = context.light
|
|
|
|
|
2020-01-21 08:59:22 +00:00
|
|
|
self.layout.template_curve_mapping(
|
|
|
|
light, "falloff_curve", use_negative_slope=True)
|
2018-06-27 12:41:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_custom_props_light(DataButtonsPanel, PropertyPanel, Panel):
|
2023-01-24 16:58:58 +00:00
|
|
|
COMPAT_ENGINES = {
|
|
|
|
'BLENDER_RENDER',
|
|
|
|
'BLENDER_EEVEE_NEXT',
|
|
|
|
'BLENDER_EEVEE',
|
|
|
|
'BLENDER_WORKBENCH',
|
|
|
|
'BLENDER_WORKBENCH_NEXT'}
|
2018-06-27 12:41:53 +00:00
|
|
|
_context_path = "object.data"
|
|
|
|
_property_type = bpy.types.Light
|
|
|
|
|
|
|
|
|
|
|
|
classes = (
|
|
|
|
DATA_PT_context_light,
|
|
|
|
DATA_PT_preview,
|
|
|
|
DATA_PT_light,
|
|
|
|
DATA_PT_EEVEE_light,
|
2018-11-15 13:44:45 +00:00
|
|
|
DATA_PT_EEVEE_light_distance,
|
2018-06-27 12:41:53 +00:00
|
|
|
DATA_PT_EEVEE_shadow,
|
|
|
|
DATA_PT_EEVEE_shadow_cascaded_shadow_map,
|
2019-08-22 14:04:25 +00:00
|
|
|
DATA_PT_EEVEE_shadow_contact,
|
2018-06-27 12:41:53 +00:00
|
|
|
DATA_PT_spot,
|
|
|
|
DATA_PT_falloff_curve,
|
|
|
|
DATA_PT_custom_props_light,
|
|
|
|
)
|
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
from bpy.utils import register_class
|
|
|
|
for cls in classes:
|
|
|
|
register_class(cls)
|