4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
27 #include "RNA_define.h"
28 #include "RNA_types.h"
30 #include "rna_internal.h"
32 #include "DNA_lamp_types.h"
33 #include "DNA_material_types.h"
34 #include "DNA_texture_types.h"
38 #include "MEM_guardedalloc.h"
40 #include "BKE_depsgraph.h"
42 #include "BKE_texture.h"
47 static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value)
49 Lamp *la= (Lamp*)ptr->data;
51 CLAMP(value, 512, 10240);
53 la->bufsize &= (~15); /* round to multiple of 16 */
56 static PointerRNA rna_Lamp_sky_settings_get(PointerRNA *ptr)
58 return rna_pointer_inherit_refine(ptr, &RNA_LampSkySettings, ptr->id.data);
61 static void rna_Lamp_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
63 Lamp *la= (Lamp*)ptr->data;
64 rna_iterator_array_begin(iter, (void*)la->mtex, sizeof(MTex*), MAX_MTEX, 0, NULL);
67 static PointerRNA rna_Lamp_active_texture_get(PointerRNA *ptr)
69 Lamp *la= (Lamp*)ptr->data;
72 tex= give_current_lamp_texture(la);
73 return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
76 static void rna_Lamp_active_texture_set(PointerRNA *ptr, PointerRNA value)
78 Lamp *la= (Lamp*)ptr->data;
80 set_current_lamp_texture(la, value.data);
83 static StructRNA* rna_Lamp_refine(struct PointerRNA *ptr)
85 Lamp *la= (Lamp*)ptr->data;
89 return &RNA_PointLamp;
103 static void rna_Lamp_update(bContext *C, PointerRNA *ptr)
105 Lamp *la= ptr->id.data;
107 DAG_id_flush_update(&la->id, 0);
108 WM_event_add_notifier(C, NC_LAMP|ND_LIGHTING, la);
111 static void rna_Lamp_draw_update(bContext *C, PointerRNA *ptr)
113 Lamp *la= ptr->id.data;
115 DAG_id_flush_update(&la->id, 0);
116 WM_event_add_notifier(C, NC_LAMP|ND_LIGHTING_DRAW, la);
119 static void rna_Lamp_sky_update(bContext *C, PointerRNA *ptr)
121 Lamp *la= ptr->id.data;
123 DAG_id_flush_update(&la->id, 0);
124 WM_event_add_notifier(C, NC_LAMP|ND_SKY, la);
129 static void rna_def_lamp_mtex(BlenderRNA *brna)
134 static EnumPropertyItem prop_texture_coordinates_items[] = {
135 {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates."},
136 {TEXCO_VIEW, "VIEW", 0, "View", "Uses view coordinates for the texture coordinates."},
137 {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates."},
138 {0, NULL, 0, NULL, NULL}};
140 srna= RNA_def_struct(brna, "LampTextureSlot", "TextureSlot");
141 RNA_def_struct_sdna(srna, "MTex");
142 RNA_def_struct_ui_text(srna, "Lamp Texture Slot", "Texture slot for textures in a Lamp datablock.");
144 prop= RNA_def_property(srna, "texture_coordinates", PROP_ENUM, PROP_NONE);
145 RNA_def_property_enum_sdna(prop, NULL, "texco");
146 RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
147 RNA_def_property_ui_text(prop, "Texture Coordinates", "");
149 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
150 RNA_def_property_pointer_sdna(prop, NULL, "object");
151 RNA_def_property_struct_type(prop, "Object");
152 RNA_def_property_flag(prop, PROP_EDITABLE);
153 RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates.");
155 prop= RNA_def_property(srna, "map_color", PROP_BOOLEAN, PROP_NONE);
156 RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_COL);
157 RNA_def_property_ui_text(prop, "Color", "Lets the texture affect the basic color of the lamp.");
158 RNA_def_property_update(prop, 0, "rna_Lamp_update");
160 prop= RNA_def_property(srna, "map_shadow", PROP_BOOLEAN, PROP_NONE);
161 RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_SHAD);
162 RNA_def_property_ui_text(prop, "Shadow", "Lets the texture affect the shadow color of the lamp.");
163 RNA_def_property_update(prop, 0, "rna_Lamp_update");
165 prop= RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_NONE);
166 RNA_def_property_float_sdna(prop, NULL, "colfac");
167 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
168 RNA_def_property_ui_text(prop, "Color Factor", "Amount texture affects color values.");
169 RNA_def_property_update(prop, 0, "rna_Lamp_update");
171 prop= RNA_def_property(srna, "shadow_factor", PROP_FLOAT, PROP_NONE);
172 RNA_def_property_float_sdna(prop, NULL, "shadowfac");
173 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
174 RNA_def_property_ui_text(prop, "Shadow Factor", "Amount texture affects shadow.");
175 RNA_def_property_update(prop, 0, "rna_Lamp_update");
178 static void rna_def_lamp_sky_settings(BlenderRNA *brna)
183 static EnumPropertyItem prop_skycolorspace_items[] = {
184 {0, "SMPTE", 0, "SMPTE", ""},
185 {1, "REC709", 0, "REC709", ""},
186 {2, "CIE", 0, "CIE", ""},
187 {0, NULL, 0, NULL, NULL}};
189 static EnumPropertyItem prop_blendmode_items[] = {
190 {0, "MIX", 0, "Mix", ""},
191 {1, "ADD", 0, "Add", ""},
192 {2, "MULTIPLY", 0, "Multiply", ""},
193 {3, "SUBTRACT", 0, "Subtract", ""},
194 {4, "SCREEN", 0, "Screen", ""},
195 {5, "DIVIDE", 0, "Divide", ""},
196 {6, "DIFFERENCE", 0, "Difference", ""},
197 {7, "DARKEN", 0, "Darken", ""},
198 {8, "LIGHTEN", 0, "Lighten", ""},
199 {9, "OVERLAY", 0, "Overlay", ""},
200 {10, "DODGE", 0, "Dodge", ""},
201 {11, "BURN", 0, "Burn", ""},
202 {12, "HUE", 0, "Hue", ""},
203 {13, "SATURATION", 0, "Saturation", ""},
204 {14, "VALUE", 0, "Value", ""},
205 {15, "COLOR", 0, "Color", ""},
206 {0, NULL, 0, NULL, NULL}};
208 srna= RNA_def_struct(brna, "LampSkySettings", NULL);
209 RNA_def_struct_sdna(srna, "Lamp");
210 RNA_def_struct_nested(brna, srna, "SunLamp");
211 RNA_def_struct_ui_text(srna, "Lamp Sky Settings", "Sky related settings for a sun lamp.");
213 prop= RNA_def_property(srna, "sky_color_space", PROP_ENUM, PROP_NONE);
214 RNA_def_property_enum_sdna(prop, NULL, "sky_colorspace");
215 RNA_def_property_enum_items(prop, prop_skycolorspace_items);
216 RNA_def_property_ui_text(prop, "Sky Color Space", "Color space to use for internal XYZ->RGB color conversion.");
217 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
219 prop= RNA_def_property(srna, "sky_blend_type", PROP_ENUM, PROP_NONE);
220 RNA_def_property_enum_sdna(prop, NULL, "skyblendtype");
221 RNA_def_property_enum_items(prop, prop_blendmode_items);
222 RNA_def_property_ui_text(prop, "Sky Blend Mode", "Blend mode for combining sun sky with world sky.");
223 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
227 prop= RNA_def_property(srna, "horizon_brightness", PROP_FLOAT, PROP_NONE);
228 RNA_def_property_range(prop, 0.0f, 20.0f);
229 RNA_def_property_ui_text(prop, "Horizon Brightness", "Horizon brightness.");
230 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
232 prop= RNA_def_property(srna, "spread", PROP_FLOAT, PROP_NONE);
233 RNA_def_property_range(prop, 0.0f, 10.0f);
234 RNA_def_property_ui_text(prop, "Horizon Spread", "Horizon Spread.");
235 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
237 prop= RNA_def_property(srna, "sun_brightness", PROP_FLOAT, PROP_NONE);
238 RNA_def_property_range(prop, 0.0f, 10.0f);
239 RNA_def_property_ui_text(prop, "Sun Brightness", "Sun brightness.");
240 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
242 prop= RNA_def_property(srna, "sun_size", PROP_FLOAT, PROP_NONE);
243 RNA_def_property_range(prop, 0.0f, 10.0f);
244 RNA_def_property_ui_text(prop, "Sun Size", "Sun size.");
245 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
247 prop= RNA_def_property(srna, "backscattered_light", PROP_FLOAT, PROP_NONE);
248 RNA_def_property_range(prop, -1.0f, 1.0f);
249 RNA_def_property_ui_text(prop, "Backscattered Light", "Backscattered light.");
250 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
252 prop= RNA_def_property(srna, "sun_intensity", PROP_FLOAT, PROP_NONE);
253 RNA_def_property_range(prop, 0.0f, 10.0f);
254 RNA_def_property_ui_text(prop, "Sun Intensity", "Sun intensity.");
255 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
257 prop= RNA_def_property(srna, "atmosphere_turbidity", PROP_FLOAT, PROP_NONE);
258 RNA_def_property_float_sdna(prop, NULL, "atm_turbidity");
259 RNA_def_property_range(prop, 1.0f, 30.0f);
260 RNA_def_property_ui_text(prop, "Atmosphere Turbidity", "Sky turbidity.");
261 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
263 prop= RNA_def_property(srna, "atmosphere_inscattering", PROP_FLOAT, PROP_NONE);
264 RNA_def_property_float_sdna(prop, NULL, "atm_inscattering_factor");
265 RNA_def_property_range(prop, 0.0f, 1.0f);
266 RNA_def_property_ui_text(prop, "Atmosphere Inscatter", "Scatter contribution factor.");
267 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
269 prop= RNA_def_property(srna, "atmosphere_extinction", PROP_FLOAT, PROP_NONE);
270 RNA_def_property_float_sdna(prop, NULL, "atm_extinction_factor");
271 RNA_def_property_range(prop, 0.0f, 1.0f);
272 RNA_def_property_ui_text(prop, "Atmosphere Extinction", "Extinction scattering contribution factor.");
273 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
275 prop= RNA_def_property(srna, "atmosphere_distance_factor", PROP_FLOAT, PROP_NONE);
276 RNA_def_property_float_sdna(prop, NULL, "atm_distance_factor");
277 RNA_def_property_range(prop, 0.0f, 500.0f);
278 RNA_def_property_ui_text(prop, "Atmosphere Distance Factor", "Multiplier to convert blender units to physical distance.");
279 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
281 prop= RNA_def_property(srna, "sky_blend", PROP_FLOAT, PROP_NONE);
282 RNA_def_property_float_sdna(prop, NULL, "skyblendfac");
283 RNA_def_property_range(prop, 0.0f, 2.0f);
284 RNA_def_property_ui_text(prop, "Sky Blend", "Blend factor with sky.");
285 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
287 prop= RNA_def_property(srna, "sky_exposure", PROP_FLOAT, PROP_NONE);
288 RNA_def_property_range(prop, 0.0f, 20.0f);
289 RNA_def_property_ui_text(prop, "Sky Exposure", "Strength of sky shading exponential exposure correction.");
290 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
294 prop= RNA_def_property(srna, "sky", PROP_BOOLEAN, PROP_NONE);
295 RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_SKY);
296 RNA_def_property_ui_text(prop, "Sky", "Apply sun effect on sky.");
297 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
299 prop= RNA_def_property(srna, "atmosphere", PROP_BOOLEAN, PROP_NONE);
300 RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_AP);
301 RNA_def_property_ui_text(prop, "Atmosphere", "Apply sun effect on atmosphere.");
302 RNA_def_property_update(prop, 0, "rna_Lamp_sky_update");
305 static void rna_def_lamp(BlenderRNA *brna)
310 static EnumPropertyItem prop_type_items[] = {
311 {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source."},
312 {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source."},
313 {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source."},
314 {LA_HEMI, "HEMI", 0, "Hemi", "180 degree constant light source."},
315 {LA_AREA, "AREA", 0, "Area", "Directional area light source."},
316 {0, NULL, 0, NULL, NULL}};
318 srna= RNA_def_struct(brna, "Lamp", "ID");
319 RNA_def_struct_refine_func(srna, "rna_Lamp_refine");
320 RNA_def_struct_ui_text(srna, "Lamp", "Lamp datablock for lighting a scene.");
321 RNA_def_struct_ui_icon(srna, ICON_LAMP_DATA);
323 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
324 RNA_def_property_enum_items(prop, prop_type_items);
325 RNA_def_property_ui_text(prop, "Type", "Type of Lamp.");
326 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
328 prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
329 RNA_def_property_float_sdna(prop, NULL, "dist");
330 RNA_def_property_ui_range(prop, 0, 1000, 1.0, 2);
331 RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point.");
332 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
334 prop= RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
335 RNA_def_property_ui_range(prop, 0, 10.0, 0.1, 2);
336 RNA_def_property_ui_text(prop, "Energy", "Amount of light that the lamp emits.");
337 RNA_def_property_update(prop, 0, "rna_Lamp_update");
339 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
340 RNA_def_property_float_sdna(prop, NULL, "r");
341 RNA_def_property_array(prop, 3);
342 RNA_def_property_ui_text(prop, "Color", "Light color.");
343 RNA_def_property_update(prop, 0, "rna_Lamp_update");
345 prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE);
346 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER);
347 RNA_def_property_ui_text(prop, "Layer", "Illuminates objects only on the same layer the lamp is on.");
348 RNA_def_property_update(prop, 0, "rna_Lamp_update");
350 prop= RNA_def_property(srna, "negative", PROP_BOOLEAN, PROP_NONE);
351 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_NEG);
352 RNA_def_property_ui_text(prop, "Negative", "Lamp casts negative light.");
353 RNA_def_property_update(prop, 0, "rna_Lamp_update");
355 prop= RNA_def_property(srna, "specular", PROP_BOOLEAN, PROP_NONE);
356 RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_SPEC);
357 RNA_def_property_ui_text(prop, "Specular", "Lamp creates specular highlights.");
358 RNA_def_property_update(prop, 0, "rna_Lamp_update");
360 prop= RNA_def_property(srna, "diffuse", PROP_BOOLEAN, PROP_NONE);
361 RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_DIFF);
362 RNA_def_property_ui_text(prop, "Diffuse", "Lamp does diffuse shading.");
363 RNA_def_property_update(prop, 0, "rna_Lamp_update");
366 rna_def_animdata_common(srna);
369 rna_def_mtex_common(srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get",
370 "rna_Lamp_active_texture_set", "LampTextureSlot", "rna_Lamp_update");
373 static void rna_def_lamp_falloff(StructRNA *srna)
377 static EnumPropertyItem prop_fallofftype_items[] = {
378 {LA_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", ""},
379 {LA_FALLOFF_INVLINEAR, "INVERSE_LINEAR", 0, "Inverse Linear", ""},
380 {LA_FALLOFF_INVSQUARE, "INVERSE_SQUARE", 0, "Inverse Square", ""},
381 {LA_FALLOFF_CURVE, "CUSTOM_CURVE", 0, "Custom Curve", ""},
382 {LA_FALLOFF_SLIDERS, "LINEAR_QUADRATIC_WEIGHTED", 0, "Lin/Quad Weighted", ""},
383 {0, NULL, 0, NULL, NULL}};
385 prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
386 RNA_def_property_enum_items(prop, prop_fallofftype_items);
387 RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance.");
388 RNA_def_property_update(prop, 0, "rna_Lamp_update");
390 prop= RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
391 RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
392 RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve");
393 RNA_def_property_update(prop, 0, "rna_Lamp_update");
395 prop= RNA_def_property(srna, "sphere", PROP_BOOLEAN, PROP_NONE);
396 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SPHERE);
397 RNA_def_property_ui_text(prop, "Sphere", "Sets light intensity to zero beyond lamp distance.");
398 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
400 prop= RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_NONE);
401 RNA_def_property_float_sdna(prop, NULL, "att1");
402 RNA_def_property_range(prop, 0.0f, 1.0f);
403 RNA_def_property_ui_text(prop, "Linear Attenuation", "Linear distance attentuation.");
404 RNA_def_property_update(prop, 0, "rna_Lamp_update");
406 prop= RNA_def_property(srna, "quadratic_attenuation", PROP_FLOAT, PROP_NONE);
407 RNA_def_property_float_sdna(prop, NULL, "att2");
408 RNA_def_property_range(prop, 0.0f, 1.0f);
409 RNA_def_property_ui_text(prop, "Quadratic Attenuation", "Quadratic distance attentuation.");
410 RNA_def_property_update(prop, 0, "rna_Lamp_update");
413 static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area)
417 static EnumPropertyItem prop_shadow_items[] = {
418 {0, "NOSHADOW", 0, "No Shadow", ""},
419 {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow."},
420 {0, NULL, 0, NULL, NULL}};
422 static EnumPropertyItem prop_spot_shadow_items[] = {
423 {0, "NOSHADOW", 0, "No Shadow", ""},
424 {LA_SHAD_BUF, "BUFFER_SHADOW", 0, "Buffer Shadow", "Lets spotlight produce shadows using shadow buffer."},
425 {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow."},
426 {0, NULL, 0, NULL, NULL}};
428 static EnumPropertyItem prop_ray_sampling_method_items[] = {
429 {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""},
430 {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""},
431 {0, NULL, 0, NULL, NULL}};
433 static EnumPropertyItem prop_spot_ray_sampling_method_items[] = {
434 {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""},
435 {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""},
436 {LA_SAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", ""},
437 {0, NULL, 0, NULL, NULL}};
439 prop= RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
440 RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
441 RNA_def_property_enum_items(prop, (spot)? prop_spot_shadow_items: prop_shadow_items);
442 RNA_def_property_ui_text(prop, "Shadow Method", "Method to compute lamp shadow with.");
443 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
445 prop= RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR);
446 RNA_def_property_float_sdna(prop, NULL, "shdwr");
447 RNA_def_property_array(prop, 3);
448 RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the lamp.");
449 RNA_def_property_update(prop, 0, "rna_Lamp_update");
451 prop= RNA_def_property(srna, "only_shadow", PROP_BOOLEAN, PROP_NONE);
452 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_ONLYSHADOW);
453 RNA_def_property_ui_text(prop, "Only Shadow", "Causes light to cast shadows only without illuminating objects.");
454 RNA_def_property_update(prop, 0, "rna_Lamp_update");
456 prop= RNA_def_property(srna, "shadow_ray_sampling_method", PROP_ENUM, PROP_NONE);
457 RNA_def_property_enum_sdna(prop, NULL, "ray_samp_method");
458 RNA_def_property_enum_items(prop, (area)? prop_spot_ray_sampling_method_items: prop_ray_sampling_method_items);
459 RNA_def_property_ui_text(prop, "Shadow Ray Sampling Method", "Method for generating shadow samples: Adaptive QMC is fastest, Constant QMC is less noisy but slower.");
460 RNA_def_property_update(prop, 0, "rna_Lamp_update");
462 prop= RNA_def_property(srna, (area)? "shadow_ray_samples_x": "shadow_ray_samples", PROP_INT, PROP_NONE);
463 RNA_def_property_int_sdna(prop, NULL, "ray_samp");
464 RNA_def_property_range(prop, 1, 64);
465 RNA_def_property_ui_text(prop, (area)? "Shadow Ray Samples": "Shadow Ray Samples X","Amount of samples taken extra (samples x samples).");
466 RNA_def_property_update(prop, 0, "rna_Lamp_update");
469 prop= RNA_def_property(srna, "shadow_ray_samples_y", PROP_INT, PROP_NONE);
470 RNA_def_property_int_sdna(prop, NULL, "ray_sampy");
471 RNA_def_property_range(prop, 1, 64);
472 RNA_def_property_ui_text(prop, "Shadow Ray Samples Y", "Amount of samples taken extra (samples x samples).");
473 RNA_def_property_update(prop, 0, "rna_Lamp_update");
476 prop= RNA_def_property(srna, "shadow_adaptive_threshold", PROP_FLOAT, PROP_NONE);
477 RNA_def_property_float_sdna(prop, NULL, "adapt_thresh");
478 RNA_def_property_range(prop, 0.0f, 1.0f);
479 RNA_def_property_ui_text(prop, "Shadow Adaptive Threshold", "Threshold for Adaptive Sampling (Raytraced shadows).");
480 RNA_def_property_update(prop, 0, "rna_Lamp_update");
482 prop= RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE);
483 RNA_def_property_float_sdna(prop, NULL, "area_size");
484 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
485 RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows).");
486 RNA_def_property_update(prop, 0, "rna_Lamp_update");
488 prop= RNA_def_property(srna, "shadow_layer", PROP_BOOLEAN, PROP_NONE);
489 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER_SHADOW);
490 RNA_def_property_ui_text(prop, "Shadow Layer", "Causes only objects on the same layer to cast shadows.");
491 RNA_def_property_update(prop, 0, "rna_Lamp_update");
494 static void rna_def_point_lamp(BlenderRNA *brna)
498 srna= RNA_def_struct(brna, "PointLamp", "Lamp");
499 RNA_def_struct_sdna(srna, "Lamp");
500 RNA_def_struct_ui_text(srna, "Point Lamp", "Omnidirectional point lamp.");
501 RNA_def_struct_ui_icon(srna, ICON_LAMP_POINT);
503 rna_def_lamp_falloff(srna);
504 rna_def_lamp_shadow(srna, 0, 0);
507 static void rna_def_area_lamp(BlenderRNA *brna)
512 static EnumPropertyItem prop_areashape_items[] = {
513 {LA_AREA_SQUARE, "SQUARE", 0, "Square", ""},
514 {LA_AREA_RECT, "RECTANGLE", 0, "Rectangle", ""},
515 {0, NULL, 0, NULL, NULL}};
517 srna= RNA_def_struct(brna, "AreaLamp", "Lamp");
518 RNA_def_struct_sdna(srna, "Lamp");
519 RNA_def_struct_ui_text(srna, "Area Lamp", "Directional area lamp.");
520 RNA_def_struct_ui_icon(srna, ICON_LAMP_AREA);
522 rna_def_lamp_shadow(srna, 0, 1);
524 prop= RNA_def_property(srna, "umbra", PROP_BOOLEAN, PROP_NONE);
525 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_UMBRA);
526 RNA_def_property_ui_text(prop, "Umbra", "Emphasize parts that are fully shadowed (Constant Jittered sampling).");
527 RNA_def_property_update(prop, 0, "rna_Lamp_update");
529 prop= RNA_def_property(srna, "dither", PROP_BOOLEAN, PROP_NONE);
530 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_DITHER);
531 RNA_def_property_ui_text(prop, "Dither", "Use 2x2 dithering for sampling (Constant Jittered sampling).");
532 RNA_def_property_update(prop, 0, "rna_Lamp_update");
534 prop= RNA_def_property(srna, "jitter", PROP_BOOLEAN, PROP_NONE);
535 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_JITTER);
536 RNA_def_property_ui_text(prop, "Jitter", "Use noise for sampling (Constant Jittered sampling).");
537 RNA_def_property_update(prop, 0, "rna_Lamp_update");
539 prop= RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
540 RNA_def_property_enum_sdna(prop, NULL, "area_shape");
541 RNA_def_property_enum_items(prop, prop_areashape_items);
542 RNA_def_property_ui_text(prop, "Shape", "Shape of the area lamp.");
543 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
545 prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE);
546 RNA_def_property_float_sdna(prop, NULL, "area_size");
547 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
548 RNA_def_property_ui_text(prop, "Size", "Size of the area of the area Lamp, X direction size for Rectangle shapes.");
549 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
551 prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE);
552 RNA_def_property_float_sdna(prop, NULL, "area_sizey");
553 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
554 RNA_def_property_ui_text(prop, "Size Y", "Size of the area of the area Lamp in the Y direction for Rectangle shapes.");
555 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
557 prop= RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
558 RNA_def_property_float_sdna(prop, NULL, "k");
559 RNA_def_property_ui_range(prop, 0.001, 2.0, 0.1, 3);
560 RNA_def_property_ui_text(prop, "Gamma", "Light gamma correction value.");
561 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
564 static void rna_def_spot_lamp(BlenderRNA *brna)
569 static EnumPropertyItem prop_shadbuftype_items[] = {
570 {LA_SHADBUF_REGULAR , "REGULAR", 0, "Classical", "Classic shadow buffer."},
571 {LA_SHADBUF_HALFWAY, "HALFWAY", 0, "Classic-Halfway", "Regular buffer, averaging the closest and 2nd closest Z value to reducing bias artifaces."},
572 {LA_SHADBUF_IRREGULAR, "IRREGULAR", 0, "Irregular", "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing."},
573 {0, NULL, 0, NULL, NULL}};
575 static EnumPropertyItem prop_shadbuffiltertype_items[] = {
576 {LA_SHADBUF_BOX , "BOX", 0, "Box", "Apply the Box filter to shadow buffer samples."},
577 {LA_SHADBUF_TENT, "TENT", 0, "Tent", "Apply the Tent Filter to shadow buffer samples."},
578 {LA_SHADBUF_GAUSS, "GAUSS", 0, "Gauss", "Apply the Gauss filter to shadow buffer samples."},
579 {0, NULL, 0, NULL, NULL}};
581 static EnumPropertyItem prop_numbuffer_items[] = {
582 {1, "BUFFERS_1", 0, "1", "Only one buffer rendered."},
583 {4, "BUFFERS_4", 0, "4", "Renders 4 buffers for better AA, this quadruples memory usage."},
584 {9, "BUFFERS_9", 0, "9", "Renders 9 buffers for better AA, this uses nine times more memory."},
585 {0, NULL, 0, NULL, NULL}};
587 srna= RNA_def_struct(brna, "SpotLamp", "Lamp");
588 RNA_def_struct_sdna(srna, "Lamp");
589 RNA_def_struct_ui_text(srna, "Spot Lamp", "Directional cone lamp.");
590 RNA_def_struct_ui_icon(srna, ICON_LAMP_SPOT);
592 rna_def_lamp_falloff(srna);
593 rna_def_lamp_shadow(srna, 1, 0);
595 prop= RNA_def_property(srna, "square", PROP_BOOLEAN, PROP_NONE);
596 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE);
597 RNA_def_property_ui_text(prop, "Square", "Casts a square spot light shape.");
598 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
600 prop= RNA_def_property(srna, "halo", PROP_BOOLEAN, PROP_NONE);
601 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_HALO);
602 RNA_def_property_ui_text(prop, "Halo", "Renders spotlight with a volumetric halo (Buffer Shadows).");
603 RNA_def_property_update(prop, 0, "rna_Lamp_update");
605 prop= RNA_def_property(srna, "halo_intensity", PROP_FLOAT, PROP_NONE);
606 RNA_def_property_float_sdna(prop, NULL, "haint");
607 RNA_def_property_ui_range(prop, 0, 5.0, 0.1, 3);
608 RNA_def_property_ui_text(prop, "Halo Intensity", "Brightness of the spotlight's halo cone (Buffer Shadows).");
609 RNA_def_property_update(prop, 0, "rna_Lamp_update");
611 prop= RNA_def_property(srna, "halo_step", PROP_INT, PROP_NONE);
612 RNA_def_property_int_sdna(prop, NULL, "shadhalostep");
613 RNA_def_property_range(prop, 0, 12);
614 RNA_def_property_ui_text(prop, "Halo Step", "Volumetric halo sampling frequency.");
615 RNA_def_property_update(prop, 0, "rna_Lamp_update");
617 prop= RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE);
618 RNA_def_property_int_sdna(prop, NULL, "bufsize");
619 RNA_def_property_range(prop, 512, 10240);
620 RNA_def_property_ui_text(prop, "Shadow Buffer Size", "Resolution of the shadow buffer, higher values give crisper shadows but use more memory");
621 RNA_def_property_int_funcs(prop, NULL, "rna_Lamp_buffer_size_set", NULL);
622 RNA_def_property_update(prop, 0, "rna_Lamp_update");
624 prop= RNA_def_property(srna, "shadow_filter_type", PROP_ENUM, PROP_NONE);
625 RNA_def_property_enum_sdna(prop, NULL, "filtertype");
626 RNA_def_property_enum_items(prop, prop_shadbuffiltertype_items);
627 RNA_def_property_ui_text(prop, "Shadow Filter Type", "Type of shadow filter (Buffer Shadows).");
628 RNA_def_property_update(prop, 0, "rna_Lamp_update");
630 prop= RNA_def_property(srna, "shadow_sample_buffers", PROP_ENUM, PROP_NONE);
631 RNA_def_property_enum_sdna(prop, NULL, "buffers");
632 RNA_def_property_enum_items(prop, prop_numbuffer_items);
633 RNA_def_property_ui_text(prop, "Shadow Sample Buffers", "Number of shadow buffers to render for better AA, this increases memory usage.");
634 RNA_def_property_update(prop, 0, "rna_Lamp_update");
636 prop= RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE);
637 RNA_def_property_float_sdna(prop, NULL, "spotblend");
638 RNA_def_property_range(prop, 0.0f ,1.0f);
639 RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge.");
640 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
642 prop= RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_NONE);
643 RNA_def_property_float_sdna(prop, NULL, "spotsize");
644 RNA_def_property_range(prop, 1.0f ,180.0f);
645 RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam in degrees.");
646 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
648 prop= RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE);
649 RNA_def_property_float_sdna(prop, NULL, "clipsta");
650 RNA_def_property_range(prop, 0.0f, 9999.0f);
651 RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start", "Shadow map clip start: objects closer will not generate shadows");
652 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
654 prop= RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_DISTANCE);
655 RNA_def_property_float_sdna(prop, NULL, "clipend");
656 RNA_def_property_range(prop, 0.0f, 9999.0f);
657 RNA_def_property_ui_text(prop, "Shadow Buffer Clip End", "Shadow map clip end beyond which objects will not generate shadows.");
658 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
660 prop= RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE);
661 RNA_def_property_float_sdna(prop, NULL, "bias");
662 RNA_def_property_range(prop, 0.0f, 5.0f);
663 RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Shadow buffer sampling bias.");
664 RNA_def_property_update(prop, 0, "rna_Lamp_update");
666 prop= RNA_def_property(srna, "shadow_buffer_soft", PROP_FLOAT, PROP_NONE);
667 RNA_def_property_float_sdna(prop, NULL, "soft");
668 RNA_def_property_range(prop, 0.0f, 100.0f);
669 RNA_def_property_ui_text(prop, "Shadow Buffer Soft", "Size of shadow buffer sampling area.");
670 RNA_def_property_update(prop, 0, "rna_Lamp_update");
672 prop= RNA_def_property(srna, "shadow_buffer_samples", PROP_INT, PROP_NONE);
673 RNA_def_property_int_sdna(prop, NULL, "samp");
674 RNA_def_property_range(prop, 1, 16);
675 RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples.");
676 RNA_def_property_update(prop, 0, "rna_Lamp_update");
678 prop= RNA_def_property(srna, "shadow_buffer_type", PROP_ENUM, PROP_NONE);
679 RNA_def_property_enum_sdna(prop, NULL, "buftype");
680 RNA_def_property_enum_items(prop, prop_shadbuftype_items);
681 RNA_def_property_ui_text(prop, "Shadow Buffer Type", "Type of shadow buffer.");
682 RNA_def_property_update(prop, 0, "rna_Lamp_update");
684 prop= RNA_def_property(srna, "auto_clip_start", PROP_BOOLEAN, PROP_NONE);
685 RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_START);
686 RNA_def_property_ui_text(prop, "Autoclip Start", "Automatic calculation of clipping-start, based on visible vertices.");
687 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
689 prop= RNA_def_property(srna, "auto_clip_end", PROP_BOOLEAN, PROP_NONE);
690 RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_END);
691 RNA_def_property_ui_text(prop, "Autoclip End", "Automatic calculation of clipping-end, based on visible vertices.");
692 RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
695 static void rna_def_sun_lamp(BlenderRNA *brna)
700 srna= RNA_def_struct(brna, "SunLamp", "Lamp");
701 RNA_def_struct_sdna(srna, "Lamp");
702 RNA_def_struct_ui_text(srna, "Sun Lamp", "Constant direction parallel ray lamp.");
703 RNA_def_struct_ui_icon(srna, ICON_LAMP_SUN);
705 rna_def_lamp_shadow(srna, 0, 0);
708 prop= RNA_def_property(srna, "sky", PROP_POINTER, PROP_NONE);
709 RNA_def_property_flag(prop, PROP_NEVER_NULL);
710 RNA_def_property_struct_type(prop, "LampSkySettings");
711 RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL, NULL);
712 RNA_def_property_ui_text(prop, "Sky Settings", "Sky related settings for sun lamps.");
714 rna_def_lamp_sky_settings(brna);
717 static void rna_def_hemi_lamp(BlenderRNA *brna)
721 srna= RNA_def_struct(brna, "HemiLamp", "Lamp");
722 RNA_def_struct_sdna(srna, "Lamp");
723 RNA_def_struct_ui_text(srna, "Hemi Lamp", "180 degree constant lamp.");
724 RNA_def_struct_ui_icon(srna, ICON_LAMP_HEMI);
727 void RNA_def_lamp(BlenderRNA *brna)
730 rna_def_point_lamp(brna);
731 rna_def_area_lamp(brna);
732 rna_def_spot_lamp(brna);
733 rna_def_sun_lamp(brna);
734 rna_def_hemi_lamp(brna);
735 rna_def_lamp_mtex(brna);