7a22cba316e4aa345a34bbe5805b4d9169e1348b
[blender-staging.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, to reduce noise at the cost of accuracy",
140                 min=0.0, max=10.0,
141                 default=0.0,
142                 )
143
144         cls.min_bounces = IntProperty(
145                 name="Min Bounces",
146                 description="Minimum number of bounces, setting this lower "
147                             "than the maximum enables probabilistic path "
148                             "termination (faster but noisier)",
149                 min=0, max=1024,
150                 default=3,
151                 )
152         cls.max_bounces = IntProperty(
153                 name="Max Bounces",
154                 description="Total maximum number of bounces",
155                 min=0, max=1024,
156                 default=8,
157                 )
158
159         cls.diffuse_bounces = IntProperty(
160                 name="Diffuse Bounces",
161                 description="Maximum number of diffuse reflection bounces, bounded by total maximum",
162                 min=0, max=1024,
163                 default=128,
164                 )
165         cls.glossy_bounces = IntProperty(
166                 name="Glossy Bounces",
167                 description="Maximum number of glossy reflection bounces, bounded by total maximum",
168                 min=0, max=1024,
169                 default=128,
170                 )
171         cls.transmission_bounces = IntProperty(
172                 name="Transmission Bounces",
173                 description="Maximum number of transmission bounces, bounded by total maximum",
174                 min=0, max=1024,
175                 default=128,
176                 )
177
178         cls.transparent_min_bounces = IntProperty(
179                 name="Transparent Min Bounces",
180                 description="Minimum number of transparent bounces, setting "
181                             "this lower than the maximum enables "
182                             "probabilistic path termination (faster but "
183                             "noisier)",
184                 min=0, max=1024,
185                 default=8,
186                 )
187         cls.transparent_max_bounces = IntProperty(
188                 name="Transparent Max Bounces",
189                 description="Maximum number of transparent bounces",
190                 min=0, max=1024,
191                 default=8,
192                 )
193         cls.use_transparent_shadows = BoolProperty(
194                 name="Transparent Shadows",
195                 description="Use transparency of surfaces for rendering shadows",
196                 default=True,
197                 )
198
199         cls.film_exposure = FloatProperty(
200                 name="Exposure",
201                 description="Image brightness scale",
202                 min=0.0, max=10.0,
203                 default=1.0,
204                 )
205         cls.film_transparent = BoolProperty(
206                 name="Transparent",
207                 description="World background is transparent",
208                 default=False,
209                 )
210
211         cls.filter_type = EnumProperty(
212                 name="Filter Type",
213                 description="Pixel filter type",
214                 items=enums.filter_types,
215                 default='GAUSSIAN',
216                 )
217         cls.filter_width = FloatProperty(
218                 name="Filter Width",
219                 description="Pixel filter width",
220                 min=0.01, max=10.0,
221                 default=1.5,
222                 )
223
224         cls.seed = IntProperty(
225                 name="Seed",
226                 description="Seed value for integrator to get different noise patterns",
227                 min=0, max=2147483647,
228                 default=0,
229                 )
230
231         cls.sample_clamp = FloatProperty(
232                 name="Clamp",
233                 description="If non-zero, the maximum value for a sample, higher values will be scaled down to avoid too much noise and slow convergence at the cost of accuracy",
234                 min=0.0, max=1e8,
235                 default=0.0,
236                 )
237
238         cls.debug_tile_size = IntProperty(
239                 name="Tile Size",
240                 description="",
241                 min=1, max=4096,
242                 default=1024,
243                 )
244         cls.debug_min_size = IntProperty(
245                 name="Min Size",
246                 description="",
247                 min=1, max=4096,
248                 default=64,
249                 )
250         cls.debug_reset_timeout = FloatProperty(
251                 name="Reset timeout",
252                 description="",
253                 min=0.01, max=10.0,
254                 default=0.1,
255                 )
256         cls.debug_cancel_timeout = FloatProperty(
257                 name="Cancel timeout",
258                 description="",
259                 min=0.01, max=10.0,
260                 default=0.1,
261                 )
262         cls.debug_text_timeout = FloatProperty(
263                 name="Text timeout",
264                 description="",
265                 min=0.01, max=10.0,
266                 default=1.0,
267                 )
268
269         cls.debug_bvh_type = EnumProperty(
270                 name="Viewport BVH Type",
271                 description="Choose between faster updates, or faster render",
272                 items=enums.bvh_types,
273                 default='DYNAMIC_BVH',
274                 )
275         cls.debug_use_spatial_splits = BoolProperty(
276                 name="Use Spatial Splits",
277                 description="Use BVH spatial splits: longer builder time, faster render",
278                 default=False,
279                 )
280         cls.use_cache = BoolProperty(
281                 name="Cache BVH",
282                 description="Cache last built BVH to disk for faster re-render if no geometry changed",
283                 default=False,
284                 )
285
286     @classmethod
287     def unregister(cls):
288         del bpy.types.Scene.cycles
289
290
291 class CyclesCameraSettings(bpy.types.PropertyGroup):
292     @classmethod
293     def register(cls):
294         bpy.types.Camera.cycles = PointerProperty(
295                 name="Cycles Camera Settings",
296                 description="Cycles camera settings",
297                 type=cls,
298                 )
299
300         cls.aperture_type = EnumProperty(
301                 name="Aperture Type",
302                 description="Use F/stop number or aperture radius",
303                 items=enums.aperture_types,
304                 default='RADIUS',
305                 )
306         cls.aperture_fstop = FloatProperty(
307                 name="Aperture F/stop",
308                 description="F/stop ratio (lower numbers give more defocus, higher numbers give a sharper image)",
309                 min=0.0, soft_min=0.1, soft_max=64.0,
310                 default=5.6,
311                 step=10,
312                 precision=1,
313                 )
314         cls.aperture_size = FloatProperty(
315                 name="Aperture Size",
316                 description="Radius of the aperture for depth of field (higher values give more defocus)",
317                 min=0.0, soft_max=10.0,
318                 default=0.0,
319                 step=1,
320                 precision=4,
321                 )
322         cls.aperture_blades = IntProperty(
323                 name="Aperture Blades",
324                 description="Number of blades in aperture for polygonal bokeh (at least 3)",
325                 min=0, max=100,
326                 default=0,
327                 )
328         cls.aperture_rotation = FloatProperty(
329                 name="Aperture Rotation",
330                 description="Rotation of blades in aperture",
331                 soft_min=-math.pi, soft_max=math.pi,
332                 subtype='ANGLE',
333                 default=0,
334                 )
335         cls.panorama_type = EnumProperty(
336                 name="Panorama Type",
337                 description="Distortion to use for the calculation",
338                 items=enums.panorama_types,
339                 default='FISHEYE_EQUISOLID',
340                 )
341         cls.fisheye_fov = FloatProperty(
342                 name="Field of View",
343                 description="Field of view for the fisheye lens",
344                 min=0.1745, soft_max=2 * math.pi, max=10.0 * math.pi,
345                 subtype='ANGLE',
346                 default=math.pi,
347                 )
348         cls.fisheye_lens = FloatProperty(
349                 name="Fisheye Lens",
350                 description="Lens focal length (mm)",
351                 min=0.01, soft_max=15.0, max=100.0,
352                 default=10.5,
353                 )
354
355     @classmethod
356     def unregister(cls):
357         del bpy.types.Camera.cycles
358
359
360 class CyclesMaterialSettings(bpy.types.PropertyGroup):
361     @classmethod
362     def register(cls):
363         bpy.types.Material.cycles = PointerProperty(
364                 name="Cycles Material Settings",
365                 description="Cycles material settings",
366                 type=cls,
367                 )
368         cls.sample_as_light = BoolProperty(
369                 name="Sample as Lamp",
370                 description="Use direct light sampling for this material, disabling may reduce overall noise for large objects that emit little light compared to other light sources",
371                 default=True,
372                 )
373         cls.homogeneous_volume = BoolProperty(
374                 name="Homogeneous Volume",
375                 description="When using volume rendering, assume volume has the same density everywhere, for faster rendering",
376                 default=False,
377                 )
378
379     @classmethod
380     def unregister(cls):
381         del bpy.types.Material.cycles
382
383
384 class CyclesLampSettings(bpy.types.PropertyGroup):
385     @classmethod
386     def register(cls):
387         bpy.types.Lamp.cycles = PointerProperty(
388                 name="Cycles Lamp Settings",
389                 description="Cycles lamp settings",
390                 type=cls,
391                 )
392         cls.cast_shadow = BoolProperty(
393                 name="Cast Shadow",
394                 description="Lamp casts shadows",
395                 default=True,
396                 )
397         cls.samples = IntProperty(
398                 name="Samples",
399                 description="Number of light samples to render for each AA sample",
400                 min=1, max=10000,
401                 default=1,
402                 )
403
404     @classmethod
405     def unregister(cls):
406         del bpy.types.Lamp.cycles
407
408
409 class CyclesWorldSettings(bpy.types.PropertyGroup):
410     @classmethod
411     def register(cls):
412         bpy.types.World.cycles = PointerProperty(
413                 name="Cycles World Settings",
414                 description="Cycles world settings",
415                 type=cls,
416                 )
417         cls.sample_as_light = BoolProperty(
418                 name="Sample as Lamp",
419                 description="Use direct light sampling for the environment, enabling for non-solid colors is recommended",
420                 default=False,
421                 )
422         cls.sample_map_resolution = IntProperty(
423                 name="Map Resolution",
424                 description="Importance map size is resolution x resolution; higher values potentially produce less noise, at the cost of memory and speed",
425                 min=4, max=8096,
426                 default=256,
427                 )
428         cls.samples = IntProperty(
429                 name="Samples",
430                 description="Number of light samples to render for each AA sample",
431                 min=1, max=10000,
432                 default=4,
433                 )
434
435     @classmethod
436     def unregister(cls):
437         del bpy.types.World.cycles
438
439
440 class CyclesVisibilitySettings(bpy.types.PropertyGroup):
441     @classmethod
442     def register(cls):
443         bpy.types.Object.cycles_visibility = PointerProperty(
444                 name="Cycles Visibility Settings",
445                 description="Cycles visibility settings",
446                 type=cls,
447                 )
448
449         cls.camera = BoolProperty(
450                 name="Camera",
451                 description="Object visibility for camera rays",
452                 default=True,
453                 )
454         cls.diffuse = BoolProperty(
455                 name="Diffuse",
456                 description="Object visibility for diffuse reflection rays",
457                 default=True,
458                 )
459         cls.glossy = BoolProperty(
460                 name="Glossy",
461                 description="Object visibility for glossy reflection rays",
462                 default=True,
463                 )
464         cls.transmission = BoolProperty(
465                 name="Transmission",
466                 description="Object visibility for transmission rays",
467                 default=True,
468                 )
469         cls.shadow = BoolProperty(
470                 name="Shadow",
471                 description="Object visibility for shadow rays",
472                 default=True,
473                 )
474
475     @classmethod
476     def unregister(cls):
477         del bpy.types.Object.cycles_visibility
478
479
480 class CyclesMeshSettings(bpy.types.PropertyGroup):
481     @classmethod
482     def register(cls):
483         bpy.types.Mesh.cycles = PointerProperty(
484                 name="Cycles Mesh Settings",
485                 description="Cycles mesh settings",
486                 type=cls,
487                 )
488         bpy.types.Curve.cycles = PointerProperty(
489                 name="Cycles Mesh Settings",
490                 description="Cycles mesh settings",
491                 type=cls,
492                 )
493         bpy.types.MetaBall.cycles = PointerProperty(
494                 name="Cycles Mesh Settings",
495                 description="Cycles mesh settings",
496                 type=cls,
497                 )
498
499         cls.displacement_method = EnumProperty(
500                 name="Displacement Method",
501                 description="Method to use for the displacement",
502                 items=enums.displacement_methods,
503                 default='BUMP',
504                 )
505         cls.use_subdivision = BoolProperty(
506                 name="Use Subdivision",
507                 description="Subdivide mesh for rendering",
508                 default=False,
509                 )
510         cls.dicing_rate = FloatProperty(
511                 name="Dicing Rate",
512                 description="",
513                 min=0.001, max=1000.0,
514                 default=1.0,
515                 )
516
517     @classmethod
518     def unregister(cls):
519         del bpy.types.Mesh.cycles
520         del bpy.types.Curve.cycles
521         del bpy.types.MetaBall.cycles
522
523
524 def register():
525     bpy.utils.register_class(CyclesRenderSettings)
526     bpy.utils.register_class(CyclesCameraSettings)
527     bpy.utils.register_class(CyclesMaterialSettings)
528     bpy.utils.register_class(CyclesLampSettings)
529     bpy.utils.register_class(CyclesWorldSettings)
530     bpy.utils.register_class(CyclesVisibilitySettings)
531     bpy.utils.register_class(CyclesMeshSettings)
532
533
534 def unregister():
535     bpy.utils.unregister_class(CyclesRenderSettings)
536     bpy.utils.unregister_class(CyclesCameraSettings)
537     bpy.utils.unregister_class(CyclesMaterialSettings)
538     bpy.utils.unregister_class(CyclesLampSettings)
539     bpy.utils.unregister_class(CyclesWorldSettings)
540     bpy.utils.unregister_class(CyclesMeshSettings)
541     bpy.utils.unregister_class(CyclesVisibilitySettings)