Merging r50049 through r50076 from trunk into soc-2011-tomato
[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, 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
245         cls.resolution_divider = IntProperty(
246                 name="Resolution Divider",
247                 description="Start viewport rendering with lower resolution which would be real resolution divided by two in power of this value",
248                 min=1, max=512,
249                 default=4,
250                 )
251
252         cls.debug_reset_timeout = FloatProperty(
253                 name="Reset timeout",
254                 description="",
255                 min=0.01, max=10.0,
256                 default=0.1,
257                 )
258         cls.debug_cancel_timeout = FloatProperty(
259                 name="Cancel timeout",
260                 description="",
261                 min=0.01, max=10.0,
262                 default=0.1,
263                 )
264         cls.debug_text_timeout = FloatProperty(
265                 name="Text timeout",
266                 description="",
267                 min=0.01, max=10.0,
268                 default=1.0,
269                 )
270
271         cls.debug_bvh_type = EnumProperty(
272                 name="Viewport BVH Type",
273                 description="Choose between faster updates, or faster render",
274                 items=enums.bvh_types,
275                 default='DYNAMIC_BVH',
276                 )
277         cls.debug_use_spatial_splits = BoolProperty(
278                 name="Use Spatial Splits",
279                 description="Use BVH spatial splits: longer builder time, faster render",
280                 default=False,
281                 )
282         cls.use_cache = BoolProperty(
283                 name="Cache BVH",
284                 description="Cache last built BVH to disk for faster re-render if no geometry changed",
285                 default=False,
286                 )
287
288     @classmethod
289     def unregister(cls):
290         del bpy.types.Scene.cycles
291
292
293 class CyclesCameraSettings(bpy.types.PropertyGroup):
294     @classmethod
295     def register(cls):
296         bpy.types.Camera.cycles = PointerProperty(
297                 name="Cycles Camera Settings",
298                 description="Cycles camera settings",
299                 type=cls,
300                 )
301
302         cls.aperture_type = EnumProperty(
303                 name="Aperture Type",
304                 description="Use F/stop number or aperture radius",
305                 items=enums.aperture_types,
306                 default='RADIUS',
307                 )
308         cls.aperture_fstop = FloatProperty(
309                 name="Aperture F/stop",
310                 description="F/stop ratio (lower numbers give more defocus, higher numbers give a sharper image)",
311                 min=0.0, soft_min=0.1, soft_max=64.0,
312                 default=5.6,
313                 step=10,
314                 precision=1,
315                 )
316         cls.aperture_size = FloatProperty(
317                 name="Aperture Size",
318                 description="Radius of the aperture for depth of field (higher values give more defocus)",
319                 min=0.0, soft_max=10.0,
320                 default=0.0,
321                 step=1,
322                 precision=4,
323                 )
324         cls.aperture_blades = IntProperty(
325                 name="Aperture Blades",
326                 description="Number of blades in aperture for polygonal bokeh (at least 3)",
327                 min=0, max=100,
328                 default=0,
329                 )
330         cls.aperture_rotation = FloatProperty(
331                 name="Aperture Rotation",
332                 description="Rotation of blades in aperture",
333                 soft_min=-math.pi, soft_max=math.pi,
334                 subtype='ANGLE',
335                 default=0,
336                 )
337         cls.panorama_type = EnumProperty(
338                 name="Panorama Type",
339                 description="Distortion to use for the calculation",
340                 items=enums.panorama_types,
341                 default='FISHEYE_EQUISOLID',
342                 )
343         cls.fisheye_fov = FloatProperty(
344                 name="Field of View",
345                 description="Field of view for the fisheye lens",
346                 min=0.1745, soft_max=2 * math.pi, max=10.0 * math.pi,
347                 subtype='ANGLE',
348                 default=math.pi,
349                 )
350         cls.fisheye_lens = FloatProperty(
351                 name="Fisheye Lens",
352                 description="Lens focal length (mm)",
353                 min=0.01, soft_max=15.0, max=100.0,
354                 default=10.5,
355                 )
356
357     @classmethod
358     def unregister(cls):
359         del bpy.types.Camera.cycles
360
361
362 class CyclesMaterialSettings(bpy.types.PropertyGroup):
363     @classmethod
364     def register(cls):
365         bpy.types.Material.cycles = PointerProperty(
366                 name="Cycles Material Settings",
367                 description="Cycles material settings",
368                 type=cls,
369                 )
370         cls.sample_as_light = BoolProperty(
371                 name="Sample as Lamp",
372                 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",
373                 default=True,
374                 )
375         cls.homogeneous_volume = BoolProperty(
376                 name="Homogeneous Volume",
377                 description="When using volume rendering, assume volume has the same density everywhere, for faster rendering",
378                 default=False,
379                 )
380
381     @classmethod
382     def unregister(cls):
383         del bpy.types.Material.cycles
384
385
386 class CyclesLampSettings(bpy.types.PropertyGroup):
387     @classmethod
388     def register(cls):
389         bpy.types.Lamp.cycles = PointerProperty(
390                 name="Cycles Lamp Settings",
391                 description="Cycles lamp settings",
392                 type=cls,
393                 )
394         cls.cast_shadow = BoolProperty(
395                 name="Cast Shadow",
396                 description="Lamp casts shadows",
397                 default=True,
398                 )
399         cls.samples = IntProperty(
400                 name="Samples",
401                 description="Number of light samples to render for each AA sample",
402                 min=1, max=10000,
403                 default=1,
404                 )
405
406     @classmethod
407     def unregister(cls):
408         del bpy.types.Lamp.cycles
409
410
411 class CyclesWorldSettings(bpy.types.PropertyGroup):
412     @classmethod
413     def register(cls):
414         bpy.types.World.cycles = PointerProperty(
415                 name="Cycles World Settings",
416                 description="Cycles world settings",
417                 type=cls,
418                 )
419         cls.sample_as_light = BoolProperty(
420                 name="Sample as Lamp",
421                 description="Use direct light sampling for the environment, enabling for non-solid colors is recommended",
422                 default=False,
423                 )
424         cls.sample_map_resolution = IntProperty(
425                 name="Map Resolution",
426                 description="Importance map size is resolution x resolution; higher values potentially produce less noise, at the cost of memory and speed",
427                 min=4, max=8096,
428                 default=256,
429                 )
430         cls.samples = IntProperty(
431                 name="Samples",
432                 description="Number of light samples to render for each AA sample",
433                 min=1, max=10000,
434                 default=4,
435                 )
436
437     @classmethod
438     def unregister(cls):
439         del bpy.types.World.cycles
440
441
442 class CyclesVisibilitySettings(bpy.types.PropertyGroup):
443     @classmethod
444     def register(cls):
445         bpy.types.Object.cycles_visibility = PointerProperty(
446                 name="Cycles Visibility Settings",
447                 description="Cycles visibility settings",
448                 type=cls,
449                 )
450
451         cls.camera = BoolProperty(
452                 name="Camera",
453                 description="Object visibility for camera rays",
454                 default=True,
455                 )
456         cls.diffuse = BoolProperty(
457                 name="Diffuse",
458                 description="Object visibility for diffuse reflection rays",
459                 default=True,
460                 )
461         cls.glossy = BoolProperty(
462                 name="Glossy",
463                 description="Object visibility for glossy reflection rays",
464                 default=True,
465                 )
466         cls.transmission = BoolProperty(
467                 name="Transmission",
468                 description="Object visibility for transmission rays",
469                 default=True,
470                 )
471         cls.shadow = BoolProperty(
472                 name="Shadow",
473                 description="Object visibility for shadow rays",
474                 default=True,
475                 )
476
477     @classmethod
478     def unregister(cls):
479         del bpy.types.Object.cycles_visibility
480
481
482 class CyclesMeshSettings(bpy.types.PropertyGroup):
483     @classmethod
484     def register(cls):
485         bpy.types.Mesh.cycles = PointerProperty(
486                 name="Cycles Mesh Settings",
487                 description="Cycles mesh settings",
488                 type=cls,
489                 )
490         bpy.types.Curve.cycles = PointerProperty(
491                 name="Cycles Mesh Settings",
492                 description="Cycles mesh settings",
493                 type=cls,
494                 )
495         bpy.types.MetaBall.cycles = PointerProperty(
496                 name="Cycles Mesh Settings",
497                 description="Cycles mesh settings",
498                 type=cls,
499                 )
500
501         cls.displacement_method = EnumProperty(
502                 name="Displacement Method",
503                 description="Method to use for the displacement",
504                 items=enums.displacement_methods,
505                 default='BUMP',
506                 )
507         cls.use_subdivision = BoolProperty(
508                 name="Use Subdivision",
509                 description="Subdivide mesh for rendering",
510                 default=False,
511                 )
512         cls.dicing_rate = FloatProperty(
513                 name="Dicing Rate",
514                 description="",
515                 min=0.001, max=1000.0,
516                 default=1.0,
517                 )
518
519     @classmethod
520     def unregister(cls):
521         del bpy.types.Mesh.cycles
522         del bpy.types.Curve.cycles
523         del bpy.types.MetaBall.cycles
524
525
526 def register():
527     bpy.utils.register_class(CyclesRenderSettings)
528     bpy.utils.register_class(CyclesCameraSettings)
529     bpy.utils.register_class(CyclesMaterialSettings)
530     bpy.utils.register_class(CyclesLampSettings)
531     bpy.utils.register_class(CyclesWorldSettings)
532     bpy.utils.register_class(CyclesVisibilitySettings)
533     bpy.utils.register_class(CyclesMeshSettings)
534
535
536 def unregister():
537     bpy.utils.unregister_class(CyclesRenderSettings)
538     bpy.utils.unregister_class(CyclesCameraSettings)
539     bpy.utils.unregister_class(CyclesMaterialSettings)
540     bpy.utils.unregister_class(CyclesLampSettings)
541     bpy.utils.unregister_class(CyclesWorldSettings)
542     bpy.utils.unregister_class(CyclesMeshSettings)
543     bpy.utils.unregister_class(CyclesVisibilitySettings)