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