Gawain: manage batch API's current shader program + uniform funcs
[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
26 # enums
27
28 import _cycles
29
30 enum_devices = (
31     ('CPU', "CPU", "Use CPU for rendering"),
32     ('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in user preferences"),
33     )
34
35 if _cycles.with_network:
36     enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),)
37
38 enum_feature_set = (
39     ('SUPPORTED', "Supported", "Only use finished and supported features"),
40     ('EXPERIMENTAL', "Experimental", "Use experimental and incomplete features that might be broken or change in the future", 'ERROR', 1),
41     )
42
43 enum_displacement_methods = (
44     ('BUMP', "Bump", "Bump mapping to simulate the appearance of displacement"),
45     ('TRUE', "True", "Use true displacement only, requires fine subdivision"),
46     ('BOTH', "Both", "Combination of displacement and bump mapping"),
47     )
48
49 enum_bvh_types = (
50     ('DYNAMIC_BVH', "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"),
51     ('STATIC_BVH', "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster"),
52     )
53
54 enum_filter_types = (
55     ('BOX', "Box", "Box filter"),
56     ('GAUSSIAN', "Gaussian", "Gaussian filter"),
57     ('BLACKMAN_HARRIS', "Blackman-Harris", "Blackman-Harris filter"),
58     )
59
60 enum_aperture_types = (
61     ('RADIUS', "Radius", "Directly change the size of the aperture"),
62     ('FSTOP', "F-stop", "Change the size of the aperture by f-stop"),
63     )
64
65 enum_panorama_types = (
66     ('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"),
67     ('FISHEYE_EQUIDISTANT', "Fisheye Equidistant", "Ideal for fulldomes, ignore the sensor dimensions"),
68     ('FISHEYE_EQUISOLID', "Fisheye Equisolid",
69                           "Similar to most fisheye modern lens, takes sensor dimensions into consideration"),
70     ('MIRRORBALL', "Mirror Ball", "Uses the mirror ball mapping"),
71     )
72
73 enum_curve_primitives = (
74     ('TRIANGLES', "Triangles", "Create triangle geometry around strands"),
75     ('LINE_SEGMENTS', "Line Segments", "Use line segment primitives"),
76     ('CURVE_SEGMENTS', "Curve Segments", "Use segmented cardinal curve primitives"),
77     )
78
79 enum_triangle_curves = (
80     ('CAMERA_TRIANGLES', "Planes", "Create individual triangles forming planes that face camera"),
81     ('TESSELLATED_TRIANGLES', "Tessellated", "Create mesh surrounding each strand"),
82     )
83
84 enum_curve_shape = (
85     ('RIBBONS', "Ribbons", "Ignore thickness of each strand"),
86     ('THICK', "Thick", "Use thickness of strand when rendering"),
87     )
88
89 enum_tile_order = (
90     ('CENTER', "Center", "Render from center to the edges"),
91     ('RIGHT_TO_LEFT', "Right to Left", "Render from right to left"),
92     ('LEFT_TO_RIGHT', "Left to Right", "Render from left to right"),
93     ('TOP_TO_BOTTOM', "Top to Bottom", "Render from top to bottom"),
94     ('BOTTOM_TO_TOP', "Bottom to Top", "Render from bottom to top"),
95     ('HILBERT_SPIRAL', "Hilbert Spiral", "Render in a Hilbert Spiral"),
96     )
97
98 enum_use_layer_samples = (
99     ('USE', "Use", "Per render layer number of samples override scene samples"),
100     ('BOUNDED', "Bounded", "Bound per render layer number of samples by global samples"),
101     ('IGNORE', "Ignore", "Ignore per render layer number of samples"),
102     )
103
104 enum_sampling_pattern = (
105     ('SOBOL', "Sobol", "Use Sobol random sampling pattern"),
106     ('CORRELATED_MUTI_JITTER', "Correlated Multi-Jitter", "Use Correlated Multi-Jitter random sampling pattern"),
107     )
108
109 enum_integrator = (
110     ('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"),
111     ('PATH', "Path Tracing", "Pure path tracing integrator"),
112     )
113
114 enum_volume_sampling = (
115     ('DISTANCE', "Distance", "Use distance sampling, best for dense volumes with lights far away"),
116     ('EQUIANGULAR', "Equiangular", "Use equiangular sampling, best for volumes with low density with light inside or near the volume"),
117     ('MULTIPLE_IMPORTANCE', "Multiple Importance", "Combine distance and equi-angular sampling for volumes where neither method is ideal"),
118     )
119
120 enum_volume_interpolation = (
121     ('LINEAR', "Linear", "Good smoothness and speed"),
122     ('CUBIC', "Cubic", "Smoothed high quality interpolation, but slower")
123     )
124
125
126 class CyclesRenderSettings(bpy.types.PropertyGroup):
127     @classmethod
128     def register(cls):
129         bpy.types.Scene.cycles = PointerProperty(
130                 name="Cycles Render Settings",
131                 description="Cycles render settings",
132                 type=cls,
133                 )
134         cls.device = EnumProperty(
135                 name="Device",
136                 description="Device to use for rendering",
137                 items=enum_devices,
138                 default='CPU',
139                 )
140         cls.feature_set = EnumProperty(
141                 name="Feature Set",
142                 description="Feature set to use for rendering",
143                 items=enum_feature_set,
144                 default='SUPPORTED',
145                 )
146         cls.shading_system = BoolProperty(
147                 name="Open Shading Language",
148                 description="Use Open Shading Language (CPU rendering only)",
149                 )
150
151         cls.progressive = EnumProperty(
152                 name="Integrator",
153                 description="Method to sample lights and materials",
154                 items=enum_integrator,
155                 default='PATH',
156                 )
157
158         cls.use_square_samples = BoolProperty(
159                 name="Square Samples",
160                 description="Square sampling values for easier artist control",
161                 default=False,
162                 )
163
164         cls.samples = IntProperty(
165                 name="Samples",
166                 description="Number of samples to render for each pixel",
167                 min=1, max=2147483647,
168                 default=128,
169                 )
170         cls.preview_samples = IntProperty(
171                 name="Preview Samples",
172                 description="Number of samples to render in the viewport, unlimited if 0",
173                 min=0, max=2147483647,
174                 default=32,
175                 )
176         cls.preview_pause = BoolProperty(
177                 name="Pause Preview",
178                 description="Pause all viewport preview renders",
179                 default=False,
180                 )
181         cls.preview_active_layer = BoolProperty(
182                 name="Preview Active Layer",
183                 description="Preview active render layer in viewport",
184                 default=False,
185                 )
186
187         cls.aa_samples = IntProperty(
188                 name="AA Samples",
189                 description="Number of antialiasing samples to render for each pixel",
190                 min=1, max=2097151,
191                 default=4,
192                 )
193         cls.preview_aa_samples = IntProperty(
194                 name="AA Samples",
195                 description="Number of antialiasing samples to render in the viewport, unlimited if 0",
196                 min=0, max=2097151,
197                 default=4,
198                 )
199         cls.diffuse_samples = IntProperty(
200                 name="Diffuse Samples",
201                 description="Number of diffuse bounce samples to render for each AA sample",
202                 min=1, max=1024,
203                 default=1,
204                 )
205         cls.glossy_samples = IntProperty(
206                 name="Glossy Samples",
207                 description="Number of glossy bounce samples to render for each AA sample",
208                 min=1, max=1024,
209                 default=1,
210                 )
211         cls.transmission_samples = IntProperty(
212                 name="Transmission Samples",
213                 description="Number of transmission bounce samples to render for each AA sample",
214                 min=1, max=1024,
215                 default=1,
216                 )
217         cls.ao_samples = IntProperty(
218                 name="Ambient Occlusion Samples",
219                 description="Number of ambient occlusion samples to render for each AA sample",
220                 min=1, max=1024,
221                 default=1,
222                 )
223         cls.mesh_light_samples = IntProperty(
224                 name="Mesh Light Samples",
225                 description="Number of mesh emission light samples to render for each AA sample",
226                 min=1, max=1024,
227                 default=1,
228                 )
229
230         cls.subsurface_samples = IntProperty(
231                 name="Subsurface Samples",
232                 description="Number of subsurface scattering samples to render for each AA sample",
233                 min=1, max=1024,
234                 default=1,
235                 )
236
237         cls.volume_samples = IntProperty(
238                 name="Volume Samples",
239                 description="Number of volume scattering samples to render for each AA sample",
240                 min=1, max=1024,
241                 default=1,
242                 )
243
244         cls.sampling_pattern = EnumProperty(
245                 name="Sampling Pattern",
246                 description="Random sampling pattern used by the integrator",
247                 items=enum_sampling_pattern,
248                 default='SOBOL',
249                 )
250
251         cls.use_layer_samples = EnumProperty(
252                 name="Layer Samples",
253                 description="How to use per render layer sample settings",
254                 items=enum_use_layer_samples,
255                 default='USE',
256                 )
257
258         cls.sample_all_lights_direct = BoolProperty(
259                 name="Sample All Direct Lights",
260                 description="Sample all lights (for direct samples), rather than randomly picking one",
261                 default=True,
262                 )
263
264         cls.sample_all_lights_indirect = BoolProperty(
265                 name="Sample All Indirect Lights",
266                 description="Sample all lights (for indirect samples), rather than randomly picking one",
267                 default=True,
268                 )
269         cls.light_sampling_threshold = FloatProperty(
270                 name="Light Sampling Threshold",
271                 description="Probabilistically terminate light samples when the light contribution is below this threshold (more noise but faster rendering). "
272                             "Zero disables the test and never ignores lights",
273                 min=0.0, max=1.0,
274                 default=0.05,
275                 )
276
277         cls.caustics_reflective = BoolProperty(
278                 name="Reflective Caustics",
279                 description="Use reflective caustics, resulting in a brighter image (more noise but added realism)",
280                 default=True,
281                 )
282
283         cls.caustics_refractive = BoolProperty(
284                 name="Refractive Caustics",
285                 description="Use refractive caustics, resulting in a brighter image (more noise but added realism)",
286                 default=True,
287                 )
288
289         cls.blur_glossy = FloatProperty(
290                 name="Filter Glossy",
291                 description="Adaptively blur glossy shaders after blurry bounces, "
292                             "to reduce noise at the cost of accuracy",
293                 min=0.0, max=10.0,
294                 default=0.0,
295                 )
296
297         cls.min_bounces = IntProperty(
298                 name="Min Bounces",
299                 description="Minimum number of bounces, setting this lower "
300                             "than the maximum enables probabilistic path "
301                             "termination (faster but noisier)",
302                 min=0, max=1024,
303                 default=3,
304                 )
305         cls.max_bounces = IntProperty(
306                 name="Max Bounces",
307                 description="Total maximum number of bounces",
308                 min=0, max=1024,
309                 default=12,
310                 )
311
312         cls.diffuse_bounces = IntProperty(
313                 name="Diffuse Bounces",
314                 description="Maximum number of diffuse reflection bounces, bounded by total maximum",
315                 min=0, max=1024,
316                 default=4,
317                 )
318         cls.glossy_bounces = IntProperty(
319                 name="Glossy Bounces",
320                 description="Maximum number of glossy reflection bounces, bounded by total maximum",
321                 min=0, max=1024,
322                 default=4,
323                 )
324         cls.transmission_bounces = IntProperty(
325                 name="Transmission Bounces",
326                 description="Maximum number of transmission bounces, bounded by total maximum",
327                 min=0, max=1024,
328                 default=12,
329                 )
330         cls.volume_bounces = IntProperty(
331                 name="Volume Bounces",
332                 description="Maximum number of volumetric scattering events",
333                 min=0, max=1024,
334                 default=0,
335                 )
336
337         cls.transparent_min_bounces = IntProperty(
338                 name="Transparent Min Bounces",
339                 description="Minimum number of transparent bounces, setting "
340                             "this lower than the maximum enables "
341                             "probabilistic path termination (faster but "
342                             "noisier)",
343                 min=0, max=1024,
344                 default=8,
345                 )
346         cls.transparent_max_bounces = IntProperty(
347                 name="Transparent Max Bounces",
348                 description="Maximum number of transparent bounces",
349                 min=0, max=1024,
350                 default=8,
351                 )
352         cls.use_transparent_shadows = BoolProperty(
353                 name="Transparent Shadows",
354                 description="Use transparency of surfaces for rendering shadows",
355                 default=True,
356                 )
357
358         cls.volume_step_size = FloatProperty(
359                 name="Step Size",
360                 description="Distance between volume shader samples when rendering the volume "
361                             "(lower values give more accurate and detailed results, but also increased render time)",
362                 default=0.1,
363                 min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0, precision=4
364                 )
365
366         cls.volume_max_steps = IntProperty(
367                 name="Max Steps",
368                 description="Maximum number of steps through the volume before giving up, "
369                             "to avoid extremely long render times with big objects or small step sizes",
370                 default=1024,
371                 min=2, max=65536
372                 )
373
374         cls.dicing_rate = FloatProperty(
375                 name="Dicing Rate",
376                 description="Size of a micropolygon in pixels",
377                 min=0.1, max=1000.0, soft_min=0.5,
378                 default=1.0,
379                 subtype="PIXEL"
380                 )
381         cls.preview_dicing_rate = FloatProperty(
382                 name="Preview Dicing Rate",
383                 description="Size of a micropolygon in pixels during preview render",
384                 min=0.1, max=1000.0, soft_min=0.5,
385                 default=8.0,
386                 subtype="PIXEL"
387                 )
388
389         cls.max_subdivisions = IntProperty(
390                 name="Max Subdivisions",
391                 description="Stop subdividing when this level is reached even if the dice rate would produce finer tessellation",
392                 min=0, max=16,
393                 default=12,
394                 )
395
396         cls.film_exposure = FloatProperty(
397                 name="Exposure",
398                 description="Image brightness scale",
399                 min=0.0, max=10.0,
400                 default=1.0,
401                 )
402         cls.film_transparent = BoolProperty(
403                 name="Transparent",
404                 description="World background is transparent with premultiplied alpha",
405                 default=False,
406                 )
407
408         # Really annoyingly, we have to keep it around for a few releases,
409         # otherwise forward compatibility breaks in really bad manner: CRASH!
410         #
411         # TODO(sergey): Remove this during 2.8x series of Blender.
412         cls.filter_type = EnumProperty(
413                 name="Filter Type",
414                 description="Pixel filter type",
415                 items=enum_filter_types,
416                 default='BLACKMAN_HARRIS',
417                 )
418
419         cls.pixel_filter_type = EnumProperty(
420                 name="Filter Type",
421                 description="Pixel filter type",
422                 items=enum_filter_types,
423                 default='BLACKMAN_HARRIS',
424                 )
425
426         cls.filter_width = FloatProperty(
427                 name="Filter Width",
428                 description="Pixel filter width",
429                 min=0.01, max=10.0,
430                 default=1.5,
431                 )
432
433         cls.seed = IntProperty(
434                 name="Seed",
435                 description="Seed value for integrator to get different noise patterns",
436                 min=0, max=2147483647,
437                 default=0,
438                 )
439
440         cls.use_animated_seed = BoolProperty(
441                 name="Use Animated Seed",
442                 description="Use different seed values (and hence noise patterns) at different frames",
443                 default=False,
444                 )
445
446         cls.sample_clamp_direct = FloatProperty(
447                 name="Clamp Direct",
448                 description="If non-zero, the maximum value for a direct sample, "
449                             "higher values will be scaled down to avoid too "
450                             "much noise and slow convergence at the cost of accuracy",
451                 min=0.0, max=1e8,
452                 default=0.0,
453                 )
454
455         cls.sample_clamp_indirect = FloatProperty(
456                 name="Clamp Indirect",
457                 description="If non-zero, the maximum value for an indirect sample, "
458                             "higher values will be scaled down to avoid too "
459                             "much noise and slow convergence at the cost of accuracy",
460                 min=0.0, max=1e8,
461                 default=0.0,
462                 )
463
464         cls.debug_tile_size = IntProperty(
465                 name="Tile Size",
466                 description="",
467                 min=1, max=4096,
468                 default=1024,
469                 )
470
471         cls.preview_start_resolution = IntProperty(
472                 name="Start Resolution",
473                 description="Resolution to start rendering preview at, "
474                             "progressively increasing it to the full viewport size",
475                 min=8, max=16384,
476                 default=64,
477                 )
478
479         cls.debug_reset_timeout = FloatProperty(
480                 name="Reset timeout",
481                 description="",
482                 min=0.01, max=10.0,
483                 default=0.1,
484                 )
485         cls.debug_cancel_timeout = FloatProperty(
486                 name="Cancel timeout",
487                 description="",
488                 min=0.01, max=10.0,
489                 default=0.1,
490                 )
491         cls.debug_text_timeout = FloatProperty(
492                 name="Text timeout",
493                 description="",
494                 min=0.01, max=10.0,
495                 default=1.0,
496                 )
497
498         cls.debug_bvh_type = EnumProperty(
499                 name="Viewport BVH Type",
500                 description="Choose between faster updates, or faster render",
501                 items=enum_bvh_types,
502                 default='DYNAMIC_BVH',
503                 )
504         cls.debug_use_spatial_splits = BoolProperty(
505                 name="Use Spatial Splits",
506                 description="Use BVH spatial splits: longer builder time, faster render",
507                 default=False,
508                 )
509         cls.debug_use_hair_bvh = BoolProperty(
510                 name="Use Hair BVH",
511                 description="Use special type BVH optimized for hair (uses more ram but renders faster)",
512                 default=True,
513                 )
514         cls.tile_order = EnumProperty(
515                 name="Tile Order",
516                 description="Tile order for rendering",
517                 items=enum_tile_order,
518                 default='HILBERT_SPIRAL',
519                 options=set(),  # Not animatable!
520                 )
521         cls.use_progressive_refine = BoolProperty(
522                 name="Progressive Refine",
523                 description="Instead of rendering each tile until it is finished, "
524                             "refine the whole image progressively "
525                             "(this renders somewhat slower, "
526                             "but time can be saved by manually stopping the render when the noise is low enough)",
527                 default=False,
528                 )
529
530         cls.bake_type = EnumProperty(
531             name="Bake Type",
532             default='COMBINED',
533             description="Type of pass to bake",
534             items=(
535                 ('COMBINED', "Combined", ""),
536                 ('AO', "Ambient Occlusion", ""),
537                 ('SHADOW', "Shadow", ""),
538                 ('NORMAL', "Normal", ""),
539                 ('UV', "UV", ""),
540                 ('EMIT', "Emit", ""),
541                 ('ENVIRONMENT', "Environment", ""),
542                 ('DIFFUSE', "Diffuse", ""),
543                 ('GLOSSY', "Glossy", ""),
544                 ('TRANSMISSION', "Transmission", ""),
545                 ('SUBSURFACE', "Subsurface", ""),
546                 ),
547             )
548
549         cls.use_camera_cull = BoolProperty(
550                 name="Use Camera Cull",
551                 description="Allow objects to be culled based on the camera frustum",
552                 default=False,
553                 )
554
555         cls.camera_cull_margin = FloatProperty(
556                 name="Camera Cull Margin",
557                 description="Margin for the camera space culling",
558                 default=0.1,
559                 min=0.0, max=5.0
560                 )
561
562         cls.motion_blur_position = EnumProperty(
563             name="Motion Blur Position",
564             default='CENTER',
565             description="Offset for the shutter's time interval, allows to change the motion blur trails",
566             items=(
567                 ('START', "Start on Frame", "The shutter opens at the current frame"),
568                 ('CENTER', "Center on Frame", "The shutter is open during the current frame"),
569                 ('END', "End on Frame", "The shutter closes at the current frame"),
570                 ),
571             )
572
573         cls.rolling_shutter_type = EnumProperty(
574             name="Shutter Type",
575             default='NONE',
576             description="Type of rolling shutter effect matching CMOS-based cameras",
577             items=(
578                 ('NONE', "None", "No rolling shutter effect used"),
579                 ('TOP', "Top-Bottom", "Sensor is being scanned from top to bottom")
580                 # TODO(seergey): Are there real cameras with different scanning direction?
581                 ),
582             )
583
584         cls.rolling_shutter_duration = FloatProperty(
585             name="Rolling Shutter Duration",
586             description="Scanline \"exposure\" time for the rolling shutter effect",
587             default=0.1,
588             min=0.0, max=1.0,
589             )
590
591         # Various fine-tuning debug flags
592
593         def devices_update_callback(self, context):
594             import _cycles
595             scene = context.scene.as_pointer()
596             return _cycles.debug_flags_update(scene)
597
598         cls.debug_use_cpu_avx2 = BoolProperty(name="AVX2", default=True)
599         cls.debug_use_cpu_avx = BoolProperty(name="AVX", default=True)
600         cls.debug_use_cpu_sse41 = BoolProperty(name="SSE41", default=True)
601         cls.debug_use_cpu_sse3 = BoolProperty(name="SSE3", default=True)
602         cls.debug_use_cpu_sse2 = BoolProperty(name="SSE2", default=True)
603         cls.debug_use_qbvh = BoolProperty(name="QBVH", default=True)
604
605         cls.debug_use_cuda_adaptive_compile = BoolProperty(name="Adaptive Compile", default=False)
606
607         cls.debug_opencl_kernel_type = EnumProperty(
608             name="OpenCL Kernel Type",
609             default='DEFAULT',
610             items=(
611                 ('DEFAULT', "Default", ""),
612                 ('MEGA', "Mega", ""),
613                 ('SPLIT', "Split", ""),
614                 ),
615             update=devices_update_callback
616             )
617
618         cls.debug_opencl_device_type = EnumProperty(
619             name="OpenCL Device Type",
620             default='ALL',
621             items=(
622                 ('NONE', "None", ""),
623                 ('ALL', "All", ""),
624                 ('DEFAULT', "Default", ""),
625                 ('CPU', "CPU", ""),
626                 ('GPU', "GPU", ""),
627                 ('ACCELERATOR', "Accelerator", ""),
628                 ),
629             update=devices_update_callback
630             )
631
632         cls.debug_use_opencl_debug = BoolProperty(name="Debug OpenCL", default=False)
633
634     @classmethod
635     def unregister(cls):
636         del bpy.types.Scene.cycles
637
638
639 class CyclesCameraSettings(bpy.types.PropertyGroup):
640     @classmethod
641     def register(cls):
642         import math
643
644         bpy.types.Camera.cycles = PointerProperty(
645                 name="Cycles Camera Settings",
646                 description="Cycles camera settings",
647                 type=cls,
648                 )
649
650         cls.aperture_type = EnumProperty(
651                 name="Aperture Type",
652                 description="Use f-stop number or aperture radius",
653                 items=enum_aperture_types,
654                 default='RADIUS',
655                 )
656         cls.aperture_fstop = FloatProperty(
657                 name="Aperture f-stop",
658                 description="F-stop ratio (lower numbers give more defocus, higher numbers give a sharper image)",
659                 min=0.0, soft_min=0.1, soft_max=64.0,
660                 default=5.6,
661                 step=10,
662                 precision=1,
663                 )
664         cls.aperture_size = FloatProperty(
665                 name="Aperture Size",
666                 description="Radius of the aperture for depth of field (higher values give more defocus)",
667                 min=0.0, soft_max=10.0,
668                 default=0.0,
669                 step=1,
670                 precision=4,
671                 subtype='DISTANCE',
672                 )
673         cls.aperture_blades = IntProperty(
674                 name="Aperture Blades",
675                 description="Number of blades in aperture for polygonal bokeh (at least 3)",
676                 min=0, max=100,
677                 default=0,
678                 )
679         cls.aperture_rotation = FloatProperty(
680                 name="Aperture Rotation",
681                 description="Rotation of blades in aperture",
682                 soft_min=-math.pi, soft_max=math.pi,
683                 subtype='ANGLE',
684                 default=0,
685                 )
686         cls.aperture_ratio = FloatProperty(
687                 name="Aperture Ratio",
688                 description="Distortion to simulate anamorphic lens bokeh",
689                 min=0.01, soft_min=1.0, soft_max=2.0,
690                 default=1.0,
691                 precision=4,
692                 )
693         cls.panorama_type = EnumProperty(
694                 name="Panorama Type",
695                 description="Distortion to use for the calculation",
696                 items=enum_panorama_types,
697                 default='FISHEYE_EQUISOLID',
698                 )
699         cls.fisheye_fov = FloatProperty(
700                 name="Field of View",
701                 description="Field of view for the fisheye lens",
702                 min=0.1745, soft_max=2.0 * math.pi, max=10.0 * math.pi,
703                 subtype='ANGLE',
704                 default=math.pi,
705                 )
706         cls.fisheye_lens = FloatProperty(
707                 name="Fisheye Lens",
708                 description="Lens focal length (mm)",
709                 min=0.01, soft_max=15.0, max=100.0,
710                 default=10.5,
711                 )
712         cls.latitude_min = FloatProperty(
713                 name="Min Latitude",
714                 description="Minimum latitude (vertical angle) for the equirectangular lens",
715                 min=-0.5 * math.pi, max=0.5 * math.pi,
716                 subtype='ANGLE',
717                 default=-0.5 * math.pi,
718                 )
719         cls.latitude_max = FloatProperty(
720                 name="Max Latitude",
721                 description="Maximum latitude (vertical angle) for the equirectangular lens",
722                 min=-0.5 * math.pi, max=0.5 * math.pi,
723                 subtype='ANGLE',
724                 default=0.5 * math.pi,
725                 )
726         cls.longitude_min = FloatProperty(
727                 name="Min Longitude",
728                 description="Minimum longitude (horizontal angle) for the equirectangular lens",
729                 min=-math.pi, max=math.pi,
730                 subtype='ANGLE',
731                 default=-math.pi,
732                 )
733         cls.longitude_max = FloatProperty(
734                 name="Max Longitude",
735                 description="Maximum longitude (horizontal angle) for the equirectangular lens",
736                 min=-math.pi, max=math.pi,
737                 subtype='ANGLE',
738                 default=math.pi,
739                 )
740
741     @classmethod
742     def unregister(cls):
743         del bpy.types.Camera.cycles
744
745
746 class CyclesMaterialSettings(bpy.types.PropertyGroup):
747     @classmethod
748     def register(cls):
749         bpy.types.Material.cycles = PointerProperty(
750                 name="Cycles Material Settings",
751                 description="Cycles material settings",
752                 type=cls,
753                 )
754         cls.sample_as_light = BoolProperty(
755                 name="Multiple Importance Sample",
756                 description="Use multiple importance sampling for this material, "
757                             "disabling may reduce overall noise for large "
758                             "objects that emit little light compared to other light sources",
759                 default=True,
760                 )
761         cls.use_transparent_shadow = BoolProperty(
762                 name="Transparent Shadows",
763                 description="Use transparent shadows for this material if it contains a Transparent BSDF, "
764                             "disabling will render faster but not give accurate shadows",
765                 default=True,
766                 )
767         cls.homogeneous_volume = BoolProperty(
768                 name="Homogeneous Volume",
769                 description="When using volume rendering, assume volume has the same density everywhere "
770                             "(not using any textures), for faster rendering",
771                 default=False,
772                 )
773         cls.volume_sampling = EnumProperty(
774                 name="Volume Sampling",
775                 description="Sampling method to use for volumes",
776                 items=enum_volume_sampling,
777                 default='MULTIPLE_IMPORTANCE',
778                 )
779
780         cls.volume_interpolation = EnumProperty(
781                 name="Volume Interpolation",
782                 description="Interpolation method to use for smoke/fire volumes",
783                 items=enum_volume_interpolation,
784                 default='LINEAR',
785                 )
786
787         cls.displacement_method = EnumProperty(
788                 name="Displacement Method",
789                 description="Method to use for the displacement",
790                 items=enum_displacement_methods,
791                 default='BUMP',
792                 )
793
794     @classmethod
795     def unregister(cls):
796         del bpy.types.Material.cycles
797
798
799 class CyclesLampSettings(bpy.types.PropertyGroup):
800     @classmethod
801     def register(cls):
802         bpy.types.Lamp.cycles = PointerProperty(
803                 name="Cycles Lamp Settings",
804                 description="Cycles lamp settings",
805                 type=cls,
806                 )
807         cls.cast_shadow = BoolProperty(
808                 name="Cast Shadow",
809                 description="Lamp casts shadows",
810                 default=True,
811                 )
812         cls.samples = IntProperty(
813                 name="Samples",
814                 description="Number of light samples to render for each AA sample",
815                 min=1, max=10000,
816                 default=1,
817                 )
818         cls.max_bounces = IntProperty(
819                 name="Max Bounces",
820                 description="Maximum number of bounces the light will contribute to the render",
821                 min=0, max=1024,
822                 default=1024,
823                 )
824         cls.use_multiple_importance_sampling = BoolProperty(
825                 name="Multiple Importance Sample",
826                 description="Use multiple importance sampling for the lamp, "
827                             "reduces noise for area lamps and sharp glossy materials",
828                 default=True,
829                 )
830         cls.is_portal = BoolProperty(
831                 name="Is Portal",
832                 description="Use this area lamp to guide sampling of the background, "
833                             "note that this will make the lamp invisible",
834                 default=False,
835                 )
836
837     @classmethod
838     def unregister(cls):
839         del bpy.types.Lamp.cycles
840
841
842 class CyclesWorldSettings(bpy.types.PropertyGroup):
843     @classmethod
844     def register(cls):
845         bpy.types.World.cycles = PointerProperty(
846                 name="Cycles World Settings",
847                 description="Cycles world settings",
848                 type=cls,
849                 )
850         cls.sample_as_light = BoolProperty(
851                 name="Multiple Importance Sample",
852                 description="Use multiple importance sampling for the environment, "
853                             "enabling for non-solid colors is recommended",
854                 default=True,
855                 )
856         cls.sample_map_resolution = IntProperty(
857                 name="Map Resolution",
858                 description="Importance map size is resolution x resolution; "
859                             "higher values potentially produce less noise, at the cost of memory and speed",
860                 min=4, max=8192,
861                 default=1024,
862                 )
863         cls.samples = IntProperty(
864                 name="Samples",
865                 description="Number of light samples to render for each AA sample",
866                 min=1, max=10000,
867                 default=1,
868                 )
869         cls.max_bounces = IntProperty(
870                 name="Max Bounces",
871                 description="Maximum number of bounces the background light will contribute to the render",
872                 min=0, max=1024,
873                 default=1024,
874                 )
875         cls.homogeneous_volume = BoolProperty(
876                 name="Homogeneous Volume",
877                 description="When using volume rendering, assume volume has the same density everywhere"
878                             "(not using any textures), for faster rendering",
879                 default=False,
880                 )
881         cls.volume_sampling = EnumProperty(
882                 name="Volume Sampling",
883                 description="Sampling method to use for volumes",
884                 items=enum_volume_sampling,
885                 default='EQUIANGULAR',
886                 )
887
888         cls.volume_interpolation = EnumProperty(
889                 name="Volume Interpolation",
890                 description="Interpolation method to use for volumes",
891                 items=enum_volume_interpolation,
892                 default='LINEAR',
893                 )
894
895     @classmethod
896     def unregister(cls):
897         del bpy.types.World.cycles
898
899
900 class CyclesVisibilitySettings(bpy.types.PropertyGroup):
901     @classmethod
902     def register(cls):
903         bpy.types.Object.cycles_visibility = PointerProperty(
904                 name="Cycles Visibility Settings",
905                 description="Cycles visibility settings",
906                 type=cls,
907                 )
908
909         bpy.types.World.cycles_visibility = PointerProperty(
910                 name="Cycles Visibility Settings",
911                 description="Cycles visibility settings",
912                 type=cls,
913                 )
914
915         cls.camera = BoolProperty(
916                 name="Camera",
917                 description="Object visibility for camera rays",
918                 default=True,
919                 )
920         cls.diffuse = BoolProperty(
921                 name="Diffuse",
922                 description="Object visibility for diffuse reflection rays",
923                 default=True,
924                 )
925         cls.glossy = BoolProperty(
926                 name="Glossy",
927                 description="Object visibility for glossy reflection rays",
928                 default=True,
929                 )
930         cls.transmission = BoolProperty(
931                 name="Transmission",
932                 description="Object visibility for transmission rays",
933                 default=True,
934                 )
935         cls.shadow = BoolProperty(
936                 name="Shadow",
937                 description="Object visibility for shadow rays",
938                 default=True,
939                 )
940         cls.scatter = BoolProperty(
941                 name="Volume Scatter",
942                 description="Object visibility for volume scatter rays",
943                 default=True,
944                 )
945
946     @classmethod
947     def unregister(cls):
948         del bpy.types.Object.cycles_visibility
949         del bpy.types.World.cycles_visibility
950
951
952 class CyclesMeshSettings(bpy.types.PropertyGroup):
953     @classmethod
954     def register(cls):
955         bpy.types.Mesh.cycles = PointerProperty(
956                 name="Cycles Mesh Settings",
957                 description="Cycles mesh settings",
958                 type=cls,
959                 )
960         bpy.types.Curve.cycles = PointerProperty(
961                 name="Cycles Mesh Settings",
962                 description="Cycles mesh settings",
963                 type=cls,
964                 )
965         bpy.types.MetaBall.cycles = PointerProperty(
966                 name="Cycles Mesh Settings",
967                 description="Cycles mesh settings",
968                 type=cls,
969                 )
970
971     @classmethod
972     def unregister(cls):
973         del bpy.types.Mesh.cycles
974         del bpy.types.Curve.cycles
975         del bpy.types.MetaBall.cycles
976
977
978 class CyclesObjectSettings(bpy.types.PropertyGroup):
979     @classmethod
980     def register(cls):
981         bpy.types.Object.cycles = PointerProperty(
982                 name="Cycles Object Settings",
983                 description="Cycles object settings",
984                 type=cls,
985                 )
986
987         cls.use_motion_blur = BoolProperty(
988                 name="Use Motion Blur",
989                 description="Use motion blur for this object",
990                 default=True,
991                 )
992
993         cls.use_deform_motion = BoolProperty(
994                 name="Use Deformation Motion",
995                 description="Use deformation motion blur for this object",
996                 default=True,
997                 )
998
999         cls.motion_steps = IntProperty(
1000                 name="Motion Steps",
1001                 description="Control accuracy of deformation motion blur, more steps gives more memory usage (actual number of steps is 2^(steps - 1))",
1002                 min=1, soft_max=8,
1003                 default=1,
1004                 )
1005
1006         cls.use_camera_cull = BoolProperty(
1007                 name="Use Camera Cull",
1008                 description="Allow this object and its duplicators to be culled by camera space culling",
1009                 default=False,
1010                 )
1011
1012         cls.use_adaptive_subdivision = BoolProperty(
1013                 name="Use Adaptive Subdivision",
1014                 description="Use adaptive render time subdivision",
1015                 default=False,
1016                 )
1017
1018         cls.dicing_rate = FloatProperty(
1019                 name="Dicing Scale",
1020                 description="Multiplier for scene dicing rate (located in the Geometry Panel)",
1021                 min=0.1, max=1000.0, soft_min=0.5,
1022                 default=1.0,
1023                 )
1024
1025     @classmethod
1026     def unregister(cls):
1027         del bpy.types.Object.cycles
1028
1029
1030 class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
1031     @classmethod
1032     def register(cls):
1033         bpy.types.Scene.cycles_curves = PointerProperty(
1034                 name="Cycles Hair Rendering Settings",
1035                 description="Cycles hair rendering settings",
1036                 type=cls,
1037                 )
1038         cls.primitive = EnumProperty(
1039                 name="Primitive",
1040                 description="Type of primitive used for hair rendering",
1041                 items=enum_curve_primitives,
1042                 default='LINE_SEGMENTS',
1043                 )
1044         cls.shape = EnumProperty(
1045                 name="Shape",
1046                 description="Form of hair",
1047                 items=enum_curve_shape,
1048                 default='THICK',
1049                 )
1050         cls.cull_backfacing = BoolProperty(
1051                 name="Cull back-faces",
1052                 description="Do not test the back-face of each strand",
1053                 default=True,
1054                 )
1055         cls.use_curves = BoolProperty(
1056                 name="Use Cycles Hair Rendering",
1057                 description="Activate Cycles hair rendering for particle system",
1058                 default=True,
1059                 )
1060         cls.resolution = IntProperty(
1061                 name="Resolution",
1062                 description="Resolution of generated mesh",
1063                 min=3, max=64,
1064                 default=3,
1065                 )
1066         cls.minimum_width = FloatProperty(
1067                 name="Minimal width",
1068                 description="Minimal pixel width for strands (0 - deactivated)",
1069                 min=0.0, max=100.0,
1070                 default=0.0,
1071                 )
1072         cls.maximum_width = FloatProperty(
1073                 name="Maximal width",
1074                 description="Maximum extension that strand radius can be increased by",
1075                 min=0.0, max=100.0,
1076                 default=0.1,
1077                 )
1078         cls.subdivisions = IntProperty(
1079                 name="Subdivisions",
1080                 description="Number of subdivisions used in Cardinal curve intersection (power of 2)",
1081                 min=0, max=24,
1082                 default=4,
1083                 )
1084
1085     @classmethod
1086     def unregister(cls):
1087         del bpy.types.Scene.cycles_curves
1088
1089
1090 def register():
1091     bpy.utils.register_class(CyclesRenderSettings)
1092     bpy.utils.register_class(CyclesCameraSettings)
1093     bpy.utils.register_class(CyclesMaterialSettings)
1094     bpy.utils.register_class(CyclesLampSettings)
1095     bpy.utils.register_class(CyclesWorldSettings)
1096     bpy.utils.register_class(CyclesVisibilitySettings)
1097     bpy.utils.register_class(CyclesMeshSettings)
1098     bpy.utils.register_class(CyclesObjectSettings)
1099     bpy.utils.register_class(CyclesCurveRenderSettings)
1100
1101
1102 def unregister():
1103     bpy.utils.unregister_class(CyclesRenderSettings)
1104     bpy.utils.unregister_class(CyclesCameraSettings)
1105     bpy.utils.unregister_class(CyclesMaterialSettings)
1106     bpy.utils.unregister_class(CyclesLampSettings)
1107     bpy.utils.unregister_class(CyclesWorldSettings)
1108     bpy.utils.unregister_class(CyclesMeshSettings)
1109     bpy.utils.unregister_class(CyclesObjectSettings)
1110     bpy.utils.unregister_class(CyclesVisibilitySettings)
1111     bpy.utils.unregister_class(CyclesCurveRenderSettings)