Cleanup: indentation, long lines
[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.min_bounces = IntProperty(
315                 name="Min Bounces",
316                 description="Minimum number of bounces, setting this lower "
317                             "than the maximum enables probabilistic path "
318                             "termination (faster but noisier)",
319                 min=0, max=1024,
320                 default=3,
321                 )
322         cls.max_bounces = IntProperty(
323                 name="Max Bounces",
324                 description="Total maximum number of bounces",
325                 min=0, max=1024,
326                 default=12,
327                 )
328
329         cls.diffuse_bounces = IntProperty(
330                 name="Diffuse Bounces",
331                 description="Maximum number of diffuse reflection bounces, bounded by total maximum",
332                 min=0, max=1024,
333                 default=4,
334                 )
335         cls.glossy_bounces = IntProperty(
336                 name="Glossy Bounces",
337                 description="Maximum number of glossy reflection bounces, bounded by total maximum",
338                 min=0, max=1024,
339                 default=4,
340                 )
341         cls.transmission_bounces = IntProperty(
342                 name="Transmission Bounces",
343                 description="Maximum number of transmission bounces, bounded by total maximum",
344                 min=0, max=1024,
345                 default=12,
346                 )
347         cls.volume_bounces = IntProperty(
348                 name="Volume Bounces",
349                 description="Maximum number of volumetric scattering events",
350                 min=0, max=1024,
351                 default=0,
352                 )
353
354         cls.transparent_min_bounces = IntProperty(
355                 name="Transparent Min Bounces",
356                 description="Minimum number of transparent bounces, setting "
357                             "this lower than the maximum enables "
358                             "probabilistic path termination (faster but "
359                             "noisier)",
360                 min=0, max=1024,
361                 default=8,
362                 )
363         cls.transparent_max_bounces = IntProperty(
364                 name="Transparent Max Bounces",
365                 description="Maximum number of transparent bounces",
366                 min=0, max=1024,
367                 default=8,
368                 )
369         cls.use_transparent_shadows = BoolProperty(
370                 name="Transparent Shadows",
371                 description="Use transparency of surfaces for rendering shadows",
372                 default=True,
373                 )
374
375         cls.volume_step_size = FloatProperty(
376                 name="Step Size",
377                 description="Distance between volume shader samples when rendering the volume "
378                             "(lower values give more accurate and detailed results, but also increased render time)",
379                 default=0.1,
380                 min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4
381                 )
382
383         cls.volume_max_steps = IntProperty(
384                 name="Max Steps",
385                 description="Maximum number of steps through the volume before giving up, "
386                             "to avoid extremely long render times with big objects or small step sizes",
387                 default=1024,
388                 min=2, max=65536
389                 )
390
391         cls.dicing_rate = FloatProperty(
392                 name="Dicing Rate",
393                 description="Size of a micropolygon in pixels",
394                 min=0.1, max=1000.0, soft_min=0.5,
395                 default=1.0,
396                 subtype="PIXEL"
397                 )
398         cls.preview_dicing_rate = FloatProperty(
399                 name="Preview Dicing Rate",
400                 description="Size of a micropolygon in pixels during preview render",
401                 min=0.1, max=1000.0, soft_min=0.5,
402                 default=8.0,
403                 subtype="PIXEL"
404                 )
405
406         cls.max_subdivisions = IntProperty(
407                 name="Max Subdivisions",
408                 description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation",
409                 min=0, max=16,
410                 default=12,
411                 )
412
413         cls.film_exposure = FloatProperty(
414                 name="Exposure",
415                 description="Image brightness scale",
416                 min=0.0, max=10.0,
417                 default=1.0,
418                 )
419         cls.film_transparent = BoolProperty(
420                 name="Transparent",
421                 description="World background is transparent with premultiplied alpha",
422                 default=False,
423                 )
424
425         # Really annoyingly, we have to keep it around for a few releases,
426         # otherwise forward compatibility breaks in really bad manner: CRASH!
427         #
428         # TODO(sergey): Remove this during 2.8x series of Blender.
429         cls.filter_type = EnumProperty(
430                 name="Filter Type",
431                 description="Pixel filter type",
432                 items=enum_filter_types,
433                 default='BLACKMAN_HARRIS',
434                 )
435
436         cls.pixel_filter_type = EnumProperty(
437                 name="Filter Type",
438                 description="Pixel filter type",
439                 items=enum_filter_types,
440                 default='BLACKMAN_HARRIS',
441                 )
442
443         cls.filter_width = FloatProperty(
444                 name="Filter Width",
445                 description="Pixel filter width",
446                 min=0.01, max=10.0,
447                 default=1.5,
448                 )
449
450         cls.seed = IntProperty(
451                 name="Seed",
452                 description="Seed value for integrator to get different noise patterns",
453                 min=0, max=2147483647,
454                 default=0,
455                 )
456
457         cls.use_animated_seed = BoolProperty(
458                 name="Use Animated Seed",
459                 description="Use different seed values (and hence noise patterns) at different frames",
460                 default=False,
461                 )
462
463         cls.sample_clamp_direct = FloatProperty(
464                 name="Clamp Direct",
465                 description="If non-zero, the maximum value for a direct sample, "
466                             "higher values will be scaled down to avoid too "
467                             "much noise and slow convergence at the cost of accuracy",
468                 min=0.0, max=1e8,
469                 default=0.0,
470                 )
471
472         cls.sample_clamp_indirect = FloatProperty(
473                 name="Clamp Indirect",
474                 description="If non-zero, the maximum value for an indirect sample, "
475                             "higher values will be scaled down to avoid too "
476                             "much noise and slow convergence at the cost of accuracy",
477                 min=0.0, max=1e8,
478                 default=0.0,
479                 )
480
481         cls.debug_tile_size = IntProperty(
482                 name="Tile Size",
483                 description="",
484                 min=1, max=4096,
485                 default=1024,
486                 )
487
488         cls.preview_start_resolution = IntProperty(
489                 name="Start Resolution",
490                 description="Resolution to start rendering preview at, "
491                             "progressively increasing it to the full viewport size",
492                 min=8, max=16384,
493                 default=64,
494                 )
495
496         cls.debug_reset_timeout = FloatProperty(
497                 name="Reset timeout",
498                 description="",
499                 min=0.01, max=10.0,
500                 default=0.1,
501                 )
502         cls.debug_cancel_timeout = FloatProperty(
503                 name="Cancel timeout",
504                 description="",
505                 min=0.01, max=10.0,
506                 default=0.1,
507                 )
508         cls.debug_text_timeout = FloatProperty(
509                 name="Text timeout",
510                 description="",
511                 min=0.01, max=10.0,
512                 default=1.0,
513                 )
514
515         cls.debug_bvh_type = EnumProperty(
516                 name="Viewport BVH Type",
517                 description="Choose between faster updates, or faster render",
518                 items=enum_bvh_types,
519                 default='DYNAMIC_BVH',
520                 )
521         cls.debug_use_spatial_splits = BoolProperty(
522                 name="Use Spatial Splits",
523                 description="Use BVH spatial splits: longer builder time, faster render",
524                 default=False,
525                 )
526         cls.debug_use_hair_bvh = BoolProperty(
527                 name="Use Hair BVH",
528                 description="Use special type BVH optimized for hair (uses more ram but renders faster)",
529                 default=True,
530                 )
531         cls.debug_bvh_time_steps = IntProperty(
532                 name="BVH Time Steps",
533                 description="Split BVH primitives by this number of time steps to speed up render time in cost of memory",
534                 default=0,
535                 min=0, max=16,
536                 )
537         cls.tile_order = EnumProperty(
538                 name="Tile Order",
539                 description="Tile order for rendering",
540                 items=enum_tile_order,
541                 default='HILBERT_SPIRAL',
542                 options=set(),  # Not animatable!
543                 )
544         cls.use_progressive_refine = BoolProperty(
545                 name="Progressive Refine",
546                 description="Instead of rendering each tile until it is finished, "
547                             "refine the whole image progressively "
548                             "(this renders somewhat slower, "
549                             "but time can be saved by manually stopping the render when the noise is low enough)",
550                 default=False,
551                 )
552
553         cls.bake_type = EnumProperty(
554             name="Bake Type",
555             default='COMBINED',
556             description="Type of pass to bake",
557             items=(
558                 ('COMBINED', "Combined", ""),
559                 ('AO', "Ambient Occlusion", ""),
560                 ('SHADOW', "Shadow", ""),
561                 ('NORMAL', "Normal", ""),
562                 ('UV', "UV", ""),
563                 ('EMIT', "Emit", ""),
564                 ('ENVIRONMENT', "Environment", ""),
565                 ('DIFFUSE', "Diffuse", ""),
566                 ('GLOSSY', "Glossy", ""),
567                 ('TRANSMISSION', "Transmission", ""),
568                 ('SUBSURFACE', "Subsurface", ""),
569                 ),
570             )
571
572         cls.use_camera_cull = BoolProperty(
573                 name="Use Camera Cull",
574                 description="Allow objects to be culled based on the camera frustum",
575                 default=False,
576                 )
577
578         cls.camera_cull_margin = FloatProperty(
579                 name="Camera Cull Margin",
580                 description="Margin for the camera space culling",
581                 default=0.1,
582                 min=0.0, max=5.0
583                 )
584
585         cls.use_distance_cull = BoolProperty(
586                 name="Use Distance Cull",
587                 description="Allow objects to be culled based on the distance from camera",
588                 default=False,
589                 )
590
591         cls.distance_cull_margin = FloatProperty(
592                 name="Cull Distance",
593                 description="Cull objects which are further away from camera than this distance",
594                 default=50,
595                 min=0.0
596                 )
597
598         cls.motion_blur_position = EnumProperty(
599             name="Motion Blur Position",
600             default='CENTER',
601             description="Offset for the shutter's time interval, allows to change the motion blur trails",
602             items=(
603                 ('START', "Start on Frame", "The shutter opens at the current frame"),
604                 ('CENTER', "Center on Frame", "The shutter is open during the current frame"),
605                 ('END', "End on Frame", "The shutter closes at the current frame"),
606                 ),
607             )
608
609         cls.rolling_shutter_type = EnumProperty(
610             name="Shutter Type",
611             default='NONE',
612             description="Type of rolling shutter effect matching CMOS-based cameras",
613             items=(
614                 ('NONE', "None", "No rolling shutter effect used"),
615                 ('TOP', "Top-Bottom", "Sensor is being scanned from top to bottom")
616                 # TODO(seergey): Are there real cameras with different scanning direction?
617                 ),
618             )
619
620         cls.rolling_shutter_duration = FloatProperty(
621             name="Rolling Shutter Duration",
622             description="Scanline \"exposure\" time for the rolling shutter effect",
623             default=0.1,
624             min=0.0, max=1.0,
625             )
626
627         cls.texture_limit = EnumProperty(
628             name="Viewport Texture Limit",
629             default='OFF',
630             description="Limit texture size used by viewport rendering",
631             items=enum_texture_limit
632             )
633
634         cls.texture_limit_render = EnumProperty(
635             name="Render Texture Limit",
636             default='OFF',
637             description="Limit texture size used by final rendering",
638             items=enum_texture_limit
639             )
640
641         cls.ao_bounces = IntProperty(
642             name="AO Bounces",
643             default=0,
644             description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature",
645             min=0, max=1024,
646             )
647
648         cls.ao_bounces_render = IntProperty(
649             name="AO Bounces Render",
650             default=0,
651             description="Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature",
652             min=0, max=1024,
653             )
654
655         # Various fine-tuning debug flags
656
657         def devices_update_callback(self, context):
658             import _cycles
659             scene = context.scene.as_pointer()
660             return _cycles.debug_flags_update(scene)
661
662         cls.debug_use_cpu_avx2 = BoolProperty(name="AVX2", default=True)
663         cls.debug_use_cpu_avx = BoolProperty(name="AVX", default=True)
664         cls.debug_use_cpu_sse41 = BoolProperty(name="SSE41", default=True)
665         cls.debug_use_cpu_sse3 = BoolProperty(name="SSE3", default=True)
666         cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True)
667         cls.debug_use_qbvh = BoolProperty(name="QBVH", default=True)
668         cls.debug_use_cpu_split_kernel = BoolProperty(name="Split Kernel", default=False)
669
670         cls.debug_use_cuda_adaptive_compile = BoolProperty(name="Adaptive Compile", default=False)
671         cls.debug_use_cuda_split_kernel = BoolProperty(name="Split Kernel", default=False)
672
673         cls.debug_opencl_kernel_type = EnumProperty(
674             name="OpenCL Kernel Type",
675             default='DEFAULT',
676             items=(
677                 ('DEFAULT', "Default", ""),
678                 ('MEGA', "Mega", ""),
679                 ('SPLIT', "Split", ""),
680                 ),
681             update=devices_update_callback
682             )
683
684         cls.debug_opencl_device_type = EnumProperty(
685             name="OpenCL Device Type",
686             default='ALL',
687             items=(
688                 ('NONE', "None", ""),
689                 ('ALL', "All", ""),
690                 ('DEFAULT', "Default", ""),
691                 ('CPU', "CPU", ""),
692                 ('GPU', "GPU", ""),
693                 ('ACCELERATOR', "Accelerator", ""),
694                 ),
695             update=devices_update_callback
696             )
697
698         cls.debug_opencl_kernel_single_program = BoolProperty(
699             name="Single Program",
700             default=True,
701             update=devices_update_callback,
702             )
703
704         cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False)
705
706     @classmethod
707     def unregister(cls):
708         del bpy.types.Scene.cycles
709
710
711 class CyclesCameraSettings(bpy.types.PropertyGroup):
712     @classmethod
713     def register(cls):
714         import math
715
716         bpy.types.Camera.cycles = PointerProperty(
717                 name="Cycles Camera Settings",
718                 description="Cycles camera settings",
719                 type=cls,
720                 )
721
722         cls.aperture_type = EnumProperty(
723                 name="Aperture Type",
724                 description="Use f-stop number or aperture radius",
725                 items=enum_aperture_types,
726                 default='RADIUS',
727                 )
728         cls.aperture_fstop = FloatProperty(
729                 name="Aperture f-stop",
730                 description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)",
731                 min=0.0, soft_min=0.1, soft_max=64.0,
732                 default=5.6,
733                 step=10,
734                 precision=1,
735                 )
736         cls.aperture_size = FloatProperty(
737                 name="Aperture Size",
738                 description="Radius of the aperture for depth of field (higher values give more defocus)",
739                 min=0.0, soft_max=10.0,
740                 default=0.0,
741                 step=1,
742                 precision=4,
743                 subtype='DISTANCE',
744                 )
745         cls.aperture_blades = IntProperty(
746                 name="Aperture Blades",
747                 description="Number of blades in aperture for polygonal bokeh (at least 3)",
748                 min=0, max=100,
749                 default=0,
750                 )
751         cls.aperture_rotation = FloatProperty(
752                 name="Aperture Rotation",
753                 description="Rotation of blades in aperture",
754                 soft_min=-math.pi, soft_max=math.pi,
755                 subtype='ANGLE',
756                 default=0,
757                 )
758         cls.aperture_ratio = FloatProperty(
759                 name="Aperture Ratio",
760                 description="Distortion to simulate anamorphic lens bokeh",
761                 min=0.01, soft_min=1.0, soft_max=2.0,
762                 default=1.0,
763                 precision=4,
764                 )
765         cls.panorama_type = EnumProperty(
766                 name="Panorama Type",
767                 description="Distortion to use for the calculation",
768                 items=enum_panorama_types,
769                 default='FISHEYE_EQUISOLID',
770                 )
771         cls.fisheye_fov = FloatProperty(
772                 name="Field of View",
773                 description="Field of view for the fisheye lens",
774                 min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi,
775                 subtype='ANGLE',
776                 default=math.pi,
777                 )
778         cls.fisheye_lens = FloatProperty(
779                 name="Fisheye Lens",
780                 description="Lens focal length (mm)",
781                 min=0.01, soft_max=15.0, max=100.0,
782                 default=10.5,
783                 )
784         cls.latitude_min = FloatProperty(
785                 name="Min Latitude",
786                 description="Minimum latitude (vertical angle) for the equirectangular lens",
787                 min=-0.5 * math.pi, max=0.5 * math.pi,
788                 subtype='ANGLE',
789                 default=-0.5 * math.pi,
790                 )
791         cls.latitude_max = FloatProperty(
792                 name="Max Latitude",
793                 description="Maximum latitude (vertical angle) for the equirectangular lens",
794                 min=-0.5 * math.pi, max=0.5 * math.pi,
795                 subtype='ANGLE',
796                 default=0.5 * math.pi,
797                 )
798         cls.longitude_min = FloatProperty(
799                 name="Min Longitude",
800                 description="Minimum longitude (horizontal angle) for the equirectangular lens",
801                 min=-math.pi, max=math.pi,
802                 subtype='ANGLE',
803                 default=-math.pi,
804                 )
805         cls.longitude_max = FloatProperty(
806                 name="Max Longitude",
807                 description="Maximum longitude (horizontal angle) for the equirectangular lens",
808                 min=-math.pi, max=math.pi,
809                 subtype='ANGLE',
810                 default=math.pi,
811                 )
812
813     @classmethod
814     def unregister(cls):
815         del bpy.types.Camera.cycles
816
817
818 class CyclesMaterialSettings(bpy.types.PropertyGroup):
819     @classmethod
820     def register(cls):
821         bpy.types.Material.cycles = PointerProperty(
822                 name="Cycles Material Settings",
823                 description="Cycles material settings",
824                 type=cls,
825                 )
826         cls.sample_as_light = BoolProperty(
827                 name="Multiple Importance Sample",
828                 description="Use multiple importance sampling for this material, "
829                             "disabling may reduce overall noise for large "
830                             "objects that emit little light compared to other light sources",
831                 default=True,
832                 )
833         cls.use_transparent_shadow = BoolProperty(
834                 name="Transparent Shadows",
835                 description="Use transparent shadows for this material if it contains a Transparent BSDF, "
836                             "disabling will render faster but not give accurate shadows",
837                 default=True,
838                 )
839         cls.homogeneous_volume = BoolProperty(
840                 name="Homogeneous Volume",
841                 description="When using volume rendering, assume volume has the same density everywhere "
842                             "(not using any textures), for faster rendering",
843                 default=False,
844                 )
845         cls.volume_sampling = EnumProperty(
846                 name="Volume Sampling",
847                 description="Sampling method to use for volumes",
848                 items=enum_volume_sampling,
849                 default='MULTIPLE_IMPORTANCE',
850                 )
851
852         cls.volume_interpolation = EnumProperty(
853                 name="Volume Interpolation",
854                 description="Interpolation method to use for smoke/fire volumes",
855                 items=enum_volume_interpolation,
856                 default='LINEAR',
857                 )
858
859         cls.displacement_method = EnumProperty(
860                 name="Displacement Method",
861                 description="Method to use for the displacement",
862                 items=enum_displacement_methods,
863                 default='BUMP',
864                 )
865
866     @classmethod
867     def unregister(cls):
868         del bpy.types.Material.cycles
869
870
871 class CyclesLampSettings(bpy.types.PropertyGroup):
872     @classmethod
873     def register(cls):
874         bpy.types.Lamp.cycles = PointerProperty(
875                 name="Cycles Lamp Settings",
876                 description="Cycles lamp settings",
877                 type=cls,
878                 )
879         cls.cast_shadow = BoolProperty(
880                 name="Cast Shadow",
881                 description="Lamp casts shadows",
882                 default=True,
883                 )
884         cls.samples = IntProperty(
885                 name="Samples",
886                 description="Number of light samples to render for each AA sample",
887                 min=1, max=10000,
888                 default=1,
889                 )
890         cls.max_bounces = IntProperty(
891                 name="Max Bounces",
892                 description="Maximum number of bounces the light will contribute to the render",
893                 min=0, max=1024,
894                 default=1024,
895                 )
896         cls.use_multiple_importance_sampling = BoolProperty(
897                 name="Multiple Importance Sample",
898                 description="Use multiple importance sampling for the lamp, "
899                             "reduces noise for area lamps and sharp glossy materials",
900                 default=True,
901                 )
902         cls.is_portal = BoolProperty(
903                 name="Is Portal",
904                 description="Use this area lamp to guide sampling of the background, "
905                             "note that this will make the lamp invisible",
906                 default=False,
907                 )
908
909     @classmethod
910     def unregister(cls):
911         del bpy.types.Lamp.cycles
912
913
914 class CyclesWorldSettings(bpy.types.PropertyGroup):
915     @classmethod
916     def register(cls):
917         bpy.types.World.cycles = PointerProperty(
918                 name="Cycles World Settings",
919                 description="Cycles world settings",
920                 type=cls,
921                 )
922         cls.sample_as_light = BoolProperty(
923                 name="Multiple Importance Sample",
924                 description="Use multiple importance sampling for the environment, "
925                             "enabling for non-solid colors is recommended",
926                 default=True,
927                 )
928         cls.sample_map_resolution = IntProperty(
929                 name="Map Resolution",
930                 description="Importance map size is resolution x resolution; "
931                             "higher values potentially produce less noise, at the cost of memory and speed",
932                 min=4, max=8192,
933                 default=1024,
934                 )
935         cls.samples = IntProperty(
936                 name="Samples",
937                 description="Number of light samples to render for each AA sample",
938                 min=1, max=10000,
939                 default=1,
940                 )
941         cls.max_bounces = IntProperty(
942                 name="Max Bounces",
943                 description="Maximum number of bounces the background light will contribute to the render",
944                 min=0, max=1024,
945                 default=1024,
946                 )
947         cls.homogeneous_volume = BoolProperty(
948                 name="Homogeneous Volume",
949                 description="When using volume rendering, assume volume has the same density everywhere"
950                             "(not using any textures), for faster rendering",
951                 default=False,
952                 )
953         cls.volume_sampling = EnumProperty(
954                 name="Volume Sampling",
955                 description="Sampling method to use for volumes",
956                 items=enum_volume_sampling,
957                 default='EQUIANGULAR',
958                 )
959
960         cls.volume_interpolation = EnumProperty(
961                 name="Volume Interpolation",
962                 description="Interpolation method to use for volumes",
963                 items=enum_volume_interpolation,
964                 default='LINEAR',
965                 )
966
967     @classmethod
968     def unregister(cls):
969         del bpy.types.World.cycles
970
971
972 class CyclesVisibilitySettings(bpy.types.PropertyGroup):
973     @classmethod
974     def register(cls):
975         bpy.types.Object.cycles_visibility = PointerProperty(
976                 name="Cycles Visibility Settings",
977                 description="Cycles visibility settings",
978                 type=cls,
979                 )
980
981         bpy.types.World.cycles_visibility = PointerProperty(
982                 name="Cycles Visibility Settings",
983                 description="Cycles visibility settings",
984                 type=cls,
985                 )
986
987         cls.camera = BoolProperty(
988                 name="Camera",
989                 description="Object visibility for camera rays",
990                 default=True,
991                 )
992         cls.diffuse = BoolProperty(
993                 name="Diffuse",
994                 description="Object visibility for diffuse reflection rays",
995                 default=True,
996                 )
997         cls.glossy = BoolProperty(
998                 name="Glossy",
999                 description="Object visibility for glossy reflection rays",
1000                 default=True,
1001                 )
1002         cls.transmission = BoolProperty(
1003                 name="Transmission",
1004                 description="Object visibility for transmission rays",
1005                 default=True,
1006                 )
1007         cls.shadow = BoolProperty(
1008                 name="Shadow",
1009                 description="Object visibility for shadow rays",
1010                 default=True,
1011                 )
1012         cls.scatter = BoolProperty(
1013                 name="Volume Scatter",
1014                 description="Object visibility for volume scatter rays",
1015                 default=True,
1016                 )
1017
1018     @classmethod
1019     def unregister(cls):
1020         del bpy.types.Object.cycles_visibility
1021         del bpy.types.World.cycles_visibility
1022
1023
1024 class CyclesMeshSettings(bpy.types.PropertyGroup):
1025     @classmethod
1026     def register(cls):
1027         bpy.types.Mesh.cycles = PointerProperty(
1028                 name="Cycles Mesh Settings",
1029                 description="Cycles mesh settings",
1030                 type=cls,
1031                 )
1032         bpy.types.Curve.cycles = PointerProperty(
1033                 name="Cycles Mesh Settings",
1034                 description="Cycles mesh settings",
1035                 type=cls,
1036                 )
1037         bpy.types.MetaBall.cycles = PointerProperty(
1038                 name="Cycles Mesh Settings",
1039                 description="Cycles mesh settings",
1040                 type=cls,
1041                 )
1042
1043     @classmethod
1044     def unregister(cls):
1045         del bpy.types.Mesh.cycles
1046         del bpy.types.Curve.cycles
1047         del bpy.types.MetaBall.cycles
1048
1049
1050 class CyclesObjectSettings(bpy.types.PropertyGroup):
1051     @classmethod
1052     def register(cls):
1053         bpy.types.Object.cycles = PointerProperty(
1054                 name="Cycles Object Settings",
1055                 description="Cycles object settings",
1056                 type=cls,
1057                 )
1058
1059         cls.use_motion_blur = BoolProperty(
1060                 name="Use Motion Blur",
1061                 description="Use motion blur for this object",
1062                 default=True,
1063                 )
1064
1065         cls.use_deform_motion = BoolProperty(
1066                 name="Use Deformation Motion",
1067                 description="Use deformation motion blur for this object",
1068                 default=True,
1069                 )
1070
1071         cls.motion_steps = IntProperty(
1072                 name="Motion Steps",
1073                 description="Control accuracy of deformation motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
1074                 min=1, soft_max=8,
1075                 default=1,
1076                 )
1077
1078         cls.use_camera_cull = BoolProperty(
1079                 name="Use Camera Cull",
1080                 description="Allow this object and its duplicators to be culled by camera space culling",
1081                 default=False,
1082                 )
1083
1084         cls.use_distance_cull = BoolProperty(
1085                 name="Use Distance Cull",
1086                 description="Allow this object and its duplicators to be culled by distance from camera",
1087                 default=False,
1088                 )
1089
1090         cls.use_adaptive_subdivision = BoolProperty(
1091                 name="Use Adaptive Subdivision",
1092                 description="Use adaptive render time subdivision",
1093                 default=False,
1094                 )
1095
1096         cls.dicing_rate = FloatProperty(
1097                 name="Dicing Scale",
1098                 description="Multiplier for scene dicing rate (located in the Geometry Panel)",
1099                 min=0.1, max=1000.0, soft_min=0.5,
1100                 default=1.0,
1101                 )
1102
1103         cls.is_shadow_catcher = BoolProperty(
1104                 name="Shadow Catcher",
1105                 description="Only render shadows on this object, for compositing renders into real footage",
1106                 default=False,
1107                 )
1108
1109     @classmethod
1110     def unregister(cls):
1111         del bpy.types.Object.cycles
1112
1113
1114 class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
1115     @classmethod
1116     def register(cls):
1117         bpy.types.Scene.cycles_curves = PointerProperty(
1118                 name="Cycles Hair Rendering Settings",
1119                 description="Cycles hair rendering settings",
1120                 type=cls,
1121                 )
1122         cls.primitive = EnumProperty(
1123                 name="Primitive",
1124                 description="Type of primitive used for hair rendering",
1125                 items=enum_curve_primitives,
1126                 default='LINE_SEGMENTS',
1127                 )
1128         cls.shape = EnumProperty(
1129                 name="Shape",
1130                 description="Form of hair",
1131                 items=enum_curve_shape,
1132                 default='THICK',
1133                 )
1134         cls.cull_backfacing = BoolProperty(
1135                 name="Cull back-faces",
1136                 description="Do not test the back-face of each strand",
1137                 default=True,
1138                 )
1139         cls.use_curves = BoolProperty(
1140                 name="Use Cycles Hair Rendering",
1141                 description="Activate Cycles hair rendering for particle system",
1142                 default=True,
1143                 )
1144         cls.resolution = IntProperty(
1145                 name="Resolution",
1146                 description="Resolution of generated mesh",
1147                 min=3, max=64,
1148                 default=3,
1149                 )
1150         cls.minimum_width = FloatProperty(
1151                 name="Minimal width",
1152                 description="Minimal pixel width for strands (0 - deactivated)",
1153                 min=0.0, max=100.0,
1154                 default=0.0,
1155                 )
1156         cls.maximum_width = FloatProperty(
1157                 name="Maximal width",
1158                 description="Maximum extension that strand radius can be increased by",
1159                 min=0.0, max=100.0,
1160                 default=0.1,
1161                 )
1162         cls.subdivisions = IntProperty(
1163                 name="Subdivisions",
1164                 description="Number of subdivisions used in Cardinal curve intersection (power of 2)",
1165                 min=0, max=24,
1166                 default=4,
1167                 )
1168
1169     @classmethod
1170     def unregister(cls):
1171         del bpy.types.Scene.cycles_curves
1172
1173 def update_render_passes(self, context):
1174     scene = context.scene
1175     rd = scene.render
1176     rl = rd.layers.active
1177     rl.update_render_passes()
1178
1179 class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
1180     @classmethod
1181     def register(cls):
1182         bpy.types.SceneRenderLayer.cycles = PointerProperty(
1183                 name="Cycles SceneRenderLayer Settings",
1184                 description="Cycles SceneRenderLayer Settings",
1185                 type=cls,
1186                 )
1187         cls.pass_debug_bvh_traversed_nodes = BoolProperty(
1188                 name="Debug BVH Traversed Nodes",
1189                 description="Store Debug BVH Traversed Nodes pass",
1190                 default=False,
1191                 update=update_render_passes,
1192                 )
1193         cls.pass_debug_bvh_traversed_instances = BoolProperty(
1194                 name="Debug BVH Traversed Instances",
1195                 description="Store Debug BVH Traversed Instances pass",
1196                 default=False,
1197                 update=update_render_passes,
1198                 )
1199         cls.pass_debug_bvh_intersections = BoolProperty(
1200                 name="Debug BVH Intersections",
1201                 description="Store Debug BVH Intersections",
1202                 default=False,
1203                 update=update_render_passes,
1204                 )
1205         cls.pass_debug_ray_bounces = BoolProperty(
1206                 name="Debug Ray Bounces",
1207                 description="Store Debug Ray Bounces pass",
1208                 default=False,
1209                 update=update_render_passes,
1210                 )
1211
1212         cls.use_denoising = BoolProperty(
1213                 name="Use Denoising",
1214                 description="Denoise the rendered image",
1215                 default=False,
1216                 update=update_render_passes,
1217                 )
1218         cls.denoising_diffuse_direct = BoolProperty(
1219                 name="Diffuse Direct",
1220                 description="Denoise the direct diffuse lighting",
1221                 default=True,
1222                 )
1223         cls.denoising_diffuse_indirect = BoolProperty(
1224                 name="Diffuse Indirect",
1225                 description="Denoise the indirect diffuse lighting",
1226                 default=True,
1227                 )
1228         cls.denoising_glossy_direct = BoolProperty(
1229                 name="Glossy Direct",
1230                 description="Denoise the direct glossy lighting",
1231                 default=True,
1232                 )
1233         cls.denoising_glossy_indirect = BoolProperty(
1234                 name="Glossy Indirect",
1235                 description="Denoise the indirect glossy lighting",
1236                 default=True,
1237                 )
1238         cls.denoising_transmission_direct = BoolProperty(
1239                 name="Transmission Direct",
1240                 description="Denoise the direct transmission lighting",
1241                 default=True,
1242                 )
1243         cls.denoising_transmission_indirect = BoolProperty(
1244                 name="Transmission Indirect",
1245                 description="Denoise the indirect transmission lighting",
1246                 default=True,
1247                 )
1248         cls.denoising_subsurface_direct = BoolProperty(
1249                 name="Subsurface Direct",
1250                 description="Denoise the direct subsurface lighting",
1251                 default=True,
1252                 )
1253         cls.denoising_subsurface_indirect = BoolProperty(
1254                 name="Subsurface Indirect",
1255                 description="Denoise the indirect subsurface lighting",
1256                 default=True,
1257                 )
1258         cls.denoising_strength = FloatProperty(
1259                 name="Denoising Strength",
1260                 description="Controls neighbor pixel weighting for the denoising filter (lower values preserve more detail, but aren't as smooth)",
1261                 min=0.0, max=1.0,
1262                 default=0.5,
1263                 )
1264         cls.denoising_feature_strength = FloatProperty(
1265                 name="Denoising Feature Strength",
1266                 description="Controls removal of noisy image feature passes (lower values preserve more detail, but aren't as smooth)",
1267                 min=0.0, max=1.0,
1268                 default=0.5,
1269                 )
1270         cls.denoising_radius = IntProperty(
1271                 name="Denoising Radius",
1272                 description="Size of the image area that's used to denoise a pixel (higher values are smoother, but might lose detail and are slower)",
1273                 min=1, max=25,
1274                 default=8,
1275         )
1276         cls.denoising_relative_pca = BoolProperty(
1277                 name="Relative filter",
1278                 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)",
1279                 default=False,
1280         )
1281         cls.denoising_store_passes = BoolProperty(
1282                 name="Store denoising passes",
1283                 description="Store the denoising feature passes and the noisy image",
1284                 default=False,
1285                 update=update_render_passes,
1286         )
1287
1288     @classmethod
1289     def unregister(cls):
1290         del bpy.types.SceneRenderLayer.cycles
1291
1292
1293 class CyclesCurveSettings(bpy.types.PropertyGroup):
1294     @classmethod
1295     def register(cls):
1296         bpy.types.ParticleSettings.cycles = PointerProperty(
1297                 name="Cycles Hair Settings",
1298                 description="Cycles hair settings",
1299                 type=cls,
1300                 )
1301         cls.radius_scale = FloatProperty(
1302                 name="Radius Scaling",
1303                 description="Multiplier of width properties",
1304                 min=0.0, max=1000.0,
1305                 default=0.01,
1306                 )
1307         cls.root_width = FloatProperty(
1308                 name="Root Size",
1309                 description="Strand's width at root",
1310                 min=0.0, max=1000.0,
1311                 default=1.0,
1312                 )
1313         cls.tip_width = FloatProperty(
1314                 name="Tip Multiplier",
1315                 description="Strand's width at tip",
1316                 min=0.0, max=1000.0,
1317                 default=0.0,
1318                 )
1319         cls.shape = FloatProperty(
1320                 name="Strand Shape",
1321                 description="Strand shape parameter",
1322                 min=-1.0, max=1.0,
1323                 default=0.0,
1324                 )
1325         cls.use_closetip = BoolProperty(
1326                 name="Close tip",
1327                 description="Set tip radius to zero",
1328                 default=True,
1329                 )
1330
1331     @classmethod
1332     def unregister(cls):
1333         del bpy.types.ParticleSettings.cycles
1334
1335
1336 class CyclesDeviceSettings(bpy.types.PropertyGroup):
1337     @classmethod
1338     def register(cls):
1339         cls.id = StringProperty(name="ID")
1340         cls.name = StringProperty(name="Name")
1341         cls.use = BoolProperty(name="Use", default=True)
1342         cls.type = EnumProperty(name="Type", items=enum_device_type, default='CUDA')
1343
1344
1345 class CyclesPreferences(bpy.types.AddonPreferences):
1346     bl_idname = __package__
1347
1348     def get_device_types(self, context):
1349         import _cycles
1350         has_cuda, has_opencl = _cycles.get_device_types()
1351         list = [('NONE', "None", "Don't use compute device", 0)]
1352         if has_cuda:
1353             list.append(('CUDA', "CUDA", "Use CUDA for GPU acceleration", 1))
1354         if has_opencl:
1355             list.append(('OPENCL', "OpenCL", "Use OpenCL for GPU acceleration", 2))
1356         return list
1357
1358     compute_device_type = EnumProperty(
1359             name="Compute Device Type",
1360             description="Device to use for computation (rendering with Cycles)",
1361             items=get_device_types,
1362             )
1363
1364     devices = bpy.props.CollectionProperty(type=CyclesDeviceSettings)
1365
1366     def get_devices(self):
1367         import _cycles
1368         # Layout of the device tuples: (Name, Type, Persistent ID)
1369         device_list = _cycles.available_devices()
1370
1371         cuda_devices = []
1372         opencl_devices = []
1373         for device in device_list:
1374             if not device[1] in {'CUDA', 'OPENCL'}:
1375                 continue
1376
1377             entry = None
1378             # Try to find existing Device entry
1379             for dev in self.devices:
1380                 if dev.id == device[2] and dev.type == device[1]:
1381                     entry = dev
1382                     break
1383             # Create new entry if no existing one was found
1384             if not entry:
1385                 entry = self.devices.add()
1386                 entry.id   = device[2]
1387                 entry.name = device[0]
1388                 entry.type = device[1]
1389
1390             # Sort entries into lists
1391             if entry.type == 'CUDA':
1392                 cuda_devices.append(entry)
1393             elif entry.type == 'OPENCL':
1394                 opencl_devices.append(entry)
1395         return cuda_devices, opencl_devices
1396
1397
1398     def get_num_gpu_devices(self):
1399         import _cycles
1400         device_list = _cycles.available_devices()
1401         num = 0
1402         for device in device_list:
1403             if device[1] != self.compute_device_type:
1404                 continue
1405             for dev in self.devices:
1406                 if dev.use and dev.id == device[2]:
1407                     num += 1
1408         return num
1409
1410
1411     def has_active_device(self):
1412         return self.get_num_gpu_devices() > 0
1413
1414
1415     def draw_impl(self, layout, context):
1416         layout.label(text="Cycles Compute Device:")
1417         layout.row().prop(self, "compute_device_type", expand=True)
1418
1419         cuda_devices, opencl_devices = self.get_devices()
1420         row = layout.row()
1421
1422         if self.compute_device_type == 'CUDA' and cuda_devices:
1423             box = row.box()
1424             for device in cuda_devices:
1425                 box.prop(device, "use", text=device.name)
1426
1427         if self.compute_device_type == 'OPENCL' and opencl_devices:
1428             box = row.box()
1429             for device in opencl_devices:
1430                 box.prop(device, "use", text=device.name)
1431
1432
1433     def draw(self, context):
1434         self.draw_impl(self.layout, context)
1435
1436
1437 def register():
1438     bpy.utils.register_class(CyclesRenderSettings)
1439     bpy.utils.register_class(CyclesCameraSettings)
1440     bpy.utils.register_class(CyclesMaterialSettings)
1441     bpy.utils.register_class(CyclesLampSettings)
1442     bpy.utils.register_class(CyclesWorldSettings)
1443     bpy.utils.register_class(CyclesVisibilitySettings)
1444     bpy.utils.register_class(CyclesMeshSettings)
1445     bpy.utils.register_class(CyclesObjectSettings)
1446     bpy.utils.register_class(CyclesCurveRenderSettings)
1447     bpy.utils.register_class(CyclesCurveSettings)
1448     bpy.utils.register_class(CyclesDeviceSettings)
1449     bpy.utils.register_class(CyclesPreferences)
1450     bpy.utils.register_class(CyclesRenderLayerSettings)
1451
1452
1453 def unregister():
1454     bpy.utils.unregister_class(CyclesRenderSettings)
1455     bpy.utils.unregister_class(CyclesCameraSettings)
1456     bpy.utils.unregister_class(CyclesMaterialSettings)
1457     bpy.utils.unregister_class(CyclesLampSettings)
1458     bpy.utils.unregister_class(CyclesWorldSettings)
1459     bpy.utils.unregister_class(CyclesMeshSettings)
1460     bpy.utils.unregister_class(CyclesObjectSettings)
1461     bpy.utils.unregister_class(CyclesVisibilitySettings)
1462     bpy.utils.unregister_class(CyclesCurveRenderSettings)
1463     bpy.utils.unregister_class(CyclesCurveSettings)
1464     bpy.utils.unregister_class(CyclesDeviceSettings)
1465     bpy.utils.unregister_class(CyclesPreferences)
1466     bpy.utils.unregister_class(CyclesRenderLayerSettings)