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