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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
#
# Copyright 2011, Blender Foundation.
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
import bpy
from cycles import enums
from cycles import engine
class CyclesButtonsPanel():
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "render"
@classmethod
def poll(cls, context):
rd = context.scene.render
return rd.engine == 'CYCLES'
class CyclesRender_PT_integrator(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Integrator"
def draw(self, context):
layout = self.layout
scene = context.scene
cycles = scene.cycles
split = layout.split()
col = split.column()
col.prop(cycles, "passes")
col.prop(cycles, "no_caustics")
col = split.column()
col = col.column(align=True)
col.prop(cycles, "max_bounces")
col.prop(cycles, "min_bounces")
#row = col.row()
#row.prop(cycles, "blur_caustics")
#row.active = not cycles.no_caustics
class CyclesRender_PT_film(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Film"
def draw(self, context):
layout = self.layout
scene = context.scene
cycles = scene.cycles
split = layout.split()
split.prop(cycles, "exposure")
split.prop(cycles, "response_curve", text="")
class CyclesRender_PT_debug(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Debug"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
scene = context.scene
cycles = scene.cycles
split = layout.split()
col = split.column()
sub = col.column(align=True)
sub.prop(cycles, "debug_bvh_type", text="")
sub.prop(cycles, "debug_use_spatial_splits")
sub = col.column(align=True)
sub.prop(cycles, "debug_tile_size")
sub.prop(cycles, "debug_min_size")
col = split.column(align=True)
col.prop(cycles, "debug_cancel_timeout")
col.prop(cycles, "debug_reset_timeout")
col.prop(cycles, "debug_text_timeout")
class Cycles_PT_post_processing(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Post Processing"
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
rd = context.scene.render
split = layout.split()
col = split.column()
col.prop(rd, "use_compositing")
col.prop(rd, "use_sequencer")
col = split.column()
col.prop(rd, "dither_intensity", text="Dither", slider=True)
class Cycles_PT_camera(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Cycles"
bl_context = "data"
@classmethod
def poll(cls, context):
return context.camera
def draw(self, context):
layout = self.layout
camera = context.camera
cycles = camera.cycles
layout.prop(cycles, "lens_radius")
class Cycles_PT_context_material(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Surface"
bl_context = "material"
bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
return (context.material or context.object) and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
mat = context.material
ob = context.object
slot = context.material_slot
space = context.space_data
if ob:
row = layout.row()
row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
col = row.column(align=True)
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
if ob.mode == 'EDIT':
row = layout.row(align=True)
row.operator("object.material_slot_assign", text="Assign")
row.operator("object.material_slot_select", text="Select")
row.operator("object.material_slot_deselect", text="Deselect")
split = layout.split(percentage=0.65)
if ob:
split.template_ID(ob, "active_material", new="material.new")
row = split.row()
if slot:
row.prop(slot, "link", text="")
else:
row.label()
elif mat:
split.template_ID(space, "pin_id")
split.separator()
class Cycles_PT_mesh_displacement(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Displacement"
bl_context = "data"
@classmethod
def poll(cls, context):
return context.mesh or context.curve or context.meta_ball
def draw(self, context):
layout = self.layout
mesh = context.mesh
curve = context.curve
mball = context.meta_ball
if mesh:
cycles = mesh.cycles
elif curve:
cycles = curve.cycles
elif mball:
cycles = mball.cycles
layout.prop(cycles, "displacement_method", text="Method")
layout.prop(cycles, "use_subdivision");
layout.prop(cycles, "dicing_rate");
def find_node(material, nodetype):
if material and material.node_tree:
ntree = material.node_tree
for node in ntree.nodes:
if type(node) is not bpy.types.NodeGroup and node.type == nodetype:
return node
return None
def find_node_input(node, name):
for input in node.inputs:
if input.name == name:
return input
return None
def panel_node_draw(layout, id, output_type, input_name):
if not id.node_tree:
layout.prop(id, "use_nodes")
return
ntree = id.node_tree
node = find_node(id, output_type)
if not node:
layout.label(text="No output node.")
input = find_node_input(node, input_name)
layout.template_node_view(id, ntree, node, input);
class CyclesLamp_PT_lamp(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Surface"
bl_context = "data"
@classmethod
def poll(cls, context):
return context.lamp and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
mat = context.lamp
panel_node_draw(layout, mat, 'OUTPUT_LAMP', 'Surface')
class CyclesWorld_PT_surface(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Surface"
bl_context = "world"
@classmethod
def poll(cls, context):
return context.world and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
mat = context.world
panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Surface')
class CyclesWorld_PT_volume(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Volume"
bl_context = "world"
@classmethod
def poll(cls, context):
return context.world and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
layout.active = False
mat = context.world
panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Volume')
class CyclesMaterial_PT_surface(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Surface"
bl_context = "material"
@classmethod
def poll(cls, context):
return context.material and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
mat = context.material
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface')
class CyclesMaterial_PT_volume(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Volume"
bl_context = "material"
@classmethod
def poll(cls, context):
return context.material and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
layout.active = False
mat = context.material
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
class CyclesMaterial_PT_displacement(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Displacement"
bl_context = "material"
@classmethod
def poll(cls, context):
return context.material and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
mat = context.material
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
class CyclesMaterial_PT_settings(CyclesButtonsPanel, bpy.types.Panel):
bl_label = "Settings"
bl_context = "material"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
# return context.material and CyclesButtonsPanel.poll(context)
return False
def draw(self, context):
layout = self.layout
mat = context.material
row = layout.row()
row.label(text="Light Group:")
row.prop(mat, "light_group", text="")
def draw_device(self, context):
scene = context.scene
layout = self.layout
if scene.render.engine == "CYCLES":
cycles = scene.cycles
if 'cuda' in engine.available_devices():
layout.prop(cycles, "device")
if cycles.device == 'CPU' and engine.with_osl():
layout.prop(cycles, "shading_system")
def get_panels():
return [
bpy.types.RENDER_PT_render,
bpy.types.RENDER_PT_output,
bpy.types.RENDER_PT_encoding,
bpy.types.RENDER_PT_dimensions,
bpy.types.RENDER_PT_stamp,
bpy.types.WORLD_PT_context_world,
bpy.types.DATA_PT_context_mesh,
bpy.types.DATA_PT_vertex_groups,
bpy.types.DATA_PT_shape_keys,
bpy.types.DATA_PT_uv_texture,
bpy.types.DATA_PT_vertex_colors,
bpy.types.DATA_PT_custom_props_mesh,
bpy.types.DATA_PT_context_camera,
bpy.types.DATA_PT_camera,
bpy.types.DATA_PT_camera_display,
bpy.types.DATA_PT_custom_props_camera,
bpy.types.DATA_PT_context_lamp,
bpy.types.DATA_PT_custom_props_lamp,
bpy.types.TEXTURE_PT_context_texture]
def register():
bpy.types.RENDER_PT_render.append(draw_device)
for panel in get_panels():
panel.COMPAT_ENGINES.add('CYCLES')
def unregister():
bpy.types.RENDER_PT_render.remove(draw_device)
for panel in get_panels():
panel.COMPAT_ENGINES.remove('CYCLES')
|