forked from bartvdbraak/blender
* Added Subsurface Scattering Presets.
Note: Add doesn't work, it writes some text into the file, not the values. (Maybe because the values are arrays?!) Campbell, please check :)
This commit is contained in:
parent
573be3e687
commit
4f6b95480f
60
release/scripts/op/preset_sss.py
Normal file
60
release/scripts/op/preset_sss.py
Normal file
@ -0,0 +1,60 @@
|
||||
# ##### BEGIN GPL LICENSE BLOCK #####
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# ##### END GPL LICENSE BLOCK #####
|
||||
|
||||
import bpy
|
||||
import os
|
||||
|
||||
class AddPreset(bpy.types.Operator):
|
||||
'''Add a Subsurface Scattering Preset'''
|
||||
bl_idname = "sss.preset_add"
|
||||
bl_label = "Add Subsurface Scattering Preset"
|
||||
|
||||
name = bpy.props.StringProperty(name="Name", description="Name of the preset, used to make the path name", maxlen= 64, default= "New Preset")
|
||||
|
||||
_preset_values = [
|
||||
"bpy.context.active_object.active_material.subsurface_scattering.radius",
|
||||
"bpy.context.active_object.active_material.subsurface_scattering.color",
|
||||
]
|
||||
|
||||
_last_preset = "" # hack to avoid remaking
|
||||
|
||||
def _as_filename(self, name): # could reuse for other presets
|
||||
for char in " !@#$%^&*(){}:\";'[]<>,./?":
|
||||
name = name.replace('.', '_')
|
||||
return name.lower()
|
||||
|
||||
def execute(self, context):
|
||||
filename = self._as_filename(self.properties.name) + ".py"
|
||||
|
||||
target_path = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "sss", filename)
|
||||
print(target_path)
|
||||
file_preset = open(target_path, 'w')
|
||||
|
||||
for rna_path in self._preset_values:
|
||||
file_preset.write("%s = %s\n" % (rna_path, eval(rna_path)))
|
||||
|
||||
file_preset.close()
|
||||
|
||||
return ('FINISHED',)
|
||||
|
||||
def invoke(self, context, event):
|
||||
wm = context.manager
|
||||
wm.invoke_props_popup(self, event)
|
||||
return ('RUNNING_MODAL',)
|
||||
|
||||
bpy.ops.add(AddPreset)
|
2
release/scripts/presets/sss/Apple.py
Normal file
2
release/scripts/presets/sss/Apple.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 11.605, 3.884, 1.754
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.430, 0.210, 0.168
|
2
release/scripts/presets/sss/Chicken.py
Normal file
2
release/scripts/presets/sss/Chicken.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 9.436, 3.348, 1.790
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.439, 0.216, 0.141
|
2
release/scripts/presets/sss/Cream.py
Normal file
2
release/scripts/presets/sss/Cream.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 15.028, 4.664, 2.541
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.987, 0.943, 0.827
|
2
release/scripts/presets/sss/Ketchup.py
Normal file
2
release/scripts/presets/sss/Ketchup.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 4.762, 0.575, 0.394
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.222, 0.008, 0.002
|
2
release/scripts/presets/sss/Marble.py
Normal file
2
release/scripts/presets/sss/Marble.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 8.509, 5.566, 3.951
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.925, 0.905, 0.884
|
2
release/scripts/presets/sss/Potato.py
Normal file
2
release/scripts/presets/sss/Potato.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 14.266, 7.228, 2.036
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.855, 0.740, 0.292
|
2
release/scripts/presets/sss/Skin1.py
Normal file
2
release/scripts/presets/sss/Skin1.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 3.673, 1.367, 0.683
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.574, 0.313, 0.174
|
2
release/scripts/presets/sss/Skin2.py
Normal file
2
release/scripts/presets/sss/Skin2.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 4.821, 1.694, 1.090
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.749, 0.571, 0.467
|
2
release/scripts/presets/sss/Skin_Milk.py
Normal file
2
release/scripts/presets/sss/Skin_Milk.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 18.424, 10.443, 3.502
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.889, 0.888, 0.796
|
2
release/scripts/presets/sss/Whole_Milk.py
Normal file
2
release/scripts/presets/sss/Whole_Milk.py
Normal file
@ -0,0 +1,2 @@
|
||||
bpy.context.active_object.active_material.subsurface_scattering.radius = 10.899, 6.575, 2.508
|
||||
bpy.context.active_object.active_material.subsurface_scattering.color = 0.947, 0.931, 0.852
|
@ -22,6 +22,18 @@ import bpy
|
||||
narrowui = 180
|
||||
|
||||
|
||||
class SSS_MT_presets(bpy.types.Menu):
|
||||
'''
|
||||
Creates the menu items by scanning scripts/templates
|
||||
'''
|
||||
bl_label = "Subsurface Scattering Presets"
|
||||
|
||||
def draw(self, context):
|
||||
import os
|
||||
template_dir = os.path.join(os.path.dirname(__file__), os.path.pardir, "presets", "sss")
|
||||
self.path_menu(template_dir, "script.python_file_run")
|
||||
|
||||
|
||||
def active_node_mat(mat):
|
||||
# TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
|
||||
# which settings from node-materials are used
|
||||
@ -475,10 +487,15 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
|
||||
sss = mat.subsurface_scattering
|
||||
wide_ui = context.region.width > narrowui
|
||||
|
||||
layout.active = sss.enabled
|
||||
layout.active = (sss.enabled) and (not mat.shadeless)
|
||||
|
||||
row = layout.row().split()
|
||||
sub = row.row(align=True).split(percentage=0.75)
|
||||
sub.itemM("SSS_MT_presets", text="Presets")
|
||||
sub.itemO("sss.preset_add", text="Add")
|
||||
row.itemL()
|
||||
|
||||
split = layout.split()
|
||||
split.active = (not mat.shadeless)
|
||||
|
||||
col = split.column()
|
||||
col.itemR(sss, "ior")
|
||||
@ -861,6 +878,8 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
|
||||
col = split.column()
|
||||
col.itemL()
|
||||
col.itemR(vol, "depth_cutoff")
|
||||
|
||||
bpy.types.register(SSS_MT_presets)
|
||||
|
||||
bpy.types.register(MATERIAL_PT_volume_density)
|
||||
bpy.types.register(MATERIAL_PT_volume_shading)
|
||||
|
Loading…
Reference in New Issue
Block a user