0b8ca6e0fbecff7159479fc973b489ab1f997559
[blender.git] / intern / cycles / blender / addon / properties.py
1 #
2 # Copyright 2011, Blender Foundation.
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18
19 # <pep8 compliant>
20
21 import bpy
22 from bpy.props import (BoolProperty,
23                        EnumProperty,
24                        FloatProperty,
25                        IntProperty,
26                        PointerProperty)
27
28 import math
29
30 from . import enums
31
32
33 class CyclesRenderSettings(bpy.types.PropertyGroup):
34     @classmethod
35     def register(cls):
36         bpy.types.Scene.cycles = PointerProperty(
37                 name="Cycles Render Settings",
38                 description="Cycles render settings",
39                 type=cls,
40                 )
41         cls.device = EnumProperty(
42                 name="Device",
43                 description="Device to use for rendering",
44                 items=enums.devices,
45                 default='CPU',
46                 )
47         cls.feature_set = EnumProperty(
48                 name="Feature Set",
49                 description="Feature set to use for rendering",
50                 items=enums.feature_set,
51                 default='SUPPORTED',
52                 )
53         cls.shading_system = EnumProperty(
54                 name="Shading System",
55                 description="Shading system to use for rendering",
56                 items=enums.shading_systems,
57                 default='GPU_COMPATIBLE',
58                 )
59
60         cls.progressive = BoolProperty(
61                 name="Progressive",
62                 description="Use progressive sampling of lighting",
63                 default=True,
64                 )
65
66         cls.samples = IntProperty(
67                 name="Samples",
68                 description="Number of samples to render for each pixel",
69                 min=1, max=2147483647,
70                 default=10,
71                 )
72         cls.preview_samples = IntProperty(
73                 name="Preview Samples",
74                 description="Number of samples to render in the viewport, unlimited if 0",
75                 min=0, max=2147483647,
76                 default=10,
77                 )
78         cls.preview_pause = BoolProperty(
79                 name="Pause Preview",
80                 description="Pause all viewport preview renders",
81                 default=False,
82                 )
83         cls.preview_active_layer = BoolProperty(
84                 name="Preview Active Layer",
85                 description="Preview active render layer in viewport",
86                 default=False,
87                 )
88
89         cls.aa_samples = IntProperty(
90                 name="AA Samples",
91                 description="Number of antialiasing samples to render for each pixel",
92                 min=1, max=10000,
93                 default=4,
94                 )
95         cls.preview_aa_samples = IntProperty(
96                 name="AA Samples",
97                 description="Number of antialiasing samples to render in the viewport, unlimited if 0",
98                 min=0, max=10000,
99                 default=4,
100                 )
101         cls.diffuse_samples = IntProperty(
102                 name="Diffuse Samples",
103                 description="Number of diffuse bounce samples to render for each AA sample",
104                 min=1, max=10000,
105                 default=1,
106                 )
107         cls.glossy_samples = IntProperty(
108                 name="Glossy Samples",
109                 description="Number of glossy bounce samples to render for each AA sample",
110                 min=1, max=10000,
111                 default=1,
112                 )
113         cls.transmission_samples = IntProperty(
114                 name="Transmission Samples",
115                 description="Number of transmission bounce samples to render for each AA sample",
116                 min=1, max=10000,
117                 default=1,
118                 )
119         cls.ao_samples = IntProperty(
120                 name="Ambient Occlusion Samples",
121                 description="Number of ambient occlusion samples to render for each AA sample",
122                 min=1, max=10000,
123                 default=1,
124                 )
125         cls.mesh_light_samples = IntProperty(
126                 name="Mesh Light Samples",
127                 description="Number of mesh emission light samples to render for each AA sample",
128                 min=1, max=10000,
129                 default=1,
130                 )
131
132         cls.no_caustics = BoolProperty(
133                 name="No Caustics",
134                 description="Leave out caustics, resulting in a darker image with less noise",
135                 default=False,
136                 )
137         cls.blur_glossy = FloatProperty(
138                 name="Filter Glossy",
139                 description="Adaptively blur glossy shaders after blurry bounces, "
140                             "to reduce noise at the cost of accuracy",
141                 min=0.0, max=10.0,
142                 default=0.0,
143                 )
144
145         cls.min_bounces = IntProperty(
146                 name="Min Bounces",
147                 description="Minimum number of bounces, setting this lower "
148                             "than the maximum enables probabilistic path "
149                             "termination (faster but noisier)",
150                 min=0, max=1024,
151                 default=3,
152                 )
153         cls.max_bounces = IntProperty(
154                 name="Max Bounces",
155                 description="Total maximum number of bounces",
156                 min=0, max=1024,
157                 default=8,
158                 )
159
160         cls.diffuse_bounces = IntProperty(
161                 name="Diffuse Bounces",
162                 description="Maximum number of diffuse reflection bounces, bounded by total maximum",
163                 min=0, max=1024,
164                 default=128,
165                 )
166         cls.glossy_bounces = IntProperty(
167                 name="Glossy Bounces",
168                 description="Maximum number of glossy reflection bounces, bounded by total maximum",
169                 min=0, max=1024,
170                 default=128,
171                 )
172         cls.transmission_bounces = IntProperty(
173                 name="Transmission Bounces",
174                 description="Maximum number of transmission bounces, bounded by total maximum",
175                 min=0, max=1024,
176                 default=128,
177                 )
178
179         cls.transparent_min_bounces = IntProperty(
180                 name="Transparent Min Bounces",
181                 description="Minimum number of transparent bounces, setting "
182                             "this lower than the maximum enables "
183                             "probabilistic path termination (faster but "
184                             "noisier)",
185                 min=0, max=1024,
186                 default=8,
187                 )
188         cls.transparent_max_bounces = IntProperty(
189                 name="Transparent Max Bounces",
190                 description="Maximum number of transparent bounces",
191                 min=0, max=1024,
192                 default=8,
193                 )
194         cls.use_transparent_shadows = BoolProperty(
195                 name="Transparent Shadows",
196                 description="Use transparency of surfaces for rendering shadows",
197                 default=True,
198                 )
199
200         cls.film_exposure = FloatProperty(
201                 name="Exposure",
202                 description="Image brightness scale",
203                 min=0.0, max=10.0,
204                 default=1.0,
205                 )
206         cls.film_transparent = BoolProperty(
207                 name="Transparent",
208                 description="World background is transparent",
209                 default=False,
210                 )
211
212         cls.filter_type = EnumProperty(
213                 name="Filter Type",
214                 description="Pixel filter type",
215                 items=enums.filter_types,
216                 default='GAUSSIAN',
217                 )
218         cls.filter_width = FloatProperty(
219                 name="Filter Width",
220                 description="Pixel filter width",
221                 min=0.01, max=10.0,
222                 default=1.5,
223                 )
224
225         cls.seed = IntProperty(
226                 name="Seed",
227                 description="Seed value for integrator to get different noise patterns",
228                 min=0, max=2147483647,
229                 default=0,
230                 )
231
232         cls.sample_clamp = FloatProperty(
233                 name="Clamp",
234                 description="If non-zero, the maximum value for a sample, "
235                             "higher values will be scaled down to avoid too "
236                             "much noise and slow convergence at the cost of accuracy",
237                 min=0.0, max=1e8,
238                 default=0.0,
239                 )
240
241         cls.debug_tile_size = IntProperty(
242                 name="Tile Size",
243                 description="",
244                 min=1, max=4096,
245                 default=1024,
246                 )
247
248         cls.preview_start_resolution = IntProperty(
249                 name="Start Resolution",
250                 description="Resolution to start rendering preview at, "
251                             "progressively increasing it to the full viewport size",
252                 min=8, max=16384,
253                 default=64,
254                 )
255
256         cls.debug_reset_timeout = FloatProperty(
257                 name="Reset timeout",
258                 description="",
259                 min=0.01, max=10.0,
260                 default=0.1,
261                 )
262         cls.debug_cancel_timeout = FloatProperty(
263                 name="Cancel timeout",
264                 description="",
265                 min=0.01, max=10.0,
266                 default=0.1,
267                 )
268         cls.debug_text_timeout = FloatProperty(
269                 name="Text timeout",
270                 description="",
271                 min=0.01, max=10.0,
272                 default=1.0,
273                 )
274
275         cls.debug_bvh_type = EnumProperty(
276                 name="Viewport BVH Type",
277                 description="Choose between faster updates, or faster render",
278                 items=enums.bvh_types,
279                 default='DYNAMIC_BVH',
280                 )
281         cls.debug_use_spatial_splits = BoolProperty(
282                 name="Use Spatial Splits",
283                 description="Use BVH spatial splits: longer builder time, faster render",
284                 default=False,
285                 )
286         cls.use_cache = BoolProperty(
287                 name="Cache BVH",
288                 description="Cache last built BVH to disk for faster re-render if no geometry changed",
289                 default=False,
290                 )
291         cls.use_progressive_refine = BoolProperty(
292                 name="Progressive Refine",
293                 description="Instead of rendering each tile until it is finished, "
294                             "refine the whole image progressively "
295                             "(this renders somewhat slower, "
296                             "but time can be saved by manually stopping the render when the noise is low enough)",
297                 default=False,
298                 )
299
300     @classmethod
301     def unregister(cls):
302         del bpy.types.Scene.cycles
303
304
305 class CyclesCameraSettings(bpy.types.PropertyGroup):
306     @classmethod
307     def register(cls):
308         bpy.types.Camera.cycles = PointerProperty(
309                 name="Cycles Camera Settings",
310                 description="Cycles camera settings",
311                 type=cls,
312                 )
313
314         cls.aperture_type = EnumProperty(
315                 name="Aperture Type",
316                 description="Use F/stop number or aperture radius",
317                 items=enums.aperture_types,
318                 default='RADIUS',
319                 )
320         cls.aperture_fstop = FloatProperty(
321                 name="Aperture F/stop",
322                 description="F/stop ratio (lower numbers give more defocus, higher numbers give a sharper image)",
323                 min=0.0, soft_min=0.1, soft_max=64.0,
324                 default=5.6,
325                 step=10,
326                 precision=1,
327                 )
328         cls.aperture_size = FloatProperty(
329                 name="Aperture Size",
330                 description="Radius of the aperture for depth of field (higher values give more defocus)",
331                 min=0.0, soft_max=10.0,
332                 default=0.0,
333                 step=1,
334                 precision=4,
335                 )
336         cls.aperture_blades = IntProperty(
337                 name="Aperture Blades",
338                 description="Number of blades in aperture for polygonal bokeh (at least 3)",
339                 min=0, max=100,
340                 default=0,
341                 )
342         cls.aperture_rotation = FloatProperty(
343                 name="Aperture Rotation",
344                 description="Rotation of blades in aperture",
345                 soft_min=-math.pi, soft_max=math.pi,
346                 subtype='ANGLE',
347                 default=0,
348                 )
349         cls.panorama_type = EnumProperty(
350                 name="Panorama Type",
351                 description="Distortion to use for the calculation",
352                 items=enums.panorama_types,
353                 default='FISHEYE_EQUISOLID',
354                 )
355         cls.fisheye_fov = FloatProperty(
356                 name="Field of View",
357                 description="Field of view for the fisheye lens",
358                 min=0.1745, soft_max=2 * math.pi, max=10.0 * math.pi,
359                 subtype='ANGLE',
360                 default=math.pi,
361                 )
362         cls.fisheye_lens = FloatProperty(
363                 name="Fisheye Lens",
364                 description="Lens focal length (mm)",
365                 min=0.01, soft_max=15.0, max=100.0,
366                 default=10.5,
367                 )
368
369     @classmethod
370     def unregister(cls):
371         del bpy.types.Camera.cycles
372
373
374 class CyclesMaterialSettings(bpy.types.PropertyGroup):
375     @classmethod
376     def register(cls):
377         bpy.types.Material.cycles = PointerProperty(
378                 name="Cycles Material Settings",
379                 description="Cycles material settings",
380                 type=cls,
381                 )
382         cls.sample_as_light = BoolProperty(
383                 name="Sample as Lamp",
384                 description="Use direct light sampling for this material, "
385                             "disabling may reduce overall noise for large "
386                             "objects that emit little light compared to other light sources",
387                 default=True,
388                 )
389         cls.homogeneous_volume = BoolProperty(
390                 name="Homogeneous Volume",
391                 description="When using volume rendering, assume volume has the same density everywhere, "
392                             "for faster rendering",
393                 default=False,
394                 )
395
396     @classmethod
397     def unregister(cls):
398         del bpy.types.Material.cycles
399
400
401 class CyclesLampSettings(bpy.types.PropertyGroup):
402     @classmethod
403     def register(cls):
404         bpy.types.Lamp.cycles = PointerProperty(
405                 name="Cycles Lamp Settings",
406                 description="Cycles lamp settings",
407                 type=cls,
408                 )
409         cls.cast_shadow = BoolProperty(
410                 name="Cast Shadow",
411                 description="Lamp casts shadows",
412                 default=True,
413                 )
414         cls.samples = IntProperty(
415                 name="Samples",
416                 description="Number of light samples to render for each AA sample",
417                 min=1, max=10000,
418                 default=1,
419                 )
420
421     @classmethod
422     def unregister(cls):
423         del bpy.types.Lamp.cycles
424
425
426 class CyclesWorldSettings(bpy.types.PropertyGroup):
427     @classmethod
428     def register(cls):
429         bpy.types.World.cycles = PointerProperty(
430                 name="Cycles World Settings",
431                 description="Cycles world settings",
432                 type=cls,
433                 )
434         cls.sample_as_light = BoolProperty(
435                 name="Sample as Lamp",
436                 description="Use direct light sampling for the environment, "
437                             "enabling for non-solid colors is recommended",
438                 default=False,
439                 )
440         cls.sample_map_resolution = IntProperty(
441                 name="Map Resolution",
442                 description="Importance map size is resolution x resolution; "
443                             "higher values potentially produce less noise, at the cost of memory and speed",
444                 min=4, max=8096,
445                 default=256,
446                 )
447         cls.samples = IntProperty(
448                 name="Samples",
449                 description="Number of light samples to render for each AA sample",
450                 min=1, max=10000,
451                 default=4,
452                 )
453
454     @classmethod
455     def unregister(cls):
456         del bpy.types.World.cycles
457
458
459 class CyclesVisibilitySettings(bpy.types.PropertyGroup):
460     @classmethod
461     def register(cls):
462         bpy.types.Object.cycles_visibility = PointerProperty(
463                 name="Cycles Visibility Settings",
464                 description="Cycles visibility settings",
465                 type=cls,
466                 )
467
468         cls.camera = BoolProperty(
469                 name="Camera",
470                 description="Object visibility for camera rays",
471                 default=True,
472                 )
473         cls.diffuse = BoolProperty(
474                 name="Diffuse",
475                 description="Object visibility for diffuse reflection rays",
476                 default=True,
477                 )
478         cls.glossy = BoolProperty(
479                 name="Glossy",
480                 description="Object visibility for glossy reflection rays",
481                 default=True,
482                 )
483         cls.transmission = BoolProperty(
484                 name="Transmission",
485                 description="Object visibility for transmission rays",
486                 default=True,
487                 )
488         cls.shadow = BoolProperty(
489                 name="Shadow",
490                 description="Object visibility for shadow rays",
491                 default=True,
492                 )
493
494     @classmethod
495     def unregister(cls):
496         del bpy.types.Object.cycles_visibility
497
498
499 class CyclesMeshSettings(bpy.types.PropertyGroup):
500     @classmethod
501     def register(cls):
502         bpy.types.Mesh.cycles = PointerProperty(
503                 name="Cycles Mesh Settings",
504                 description="Cycles mesh settings",
505                 type=cls,
506                 )
507         bpy.types.Curve.cycles = PointerProperty(
508                 name="Cycles Mesh Settings",
509                 description="Cycles mesh settings",
510                 type=cls,
511                 )
512         bpy.types.MetaBall.cycles = PointerProperty(
513                 name="Cycles Mesh Settings",
514                 description="Cycles mesh settings",
515                 type=cls,
516                 )
517
518         cls.displacement_method = EnumProperty(
519                 name="Displacement Method",
520                 description="Method to use for the displacement",
521                 items=enums.displacement_methods,
522                 default='BUMP',
523                 )
524         cls.use_subdivision = BoolProperty(
525                 name="Use Subdivision",
526                 description="Subdivide mesh for rendering",
527                 default=False,
528                 )
529         cls.dicing_rate = FloatProperty(
530                 name="Dicing Rate",
531                 description="",
532                 min=0.001, max=1000.0,
533                 default=1.0,
534                 )
535
536     @classmethod
537     def unregister(cls):
538         del bpy.types.Mesh.cycles
539         del bpy.types.Curve.cycles
540         del bpy.types.MetaBall.cycles
541
542
543 def register():
544     bpy.utils.register_class(CyclesRenderSettings)
545     bpy.utils.register_class(CyclesCameraSettings)
546     bpy.utils.register_class(CyclesMaterialSettings)
547     bpy.utils.register_class(CyclesLampSettings)
548     bpy.utils.register_class(CyclesWorldSettings)
549     bpy.utils.register_class(CyclesVisibilitySettings)
550     bpy.utils.register_class(CyclesMeshSettings)
551
552
553 def unregister():
554     bpy.utils.unregister_class(CyclesRenderSettings)
555     bpy.utils.unregister_class(CyclesCameraSettings)
556     bpy.utils.unregister_class(CyclesMaterialSettings)
557     bpy.utils.unregister_class(CyclesLampSettings)
558     bpy.utils.unregister_class(CyclesWorldSettings)
559     bpy.utils.unregister_class(CyclesMeshSettings)
560     bpy.utils.unregister_class(CyclesVisibilitySettings)