-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBackgrounds.py
283 lines (221 loc) · 10.8 KB
/
Backgrounds.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
import bpy
# Default Color Background
def DefaultBG():
node_tree = bpy.data.worlds['World'].node_tree
node_tree.nodes.clear()
nodes = node_tree.nodes
output = nodes.new(type='ShaderNodeOutputMaterial')
background = nodes.new(type='ShaderNodeBackground')
background.inputs[0].default_value = [0.050876, 0.050876, 0.050876, 1.000000]
links = node_tree.links
links.new(background.outputs[0], output.inputs[0])
# Blue Sky Background
def BlueSkyBG():
node_tree = bpy.data.worlds['World'].node_tree
node_tree.nodes.clear()
nodes = node_tree.nodes
output = nodes.new(type='ShaderNodeOutputMaterial')
background = nodes.new(type='ShaderNodeBackground')
colorramp = nodes.new(type='ShaderNodeValToRGB')
colorramp.color_ramp.interpolation = 'B_SPLINE'
colorramp.color_ramp.elements.new(0.5)
colorramp.color_ramp.elements[0].position = 0
colorramp.color_ramp.elements[1].position = 0.3
colorramp.color_ramp.elements[2].position = 0.7
colorramp.color_ramp.elements[0].color = [0.639438, 0.775820, 0.390884, 1.000000]
colorramp.color_ramp.elements[1].color = [0.000000, 0.016061, 1.000000, 1.000000]
colorramp.color_ramp.elements[2].color = [0.003531, 0.000000, 0.329258, 1.000000]
gradient = nodes.new(type='ShaderNodeTexGradient')
mapping = nodes.new(type='ShaderNodeMapping')
mapping.inputs[1].default_value = (0.3, 0, 0)
mapping.inputs[2].default_value = (0, 1.5708, 0)
texcoord = nodes.new(type='ShaderNodeTexCoord')
links = node_tree.links
links.new(background.outputs[0], output.inputs[0])
links.new(colorramp.outputs[0], background.inputs[0])
links.new(gradient.outputs[0], colorramp.inputs[0])
links.new(mapping.outputs[0], gradient.inputs[0])
links.new(texcoord.outputs[0], mapping.inputs[0])
# Sunset Background
def SunsetBG():
node_tree = bpy.data.worlds['World'].node_tree
node_tree.nodes.clear()
nodes = node_tree.nodes
output = nodes.new(type='ShaderNodeOutputMaterial')
background = nodes.new(type='ShaderNodeBackground')
colorramp = nodes.new(type='ShaderNodeValToRGB')
colorramp.color_ramp.interpolation = 'B_SPLINE'
colorramp.color_ramp.elements.new(0.5)
colorramp.color_ramp.elements.new(0.25)
colorramp.color_ramp.elements.new(0.125)
colorramp.color_ramp.elements.new(0.062)
colorramp.color_ramp.elements[0].position = 0
colorramp.color_ramp.elements[1].position = 0.2
colorramp.color_ramp.elements[2].position = 0.4
colorramp.color_ramp.elements[3].position = 0.6
colorramp.color_ramp.elements[4].position = 0.8
colorramp.color_ramp.elements[5].position = 1
colorramp.color_ramp.elements[0].color = [0.861933, 1.000000, 0.000000, 1.000000]
colorramp.color_ramp.elements[1].color = [0.500000, 0.089998, 0.000000, 1.000000]
colorramp.color_ramp.elements[2].color = [0.400000, 0.001788, 0.000000, 1.000000]
colorramp.color_ramp.elements[3].color = [0.300000, 0.000000, 0.080976, 1.000000]
colorramp.color_ramp.elements[4].color = [0.192383, 0.000000, 0.200000, 1.000000]
colorramp.color_ramp.elements[5].color = [0.000000, 0.002117, 0.100000, 1.000000]
gradient = nodes.new(type='ShaderNodeTexGradient')
mapping = nodes.new(type='ShaderNodeMapping')
mapping.inputs[1].default_value = (0.3, 0, 0)
mapping.inputs[2].default_value = (0, 1.5708, 0)
texcoord = nodes.new(type='ShaderNodeTexCoord')
links = node_tree.links
links.new(background.outputs[0], output.inputs[0])
links.new(colorramp.outputs[0], background.inputs[0])
links.new(gradient.outputs[0], colorramp.inputs[0])
links.new(mapping.outputs[0], gradient.inputs[0])
links.new(texcoord.outputs[0], mapping.inputs[0])
# Overcast Background
def OvercastBG():
node_tree = bpy.data.worlds['World'].node_tree
node_tree.nodes.clear()
nodes = node_tree.nodes
output = nodes.new(type='ShaderNodeOutputMaterial')
background = nodes.new(type='ShaderNodeBackground')
colorramp = nodes.new(type='ShaderNodeValToRGB')
colorramp.color_ramp.interpolation = 'B_SPLINE'
colorramp.color_ramp.elements.new(0.5)
colorramp.color_ramp.elements[0].position = 0
colorramp.color_ramp.elements[1].position = 0.3
colorramp.color_ramp.elements[2].position = 0.7
colorramp.color_ramp.elements[0].color = [0.3, 0.3, 0.3, 1.000000]
colorramp.color_ramp.elements[1].color = [0.2, 0.2, 0.2, 1.000000]
colorramp.color_ramp.elements[2].color = [0.1, 0.1, 0.1, 1.000000]
gradient = nodes.new(type='ShaderNodeTexGradient')
mapping = nodes.new(type='ShaderNodeMapping')
mapping.inputs[1].default_value = (0.3, 0, 0)
mapping.inputs[2].default_value = (0, 1.5708, 0)
texcoord = nodes.new(type='ShaderNodeTexCoord')
links = node_tree.links
links.new(background.outputs[0], output.inputs[0])
links.new(colorramp.outputs[0], background.inputs[0])
links.new(gradient.outputs[0], colorramp.inputs[0])
links.new(mapping.outputs[0], gradient.inputs[0])
links.new(texcoord.outputs[0], mapping.inputs[0])
# Twilight Background
def TwilightBG():
node_tree = bpy.data.worlds['World'].node_tree
node_tree.nodes.clear()
nodes = node_tree.nodes
output = nodes.new(type='ShaderNodeOutputMaterial')
background = nodes.new(type='ShaderNodeBackground')
colorramp = nodes.new(type='ShaderNodeValToRGB')
colorramp.color_ramp.interpolation = 'B_SPLINE'
colorramp.color_ramp.elements.new(0.5)
colorramp.color_ramp.elements.new(0.25)
colorramp.color_ramp.elements.new(0.125)
colorramp.color_ramp.elements[0].position = 0
colorramp.color_ramp.elements[1].position = 0.2
colorramp.color_ramp.elements[2].position = 0.4
colorramp.color_ramp.elements[3].position = 0.7
colorramp.color_ramp.elements[4].position = 0.9
colorramp.color_ramp.elements[0].color = [0.000000, 0.029845, 0.007454, 1.000000]
colorramp.color_ramp.elements[1].color = [0.010390, 0.067757, 0.099999, 1.000000]
colorramp.color_ramp.elements[2].color = [0.006086, 0.006665, 0.022857, 1.000000]
colorramp.color_ramp.elements[3].color = [0.004441, 0.010000, 0.007736, 1.000000]
colorramp.color_ramp.elements[4].color = [0.000000, 0.000000, 0.000000, 1.000000]
gradient = nodes.new(type='ShaderNodeTexGradient')
mapping = nodes.new(type='ShaderNodeMapping')
mapping.inputs[1].default_value = (0.3, 0, 0)
mapping.inputs[2].default_value = (0, 1.5708, 0)
texcoord = nodes.new(type='ShaderNodeTexCoord')
links = node_tree.links
links.new(background.outputs[0], output.inputs[0])
links.new(colorramp.outputs[0], background.inputs[0])
links.new(gradient.outputs[0], colorramp.inputs[0])
links.new(mapping.outputs[0], gradient.inputs[0])
links.new(texcoord.outputs[0], mapping.inputs[0])
# Starry Night Background
def StarryNightBG():
node_tree = bpy.data.worlds['World'].node_tree
node_tree.nodes.clear()
nodes = node_tree.nodes
output = nodes.new(type='ShaderNodeOutputMaterial')
mixshader = nodes.new(type='ShaderNodeMixShader')
background = nodes.new(type='ShaderNodeBackground')
colorramp1 = nodes.new(type='ShaderNodeValToRGB')
colorramp1.color_ramp.interpolation = 'B_SPLINE'
colorramp1.color_ramp.elements.new(0.5)
colorramp1.color_ramp.elements[0].position = 0
colorramp1.color_ramp.elements[1].position = 0.1
colorramp1.color_ramp.elements[2].position = 1
colorramp1.color_ramp.elements[0].color = [0.000000, 0.000566, 0.050000, 1.000000]
colorramp1.color_ramp.elements[1].color = [0.000000, 0.000226, 0.020000, 1.000000]
colorramp1.color_ramp.elements[2].color = [0.000000, 0.000000, 0.000000, 1.000000]
gradient = nodes.new(type='ShaderNodeTexGradient')
mapping = nodes.new(type='ShaderNodeMapping')
mapping.inputs[1].default_value = (0.3, 0, 0)
mapping.inputs[2].default_value = (0, 1.5708, 0)
texcoord = nodes.new(type='ShaderNodeTexCoord')
emission = nodes.new(type='ShaderNodeEmission')
emission.inputs[1].default_value = 100
colorramp2 = nodes.new(type='ShaderNodeValToRGB')
colorramp2.color_ramp.elements[0].position = 0.8
colorramp2.color_ramp.elements[1].position = 1
noise = nodes.new(type='ShaderNodeTexNoise')
noise.inputs[2].default_value = 300
links = node_tree.links
links.new(mixshader.outputs[0], output.inputs[0])
links.new(background.outputs[0], mixshader.inputs[1])
links.new(emission.outputs[0], mixshader.inputs[2])
links.new(colorramp1.outputs[0], background.inputs[0])
links.new(gradient.outputs[0], colorramp1.inputs[0])
links.new(mapping.outputs[0], gradient.inputs[0])
links.new(texcoord.outputs[0], mapping.inputs[0])
links.new(colorramp2.outputs[0], emission.inputs[0])
links.new(noise.outputs[0], colorramp2.inputs[0])
class OBJECT_OT_generateDefaultBG(bpy.types.Operator):
"""Create the default Blender background"""
bl_idname = "mesh.generate_default"
bl_label = "Returns to the Blender default background"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
DefaultBG()
return {'FINISHED'}
class OBJECT_OT_generateBlueSkyBG(bpy.types.Operator):
"""Create a blue sky background"""
bl_idname = "mesh.generate_blue_sky"
bl_label = "Add a blue sky background"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
BlueSkyBG()
return {'FINISHED'}
class OBJECT_OT_generateSunsetBG(bpy.types.Operator):
"""Create a sunset/sunrise background"""
bl_idname = "mesh.generate_sunset"
bl_label = "Add a sunset/sunrise background"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
SunsetBG()
return {'FINISHED'}
class OBJECT_OT_generateOvercastBG(bpy.types.Operator):
"""Create an overcast background"""
bl_idname = "mesh.generate_overcast"
bl_label = "Add an overcast background"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
OvercastBG()
return {'FINISHED'}
class OBJECT_OT_generateTwilightBG(bpy.types.Operator):
"""Create a twilight background"""
bl_idname = "mesh.generate_twilight"
bl_label = "Add a twilight background"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
TwilightBG()
return {'FINISHED'}
class OBJECT_OT_generateStarryNightBG(bpy.types.Operator):
"""Create a starry night background"""
bl_idname = "mesh.generate_starry_night"
bl_label = "Add a starry night background"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
StarryNightBG()
return {'FINISHED'}