2022-02-10 22:07:11 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2009-04-27 18:05:58 +00:00
|
|
|
import bpy
|
2011-08-12 06:57:00 +00:00
|
|
|
from bpy.types import Panel
|
2010-01-08 08:54:41 +00:00
|
|
|
from rna_prop_ui import PropertyPanel
|
2018-07-05 10:44:15 +00:00
|
|
|
from bpy_extras.node_utils import find_node_input
|
2010-08-21 04:51:00 +00:00
|
|
|
|
2009-11-14 13:35:44 +00:00
|
|
|
|
2015-01-29 04:35:06 +00:00
|
|
|
class WorldButtonsPanel:
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = "world"
|
|
|
|
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
|
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2017-10-16 19:15:03 +00:00
|
|
|
return (context.world and context.engine in cls.COMPAT_ENGINES)
|
2010-08-09 01:37:09 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class WORLD_PT_context_world(WorldButtonsPanel, Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = ""
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'HIDE_HEADER'}
|
2023-01-24 16:58:58 +00:00
|
|
|
COMPAT_ENGINES = {
|
|
|
|
'BLENDER_RENDER',
|
|
|
|
'BLENDER_EEVEE',
|
|
|
|
'BLENDER_EEVEE_NEXT',
|
|
|
|
'BLENDER_WORKBENCH',
|
|
|
|
'BLENDER_WORKBENCH_NEXT'}
|
2009-04-27 18:05:58 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2018-04-17 11:35:05 +00:00
|
|
|
return (context.engine in cls.COMPAT_ENGINES)
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
scene = context.scene
|
|
|
|
world = context.world
|
|
|
|
space = context.space_data
|
2010-09-07 15:17:42 +00:00
|
|
|
|
2010-08-06 15:17:44 +00:00
|
|
|
if scene:
|
2021-01-13 14:08:09 +00:00
|
|
|
layout.template_ID(scene, "world", new="world.new")
|
2010-08-06 15:17:44 +00:00
|
|
|
elif world:
|
2018-07-14 23:15:32 +00:00
|
|
|
layout.template_ID(space, "pin_id")
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2010-08-12 19:36:10 +00:00
|
|
|
|
2018-02-01 17:09:06 +00:00
|
|
|
class EEVEE_WORLD_PT_mist(WorldButtonsPanel, Panel):
|
|
|
|
bl_label = "Mist Pass"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2022-06-28 16:33:25 +00:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT'}
|
2018-02-01 17:09:06 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
engine = context.engine
|
2022-06-28 16:31:49 +00:00
|
|
|
return context.world and (engine in cls.COMPAT_ENGINES)
|
2018-02-01 17:09:06 +00:00
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2018-06-25 15:02:47 +00:00
|
|
|
layout.use_property_split = True
|
2018-02-01 17:09:06 +00:00
|
|
|
|
|
|
|
world = context.world
|
|
|
|
|
2020-09-10 01:15:05 +00:00
|
|
|
col = layout.column(align=True)
|
|
|
|
col.prop(world.mist_settings, "start")
|
|
|
|
col.prop(world.mist_settings, "depth")
|
|
|
|
|
|
|
|
col = layout.column()
|
|
|
|
col.prop(world.mist_settings, "falloff")
|
2018-02-01 17:09:06 +00:00
|
|
|
|
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class WORLD_PT_custom_props(WorldButtonsPanel, PropertyPanel, Panel):
|
2023-01-24 16:58:58 +00:00
|
|
|
COMPAT_ENGINES = {
|
|
|
|
'BLENDER_RENDER',
|
|
|
|
'BLENDER_EEVEE',
|
|
|
|
'BLENDER_EEVEE_NEXT',
|
|
|
|
'BLENDER_WORKBENCH',
|
|
|
|
'BLENDER_WORKBENCH_NEXT'}
|
2010-08-12 19:36:10 +00:00
|
|
|
_context_path = "world"
|
2010-12-17 10:33:28 +00:00
|
|
|
_property_type = bpy.types.World
|
2011-04-04 10:13:04 +00:00
|
|
|
|
2017-03-18 09:03:24 +00:00
|
|
|
|
2017-04-25 21:48:26 +00:00
|
|
|
class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel):
|
|
|
|
bl_label = "Surface"
|
2022-06-28 16:33:25 +00:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_EEVEE_NEXT'}
|
2017-04-25 21:48:26 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
2017-10-16 19:15:03 +00:00
|
|
|
engine = context.engine
|
2017-04-25 21:48:26 +00:00
|
|
|
return context.world and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
world = context.world
|
|
|
|
|
2017-05-30 15:16:36 +00:00
|
|
|
layout.prop(world, "use_nodes", icon='NODETREE')
|
|
|
|
layout.separator()
|
|
|
|
|
2020-05-01 13:21:41 +00:00
|
|
|
layout.use_property_split = True
|
|
|
|
|
2017-05-30 15:16:36 +00:00
|
|
|
if world.use_nodes:
|
|
|
|
ntree = world.node_tree
|
2018-07-05 10:44:15 +00:00
|
|
|
node = ntree.get_output_node('EEVEE')
|
2017-05-30 15:16:36 +00:00
|
|
|
|
2017-08-01 16:03:16 +00:00
|
|
|
if node:
|
2017-05-30 15:16:36 +00:00
|
|
|
input = find_node_input(node, 'Surface')
|
2017-08-01 16:03:16 +00:00
|
|
|
if input:
|
|
|
|
layout.template_node_view(ntree, node, input)
|
|
|
|
else:
|
|
|
|
layout.label(text="Incompatible output node")
|
|
|
|
else:
|
|
|
|
layout.label(text="No output node")
|
2017-05-30 15:16:36 +00:00
|
|
|
else:
|
2018-07-17 10:35:45 +00:00
|
|
|
layout.prop(world, "color")
|
|
|
|
|
|
|
|
|
2019-05-07 09:56:55 +00:00
|
|
|
class EEVEE_WORLD_PT_volume(WorldButtonsPanel, Panel):
|
|
|
|
bl_label = "Volume"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
engine = context.engine
|
|
|
|
world = context.world
|
|
|
|
return world and world.use_nodes and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
world = context.world
|
|
|
|
ntree = world.node_tree
|
|
|
|
node = ntree.get_output_node('EEVEE')
|
|
|
|
|
2020-05-01 13:21:41 +00:00
|
|
|
layout.use_property_split = True
|
|
|
|
|
2019-05-07 09:56:55 +00:00
|
|
|
if node:
|
|
|
|
input = find_node_input(node, 'Volume')
|
|
|
|
if input:
|
|
|
|
layout.template_node_view(ntree, node, input)
|
|
|
|
else:
|
|
|
|
layout.label(text="Incompatible output node")
|
|
|
|
else:
|
|
|
|
layout.label(text="No output node")
|
|
|
|
|
|
|
|
|
2018-07-17 10:35:45 +00:00
|
|
|
class WORLD_PT_viewport_display(WorldButtonsPanel, Panel):
|
|
|
|
bl_label = "Viewport Display"
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2019-05-19 09:23:43 +00:00
|
|
|
bl_order = 10
|
2018-07-17 10:35:45 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return context.world
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
layout.use_property_split = True
|
|
|
|
world = context.world
|
|
|
|
layout.prop(world, "color")
|
2017-04-25 21:48:26 +00:00
|
|
|
|
|
|
|
|
2017-03-18 09:03:24 +00:00
|
|
|
classes = (
|
|
|
|
WORLD_PT_context_world,
|
2017-04-25 21:48:26 +00:00
|
|
|
EEVEE_WORLD_PT_surface,
|
2019-05-07 09:56:55 +00:00
|
|
|
EEVEE_WORLD_PT_volume,
|
2018-02-01 17:09:06 +00:00
|
|
|
EEVEE_WORLD_PT_mist,
|
2018-07-17 10:35:45 +00:00
|
|
|
WORLD_PT_viewport_display,
|
2018-07-14 23:15:32 +00:00
|
|
|
WORLD_PT_custom_props,
|
2017-03-18 09:03:24 +00:00
|
|
|
)
|
|
|
|
|
2011-04-04 10:13:04 +00:00
|
|
|
if __name__ == "__main__": # only for live edit.
|
2017-03-18 09:03:24 +00:00
|
|
|
from bpy.utils import register_class
|
|
|
|
for cls in classes:
|
|
|
|
register_class(cls)
|