Cycles: remove option to disable transparent shadows globally.
[blender-staging.git] / intern / cycles / blender / addon / properties.py
1 #
2 # Copyright 2011-2013 Blender Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 # <pep8 compliant>
18
19 import bpy
20 from bpy.props import (BoolProperty,
21                        EnumProperty,
22                        FloatProperty,
23                        IntProperty,
24                        PointerProperty,
25                        StringProperty)
26
27 # enums
28
29 import _cycles
30
31 enum_devices = (
32     ('CPU', "CPU", "Use CPU for rendering"),
33     ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in the system tab in the user preferences"),
34     )
35
36 if _cycles.with_network:
37     enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),)
38
39 enum_feature_set = (
40     ('SUPPORTED', "Supported", "Only use finished and supported features"),
41     ('EXPERIMENTAL', "Experimental", "Use experimental and incomplete features that might be broken or change in the future", 'ERROR', 1),
42     )
43
44 enum_displacement_methods = (
45     ('BUMP', "Bump", "Bump mapping to simulate the appearance of displacement"),
46     ('TRUE', "True", "Use true displacement only, requires fine subdivision"),
47     ('BOTH', "Both", "Combination of displacement and bump mapping"),
48     )
49
50 enum_bvh_types = (
51     ('DYNAMIC_BVH', "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"),
52     ('STATIC_BVH', "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster"),
53     )
54
55 enum_filter_types = (
56     ('BOX', "Box", "Box filter"),
57     ('GAUSSIAN', "Gaussian", "Gaussian filter"),
58     ('BLACKMAN_HARRIS', "Blackman-Harris", "Blackman-Harris filter"),
59     )
60
61 enum_aperture_types = (
62     ('RADIUS', "Radius", "Directly change the size of the aperture"),
63     ('FSTOP', "F-stop", "Change the size of the aperture by f-stop"),
64     )
65
66 enum_panorama_types = (
67     ('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"),
68     ('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ideal for fulldomes, ignore the sensor dimensions"),
69     ('FISHEYE_EQUISOLID', "Fisheye Equisolid",
70                           "Similar to most fisheye modern lens, takes sensor dimensions into consideration"),
71     ('MIRRORBALL', "Mirror Ball", "Uses the mirror ball mapping"),
72     )
73
74 enum_curve_primitives = (
75     ('TRIANGLES', "Triangles", "Create triangle geometry around strands"),
76     ('LINE_SEGMENTS', "Line Segments", "Use line segment primitives"),
77     ('CURVE_SEGMENTS', "Curve Segments", "Use segmented cardinal curve primitives"),
78     )
79
80 enum_triangle_curves = (
81     ('CAMERA_TRIANGLES', "Planes", "Create individual triangles forming planes that face camera"),
82     ('TESSELLATED_TRIANGLES', "Tessellated", "Create mesh surrounding each strand"),
83     )
84
85 enum_curve_shape = (
86     ('RIBBONS', "Ribbons", "Ignore thickness of each strand"),
87     ('THICK', "Thick", "Use thickness of strand when rendering"),
88     )
89
90 enum_tile_order = (
91     ('CENTER', "Center", "Render from center to the edges"),
92     ('RIGHT_TO_LEFT', "Right to Left", "Render from right to left"),
93     ('LEFT_TO_RIGHT', "Left to Right", "Render from left to right"),
94     ('TOP_TO_BOTTOM', "Top to Bottom", "Render from top to bottom"),
95     ('BOTTOM_TO_TOP', "Bottom to Top", "Render from bottom to top"),
96     ('HILBERT_SPIRAL', "Hilbert Spiral", "Render in a Hilbert Spiral"),
97     )
98
99 enum_use_layer_samples = (
100     ('USE', "Use", "Per render layer number of samples override scene samples"),
101     ('BOUNDED', "Bounded", "Bound per render layer number of samples by global samples"),
102     ('IGNORE', "Ignore", "Ignore per render layer number of samples"),
103     )
104
105 enum_sampling_pattern = (
106     ('SOBOL', "Sobol", "Use Sobol random sampling pattern"),
107     ('CORRELATED_MUTI_JITTER', "Correlated Multi-Jitter", "Use Correlated Multi-Jitter random sampling pattern"),
108     )
109
110 enum_integrator = (
111     ('BRANCHED_PATH', "Branched Path Tracing", "Path tracing integrator that branches on the first bounce, giving more control over the number of light and material samples"),
112     ('PATH', "Path Tracing", "Pure path tracing integrator"),
113     )
114
115 enum_volume_sampling = (
116     ('DISTANCE', "Distance", "Use distance sampling, best for dense volumes with lights far away"),
117     ('EQUIANGULAR', "Equiangular", "Use equiangular sampling, best for volumes with low density with light inside or near the volume"),
118     ('MULTIPLE_IMPORTANCE', "Multiple Importance", "Combine distance and equi-angular sampling for volumes where neither method is ideal"),
119     )
120
121 enum_volume_interpolation = (
122     ('LINEAR', "Linear", "Good smoothness and speed"),
123     ('CUBIC', "Cubic", "Smoothed high quality interpolation, but slower")
124     )
125
126 enum_device_type = (
127     ('CPU', "CPU", "CPU", 0),
128     ('CUDA', "CUDA", "CUDA", 1),
129     ('OPENCL', "OpenCL", "OpenCL", 2)
130     )
131
132 enum_texture_limit = (
133     ('OFF', "No Limit", "No texture size limit", 0),
134     ('128', "128", "Limit texture size to 128 pixels", 1),
135     ('256', "256", "Limit texture size to 256 pixels", 2),
136     ('512', "512", "Limit texture size to 512 pixels", 3),
137     ('1024', "1024", "Limit texture size to 1024 pixels", 4),
138     ('2048', "2048", "Limit texture size to 2048 pixels", 5),
139     ('4096', "4096", "Limit texture size to 4096 pixels", 6),
140     ('8192', "8192", "Limit texture size to 8192 pixels", 7),
141     )
142
143 class CyclesRenderSettings(bpy.types.PropertyGroup):
144     @classmethod
145     def register(cls):
146         bpy.types.Scene.cycles = PointerProperty(
147                 name="Cycles Render Settings",
148                 description="Cycles render settings",
149                 type=cls,
150                 )
151         cls.device = EnumProperty(
152                 name="Device",
153                 description="Device to use for rendering",
154                 items=enum_devices,
155                 default='CPU',
156                 )
157         cls.feature_set = EnumProperty(
158                 name="Feature Set",
159                 description="Feature set to use for rendering",
160                 items=enum_feature_set,
161                 default='SUPPORTED',
162                 )
163         cls.shading_system = BoolProperty(
164                 name="Open Shading Language",
165                 description="Use Open Shading Language (CPU rendering only)",
166                 )
167
168         cls.progressive = EnumProperty(
169                 name="Integrator",
170                 description="Method to sample lights and materials",
171                 items=enum_integrator,
172                 default='PATH',
173                 )
174
175         cls.use_square_samples = BoolProperty(
176                 name="Square Samples",
177                 description="Square sampling values for easier artist control",
178                 default=False,
179                 )
180
181         cls.samples = IntProperty(
182                 name="Samples",
183                 description="Number of samples to render for each pixel",
184                 min=1, max=2147483647,
185                 default=128,
186                 )
187         cls.preview_samples = IntProperty(
188                 name="Preview Samples",
189                 description="Number of samples to render in the viewport, unlimited if 0",
190                 min=0, max=2147483647,
191                 default=32,
192                 )
193         cls.preview_pause = BoolProperty(
194                 name="Pause Preview",
195                 description="Pause all viewport preview renders",
196                 default=False,
197                 )
198         cls.preview_active_layer = BoolProperty(
199                 name="Preview Active Layer",
200                 description="Preview active render layer in viewport",
201                 default=False,
202                 )
203
204         cls.aa_samples = IntProperty(
205                 name="AA Samples",
206                 description="Number of antialiasing samples to render for each pixel",
207                 min=1, max=2097151,
208                 default=4,
209                 )
210         cls.preview_aa_samples = IntProperty(
211                 name="AA Samples",
212                 description="Number of antialiasing samples to render in the viewport, unlimited if 0",
213                 min=0, max=2097151,
214                 default=4,
215                 )
216         cls.diffuse_samples = IntProperty(
217                 name="Diffuse Samples",
218                 description="Number of diffuse bounce samples to render for each AA sample",
219                 min=1, max=1024,
220                 default=1,
221                 )
222         cls.glossy_samples = IntProperty(
223                 name="Glossy Samples",
224                 description="Number of glossy bounce samples to render for each AA sample",
225                 min=1, max=1024,
226                 default=1,
227                 )
228         cls.transmission_samples = IntProperty(
229                 name="Transmission Samples",
230                 description="Number of transmission bounce samples to render for each AA sample",
231                 min=1, max=1024,
232                 default=1,
233                 )
234         cls.ao_samples = IntProperty(
235                 name="Ambient Occlusion Samples",
236                 description="Number of ambient occlusion samples to render for each AA sample",
237                 min=1, max=1024,
238                 default=1,
239                 )
240         cls.mesh_light_samples = IntProperty(
241                 name="Mesh Light Samples",
242                 description="Number of mesh emission light samples to render for each AA sample",
243                 min=1, max=1024,
244                 default=1,
245                 )
246
247         cls.subsurface_samples = IntProperty(
248                 name="Subsurface Samples",
249                 description="Number of subsurface scattering samples to render for each AA sample",
250                 min=1, max=1024,
251                 default=1,
252                 )
253
254         cls.volume_samples = IntProperty(
255                 name="Volume Samples",
256                 description="Number of volume scattering samples to render for each AA sample",
257                 min=1, max=1024,
258                 default=1,
259                 )
260
261         cls.sampling_pattern = EnumProperty(
262                 name="Sampling Pattern",
263                 description="Random sampling pattern used by the integrator",
264                 items=enum_sampling_pattern,
265                 default='SOBOL',
266                 )
267
268         cls.use_layer_samples = EnumProperty(
269                 name="Layer Samples",
270                 description="How to use per render layer sample settings",
271                 items=enum_use_layer_samples,
272                 default='USE',
273                 )
274
275         cls.sample_all_lights_direct = BoolProperty(
276                 name="Sample All Direct Lights",
277                 description="Sample all lights (for direct samples), rather than randomly picking one",
278                 default=True,
279                 )
280
281         cls.sample_all_lights_indirect = BoolProperty(
282                 name="Sample All Indirect Lights",
283                 description="Sample all lights (for indirect samples), rather than randomly picking one",
284                 default=True,
285                 )
286         cls.light_sampling_threshold = FloatProperty(
287                 name="Light Sampling Threshold",
288                 description="Probabilistically terminate light samples when the light contribution is below this threshold (more noise but faster rendering). "
289                             "Zero disables the test and never ignores lights",
290                 min=0.0, max=1.0,
291                 default=0.01,
292                 )
293
294         cls.caustics_reflective = BoolProperty(
295                 name="Reflective Caustics",
296                 description="Use reflective caustics, resulting in a brighter image (more noise but added realism)",
297                 default=True,
298                 )
299
300         cls.caustics_refractive = BoolProperty(
301                 name="Refractive Caustics",
302                 description="Use refractive caustics, resulting in a brighter image (more noise but added realism)",
303                 default=True,
304                 )
305
306         cls.blur_glossy = FloatProperty(
307                 name="Filter Glossy",
308                 description="Adaptively blur glossy shaders after blurry bounces, "
309                             "to reduce noise at the cost of accuracy",
310                 min=0.0, max=10.0,
311                 default=0.0,
312                 )
313
314         cls.max_bounces = IntProperty(
315                 name="Max Bounces",
316                 description="Total maximum number of bounces",
317                 min=0, max=1024,
318                 default=12,
319                 )
320
321         cls.diffuse_bounces = IntProperty(
322                 name="Diffuse Bounces",
323                 description="Maximum number of diffuse reflection bounces, bounded by total maximum",
324                 min=0, max=1024,
325                 default=4,
326                 )
327         cls.glossy_bounces = IntProperty(
328                 name="Glossy Bounces",
329                 description="Maximum number of glossy reflection bounces, bounded by total maximum",
330                 min=0, max=1024,
331                 default=4,
332                 )
333         cls.transmission_bounces = IntProperty(
334                 name="Transmission Bounces",
335                 description="Maximum number of transmission bounces, bounded by total maximum",
336                 min=0, max=1024,
337                 default=12,
338                 )
339         cls.volume_bounces = IntProperty(
340                 name="Volume Bounces",
341                 description="Maximum number of volumetric scattering events",
342                 min=0, max=1024,
343                 default=0,
344                 )
345
346         cls.transparent_max_bounces = IntProperty(
347                 name="Transparent Max Bounces",
348                 description="Maximum number of transparent bounces",
349                 min=0, max=1024,
350                 default=8,
351                 )
352
353         cls.volume_step_size = FloatProperty(
354                 name="Step Size",
355                 description="Distance between volume shader samples when rendering the volume "
356                             "(lower values give more accurate and detailed results, but also increased render time)",
357                 default=0.1,
358                 min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4
359                 )
360
361         cls.volume_max_steps = IntProperty(
362                 name="Max Steps",
363                 description="Maximum number of steps through the volume before giving up, "
364                             "to avoid extremely long render times with big objects or small step sizes",
365                 default=1024,
366                 min=2, max=65536
367                 )
368
369         cls.dicing_rate = FloatProperty(
370                 name="Dicing Rate",
371                 description="Size of a micropolygon in pixels",
372                 min=0.1, max=1000.0, soft_min=0.5,
373                 default=1.0,
374                 subtype="PIXEL"
375                 )
376         cls.preview_dicing_rate = FloatProperty(
377                 name="Preview Dicing Rate",
378                 description="Size of a micropolygon in pixels during preview render",
379                 min=0.1, max=1000.0, soft_min=0.5,
380                 default=8.0,
381                 subtype="PIXEL"
382                 )
383
384         cls.max_subdivisions = IntProperty(
385                 name="Max Subdivisions",
386                 description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation",
387                 min=0, max=16,
388                 default=12,
389                 )
390
391         cls.film_exposure = FloatProperty(
392                 name="Exposure",
393                 description="Image brightness scale",
394                 min=0.0, max=10.0,
395                 default=1.0,
396                 )
397         cls.film_transparent = BoolProperty(
398                 name="Transparent",
399                 description="World background is transparent with premultiplied alpha",
400                 default=False,
401                 )
402
403         # Really annoyingly, we have to keep it around for a few releases,
404         # otherwise forward compatibility breaks in really bad manner: CRASH!
405         #
406         # TODO(sergey): Remove this during 2.8x series of Blender.
407         cls.filter_type = EnumProperty(
408                 name="Filter Type",
409                 description="Pixel filter type",
410                 items=enum_filter_types,
411                 default='BLACKMAN_HARRIS',
412                 )
413
414         cls.pixel_filter_type = EnumProperty(
415                 name="Filter Type",
416                 description="Pixel filter type",
417                 items=enum_filter_types,
418                 default='BLACKMAN_HARRIS',
419                 )
420
421         cls.filter_width = FloatProperty(
422                 name="Filter Width",
423                 description="Pixel filter width",
424                 min=0.01, max=10.0,
425                 default=1.5,
426                 )
427
428         cls.seed = IntProperty(
429                 name="Seed",
430                 description="Seed value for integrator to get different noise patterns",
431                 min=0, max=2147483647,
432                 default=0,
433                 )
434
435         cls.use_animated_seed = BoolProperty(
436                 name="Use Animated Seed",
437                 description="Use different seed values (and hence noise patterns) at different frames",
438                 default=False,
439                 )
440
441         cls.sample_clamp_direct = FloatProperty(
442                 name="Clamp Direct",
443                 description="If non-zero, the maximum value for a direct sample, "
444                             "higher values will be scaled down to avoid too "
445                             "much noise and slow convergence at the cost of accuracy",
446                 min=0.0, max=1e8,
447                 default=0.0,
448                 )
449
450         cls.sample_clamp_indirect = FloatProperty(
451                 name="Clamp Indirect",
452                 description="If non-zero, the maximum value for an indirect sample, "
453                             "higher values will be scaled down to avoid too "
454                             "much noise and slow convergence at the cost of accuracy",
455                 min=0.0, max=1e8,
456                 default=0.0,
457                 )
458
459         cls.debug_tile_size = IntProperty(
460                 name="Tile Size",
461                 description="",
462                 min=1, max=4096,
463                 default=1024,
464                 )
465
466         cls.preview_start_resolution = IntProperty(
467                 name="Start Resolution",
468                 description="Resolution to start rendering preview at, "
469                             "progressively increasing it to the full viewport size",
470                 min=8, max=16384,
471                 default=64,
472                 )
473
474         cls.debug_reset_timeout = FloatProperty(
475                 name="Reset timeout",
476                 description="",
477                 min=0.01, max=10.0,
478                 default=0.1,
479                 )
480         cls.debug_cancel_timeout = FloatProperty(
481                 name="Cancel timeout",
482                 description="",
483                 min=0.01, max=10.0,
484                 default=0.1,
485                 )
486         cls.debug_text_timeout = FloatProperty(
487                 name="Text timeout",
488                 description="",
489                 min=0.01, max=10.0,
490                 default=1.0,
491                 )
492
493         cls.debug_bvh_type = EnumProperty(
494                 name="Viewport BVH Type",
495                 description="Choose between faster updates, or faster render",
496                 items=enum_bvh_types,
497                 default='DYNAMIC_BVH',
498                 )
499         cls.debug_use_spatial_splits = BoolProperty(
500                 name="Use Spatial Splits",
501                 description="Use BVH spatial splits: longer builder time, faster render",
502                 default=False,
503                 )
504         cls.debug_use_hair_bvh = BoolProperty(
505                 name="Use Hair BVH",
506                 description="Use special type BVH optimized for hair (uses more ram but renders faster)",
507                 default=True,
508                 )
509         cls.debug_bvh_time_steps = IntProperty(
510                 name="BVH Time Steps",
511                 description="Split BVH primitives by this number of time steps to speed up render time in cost of memory",
512                 default=0,
513                 min=0, max=16,
514                 )
515         cls.tile_order = EnumProperty(
516                 name="Tile Order",
517                 description="Tile order for rendering",
518                 items=enum_tile_order,
519                 default='HILBERT_SPIRAL',
520                 options=set(),  # Not animatable!
521                 )
522         cls.use_progressive_refine = BoolProperty(
523                 name="Progressive Refine",
524                 description="Instead of rendering each tile until it is finished, "
525                             "refine the whole image progressively "
526                             "(this renders somewhat slower, "
527                             "but time can be saved by manually stopping the render when the noise is low enough)",
528                 default=False,
529                 )
530
531         cls.bake_type = EnumProperty(
532             name="Bake Type",
533             default='COMBINED',
534             description="Type of pass to bake",
535             items=(
536                 ('COMBINED', "Combined", ""),
537                 ('AO', "Ambient Occlusion", ""),
538                 ('SHADOW', "Shadow", ""),
539                 ('NORMAL', "Normal", ""),
540                 ('UV', "UV", ""),
541                 ('EMIT', "Emit", ""),
542                 ('ENVIRONMENT', "Environment", ""),
543                 ('DIFFUSE', "Diffuse", ""),
544                 ('GLOSSY', "Glossy", ""),
545                 ('TRANSMISSION', "Transmission", ""),
546                 ('SUBSURFACE', "Subsurface", ""),
547                 ),
548             )
549
550         cls.use_camera_cull = BoolProperty(
551                 name="Use Camera Cull",
552                 description="Allow objects to be culled based on the camera frustum",
553                 default=False,
554                 )
555
556         cls.camera_cull_margin = FloatProperty(
557                 name="Camera Cull Margin",
558                 description="Margin for the camera space culling",
559                 default=0.1,
560                 min=0.0, max=5.0
561                 )
562
563         cls.use_distance_cull = BoolProperty(
564                 name="Use Distance Cull",
565                 description="Allow objects to be culled based on the distance from camera",
566                 default=False,
567                 )
568
569         cls.distance_cull_margin = FloatProperty(
570                 name="Cull Distance",
571                 description="Cull objects which are further away from camera than this distance",
572                 default=50,
573                 min=0.0
574                 )
575
576         cls.motion_blur_position = EnumProperty(
577             name="Motion Blur Position",
578             default='CENTER',
579             description="Offset for the shutter's time interval, allows to change the motion blur trails",
580             items=(
581                 ('START', "Start on Frame", "The shutter opens at the current frame"),
582                 ('CENTER', "Center on Frame", "The shutter is open during the current frame"),
583                 ('END', "End on Frame", "The shutter closes at the current frame"),
584                 ),
585             )
586
587         cls.rolling_shutter_type = EnumProperty(
588             name="Shutter Type",
589             default='NONE',
590             description="Type of rolling shutter effect matching CMOS-based cameras",
591             items=(
592                 ('NONE', "None", "No rolling shutter effect used"),
593                 ('TOP', "Top-Bottom", "Sensor is being scanned from top to bottom")
594                 # TODO(seergey): Are there real cameras with different scanning direction?
595                 ),
596             )
597
598         cls.rolling_shutter_duration = FloatProperty(
599             name="Rolling Shutter Duration",
600             description="Scanline \"exposure\" time for the rolling shutter effect",
601             default=0.1,
602             min=0.0, max=1.0,
603             )
604
605         cls.texture_limit = EnumProperty(
606             name="Viewport Texture Limit",
607             default='OFF',
608             description="Limit texture size used by viewport rendering",
609             items=enum_texture_limit
610             )
611
612         cls.texture_limit_render = EnumProperty(
613             name="Render Texture Limit",
614             default='OFF',
615             description="Limit texture size used by final rendering",
616             items=enum_texture_limit
617             )
618
619         cls.ao_bounces = IntProperty(
620             name="AO Bounces",
621             default=0,
622             description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature",
623             min=0, max=1024,
624             )
625
626         cls.ao_bounces_render = IntProperty(
627             name="AO Bounces Render",
628             default=0,
629             description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature",
630             min=0, max=1024,
631             )
632
633         # Various fine-tuning debug flags
634
635         def devices_update_callback(self, context):
636             import _cycles
637             scene = context.scene.as_pointer()
638             return _cycles.debug_flags_update(scene)
639
640         cls.debug_use_cpu_avx2 = BoolProperty(name="AVX2", default=True)
641         cls.debug_use_cpu_avx = BoolProperty(name="AVX", default=True)
642         cls.debug_use_cpu_sse41 = BoolProperty(name="SSE41", default=True)
643         cls.debug_use_cpu_sse3 = BoolProperty(name="SSE3", default=True)
644         cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True)
645         cls.debug_use_qbvh = BoolProperty(name="QBVH", default=True)
646         cls.debug_use_cpu_split_kernel = BoolProperty(name="Split Kernel", default=False)
647
648         cls.debug_use_cuda_adaptive_compile = BoolProperty(name="Adaptive Compile", default=False)
649         cls.debug_use_cuda_split_kernel = BoolProperty(name="Split Kernel", default=False)
650
651         cls.debug_opencl_kernel_type = EnumProperty(
652             name="OpenCL Kernel Type",
653             default='DEFAULT',
654             items=(
655                 ('DEFAULT', "Default", ""),
656                 ('MEGA', "Mega", ""),
657                 ('SPLIT', "Split", ""),
658                 ),
659             update=devices_update_callback
660             )
661
662         cls.debug_opencl_device_type = EnumProperty(
663             name="OpenCL Device Type",
664             default='ALL',
665             items=(
666                 ('NONE', "None", ""),
667                 ('ALL', "All", ""),
668                 ('DEFAULT', "Default", ""),
669                 ('CPU', "CPU", ""),
670                 ('GPU', "GPU", ""),
671                 ('ACCELERATOR', "Accelerator", ""),
672                 ),
673             update=devices_update_callback
674             )
675
676         cls.debug_opencl_kernel_single_program = BoolProperty(
677             name="Single Program",
678             default=True,
679             update=devices_update_callback,
680             )
681
682         cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False)
683
684         cls.debug_opencl_mem_limit = IntProperty(name="Memory limit", default=0,
685             description="Artificial limit on OpenCL memory usage in MB (0 to disable limit)")
686
687     @classmethod
688     def unregister(cls):
689         del bpy.types.Scene.cycles
690
691
692 class CyclesCameraSettings(bpy.types.PropertyGroup):
693     @classmethod
694     def register(cls):
695         import math
696
697         bpy.types.Camera.cycles = PointerProperty(
698                 name="Cycles Camera Settings",
699                 description="Cycles camera settings",
700                 type=cls,
701                 )
702
703         cls.aperture_type = EnumProperty(
704                 name="Aperture Type",
705                 description="Use f-stop number or aperture radius",
706                 items=enum_aperture_types,
707                 default='RADIUS',
708                 )
709         cls.aperture_fstop = FloatProperty(
710                 name="Aperture f-stop",
711                 description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)",
712                 min=0.0, soft_min=0.1, soft_max=64.0,
713                 default=5.6,
714                 step=10,
715                 precision=1,
716                 )
717         cls.aperture_size = FloatProperty(
718                 name="Aperture Size",
719                 description="Radius of the aperture for depth of field (higher values give more defocus)",
720                 min=0.0, soft_max=10.0,
721                 default=0.0,
722                 step=1,
723                 precision=4,
724                 subtype='DISTANCE',
725                 )
726         cls.aperture_blades = IntProperty(
727                 name="Aperture Blades",
728                 description="Number of blades in aperture for polygonal bokeh (at least 3)",
729                 min=0, max=100,
730                 default=0,
731                 )
732         cls.aperture_rotation = FloatProperty(
733                 name="Aperture Rotation",
734                 description="Rotation of blades in aperture",
735                 soft_min=-math.pi, soft_max=math.pi,
736                 subtype='ANGLE',
737                 default=0,
738                 )
739         cls.aperture_ratio = FloatProperty(
740                 name="Aperture Ratio",
741                 description="Distortion to simulate anamorphic lens bokeh",
742                 min=0.01, soft_min=1.0, soft_max=2.0,
743                 default=1.0,
744                 precision=4,
745                 )
746         cls.panorama_type = EnumProperty(
747                 name="Panorama Type",
748                 description="Distortion to use for the calculation",
749                 items=enum_panorama_types,
750                 default='FISHEYE_EQUISOLID',
751                 )
752         cls.fisheye_fov = FloatProperty(
753                 name="Field of View",
754                 description="Field of view for the fisheye lens",
755                 min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi,
756                 subtype='ANGLE',
757                 default=math.pi,
758                 )
759         cls.fisheye_lens = FloatProperty(
760                 name="Fisheye Lens",
761                 description="Lens focal length (mm)",
762                 min=0.01, soft_max=15.0, max=100.0,
763                 default=10.5,
764                 )
765         cls.latitude_min = FloatProperty(
766                 name="Min Latitude",
767                 description="Minimum latitude (vertical angle) for the equirectangular lens",
768                 min=-0.5 * math.pi, max=0.5 * math.pi,
769                 subtype='ANGLE',
770                 default=-0.5 * math.pi,
771                 )
772         cls.latitude_max = FloatProperty(
773                 name="Max Latitude",
774                 description="Maximum latitude (vertical angle) for the equirectangular lens",
775                 min=-0.5 * math.pi, max=0.5 * math.pi,
776                 subtype='ANGLE',
777                 default=0.5 * math.pi,
778                 )
779         cls.longitude_min = FloatProperty(
780                 name="Min Longitude",
781                 description="Minimum longitude (horizontal angle) for the equirectangular lens",
782                 min=-math.pi, max=math.pi,
783                 subtype='ANGLE',
784                 default=-math.pi,
785                 )
786         cls.longitude_max = FloatProperty(
787                 name="Max Longitude",
788                 description="Maximum longitude (horizontal angle) for the equirectangular lens",
789                 min=-math.pi, max=math.pi,
790                 subtype='ANGLE',
791                 default=math.pi,
792                 )
793
794     @classmethod
795     def unregister(cls):
796         del bpy.types.Camera.cycles
797
798
799 class CyclesMaterialSettings(bpy.types.PropertyGroup):
800     @classmethod
801     def register(cls):
802         bpy.types.Material.cycles = PointerProperty(
803                 name="Cycles Material Settings",
804                 description="Cycles material settings",
805                 type=cls,
806                 )
807         cls.sample_as_light = BoolProperty(
808                 name="Multiple Importance Sample",
809                 description="Use multiple importance sampling for this material, "
810                             "disabling may reduce overall noise for large "
811                             "objects that emit little light compared to other light sources",
812                 default=True,
813                 )
814         cls.use_transparent_shadow = BoolProperty(
815                 name="Transparent Shadows",
816                 description="Use transparent shadows for this material if it contains a Transparent BSDF, "
817                             "disabling will render faster but not give accurate shadows",
818                 default=True,
819                 )
820         cls.homogeneous_volume = BoolProperty(
821                 name="Homogeneous Volume",
822                 description="When using volume rendering, assume volume has the same density everywhere "
823                             "(not using any textures), for faster rendering",
824                 default=False,
825                 )
826         cls.volume_sampling = EnumProperty(
827                 name="Volume Sampling",
828                 description="Sampling method to use for volumes",
829                 items=enum_volume_sampling,
830                 default='MULTIPLE_IMPORTANCE',
831                 )
832
833         cls.volume_interpolation = EnumProperty(
834                 name="Volume Interpolation",
835                 description="Interpolation method to use for smoke/fire volumes",
836                 items=enum_volume_interpolation,
837                 default='LINEAR',
838                 )
839
840         cls.displacement_method = EnumProperty(
841                 name="Displacement Method",
842                 description="Method to use for the displacement",
843                 items=enum_displacement_methods,
844                 default='BUMP',
845                 )
846
847     @classmethod
848     def unregister(cls):
849         del bpy.types.Material.cycles
850
851
852 class CyclesLampSettings(bpy.types.PropertyGroup):
853     @classmethod
854     def register(cls):
855         bpy.types.Lamp.cycles = PointerProperty(
856                 name="Cycles Lamp Settings",
857                 description="Cycles lamp settings",
858                 type=cls,
859                 )
860         cls.cast_shadow = BoolProperty(
861                 name="Cast Shadow",
862                 description="Lamp casts shadows",
863                 default=True,
864                 )
865         cls.samples = IntProperty(
866                 name="Samples",
867                 description="Number of light samples to render for each AA sample",
868                 min=1, max=10000,
869                 default=1,
870                 )
871         cls.max_bounces = IntProperty(
872                 name="Max Bounces",
873                 description="Maximum number of bounces the light will contribute to the render",
874                 min=0, max=1024,
875                 default=1024,
876                 )
877         cls.use_multiple_importance_sampling = BoolProperty(
878                 name="Multiple Importance Sample",
879                 description="Use multiple importance sampling for the lamp, "
880                             "reduces noise for area lamps and sharp glossy materials",
881                 default=True,
882                 )
883         cls.is_portal = BoolProperty(
884                 name="Is Portal",
885                 description="Use this area lamp to guide sampling of the background, "
886                             "note that this will make the lamp invisible",
887                 default=False,
888                 )
889
890     @classmethod
891     def unregister(cls):
892         del bpy.types.Lamp.cycles
893
894
895 class CyclesWorldSettings(bpy.types.PropertyGroup):
896     @classmethod
897     def register(cls):
898         bpy.types.World.cycles = PointerProperty(
899                 name="Cycles World Settings",
900                 description="Cycles world settings",
901                 type=cls,
902                 )
903         cls.sample_as_light = BoolProperty(
904                 name="Multiple Importance Sample",
905                 description="Use multiple importance sampling for the environment, "
906                             "enabling for non-solid colors is recommended",
907                 default=True,
908                 )
909         cls.sample_map_resolution = IntProperty(
910                 name="Map Resolution",
911                 description="Importance map size is resolution x resolution; "
912                             "higher values potentially produce less noise, at the cost of memory and speed",
913                 min=4, max=8192,
914                 default=1024,
915                 )
916         cls.samples = IntProperty(
917                 name="Samples",
918                 description="Number of light samples to render for each AA sample",
919                 min=1, max=10000,
920                 default=1,
921                 )
922         cls.max_bounces = IntProperty(
923                 name="Max Bounces",
924                 description="Maximum number of bounces the background light will contribute to the render",
925                 min=0, max=1024,
926                 default=1024,
927                 )
928         cls.homogeneous_volume = BoolProperty(
929                 name="Homogeneous Volume",
930                 description="When using volume rendering, assume volume has the same density everywhere"
931                             "(not using any textures), for faster rendering",
932                 default=False,
933                 )
934         cls.volume_sampling = EnumProperty(
935                 name="Volume Sampling",
936                 description="Sampling method to use for volumes",
937                 items=enum_volume_sampling,
938                 default='EQUIANGULAR',
939                 )
940
941         cls.volume_interpolation = EnumProperty(
942                 name="Volume Interpolation",
943                 description="Interpolation method to use for volumes",
944                 items=enum_volume_interpolation,
945                 default='LINEAR',
946                 )
947
948     @classmethod
949     def unregister(cls):
950         del bpy.types.World.cycles
951
952
953 class CyclesVisibilitySettings(bpy.types.PropertyGroup):
954     @classmethod
955     def register(cls):
956         bpy.types.Object.cycles_visibility = PointerProperty(
957                 name="Cycles Visibility Settings",
958                 description="Cycles visibility settings",
959                 type=cls,
960                 )
961
962         bpy.types.World.cycles_visibility = PointerProperty(
963                 name="Cycles Visibility Settings",
964                 description="Cycles visibility settings",
965                 type=cls,
966                 )
967
968         cls.camera = BoolProperty(
969                 name="Camera",
970                 description="Object visibility for camera rays",
971                 default=True,
972                 )
973         cls.diffuse = BoolProperty(
974                 name="Diffuse",
975                 description="Object visibility for diffuse reflection rays",
976                 default=True,
977                 )
978         cls.glossy = BoolProperty(
979                 name="Glossy",
980                 description="Object visibility for glossy reflection rays",
981                 default=True,
982                 )
983         cls.transmission = BoolProperty(
984                 name="Transmission",
985                 description="Object visibility for transmission rays",
986                 default=True,
987                 )
988         cls.shadow = BoolProperty(
989                 name="Shadow",
990                 description="Object visibility for shadow rays",
991                 default=True,
992                 )
993         cls.scatter = BoolProperty(
994                 name="Volume Scatter",
995                 description="Object visibility for volume scatter rays",
996                 default=True,
997                 )
998
999     @classmethod
1000     def unregister(cls):
1001         del bpy.types.Object.cycles_visibility
1002         del bpy.types.World.cycles_visibility
1003
1004
1005 class CyclesMeshSettings(bpy.types.PropertyGroup):
1006     @classmethod
1007     def register(cls):
1008         bpy.types.Mesh.cycles = PointerProperty(
1009                 name="Cycles Mesh Settings",
1010                 description="Cycles mesh settings",
1011                 type=cls,
1012                 )
1013         bpy.types.Curve.cycles = PointerProperty(
1014                 name="Cycles Mesh Settings",
1015                 description="Cycles mesh settings",
1016                 type=cls,
1017                 )
1018         bpy.types.MetaBall.cycles = PointerProperty(
1019                 name="Cycles Mesh Settings",
1020                 description="Cycles mesh settings",
1021                 type=cls,
1022                 )
1023
1024     @classmethod
1025     def unregister(cls):
1026         del bpy.types.Mesh.cycles
1027         del bpy.types.Curve.cycles
1028         del bpy.types.MetaBall.cycles
1029
1030
1031 class CyclesObjectSettings(bpy.types.PropertyGroup):
1032     @classmethod
1033     def register(cls):
1034         bpy.types.Object.cycles = PointerProperty(
1035                 name="Cycles Object Settings",
1036                 description="Cycles object settings",
1037                 type=cls,
1038                 )
1039
1040         cls.use_motion_blur = BoolProperty(
1041                 name="Use Motion Blur",
1042                 description="Use motion blur for this object",
1043                 default=True,
1044                 )
1045
1046         cls.use_deform_motion = BoolProperty(
1047                 name="Use Deformation Motion",
1048                 description="Use deformation motion blur for this object",
1049                 default=True,
1050                 )
1051
1052         cls.motion_steps = IntProperty(
1053                 name="Motion Steps",
1054                 description="Control accuracy of deformation motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
1055                 min=1, soft_max=8,
1056                 default=1,
1057                 )
1058
1059         cls.use_camera_cull = BoolProperty(
1060                 name="Use Camera Cull",
1061                 description="Allow this object and its duplicators to be culled by camera space culling",
1062                 default=False,
1063                 )
1064
1065         cls.use_distance_cull = BoolProperty(
1066                 name="Use Distance Cull",
1067                 description="Allow this object and its duplicators to be culled by distance from camera",
1068                 default=False,
1069                 )
1070
1071         cls.use_adaptive_subdivision = BoolProperty(
1072                 name="Use Adaptive Subdivision",
1073                 description="Use adaptive render time subdivision",
1074                 default=False,
1075                 )
1076
1077         cls.dicing_rate = FloatProperty(
1078                 name="Dicing Scale",
1079                 description="Multiplier for scene dicing rate (located in the Geometry Panel)",
1080                 min=0.1, max=1000.0, soft_min=0.5,
1081                 default=1.0,
1082                 )
1083
1084         cls.is_shadow_catcher = BoolProperty(
1085                 name="Shadow Catcher",
1086                 description="Only render shadows on this object, for compositing renders into real footage",
1087                 default=False,
1088                 )
1089
1090     @classmethod
1091     def unregister(cls):
1092         del bpy.types.Object.cycles
1093
1094
1095 class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
1096     @classmethod
1097     def register(cls):
1098         bpy.types.Scene.cycles_curves = PointerProperty(
1099                 name="Cycles Hair Rendering Settings",
1100                 description="Cycles hair rendering settings",
1101                 type=cls,
1102                 )
1103         cls.primitive = EnumProperty(
1104                 name="Primitive",
1105                 description="Type of primitive used for hair rendering",
1106                 items=enum_curve_primitives,
1107                 default='LINE_SEGMENTS',
1108                 )
1109         cls.shape = EnumProperty(
1110                 name="Shape",
1111                 description="Form of hair",
1112                 items=enum_curve_shape,
1113                 default='THICK',
1114                 )
1115         cls.cull_backfacing = BoolProperty(
1116                 name="Cull back-faces",
1117                 description="Do not test the back-face of each strand",
1118                 default=True,
1119                 )
1120         cls.use_curves = BoolProperty(
1121                 name="Use Cycles Hair Rendering",
1122                 description="Activate Cycles hair rendering for particle system",
1123                 default=True,
1124                 )
1125         cls.resolution = IntProperty(
1126                 name="Resolution",
1127                 description="Resolution of generated mesh",
1128                 min=3, max=64,
1129                 default=3,
1130                 )
1131         cls.minimum_width = FloatProperty(
1132                 name="Minimal width",
1133                 description="Minimal pixel width for strands (0 - deactivated)",
1134                 min=0.0, max=100.0,
1135                 default=0.0,
1136                 )
1137         cls.maximum_width = FloatProperty(
1138                 name="Maximal width",
1139                 description="Maximum extension that strand radius can be increased by",
1140                 min=0.0, max=100.0,
1141                 default=0.1,
1142                 )
1143         cls.subdivisions = IntProperty(
1144                 name="Subdivisions",
1145                 description="Number of subdivisions used in Cardinal curve intersection (power of 2)",
1146                 min=0, max=24,
1147                 default=4,
1148                 )
1149
1150     @classmethod
1151     def unregister(cls):
1152         del bpy.types.Scene.cycles_curves
1153
1154 def update_render_passes(self, context):
1155     scene = context.scene
1156     rd = scene.render
1157     rl = rd.layers.active
1158     rl.update_render_passes()
1159
1160 class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
1161     @classmethod
1162     def register(cls):
1163         bpy.types.SceneRenderLayer.cycles = PointerProperty(
1164                 name="Cycles SceneRenderLayer Settings",
1165                 description="Cycles SceneRenderLayer Settings",
1166                 type=cls,
1167                 )
1168         cls.pass_debug_bvh_traversed_nodes = BoolProperty(
1169                 name="Debug BVH Traversed Nodes",
1170                 description="Store Debug BVH Traversed Nodes pass",
1171                 default=False,
1172                 update=update_render_passes,
1173                 )
1174         cls.pass_debug_bvh_traversed_instances = BoolProperty(
1175                 name="Debug BVH Traversed Instances",
1176                 description="Store Debug BVH Traversed Instances pass",
1177                 default=False,
1178                 update=update_render_passes,
1179                 )
1180         cls.pass_debug_bvh_intersections = BoolProperty(
1181                 name="Debug BVH Intersections",
1182                 description="Store Debug BVH Intersections",
1183                 default=False,
1184                 update=update_render_passes,
1185                 )
1186         cls.pass_debug_ray_bounces = BoolProperty(
1187                 name="Debug Ray Bounces",
1188                 description="Store Debug Ray Bounces pass",
1189                 default=False,
1190                 update=update_render_passes,
1191                 )
1192
1193         cls.use_denoising = BoolProperty(
1194                 name="Use Denoising",
1195                 description="Denoise the rendered image",
1196                 default=False,
1197                 update=update_render_passes,
1198                 )
1199         cls.denoising_diffuse_direct = BoolProperty(
1200                 name="Diffuse Direct",
1201                 description="Denoise the direct diffuse lighting",
1202                 default=True,
1203                 )
1204         cls.denoising_diffuse_indirect = BoolProperty(
1205                 name="Diffuse Indirect",
1206                 description="Denoise the indirect diffuse lighting",
1207                 default=True,
1208                 )
1209         cls.denoising_glossy_direct = BoolProperty(
1210                 name="Glossy Direct",
1211                 description="Denoise the direct glossy lighting",
1212                 default=True,
1213                 )
1214         cls.denoising_glossy_indirect = BoolProperty(
1215                 name="Glossy Indirect",
1216                 description="Denoise the indirect glossy lighting",
1217                 default=True,
1218                 )
1219         cls.denoising_transmission_direct = BoolProperty(
1220                 name="Transmission Direct",
1221                 description="Denoise the direct transmission lighting",
1222                 default=True,
1223                 )
1224         cls.denoising_transmission_indirect = BoolProperty(
1225                 name="Transmission Indirect",
1226                 description="Denoise the indirect transmission lighting",
1227                 default=True,
1228                 )
1229         cls.denoising_subsurface_direct = BoolProperty(
1230                 name="Subsurface Direct",
1231                 description="Denoise the direct subsurface lighting",
1232                 default=True,
1233                 )
1234         cls.denoising_subsurface_indirect = BoolProperty(
1235                 name="Subsurface Indirect",
1236                 description="Denoise the indirect subsurface lighting",
1237                 default=True,
1238                 )
1239         cls.denoising_strength = FloatProperty(
1240                 name="Denoising Strength",
1241                 description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)",
1242                 min=0.0, max=1.0,
1243                 default=0.5,
1244                 )
1245         cls.denoising_feature_strength = FloatProperty(
1246                 name="Denoising Feature Strength",
1247                 description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)",
1248                 min=0.0, max=1.0,
1249                 default=0.5,
1250                 )
1251         cls.denoising_radius = IntProperty(
1252                 name="Denoising Radius",
1253                 description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)",
1254                 min=1, max=25,
1255                 default=8,
1256         )
1257         cls.denoising_relative_pca = BoolProperty(
1258                 name="Relative filter",
1259                 description="When removing pixels that don't carry information, use a relative threshold instead of an absolute one (can help to reduce artifacts, but might cause detail loss around edges)",
1260                 default=False,
1261         )
1262         cls.denoising_store_passes = BoolProperty(
1263                 name="Store denoising passes",
1264                 description="Store the denoising feature passes and the noisy image",
1265                 default=False,
1266                 update=update_render_passes,
1267         )
1268
1269     @classmethod
1270     def unregister(cls):
1271         del bpy.types.SceneRenderLayer.cycles
1272
1273
1274 class CyclesCurveSettings(bpy.types.PropertyGroup):
1275     @classmethod
1276     def register(cls):
1277         bpy.types.ParticleSettings.cycles = PointerProperty(
1278                 name="Cycles Hair Settings",
1279                 description="Cycles hair settings",
1280                 type=cls,
1281                 )
1282         cls.radius_scale = FloatProperty(
1283                 name="Radius Scaling",
1284                 description="Multiplier of width properties",
1285                 min=0.0, max=1000.0,
1286                 default=0.01,
1287                 )
1288         cls.root_width = FloatProperty(
1289                 name="Root Size",
1290                 description="Strand's width at root",
1291                 min=0.0, max=1000.0,
1292                 default=1.0,
1293                 )
1294         cls.tip_width = FloatProperty(
1295                 name="Tip Multiplier",
1296                 description="Strand's width at tip",
1297                 min=0.0, max=1000.0,
1298                 default=0.0,
1299                 )
1300         cls.shape = FloatProperty(
1301                 name="Strand Shape",
1302                 description="Strand shape parameter",
1303                 min=-1.0, max=1.0,
1304                 default=0.0,
1305                 )
1306         cls.use_closetip = BoolProperty(
1307                 name="Close tip",
1308                 description="Set tip radius to zero",
1309                 default=True,
1310                 )
1311
1312     @classmethod
1313     def unregister(cls):
1314         del bpy.types.ParticleSettings.cycles
1315
1316
1317 class CyclesDeviceSettings(bpy.types.PropertyGroup):
1318     @classmethod
1319     def register(cls):
1320         cls.id = StringProperty(name="ID")
1321         cls.name = StringProperty(name="Name")
1322         cls.use = BoolProperty(name="Use", default=True)
1323         cls.type = EnumProperty(name="Type", items=enum_device_type, default='CUDA')
1324
1325
1326 class CyclesPreferences(bpy.types.AddonPreferences):
1327     bl_idname = __package__
1328
1329     def get_device_types(self, context):
1330         import _cycles
1331         has_cuda, has_opencl = _cycles.get_device_types()
1332         list = [('NONE', "None", "Don't use compute device", 0)]
1333         if has_cuda:
1334             list.append(('CUDA', "CUDA", "Use CUDA for GPU acceleration", 1))
1335         if has_opencl:
1336             list.append(('OPENCL', "OpenCL", "Use OpenCL for GPU acceleration", 2))
1337         return list
1338
1339     compute_device_type = EnumProperty(
1340             name="Compute Device Type",
1341             description="Device to use for computation (rendering with Cycles)",
1342             items=get_device_types,
1343             )
1344
1345     devices = bpy.props.CollectionProperty(type=CyclesDeviceSettings)
1346
1347     def get_devices(self):
1348         import _cycles
1349         # Layout of the device tuples: (Name, Type, Persistent ID)
1350         device_list = _cycles.available_devices()
1351
1352         cuda_devices = []
1353         opencl_devices = []
1354         for device in device_list:
1355             if not device[1] in {'CUDA', 'OPENCL'}:
1356                 continue
1357
1358             entry = None
1359             # Try to find existing Device entry
1360             for dev in self.devices:
1361                 if dev.id == device[2] and dev.type == device[1]:
1362                     entry = dev
1363                     break
1364             # Create new entry if no existing one was found
1365             if not entry:
1366                 entry = self.devices.add()
1367                 entry.id   = device[2]
1368                 entry.name = device[0]
1369                 entry.type = device[1]
1370
1371             # Sort entries into lists
1372             if entry.type == 'CUDA':
1373                 cuda_devices.append(entry)
1374             elif entry.type == 'OPENCL':
1375                 opencl_devices.append(entry)
1376         return cuda_devices, opencl_devices
1377
1378
1379     def get_num_gpu_devices(self):
1380         import _cycles
1381         device_list = _cycles.available_devices()
1382         num = 0
1383         for device in device_list:
1384             if device[1] != self.compute_device_type:
1385                 continue
1386             for dev in self.devices:
1387                 if dev.use and dev.id == device[2]:
1388                     num += 1
1389         return num
1390
1391
1392     def has_active_device(self):
1393         return self.get_num_gpu_devices() > 0
1394
1395
1396     def draw_impl(self, layout, context):
1397         layout.label(text="Cycles Compute Device:")
1398         layout.row().prop(self, "compute_device_type", expand=True)
1399
1400         cuda_devices, opencl_devices = self.get_devices()
1401         row = layout.row()
1402
1403         if self.compute_device_type == 'CUDA' and cuda_devices:
1404             box = row.box()
1405             for device in cuda_devices:
1406                 box.prop(device, "use", text=device.name)
1407
1408         if self.compute_device_type == 'OPENCL' and opencl_devices:
1409             box = row.box()
1410             for device in opencl_devices:
1411                 box.prop(device, "use", text=device.name)
1412
1413
1414     def draw(self, context):
1415         self.draw_impl(self.layout, context)
1416
1417
1418 def register():
1419     bpy.utils.register_class(CyclesRenderSettings)
1420     bpy.utils.register_class(CyclesCameraSettings)
1421     bpy.utils.register_class(CyclesMaterialSettings)
1422     bpy.utils.register_class(CyclesLampSettings)
1423     bpy.utils.register_class(CyclesWorldSettings)
1424     bpy.utils.register_class(CyclesVisibilitySettings)
1425     bpy.utils.register_class(CyclesMeshSettings)
1426     bpy.utils.register_class(CyclesObjectSettings)
1427     bpy.utils.register_class(CyclesCurveRenderSettings)
1428     bpy.utils.register_class(CyclesCurveSettings)
1429     bpy.utils.register_class(CyclesDeviceSettings)
1430     bpy.utils.register_class(CyclesPreferences)
1431     bpy.utils.register_class(CyclesRenderLayerSettings)
1432
1433
1434 def unregister():
1435     bpy.utils.unregister_class(CyclesRenderSettings)
1436     bpy.utils.unregister_class(CyclesCameraSettings)
1437     bpy.utils.unregister_class(CyclesMaterialSettings)
1438     bpy.utils.unregister_class(CyclesLampSettings)
1439     bpy.utils.unregister_class(CyclesWorldSettings)
1440     bpy.utils.unregister_class(CyclesMeshSettings)
1441     bpy.utils.unregister_class(CyclesObjectSettings)
1442     bpy.utils.unregister_class(CyclesVisibilitySettings)
1443     bpy.utils.unregister_class(CyclesCurveRenderSettings)
1444     bpy.utils.unregister_class(CyclesCurveSettings)
1445     bpy.utils.unregister_class(CyclesDeviceSettings)
1446     bpy.utils.unregister_class(CyclesPreferences)
1447     bpy.utils.unregister_class(CyclesRenderLayerSettings)