Workbench: Add back studio lighting presets

This changes a bit how the userprefs solid lights works. They are not
visible until enabling the "Edit Solid Light" checkbox. Once enabled the
current studiolight used for solid mode will be overwritten.

Once the lighting settings are tweaked, the user can click the
"Save as Studio light" button to save the current settings.
This makes it easy to create new lighting without messing the other
presets.

The studio lights are stored as ASCII files on the disk using a dead
simple custom format.

The UI/UX is not perfect and will be improved in other commits.

Also includes:
* Separate LookDev HDRI selection from Solid Lights
* Hide LookDev HDRIs from the Solid Lights selection list
This commit is contained in:
2018-11-29 19:54:23 +01:00
parent 8f4ab480bf
commit 844788a36c
14 changed files with 430 additions and 97 deletions

View File

@@ -2462,7 +2462,7 @@ class WM_OT_studiolight_install(Operator):
for filepath in filepaths:
shutil.copy(str(filepath), str(path_studiolights))
userpref.studio_lights.new(str(path_studiolights.joinpath(filepath.name)), self.type)
userpref.studio_lights.load(str(path_studiolights.joinpath(filepath.name)), self.type)
# print message
msg = (
@@ -2479,6 +2479,57 @@ class WM_OT_studiolight_install(Operator):
return {'RUNNING_MODAL'}
class WM_OT_studiolight_new(Operator):
bl_idname = 'wm.studiolight_new'
bl_label = "Create Studio Light from default light setup"
filename: StringProperty(
name="Filename",
default="StudioLight",
)
def execute(self, context):
import pathlib
userpref = context.user_preferences
path_studiolights = bpy.utils.user_resource('DATAFILES')
if not path_studiolights:
self.report({'ERROR'}, "Failed to get Studio Light path")
return {'CANCELLED'}
path_studiolights = pathlib.Path(path_studiolights, "studiolights", "studio")
if not path_studiolights.exists():
try:
path_studiolights.mkdir(parents=True, exist_ok=True)
except:
traceback.print_exc()
finalpath = str(path_studiolights.joinpath(self.filename));
if pathlib.Path(finalpath + ".sl").is_file():
self.report({'ERROR'}, "File already exists")
return {'CANCELLED'}
userpref.studio_lights.new(path=finalpath)
# print message
msg = (
tip_("StudioLight Installed %r into %r") %
(self.filename, str(path_studiolights))
)
print(msg)
self.report({'INFO'}, msg)
return {'FINISHED'}
def draw(self, context):
layout = self.layout
layout.prop(self, "filename")
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self, width=600)
class WM_OT_studiolight_uninstall(Operator):
bl_idname = 'wm.studiolight_uninstall'
bl_label = "Uninstall Studio Light"
@@ -2765,6 +2816,7 @@ classes = (
WM_OT_owner_enable,
WM_OT_url_open,
WM_OT_studiolight_install,
WM_OT_studiolight_new,
WM_OT_studiolight_uninstall,
WM_OT_studiolight_userpref_show,
WM_OT_tool_set_by_name,