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