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