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