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