Sculpt: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24257...
[blender.git] / release / scripts / ui / properties_data_lamp.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 class DataButtonsPanel(bpy.types.Panel):
24     bl_space_type = 'PROPERTIES'
25     bl_region_type = 'WINDOW'
26     bl_context = "data"
27
28     def poll(self, context):
29         return context.lamp
30
31
32 class DATA_PT_preview(DataButtonsPanel):
33     bl_label = "Preview"
34
35     def draw(self, context):
36         self.layout.template_preview(context.lamp)
37
38
39 class DATA_PT_context_lamp(DataButtonsPanel):
40     bl_label = ""
41     bl_show_header = False
42
43     def draw(self, context):
44         layout = self.layout
45
46         ob = context.object
47         lamp = context.lamp
48         space = context.space_data
49
50         split = layout.split(percentage=0.65)
51
52         if ob:
53             split.template_ID(ob, "data")
54             split.itemS()
55         elif lamp:
56             split.template_ID(space, "pin_id")
57             split.itemS()
58
59
60 class DATA_PT_lamp(DataButtonsPanel):
61     bl_label = "Lamp"
62
63     def draw(self, context):
64         layout = self.layout
65
66         lamp = context.lamp
67
68         layout.itemR(lamp, "type", expand=True)
69
70         split = layout.split()
71
72         col = split.column()
73         sub = col.column()
74         sub.itemR(lamp, "color", text="")
75         sub.itemR(lamp, "energy")
76
77         if lamp.type in ('POINT', 'SPOT'):
78             sub.itemL(text="Falloff:")
79             sub.itemR(lamp, "falloff_type", text="")
80             sub.itemR(lamp, "distance")
81
82             if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
83                 col.itemL(text="Attenuation Factors:")
84                 sub = col.column(align=True)
85                 sub.itemR(lamp, "linear_attenuation", slider=True, text="Linear")
86                 sub.itemR(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
87
88             col.itemR(lamp, "sphere")
89
90         if lamp.type == 'AREA':
91             col.itemR(lamp, "distance")
92             col.itemR(lamp, "gamma")
93
94         col = split.column()
95         col.itemR(lamp, "negative")
96         col.itemR(lamp, "layer", text="This Layer Only")
97         col.itemR(lamp, "specular")
98         col.itemR(lamp, "diffuse")
99
100
101 class DATA_PT_sunsky(DataButtonsPanel):
102     bl_label = "Sky & Atmosphere"
103
104     def poll(self, context):
105         lamp = context.lamp
106         return (lamp and lamp.type == 'SUN')
107
108     def draw(self, context):
109         layout = self.layout
110
111         lamp = context.lamp.sky
112
113         layout.itemR(lamp, "sky")
114
115         row = layout.row()
116         row.active = lamp.sky or lamp.atmosphere
117         row.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
118
119         split = layout.split()
120
121         col = split.column()
122         col.active = lamp.sky
123         col.itemL(text="Blending:")
124         sub = col.column()
125         sub.itemR(lamp, "sky_blend_type", text="")
126         sub.itemR(lamp, "sky_blend", text="Factor")
127
128         col.itemL(text="Color Space:")
129         sub = col.column()
130         sub.row().itemR(lamp, "sky_color_space", expand=True)
131         sub.itemR(lamp, "sky_exposure", text="Exposure")
132
133         col = split.column()
134         col.active = lamp.sky
135         col.itemL(text="Horizon:")
136         sub = col.column()
137         sub.itemR(lamp, "horizon_brightness", text="Brightness")
138         sub.itemR(lamp, "spread", text="Spread")
139
140         col.itemL(text="Sun:")
141         sub = col.column()
142         sub.itemR(lamp, "sun_brightness", text="Brightness")
143         sub.itemR(lamp, "sun_size", text="Size")
144         sub.itemR(lamp, "backscattered_light", slider=True, text="Back Light")
145
146         layout.itemS()
147
148         layout.itemR(lamp, "atmosphere")
149
150         split = layout.split()
151
152         col = split.column()
153         col.active = lamp.atmosphere
154         col.itemL(text="Intensity:")
155         col.itemR(lamp, "sun_intensity", text="Sun")
156         col.itemR(lamp, "atmosphere_distance_factor", text="Distance")
157
158         col = split.column()
159         col.active = lamp.atmosphere
160         col.itemL(text="Scattering:")
161         sub = col.column(align=True)
162         sub.itemR(lamp, "atmosphere_inscattering", slider=True, text="Inscattering")
163         sub.itemR(lamp, "atmosphere_extinction", slider=True, text="Extinction")
164
165
166 class DATA_PT_shadow(DataButtonsPanel):
167     bl_label = "Shadow"
168
169     def poll(self, context):
170         lamp = context.lamp
171         return (lamp and lamp.type in ('POINT', 'SUN', 'SPOT', 'AREA'))
172
173     def draw(self, context):
174         layout = self.layout
175
176         lamp = context.lamp
177
178         layout.itemR(lamp, "shadow_method", expand=True)
179
180         if lamp.shadow_method != 'NOSHADOW':
181             split = layout.split()
182
183             col = split.column()
184             col.itemR(lamp, "shadow_color", text="")
185
186             col = split.column()
187             col.itemR(lamp, "shadow_layer", text="This Layer Only")
188             col.itemR(lamp, "only_shadow")
189
190         if lamp.shadow_method == 'RAY_SHADOW':
191             col = layout.column()
192             col.itemL(text="Sampling:")
193             col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
194
195             if lamp.type in ('POINT', 'SUN', 'SPOT'):
196                 split = layout.split()
197
198                 col = split.column()
199                 col.itemR(lamp, "shadow_soft_size", text="Soft Size")
200
201                 col.itemR(lamp, "shadow_ray_samples", text="Samples")
202                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
203                     col.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
204                 col = split.column()
205
206             elif lamp.type == 'AREA':
207                 split = layout.split()
208
209                 col = split.column()
210                 sub = split.column(align=True)
211                 if lamp.shape == 'SQUARE':
212                     col.itemR(lamp, "shadow_ray_samples_x", text="Samples")
213                 elif lamp.shape == 'RECTANGLE':
214                     col.itemR(lamp, "shadow_ray_samples_x", text="Samples X")
215                     col.itemR(lamp, "shadow_ray_samples_y", text="Samples Y")
216
217                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
218                     col.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
219
220                 elif lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
221                     sub.itemR(lamp, "umbra")
222                     sub.itemR(lamp, "dither")
223                     sub.itemR(lamp, "jitter")
224
225         elif lamp.shadow_method == 'BUFFER_SHADOW':
226             col = layout.column()
227             col.itemL(text="Buffer Type:")
228             col.row().itemR(lamp, "shadow_buffer_type", expand=True)
229
230             if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY', 'DEEP'):
231                 split = layout.split()
232
233                 col = split.column()
234                 col.itemL(text="Filter Type:")
235                 col.itemR(lamp, "shadow_filter_type", text="")
236                 sub = col.column(align=True)
237                 sub.itemR(lamp, "shadow_buffer_soft", text="Soft")
238                 sub.itemR(lamp, "shadow_buffer_bias", text="Bias")
239
240                 col = split.column()
241                 col.itemL(text="Sample Buffers:")
242                 col.itemR(lamp, "shadow_sample_buffers", text="")
243                 sub = col.column(align=True)
244                 sub.itemR(lamp, "shadow_buffer_size", text="Size")
245                 sub.itemR(lamp, "shadow_buffer_samples", text="Samples")
246                 if lamp.shadow_buffer_type == 'DEEP':
247                     col.itemR(lamp, "compression_threshold")
248
249             elif lamp.shadow_buffer_type == 'IRREGULAR':
250                 layout.itemR(lamp, "shadow_buffer_bias", text="Bias")
251
252             row = layout.row()
253             row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
254             sub = row.row()
255             sub.active = not lamp.auto_clip_start
256             sub.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")
257
258             row = layout.row()
259             row.itemR(lamp, "auto_clip_end", text="Autoclip End")
260             sub = row.row()
261             sub.active = not lamp.auto_clip_end
262             sub.itemR(lamp, "shadow_buffer_clip_end", text=" Clip End")
263
264
265 class DATA_PT_area(DataButtonsPanel):
266     bl_label = "Area Shape"
267
268     def poll(self, context):
269         lamp = context.lamp
270         return (lamp and lamp.type == 'AREA')
271
272     def draw(self, context):
273         layout = self.layout
274
275         lamp = context.lamp
276
277         split = layout.split()
278
279         col = split.column()
280         col.row().itemR(lamp, "shape", expand=True)
281
282         sub = col.column(align=True)
283         if (lamp.shape == 'SQUARE'):
284             sub.itemR(lamp, "size")
285         elif (lamp.shape == 'RECTANGLE'):
286             sub.itemR(lamp, "size", text="Size X")
287             sub.itemR(lamp, "size_y", text="Size Y")
288
289
290 class DATA_PT_spot(DataButtonsPanel):
291     bl_label = "Spot Shape"
292
293     def poll(self, context):
294         lamp = context.lamp
295         return (lamp and lamp.type == 'SPOT')
296
297     def draw(self, context):
298         layout = self.layout
299
300         lamp = context.lamp
301
302         split = layout.split()
303
304         col = split.column()
305         sub = col.column()
306         sub.itemR(lamp, "spot_size", text="Size")
307         sub.itemR(lamp, "spot_blend", text="Blend", slider=True)
308         col.itemR(lamp, "square")
309
310         col = split.column()
311         col.itemR(lamp, "halo")
312         sub = col.column(align=True)
313         sub.active = lamp.halo
314         sub.itemR(lamp, "halo_intensity", text="Intensity")
315         if lamp.shadow_method == 'BUFFER_SHADOW':
316             sub.itemR(lamp, "halo_step", text="Step")
317
318
319 class DATA_PT_falloff_curve(DataButtonsPanel):
320     bl_label = "Falloff Curve"
321     bl_default_closed = True
322
323     def poll(self, context):
324         lamp = context.lamp
325
326         return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE')
327
328     def draw(self, context):
329         lamp = context.lamp
330
331         self.layout.template_curve_mapping(lamp, "falloff_curve")
332
333 bpy.types.register(DATA_PT_context_lamp)
334 bpy.types.register(DATA_PT_preview)
335 bpy.types.register(DATA_PT_lamp)
336 bpy.types.register(DATA_PT_falloff_curve)
337 bpy.types.register(DATA_PT_area)
338 bpy.types.register(DATA_PT_spot)
339 bpy.types.register(DATA_PT_shadow)
340 bpy.types.register(DATA_PT_sunsky)