Merged changes in the trunk up to revision 42116.
[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 cycles import enums
31
32
33 class CyclesRenderSettings(bpy.types.PropertyGroup):
34     @classmethod
35     def register(cls):
36         bpy.types.Scene.cycles = PointerProperty(type=cls, name="Cycles Render Settings", description="Cycles render settings")
37
38         cls.device = EnumProperty(name="Device", description="Device to use for rendering",
39             items=enums.devices, default="CPU")
40
41         cls.gpu_type = EnumProperty(name="GPU Type", description="Processing system to use on the GPU",
42             items=enums.gpu_type, default="CUDA")
43
44         cls.shading_system = EnumProperty(name="Shading System", description="Shading system to use for rendering",
45             items=enums.shading_systems, default="GPU_COMPATIBLE")
46
47         cls.samples = IntProperty(name="Samples", description="Number of samples to render for each pixel",
48             default=10, min=1, max=2147483647)
49         cls.preview_samples = IntProperty(name="Preview Samples", description="Number of samples to render in the viewport, unlimited if 0",
50             default=10, min=0, max=2147483647)
51         cls.preview_pause = BoolProperty(name="Pause Preview", description="Pause all viewport preview renders",
52             default=False)
53
54         cls.no_caustics = BoolProperty(name="No Caustics", description="Leave out caustics, resulting in a darker image with less noise",
55             default=False)
56         cls.blur_caustics = FloatProperty(name="Blur Caustics", description="Blur caustics to reduce noise",
57             default=0.0, min=0.0, max=1.0)
58
59         cls.min_bounces = IntProperty(name="Min Bounces", description="Minimum number of bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)",
60             default=3, min=0, max=1024)
61         cls.max_bounces = IntProperty(name="Max Bounces", description="Total maximum number of bounces",
62             default=8, min=0, max=1024)
63
64         cls.diffuse_bounces = IntProperty(name="Diffuse Bounces", description="Maximum number of diffuse reflection bounces, bounded by total maximum",
65             default=128, min=0, max=1024)
66         cls.glossy_bounces = IntProperty(name="Glossy Bounces", description="Maximum number of glossy reflection bounces, bounded by total maximum",
67             default=128, min=0, max=1024)
68         cls.transmission_bounces = IntProperty(name="Transmission Bounces", description="Maximum number of transmission bounces, bounded by total maximum",
69             default=128, min=0, max=1024)
70
71         cls.transparent_min_bounces = IntProperty(name="Transparent Min Bounces", description="Minimum number of transparent bounces, setting this lower than the maximum enables probalistic path termination (faster but noisier)",
72             default=8, min=0, max=1024)
73         cls.transparent_max_bounces = IntProperty(name="Transparent Max Bounces", description="Maximum number of transparent bounces",
74             default=8, min=0, max=1024)
75         cls.use_transparent_shadows = BoolProperty(name="Transparent Shadows", description="Use transparency of surfaces for rendering shadows",
76             default=True)
77
78         cls.film_exposure = FloatProperty(name="Exposure", description="Image brightness scale",
79             default=1.0, min=0.0, max=10.0)
80         cls.film_transparent = BoolProperty(name="Transparent", description="World background is transparent",
81             default=False)
82
83         cls.filter_type = EnumProperty(name="Filter Type", description="Pixel filter type",
84             items=enums.filter_types, default="GAUSSIAN")
85         cls.filter_width = FloatProperty(name="Filter Width", description="Pixel filter width",
86             default=1.5, min=0.01, max=10.0)
87
88         cls.seed = IntProperty(name="Seed", description="Seed value for integrator to get different noise patterns",
89             default=0, min=0, max=2147483647)
90
91         cls.debug_tile_size = IntProperty(name="Tile Size", description="",
92             default=1024, min=1, max=4096)
93         cls.debug_min_size = IntProperty(name="Min Size", description="",
94             default=64, min=1, max=4096)
95         cls.debug_reset_timeout = FloatProperty(name="Reset timeout", description="",
96             default=0.1, min=0.01, max=10.0)
97         cls.debug_cancel_timeout = FloatProperty(name="Cancel timeout", description="",
98             default=0.1, min=0.01, max=10.0)
99         cls.debug_text_timeout = FloatProperty(name="Text timeout", description="",
100             default=1.0, min=0.01, max=10.0)
101
102         cls.debug_bvh_type = EnumProperty(name="Viewport BVH Type", description="Choose between faster updates, or faster render",
103             items=enums.bvh_types, default="DYNAMIC_BVH")
104         cls.debug_use_spatial_splits = BoolProperty(name="Use Spatial Splits", description="Use BVH spatial splits: longer builder time, faster render",
105             default=False)
106
107     @classmethod
108     def unregister(cls):
109         del bpy.types.Scene.cycles
110
111
112 class CyclesCameraSettings(bpy.types.PropertyGroup):
113     @classmethod
114     def register(cls):
115         bpy.types.Camera.cycles = PointerProperty(type=cls, name="Cycles Camera Settings", description="Cycles camera settings")
116
117         cls.aperture_size = FloatProperty(name="Aperture Size", description="Radius of the aperture for depth of field",
118             default=0.0, min=0.0, max=10.0)
119         cls.aperture_blades = IntProperty(name="Aperture Blades", description="Number of blades in aperture for polygonal bokeh (at least 3)",
120             default=0, min=0, max=100)
121         cls.aperture_rotation = FloatProperty(name="Aperture Rotation", description="Rotation of blades in aperture",
122             default=0, soft_min=-math.pi, soft_max=math.pi, subtype='ANGLE')
123
124     @classmethod
125     def unregister(cls):
126         del bpy.types.Camera.cycles
127
128
129 class CyclesMaterialSettings(bpy.types.PropertyGroup):
130     @classmethod
131     def register(cls):
132         bpy.types.Material.cycles = PointerProperty(type=cls, name="Cycles Material Settings", description="Cycles material settings")
133         cls.sample_as_light = BoolProperty(name="Sample as Lamp", 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", default=True)
134         cls.homogeneous_volume = BoolProperty(name="Homogeneous Volume", description="When using volume rendering, assume volume has the same density everywhere, for faster rendering", default=False)
135
136     @classmethod
137     def unregister(cls):
138         del bpy.types.Material.cycles
139
140
141 class CyclesLampSettings(bpy.types.PropertyGroup):
142     @classmethod
143     def register(cls):
144         bpy.types.Lamp.cycles = PointerProperty(type=cls, name="Cycles Lamp Settings", description="Cycles lamp settings")
145         cls.cast_shadow = BoolProperty(name="Cast Shadow", description="Lamp casts shadows", default=True)
146
147     @classmethod
148     def unregister(cls):
149         del bpy.types.Lamp.cycles
150
151
152 class CyclesWorldSettings(bpy.types.PropertyGroup):
153     @classmethod
154     def register(cls):
155         bpy.types.World.cycles = PointerProperty(type=cls, name="Cycles World Settings", description="Cycles world settings")
156
157     @classmethod
158     def unregister(cls):
159         del bpy.types.World.cycles
160
161
162 class CyclesVisibilitySettings(bpy.types.PropertyGroup):
163     @classmethod
164     def register(cls):
165         bpy.types.Object.cycles_visibility = PointerProperty(type=cls, name="Cycles Visibility Settings", description="Cycles visibility settings")
166
167         cls.camera = BoolProperty(name="Camera", description="Object visibility for camera rays", default=True)
168         cls.diffuse = BoolProperty(name="Diffuse", description="Object visibility for diffuse reflection rays", default=True)
169         cls.glossy = BoolProperty(name="Glossy", description="Object visibility for glossy reflection rays", default=True)
170         cls.transmission = BoolProperty(name="Transmission", description="Object visibility for transmission rays", default=True)
171         cls.shadow = BoolProperty(name="Shadow", description="Object visibility for shadow rays", default=True)
172
173     @classmethod
174     def unregister(cls):
175         del bpy.types.Object.cycles_visibility
176
177
178 class CyclesMeshSettings(bpy.types.PropertyGroup):
179     @classmethod
180     def register(cls):
181         bpy.types.Mesh.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles mesh settings")
182         bpy.types.Curve.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles mesh settings")
183         bpy.types.MetaBall.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles mesh settings")
184
185         cls.displacement_method = EnumProperty(name="Displacement Method", description="Method to use for the displacement",
186             items=enums.displacement_methods, default="BUMP")
187         cls.use_subdivision = BoolProperty(name="Use Subdivision", description="Subdivide mesh for rendering",
188             default=False)
189         cls.dicing_rate = FloatProperty(name="Dicing Rate", description="", default=1.0, min=0.001, max=1000.0)
190
191     @classmethod
192     def unregister(cls):
193         del bpy.types.Mesh.cycles
194         del bpy.types.Curve.cycles
195         del bpy.types.MetaBall.cycles
196
197
198 def register():
199     bpy.utils.register_class(CyclesRenderSettings)
200     bpy.utils.register_class(CyclesCameraSettings)
201     bpy.utils.register_class(CyclesMaterialSettings)
202     bpy.utils.register_class(CyclesLampSettings)
203     bpy.utils.register_class(CyclesWorldSettings)
204     bpy.utils.register_class(CyclesVisibilitySettings)
205     bpy.utils.register_class(CyclesMeshSettings)
206
207
208 def unregister():
209     bpy.utils.unregister_class(CyclesRenderSettings)
210     bpy.utils.unregister_class(CyclesCameraSettings)
211     bpy.utils.unregister_class(CyclesMaterialSettings)
212     bpy.utils.unregister_class(CyclesLampSettings)
213     bpy.utils.unregister_class(CyclesWorldSettings)
214     bpy.utils.unregister_class(CyclesMeshSettings)
215     bpy.utils.unregister_class(CyclesVisibilitySettings)