-
Notifications
You must be signed in to change notification settings - Fork 147
/
Copy pathproperties_shader.py
138 lines (122 loc) · 4.58 KB
/
properties_shader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# ##### BEGIN MIT LICENSE BLOCK #####
#
# Copyright (c) 2011 Matt Ebb
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#
# ##### END MIT LICENSE BLOCK #####
import bpy
from bpy.props import PointerProperty, StringProperty, BoolProperty, EnumProperty, \
IntProperty, FloatProperty, FloatVectorProperty, CollectionProperty
'''
Currently:
Material
\
- Renderman
\
- Surface Shader Settings
\
- Active Surface Shader
- Shader Foo Settings (dynamically generated RNA type)
\
- Parameter A
- Parameter B
- Shader Bar Settings (dynamically generated RNA type)
\
- Parameter X
- Displacement Shader Settings
Perhaps:
Material
\
- Renderman
\
- Surface Shader
\
- Surface Shader Name
- Parameters
\
- Parameter A
- Parameter B
- Displacement Shader
\
- Displacement Shader Name
- Parameters (dynamically generated RNA type)
\
- Parameter Z
'''
class coshaderShaders(bpy.types.PropertyGroup):
def coshader_shader_active_update(self, context):
# BBM addition begin
if self.id_data.name == 'World': # world coshaders
location = 'world'
mat_rm = context.scene.world.renderman
elif bpy.context.active_object.name in bpy.data.lamps.keys(): # lamp coshaders
location = 'lamp'
lamp = bpy.data.lamps.get(bpy.context.active_object.name)
mat_rm = lamp.renderman
else: # material coshaders
location = 'material'
mat_rm = context.active_object.active_material.renderman
shader_active_update(self, context, 'shader', location) # BBM modified (from 'surface' to 'shader')
cosh_index = mat_rm.coshaders_index
active_cosh = mat_rm.coshaders[cosh_index]
active_cosh_name = active_cosh.shader_shaders.active
if active_cosh_name == 'null':
coshader_name = active_cosh_name
else:
all_cosh = [ (cosh.name) for cosh in mat_rm.coshaders ]
same_name = 1
for cosh in all_cosh:
if cosh.startswith( active_cosh_name ):
same_name += 1
coshader_name = ('%s_%d' % (active_cosh_name, same_name))
active_cosh.name = coshader_name
# BBM addition end
active = StringProperty(
name="Active Co-Shader",
description="Shader name to use for coshader",
update=coshader_shader_active_update,
default="null"
)
def coshader_shader_list_items(self, context):
print('----coshader list items')
print(shader_list_items(self, context, 'shader'))
return shader_list_items(self, context, 'shader')
def coshader_shader_list_update(self, context):
shader_list_update(self, context, 'shader')
shader_list = EnumProperty(
name="Active Co-Shader",
description="Shader name to use for coshader",
update=coshader_shader_list_update,
items=coshader_shader_list_items
)
class RendermanCoshader(bpy.types.PropertyGroup):
name = StringProperty(
name="Name (Handle)",
description="Handle to refer to this co-shader from another shader")
#BBM replace begin
#surface_shaders = PointerProperty(
# type=surfaceShaders,
# name="Surface Shader Settings")
#by
shader_shaders = PointerProperty(
type=coshaderShaders,
name="Coshader Shader Settings")
#BBM modification end