Deep Shadow Buffer
[blender.git] / release / scripts / ui / buttons_data_lamp.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = 'PROPERTIES'
6         __region_type__ = 'WINDOW'
7         __context__ = "data"
8         
9         def poll(self, context):
10                 return context.lamp
11                 
12 class DATA_PT_preview(DataButtonsPanel):
13         __label__ = "Preview"
14
15         def draw(self, context):
16                 self.layout.template_preview(context.lamp)
17         
18 class DATA_PT_context_lamp(DataButtonsPanel):
19         __show_header__ = False
20         
21         def draw(self, context):
22                 layout = self.layout
23                 
24                 ob = context.object
25                 lamp = context.lamp
26                 space = context.space_data
27
28                 split = layout.split(percentage=0.65)
29
30                 if ob:
31                         split.template_ID(ob, "data")
32                         split.itemS()
33                 elif lamp:
34                         split.template_ID(space, "pin_id")
35                         split.itemS()
36
37 class DATA_PT_lamp(DataButtonsPanel):
38         __label__ = "Lamp"
39
40         def draw(self, context):
41                 layout = self.layout
42                 
43                 lamp = context.lamp
44                 
45                 layout.itemR(lamp, "type", expand=True)
46                 
47                 split = layout.split()
48                 
49                 col = split.column()
50                 sub = col.column()
51                 sub.itemR(lamp, "color", text="")
52                 sub.itemR(lamp, "energy")
53
54                 if lamp.type in ('POINT', 'SPOT'):
55                         sub.itemL(text="Falloff:")
56                         sub.itemR(lamp, "falloff_type", text="")
57                         sub.itemR(lamp, "distance")
58
59                         if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
60                                 col.itemL(text="Attenuation Factors:")
61                                 sub = col.column(align=True)
62                                 sub.itemR(lamp, "linear_attenuation", slider=True, text="Linear")
63                                 sub.itemR(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
64                         
65                         col.itemR(lamp, "sphere")
66                         
67                 if lamp.type == 'AREA':
68                         col.itemR(lamp, "distance")
69                         col.itemR(lamp, "gamma")
70         
71                 col = split.column()
72                 col.itemR(lamp, "negative")
73                 col.itemR(lamp, "layer", text="This Layer Only")
74                 col.itemR(lamp, "specular")
75                 col.itemR(lamp, "diffuse")      
76
77 class DATA_PT_sunsky(DataButtonsPanel):
78         __label__ = "Sky & Atmosphere"
79         
80         def poll(self, context):
81                 lamp = context.lamp
82                 return (lamp and lamp.type == 'SUN')
83
84         def draw(self, context):
85                 layout = self.layout
86                 
87                 lamp = context.lamp.sky
88
89                 layout.itemR(lamp, "sky")
90
91                 row = layout.row()
92                 row.active = lamp.sky or lamp.atmosphere
93                 row.itemR(lamp, "atmosphere_turbidity", text="Turbidity")
94                         
95                 split = layout.split()
96                 
97                 col = split.column()
98                 col.active = lamp.sky
99                 col.itemL(text="Blending:")
100                 sub = col.column()
101                 sub.itemR(lamp, "sky_blend_type", text="")
102                 sub.itemR(lamp, "sky_blend", text="Factor")
103                 
104                 col.itemL(text="Color Space:")
105                 sub = col.column()
106                 sub.row().itemR(lamp, "sky_color_space", expand=True)
107                 sub.itemR(lamp, "sky_exposure", text="Exposure")
108                         
109                 col = split.column()
110                 col.active = lamp.sky
111                 col.itemL(text="Horizon:")
112                 sub = col.column()
113                 sub.itemR(lamp, "horizon_brightness", text="Brightness")
114                 sub.itemR(lamp, "spread", text="Spread")
115                 
116                 col.itemL(text="Sun:")
117                 sub = col.column()
118                 sub.itemR(lamp, "sun_brightness", text="Brightness")
119                 sub.itemR(lamp, "sun_size", text="Size")
120                 sub.itemR(lamp, "backscattered_light", slider=True,text="Back Light")
121                 
122                 layout.itemS()
123                 
124                 layout.itemR(lamp, "atmosphere")
125                 
126                 split = layout.split()
127                 
128                 col = split.column()
129                 col.active = lamp.atmosphere
130                 col.itemL(text="Intensity:")
131                 col.itemR(lamp, "sun_intensity", text="Sun")
132                 col.itemR(lamp, "atmosphere_distance_factor", text="Distance")
133                         
134                 col = split.column()
135                 col.active = lamp.atmosphere
136                 col.itemL(text="Scattering:")
137                 sub = col.column(align=True)
138                 sub.itemR(lamp, "atmosphere_inscattering", slider=True, text="Inscattering")
139                 sub.itemR(lamp, "atmosphere_extinction", slider=True ,text="Extinction")
140                 
141 class DATA_PT_shadow(DataButtonsPanel):
142         __label__ = "Shadow"
143         
144         def poll(self, context):
145                 lamp = context.lamp
146                 return (lamp and lamp.type in ('POINT','SUN', 'SPOT', 'AREA'))
147
148         def draw(self, context):
149                 layout = self.layout
150                 
151                 lamp = context.lamp
152
153                 layout.itemR(lamp, "shadow_method", expand=True)
154                 
155                 if lamp.shadow_method != 'NOSHADOW':
156                         split = layout.split()
157                         
158                         col = split.column()
159                         col.itemR(lamp, "shadow_color", text="")
160                         
161                         col = split.column()
162                         col.itemR(lamp, "shadow_layer", text="This Layer Only")
163                         col.itemR(lamp, "only_shadow")
164                 
165                 if lamp.shadow_method == 'RAY_SHADOW':
166                         col = layout.column()
167                         col.itemL(text="Sampling:")
168                         col.row().itemR(lamp, "shadow_ray_sampling_method", expand=True)
169                                 
170                         if lamp.type in ('POINT', 'SUN', 'SPOT'):
171                                 split = layout.split()
172                                 
173                                 col = split.column()
174                                 col.itemR(lamp, "shadow_soft_size", text="Soft Size")
175                                 
176                                 col.itemR(lamp, "shadow_ray_samples", text="Samples")
177                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
178                                         col.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
179                                 col = split.column()
180                                                 
181                         elif lamp.type == 'AREA':
182                                 split = layout.split()
183                                 
184                                 col = split.column()
185                                 sub = split.column(align=True)
186                                 if lamp.shape == 'SQUARE':
187                                         col.itemR(lamp, "shadow_ray_samples_x", text="Samples")
188                                 elif lamp.shape == 'RECTANGLE':
189                                         col.itemR(lamp, "shadow_ray_samples_x", text="Samples X")
190                                         col.itemR(lamp, "shadow_ray_samples_y", text="Samples Y")
191                                         
192                                 if lamp.shadow_ray_sampling_method == 'ADAPTIVE_QMC':
193                                         col.itemR(lamp, "shadow_adaptive_threshold", text="Threshold")
194                                         
195                                 elif lamp.shadow_ray_sampling_method == 'CONSTANT_JITTERED':
196                                         sub.itemR(lamp, "umbra")
197                                         sub.itemR(lamp, "dither")
198                                         sub.itemR(lamp, "jitter")       
199
200                 elif lamp.shadow_method == 'BUFFER_SHADOW':
201                         col = layout.column()
202                         col.itemL(text="Buffer Type:")
203                         col.row().itemR(lamp, "shadow_buffer_type", expand=True)
204
205                         if lamp.shadow_buffer_type in ('REGULAR', 'HALFWAY', 'DEEP'):
206                                 split = layout.split()
207                                 
208                                 col = split.column()
209                                 col.itemL(text="Filter Type:")
210                                 col.itemR(lamp, "shadow_filter_type", text="")
211                                 sub = col.column(align=True)
212                                 sub.itemR(lamp, "shadow_buffer_soft", text="Soft")
213                                 sub.itemR(lamp, "shadow_buffer_bias", text="Bias")
214                                 
215                                 col = split.column()
216                                 col.itemL(text="Sample Buffers:")
217                                 col.itemR(lamp, "shadow_sample_buffers", text="")
218                                 sub = col.column(align=True)
219                                 sub.itemR(lamp, "shadow_buffer_size", text="Size")
220                                 sub.itemR(lamp, "shadow_buffer_samples", text="Samples")
221                                 if lamp.shadow_buffer_type == 'DEEP':
222                                         col.itemR(lamp, "compression_threshold")
223                                 
224                         elif lamp.shadow_buffer_type == 'IRREGULAR':
225                                 layout.itemR(lamp, "shadow_buffer_bias", text="Bias")
226                         
227                         row = layout.row()
228                         row.itemR(lamp, "auto_clip_start", text="Autoclip Start")
229                         sub = row.row()
230                         sub.active = not lamp.auto_clip_start
231                         sub.itemR(lamp, "shadow_buffer_clip_start", text="Clip Start")
232
233                         row = layout.row()
234                         row.itemR(lamp, "auto_clip_end", text="Autoclip End")
235                         sub = row.row()
236                         sub.active = not lamp.auto_clip_end
237                         sub.itemR(lamp, "shadow_buffer_clip_end", text=" Clip End")
238
239 class DATA_PT_area(DataButtonsPanel):
240         __label__ = "Area Shape"
241         
242         def poll(self, context):
243                 lamp = context.lamp
244                 return (lamp and lamp.type == 'AREA')
245
246         def draw(self, context):
247                 layout = self.layout
248                 
249                 lamp = context.lamp
250
251                 split = layout.split()
252                 
253                 col = split.column()
254                 col.row().itemR(lamp, "shape", expand=True)
255                 
256                 sub = col.column(align=True)
257                 if (lamp.shape == 'SQUARE'):
258                         sub.itemR(lamp, "size")
259                 elif (lamp.shape == 'RECTANGLE'):
260                         sub.itemR(lamp, "size", text="Size X")
261                         sub.itemR(lamp, "size_y", text="Size Y")
262
263 class DATA_PT_spot(DataButtonsPanel):
264         __label__ = "Spot Shape"
265         
266         def poll(self, context):
267                 lamp = context.lamp
268                 return (lamp and lamp.type == 'SPOT')
269
270         def draw(self, context):
271                 layout = self.layout
272                 
273                 lamp = context.lamp
274
275                 split = layout.split()
276                 
277                 col = split.column()
278                 sub = col.column()
279                 sub.itemR(lamp, "spot_size", text="Size")
280                 sub.itemR(lamp, "spot_blend", text="Blend", slider=True)
281                 col.itemR(lamp, "square")
282                 
283                 col = split.column()
284                 col.itemR(lamp, "halo")
285                 sub = col.column(align=True)
286                 sub.active = lamp.halo
287                 sub.itemR(lamp, "halo_intensity", text="Intensity")
288                 if lamp.shadow_method == 'BUFFER_SHADOW':
289                         sub.itemR(lamp, "halo_step", text="Step")
290
291 class DATA_PT_falloff_curve(DataButtonsPanel):
292         __label__ = "Falloff Curve"
293         __default_closed__ = True
294         
295         def poll(self, context):
296                 lamp = context.lamp
297
298                 return (lamp and lamp.type in ('POINT', 'SPOT') and lamp.falloff_type == 'CUSTOM_CURVE')
299
300         def draw(self, context):
301                 lamp = context.lamp
302
303                 self.layout.template_curve_mapping(lamp, "falloff_curve")
304
305 bpy.types.register(DATA_PT_context_lamp)
306 bpy.types.register(DATA_PT_preview)
307 bpy.types.register(DATA_PT_lamp)
308 bpy.types.register(DATA_PT_falloff_curve)
309 bpy.types.register(DATA_PT_area)
310 bpy.types.register(DATA_PT_spot)
311 bpy.types.register(DATA_PT_shadow)
312 bpy.types.register(DATA_PT_sunsky)