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"
40 static void rna_Lamp_buffer_size_set(PointerRNA *ptr, int value)
42 Lamp *la= (Lamp*)ptr->data;
44 CLAMP(value, 512, 10240);
46 la->bufsize &= (~15); /* round to multiple of 16 */
49 static PointerRNA rna_Lamp_sky_settings_get(PointerRNA *ptr)
51 return rna_pointer_inherit_refine(ptr, &RNA_LampSkySettings, ptr->id.data);
54 static void rna_Lamp_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
56 Lamp *la= (Lamp*)ptr->data;
57 rna_iterator_array_begin(iter, (void*)la->mtex, sizeof(MTex*), MAX_MTEX, 0, NULL);
60 static PointerRNA rna_Lamp_active_texture_get(PointerRNA *ptr)
62 Lamp *la= (Lamp*)ptr->data;
63 return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, la->mtex[(int)la->texact]);
66 static StructRNA* rna_Lamp_refine(struct PointerRNA *ptr)
68 Lamp *la= (Lamp*)ptr->data;
72 return &RNA_LocalLamp;
88 static void rna_def_lamp_mtex(BlenderRNA *brna)
93 static EnumPropertyItem prop_texture_coordinates_items[] = {
94 {TEXCO_GLOB, "GLOBAL", 0, "Global", "Uses global coordinates for the texture coordinates."},
95 {TEXCO_VIEW, "VIEW", 0, "View", "Uses view coordinates for the texture coordinates."},
96 {TEXCO_OBJECT, "OBJECT", 0, "Object", "Uses linked object's coordinates for texture coordinates."},
97 {0, NULL, 0, NULL, NULL}};
99 srna= RNA_def_struct(brna, "LampTextureSlot", "TextureSlot");
100 RNA_def_struct_sdna(srna, "MTex");
101 RNA_def_struct_ui_text(srna, "Lamp Texture Slot", "Texture slot for textures in a Lamp datablock.");
103 prop= RNA_def_property(srna, "texture_coordinates", PROP_ENUM, PROP_NONE);
104 RNA_def_property_enum_sdna(prop, NULL, "texco");
105 RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
106 RNA_def_property_ui_text(prop, "Texture Coordinates", "");
108 prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
109 RNA_def_property_pointer_sdna(prop, NULL, "object");
110 RNA_def_property_struct_type(prop, "Object");
111 RNA_def_property_flag(prop, PROP_EDITABLE);
112 RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates.");
114 prop= RNA_def_property(srna, "map_to_color", PROP_BOOLEAN, PROP_NONE);
115 RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_COL);
116 RNA_def_property_ui_text(prop, "Map To Color", "Lets the texture affect the basic color of the lamp.");
118 prop= RNA_def_property(srna, "map_to_shadow", PROP_BOOLEAN, PROP_NONE);
119 RNA_def_property_boolean_sdna(prop, NULL, "mapto", LAMAP_SHAD);
120 RNA_def_property_ui_text(prop, "Map To Shadow", "Lets the texture affect the shadow color of the lamp.");
123 static void rna_def_lamp_sky_settings(BlenderRNA *brna)
128 static EnumPropertyItem prop_skycolorspace_items[] = {
129 {0, "SMPTE", 0, "SMPTE", ""},
130 {1, "REC709", 0, "REC709", ""},
131 {2, "CIE", 0, "CIE", ""},
132 {0, NULL, 0, NULL, NULL}};
134 static EnumPropertyItem prop_blendmode_items[] = {
135 {0, "MIX", 0, "Mix", ""},
136 {1, "ADD", 0, "Add", ""},
137 {2, "MULTIPLY", 0, "Multiply", ""},
138 {3, "SUBTRACT", 0, "Subtract", ""},
139 {4, "SCREEN", 0, "Screen", ""},
140 {5, "DIVIDE", 0, "Divide", ""},
141 {6, "DIFFERENCE", 0, "Difference", ""},
142 {7, "DARKEN", 0, "Darken", ""},
143 {8, "LIGHTEN", 0, "Lighten", ""},
144 {9, "OVERLAY", 0, "Overlay", ""},
145 {10, "DODGE", 0, "Dodge", ""},
146 {11, "BURN", 0, "Burn", ""},
147 {12, "HUE", 0, "Hue", ""},
148 {13, "SATURATION", 0, "Saturation", ""},
149 {14, "VALUE", 0, "Value", ""},
150 {15, "COLOR", 0, "Color", ""},
151 {0, NULL, 0, NULL, NULL}};
153 srna= RNA_def_struct(brna, "LampSkySettings", NULL);
154 RNA_def_struct_sdna(srna, "Lamp");
155 RNA_def_struct_nested(brna, srna, "SunLamp");
156 RNA_def_struct_ui_text(srna, "Lamp Sky Settings", "Sky related settings for a sun lamp.");
158 prop= RNA_def_property(srna, "sky_color_space", PROP_ENUM, PROP_NONE);
159 RNA_def_property_enum_sdna(prop, NULL, "sky_colorspace");
160 RNA_def_property_enum_items(prop, prop_skycolorspace_items);
161 RNA_def_property_ui_text(prop, "Sky Color Space", "Color space to use for internal XYZ->RGB color conversion.");
162 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
164 prop= RNA_def_property(srna, "sky_blend_type", PROP_ENUM, PROP_NONE);
165 RNA_def_property_enum_sdna(prop, NULL, "skyblendtype");
166 RNA_def_property_enum_items(prop, prop_blendmode_items);
167 RNA_def_property_ui_text(prop, "Sky Blend Mode", "Blend mode for combining sun sky with world sky.");
168 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
172 prop= RNA_def_property(srna, "horizon_brightness", PROP_FLOAT, PROP_NONE);
173 RNA_def_property_range(prop, 0.0f, 20.0f);
174 RNA_def_property_ui_text(prop, "Horizon Brightness", "Horizon brightness.");
175 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
177 prop= RNA_def_property(srna, "spread", PROP_FLOAT, PROP_NONE);
178 RNA_def_property_range(prop, 0.0f, 10.0f);
179 RNA_def_property_ui_text(prop, "Horizon Spread", "Horizon Spread.");
180 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
182 prop= RNA_def_property(srna, "sun_brightness", PROP_FLOAT, PROP_NONE);
183 RNA_def_property_range(prop, 0.0f, 10.0f);
184 RNA_def_property_ui_text(prop, "Sun Brightness", "Sun brightness.");
185 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
187 prop= RNA_def_property(srna, "sun_size", PROP_FLOAT, PROP_NONE);
188 RNA_def_property_range(prop, 0.0f, 10.0f);
189 RNA_def_property_ui_text(prop, "Sun Size", "Sun size.");
190 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
192 prop= RNA_def_property(srna, "backscattered_light", PROP_FLOAT, PROP_NONE);
193 RNA_def_property_range(prop, -1.0f, 1.0f);
194 RNA_def_property_ui_text(prop, "Backscattered Light", "Backscattered light.");
195 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
197 prop= RNA_def_property(srna, "sun_intensity", PROP_FLOAT, PROP_NONE);
198 RNA_def_property_range(prop, 0.0f, 10.0f);
199 RNA_def_property_ui_text(prop, "Sun Intensity", "Sun intensity.");
200 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
202 prop= RNA_def_property(srna, "atmosphere_turbidity", PROP_FLOAT, PROP_NONE);
203 RNA_def_property_float_sdna(prop, NULL, "atm_turbidity");
204 RNA_def_property_range(prop, 1.0f, 30.0f);
205 RNA_def_property_ui_text(prop, "Atmosphere Turbidity", "Sky turbidity.");
206 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
208 prop= RNA_def_property(srna, "atmosphere_inscattering", PROP_FLOAT, PROP_NONE);
209 RNA_def_property_float_sdna(prop, NULL, "atm_inscattering_factor");
210 RNA_def_property_range(prop, 0.0f, 1.0f);
211 RNA_def_property_ui_text(prop, "Atmosphere Inscatter", "Scatter contribution factor.");
212 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
214 prop= RNA_def_property(srna, "atmosphere_extinction", PROP_FLOAT, PROP_NONE);
215 RNA_def_property_float_sdna(prop, NULL, "atm_extinction_factor");
216 RNA_def_property_range(prop, 0.0f, 1.0f);
217 RNA_def_property_ui_text(prop, "Atmosphere Extinction", "Extinction scattering contribution factor.");
218 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
220 prop= RNA_def_property(srna, "atmosphere_distance_factor", PROP_FLOAT, PROP_NONE);
221 RNA_def_property_float_sdna(prop, NULL, "atm_distance_factor");
222 RNA_def_property_range(prop, 0.0f, 500.0f);
223 RNA_def_property_ui_text(prop, "Atmosphere Distance Factor", "Multiplier to convert blender units to physical distance.");
224 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
226 prop= RNA_def_property(srna, "sky_blend", PROP_FLOAT, PROP_NONE);
227 RNA_def_property_float_sdna(prop, NULL, "skyblendfac");
228 RNA_def_property_range(prop, 0.0f, 2.0f);
229 RNA_def_property_ui_text(prop, "Sky Blend", "Blend factor with sky.");
230 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
232 prop= RNA_def_property(srna, "sky_exposure", PROP_FLOAT, PROP_NONE);
233 RNA_def_property_range(prop, 0.0f, 20.0f);
234 RNA_def_property_ui_text(prop, "Sky Exposure", "Strength of sky shading exponential exposure correction.");
235 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
239 prop= RNA_def_property(srna, "sky", PROP_BOOLEAN, PROP_NONE);
240 RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_SKY);
241 RNA_def_property_ui_text(prop, "Sky", "Apply sun effect on sky.");
242 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
244 prop= RNA_def_property(srna, "atmosphere", PROP_BOOLEAN, PROP_NONE);
245 RNA_def_property_boolean_sdna(prop, NULL, "sun_effect_type", LA_SUN_EFFECT_AP);
246 RNA_def_property_ui_text(prop, "Atmosphere", "Apply sun effect on atmosphere.");
247 RNA_def_property_update(prop, NC_LAMP|ND_SKY, NULL);
250 static void rna_def_lamp(BlenderRNA *brna)
255 static EnumPropertyItem prop_type_items[] = {
256 {LA_LOCAL, "POINT", ICON_LAMP_POINT, "Point", "Omnidirectional point light source."},
257 {LA_SUN, "SUN", ICON_LAMP_SUN, "Sun", "Constant direction parallel ray light source."},
258 {LA_SPOT, "SPOT", ICON_LAMP_SPOT, "Spot", "Directional cone light source."},
259 {LA_HEMI, "HEMI", ICON_LAMP_HEMI, "Hemi", "180 degree constant light source."},
260 {LA_AREA, "AREA", ICON_LAMP_AREA, "Area", "Directional area light source."},
261 {0, NULL, 0, NULL, NULL}};
263 srna= RNA_def_struct(brna, "Lamp", "ID");
264 RNA_def_struct_refine_func(srna, "rna_Lamp_refine");
265 RNA_def_struct_ui_text(srna, "Lamp", "Lamp datablock for lighting a scene.");
266 RNA_def_struct_ui_icon(srna, ICON_LAMP_DATA);
268 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
269 RNA_def_property_enum_items(prop, prop_type_items);
270 RNA_def_property_ui_text(prop, "Type", "Type of Lamp.");
271 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
273 prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
274 RNA_def_property_float_sdna(prop, NULL, "dist");
275 RNA_def_property_ui_range(prop, 0, 1000, 1.0, 2);
276 RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point.");
277 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
279 prop= RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
280 RNA_def_property_ui_range(prop, 0, 10.0, 0.1, 2);
281 RNA_def_property_ui_text(prop, "Energy", "Amount of light that the lamp emits.");
282 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
284 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
285 RNA_def_property_float_sdna(prop, NULL, "r");
286 RNA_def_property_array(prop, 3);
287 RNA_def_property_ui_text(prop, "Color", "Light color.");
288 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
290 prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE);
291 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER);
292 RNA_def_property_ui_text(prop, "Layer", "Illuminates objects only on the same layer the lamp is on.");
293 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
295 prop= RNA_def_property(srna, "negative", PROP_BOOLEAN, PROP_NONE);
296 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_NEG);
297 RNA_def_property_ui_text(prop, "Negative", "Lamp casts negative light.");
298 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
300 prop= RNA_def_property(srna, "specular", PROP_BOOLEAN, PROP_NONE);
301 RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_SPEC);
302 RNA_def_property_ui_text(prop, "Specular", "Lamp creates specular highlights.");
303 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
305 prop= RNA_def_property(srna, "diffuse", PROP_BOOLEAN, PROP_NONE);
306 RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", LA_NO_DIFF);
307 RNA_def_property_ui_text(prop, "Diffuse", "Lamp does diffuse shading.");
308 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
311 rna_def_mtex_common(srna, "rna_Lamp_mtex_begin", "rna_Lamp_active_texture_get", "LampTextureSlot");
314 prop= RNA_def_property(srna, "script_link", PROP_POINTER, PROP_NEVER_NULL);
315 RNA_def_property_pointer_sdna(prop, NULL, "scriptlink");
316 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
317 RNA_def_property_ui_text(prop, "Script Link", "Scripts linked to this lamp.");
320 static void rna_def_lamp_falloff(StructRNA *srna)
324 static EnumPropertyItem prop_fallofftype_items[] = {
325 {LA_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", ""},
326 {LA_FALLOFF_INVLINEAR, "INVERSE_LINEAR", 0, "Inverse Linear", ""},
327 {LA_FALLOFF_INVSQUARE, "INVERSE_SQUARE", 0, "Inverse Square", ""},
328 {LA_FALLOFF_CURVE, "CUSTOM_CURVE", 0, "Custom Curve", ""},
329 {LA_FALLOFF_SLIDERS, "LINEAR_QUADRATIC_WEIGHTED", 0, "Lin/Quad Weighted", ""},
330 {0, NULL, 0, NULL, NULL}};
332 prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
333 RNA_def_property_enum_items(prop, prop_fallofftype_items);
334 RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance.");
335 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
337 prop= RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
338 RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
339 RNA_def_property_ui_text(prop, "Falloff Curve", "Custom Lamp Falloff Curve");
340 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
342 prop= RNA_def_property(srna, "sphere", PROP_BOOLEAN, PROP_NONE);
343 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SPHERE);
344 RNA_def_property_ui_text(prop, "Sphere", "Sets light intensity to zero beyond lamp distance.");
345 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
347 prop= RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_NONE);
348 RNA_def_property_float_sdna(prop, NULL, "att1");
349 RNA_def_property_range(prop, 0.0f, 1.0f);
350 RNA_def_property_ui_text(prop, "Linear Attenuation", "Linear distance attentuation.");
351 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
353 prop= RNA_def_property(srna, "quadratic_attenuation", PROP_FLOAT, PROP_NONE);
354 RNA_def_property_float_sdna(prop, NULL, "att2");
355 RNA_def_property_range(prop, 0.0f, 1.0f);
356 RNA_def_property_ui_text(prop, "Quadratic Attenuation", "Quadratic distance attentuation.");
357 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
360 static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area)
364 static EnumPropertyItem prop_shadow_items[] = {
365 {0, "NOSHADOW", 0, "No Shadow", ""},
366 {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow."},
367 {0, NULL, 0, NULL, NULL}};
369 static EnumPropertyItem prop_spot_shadow_items[] = {
370 {0, "NOSHADOW", 0, "No Shadow", ""},
371 {LA_SHAD_BUF, "BUFFER_SHADOW", 0, "Buffer Shadow", "Lets spotlight produce shadows using shadow buffer."},
372 {LA_SHAD_RAY, "RAY_SHADOW", 0, "Ray Shadow", "Use ray tracing for shadow."},
373 {0, NULL, 0, NULL, NULL}};
375 static EnumPropertyItem prop_ray_sampling_method_items[] = {
376 {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""},
377 {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""},
378 {0, NULL, 0, NULL, NULL}};
380 static EnumPropertyItem prop_spot_ray_sampling_method_items[] = {
381 {LA_SAMP_HALTON, "ADAPTIVE_QMC", 0, "Adaptive QMC", ""},
382 {LA_SAMP_HAMMERSLEY, "CONSTANT_QMC", 0, "Constant QMC", ""},
383 {LA_SAMP_CONSTANT, "CONSTANT_JITTERED", 0, "Constant Jittered", ""},
384 {0, NULL, 0, NULL, NULL}};
387 prop= RNA_def_property(srna, "shadow_method", PROP_ENUM, PROP_NONE);
388 RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
389 RNA_def_property_enum_items(prop, (spot)? prop_spot_shadow_items: prop_shadow_items);
390 RNA_def_property_ui_text(prop, "Shadow Method", "Method to compute lamp shadow with.");
391 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
393 prop= RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR);
394 RNA_def_property_float_sdna(prop, NULL, "shdwr");
395 RNA_def_property_array(prop, 3);
396 RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows casted by the lamp.");
397 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
399 prop= RNA_def_property(srna, "only_shadow", PROP_BOOLEAN, PROP_NONE);
400 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_ONLYSHADOW);
401 RNA_def_property_ui_text(prop, "Only Shadow", "Causes light to cast shadows only without illuminating objects.");
402 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
404 prop= RNA_def_property(srna, "shadow_ray_sampling_method", PROP_ENUM, PROP_NONE);
405 RNA_def_property_enum_sdna(prop, NULL, "ray_samp_method");
406 RNA_def_property_enum_items(prop, (area)? prop_spot_ray_sampling_method_items: prop_ray_sampling_method_items);
407 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.");
408 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
410 prop= RNA_def_property(srna, (area)? "shadow_ray_samples_x": "shadow_ray_samples", PROP_INT, PROP_NONE);
411 RNA_def_property_int_sdna(prop, NULL, "ray_samp");
412 RNA_def_property_range(prop, 1, 64);
413 RNA_def_property_ui_text(prop, (area)? "Shadow Ray Samples": "Shadow Ray Samples X","Amount of samples taken extra (samples x samples).");
414 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
417 prop= RNA_def_property(srna, "shadow_ray_samples_y", PROP_INT, PROP_NONE);
418 RNA_def_property_int_sdna(prop, NULL, "ray_sampy");
419 RNA_def_property_range(prop, 1, 64);
420 RNA_def_property_ui_text(prop, "Shadow Ray Samples Y", "Amount of samples taken extra (samples x samples).");
421 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
424 prop= RNA_def_property(srna, "shadow_adaptive_threshold", PROP_FLOAT, PROP_NONE);
425 RNA_def_property_float_sdna(prop, NULL, "adapt_thresh");
426 RNA_def_property_range(prop, 0.0f, 1.0f);
427 RNA_def_property_ui_text(prop, "Shadow Adaptive Threshold", "Threshold for Adaptive Sampling (Raytraced shadows).");
428 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
430 prop= RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_NONE);
431 RNA_def_property_float_sdna(prop, NULL, "soft");
432 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
433 RNA_def_property_ui_text(prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows).");
434 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
436 prop= RNA_def_property(srna, "shadow_layer", PROP_BOOLEAN, PROP_NONE);
437 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_LAYER_SHADOW);
438 RNA_def_property_ui_text(prop, "Shadow Layer", "Causes only objects on the same layer to cast shadows.");
439 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
442 static void rna_def_local_lamp(BlenderRNA *brna)
446 srna= RNA_def_struct(brna, "LocalLamp", "Lamp");
447 RNA_def_struct_sdna(srna, "Lamp");
448 RNA_def_struct_ui_text(srna, "Local Lamp", "Omnidirectional point lamp.");
450 rna_def_lamp_falloff(srna);
451 rna_def_lamp_shadow(srna, 0, 0);
454 static void rna_def_area_lamp(BlenderRNA *brna)
459 static EnumPropertyItem prop_areashape_items[] = {
460 {LA_AREA_SQUARE, "SQUARE", 0, "Square", ""},
461 {LA_AREA_RECT, "RECTANGLE", 0, "Rectangle", ""},
462 {0, NULL, 0, NULL, NULL}};
464 srna= RNA_def_struct(brna, "AreaLamp", "Lamp");
465 RNA_def_struct_sdna(srna, "Lamp");
466 RNA_def_struct_ui_text(srna, "Area Lamp", "Directional area lamp.");
468 rna_def_lamp_shadow(srna, 0, 1);
470 prop= RNA_def_property(srna, "umbra", PROP_BOOLEAN, PROP_NONE);
471 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_UMBRA);
472 RNA_def_property_ui_text(prop, "Umbra", "Emphasize parts that are fully shadowed (Constant Jittered sampling).");
473 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
475 prop= RNA_def_property(srna, "dither", PROP_BOOLEAN, PROP_NONE);
476 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_DITHER);
477 RNA_def_property_ui_text(prop, "Dither", "Use 2x2 dithering for sampling (Constant Jittered sampling).");
478 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
480 prop= RNA_def_property(srna, "jitter", PROP_BOOLEAN, PROP_NONE);
481 RNA_def_property_boolean_sdna(prop, NULL, "ray_samp_type", LA_SAMP_JITTER);
482 RNA_def_property_ui_text(prop, "Jitter", "Use noise for sampling (Constant Jittered sampling).");
483 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
485 prop= RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
486 RNA_def_property_enum_sdna(prop, NULL, "area_shape");
487 RNA_def_property_enum_items(prop, prop_areashape_items);
488 RNA_def_property_ui_text(prop, "Shape", "Shape of the area lamp.");
489 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
491 prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
492 RNA_def_property_float_sdna(prop, NULL, "area_size");
493 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
494 RNA_def_property_ui_text(prop, "Size", "Size of the area of the area Lamp, X direction size for Rectangle shapes.");
495 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
497 prop= RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_NONE);
498 RNA_def_property_float_sdna(prop, NULL, "area_sizey");
499 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
500 RNA_def_property_ui_text(prop, "Size Y", "Size of the area of the area Lamp in the Y direction for Rectangle shapes.");
501 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
503 prop= RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_NONE);
504 RNA_def_property_float_sdna(prop, NULL, "k");
505 RNA_def_property_ui_range(prop, 0.001, 2.0, 0.1, 3);
506 RNA_def_property_ui_text(prop, "Gamma", "Light gamma correction value.");
507 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
510 static void rna_def_spot_lamp(BlenderRNA *brna)
515 static EnumPropertyItem prop_shadbuftype_items[] = {
516 {LA_SHADBUF_REGULAR , "REGULAR", 0, "Classical", "Classic shadow buffer."},
517 {LA_SHADBUF_HALFWAY, "HALFWAY", 0, "Classic-Halfway", "Regular buffer, averaging the closest and 2nd closest Z value to reducing bias artifaces."},
518 {LA_SHADBUF_IRREGULAR, "IRREGULAR", 0, "Irregular", "Irregular buffer produces sharp shadow always, but it doesn't show up for raytracing."},
519 {0, NULL, 0, NULL, NULL}};
521 static EnumPropertyItem prop_shadbuffiltertype_items[] = {
522 {LA_SHADBUF_BOX , "BOX", 0, "Box", "Apply the Box filter to shadow buffer samples."},
523 {LA_SHADBUF_TENT, "TENT", 0, "Tent", "Apply the Tent Filter to shadow buffer samples."},
524 {LA_SHADBUF_GAUSS, "GAUSS", 0, "Gauss", "Apply the Gauss filter to shadow buffer samples."},
525 {0, NULL, 0, NULL, NULL}};
527 static EnumPropertyItem prop_numbuffer_items[] = {
528 {1, "BUFFERS_1", 0, "1", "Only one buffer rendered."},
529 {4, "BUFFERS_4", 0, "4", "Renders 4 buffers for better AA, this quadruples memory usage."},
530 {9, "BUFFERS_9", 0, "9", "Renders 9 buffers for better AA, this uses nine times more memory."},
531 {0, NULL, 0, NULL, NULL}};
533 srna= RNA_def_struct(brna, "SpotLamp", "Lamp");
534 RNA_def_struct_sdna(srna, "Lamp");
535 RNA_def_struct_ui_text(srna, "Spot Lamp", "Directional cone lamp.");
537 rna_def_lamp_falloff(srna);
538 rna_def_lamp_shadow(srna, 1, 0);
540 prop= RNA_def_property(srna, "square", PROP_BOOLEAN, PROP_NONE);
541 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_SQUARE);
542 RNA_def_property_ui_text(prop, "Square", "Casts a square spot light shape.");
543 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
545 prop= RNA_def_property(srna, "halo", PROP_BOOLEAN, PROP_NONE);
546 RNA_def_property_boolean_sdna(prop, NULL, "mode", LA_HALO);
547 RNA_def_property_ui_text(prop, "Halo", "Renders spotlight with a volumetric halo (Buffer Shadows).");
548 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
550 prop= RNA_def_property(srna, "halo_intensity", PROP_FLOAT, PROP_NONE);
551 RNA_def_property_float_sdna(prop, NULL, "haint");
552 RNA_def_property_ui_range(prop, 0, 5.0, 0.1, 3);
553 RNA_def_property_ui_text(prop, "Halo Intensity", "Brightness of the spotlight's halo cone (Buffer Shadows).");
554 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
556 prop= RNA_def_property(srna, "halo_step", PROP_INT, PROP_NONE);
557 RNA_def_property_int_sdna(prop, NULL, "shadhalostep");
558 RNA_def_property_range(prop, 0, 12);
559 RNA_def_property_ui_text(prop, "Halo Step", "Volumetric halo sampling frequency.");
560 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
562 prop= RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE);
563 RNA_def_property_int_sdna(prop, NULL, "bufsize");
564 RNA_def_property_range(prop, 512, 10240);
565 RNA_def_property_ui_text(prop, "Shadow Buffer Size", "Resolution of the shadow buffer, higher values give crisper shadows but use more memory");
566 RNA_def_property_int_funcs(prop, NULL, "rna_Lamp_buffer_size_set", NULL);
567 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
569 prop= RNA_def_property(srna, "shadow_filter_type", PROP_ENUM, PROP_NONE);
570 RNA_def_property_enum_sdna(prop, NULL, "filtertype");
571 RNA_def_property_enum_items(prop, prop_shadbuffiltertype_items);
572 RNA_def_property_ui_text(prop, "Shadow Filter Type", "Type of shadow filter (Buffer Shadows).");
573 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
575 prop= RNA_def_property(srna, "shadow_sample_buffers", PROP_ENUM, PROP_NONE);
576 RNA_def_property_enum_sdna(prop, NULL, "buffers");
577 RNA_def_property_enum_items(prop, prop_numbuffer_items);
578 RNA_def_property_ui_text(prop, "Shadow Sample Buffers", "Number of shadow buffers to render for better AA, this increases memory usage.");
579 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
581 prop= RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE);
582 RNA_def_property_float_sdna(prop, NULL, "spotblend");
583 RNA_def_property_range(prop, 0.0f ,1.0f);
584 RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge.");
585 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
587 prop= RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_NONE);
588 RNA_def_property_float_sdna(prop, NULL, "spotsize");
589 RNA_def_property_range(prop, 1.0f ,180.0f);
590 RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam in degrees.");
591 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
593 prop= RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_NONE);
594 RNA_def_property_float_sdna(prop, NULL, "clipsta");
595 RNA_def_property_range(prop, 0.0f, 9999.0f);
596 RNA_def_property_ui_text(prop, "Shadow Buffer Clip Start", "Shadow map clip start: objects closer will not generate shadows");
597 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
599 prop= RNA_def_property(srna, "shadow_buffer_clip_end", PROP_FLOAT, PROP_NONE);
600 RNA_def_property_float_sdna(prop, NULL, "clipend");
601 RNA_def_property_range(prop, 0.0f, 9999.0f);
602 RNA_def_property_ui_text(prop, "Shadow Buffer Clip End", "Shadow map clip end beyond which objects will not generate shadows.");
603 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
605 prop= RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE);
606 RNA_def_property_float_sdna(prop, NULL, "bias");
607 RNA_def_property_range(prop, 0.0f, 5.0f);
608 RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Shadow buffer sampling bias.");
609 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
611 prop= RNA_def_property(srna, "shadow_buffer_soft", PROP_FLOAT, PROP_NONE);
612 RNA_def_property_float_sdna(prop, NULL, "soft");
613 RNA_def_property_range(prop, 0.0f, 100.0f);
614 RNA_def_property_ui_text(prop, "Shadow Buffer Soft", "Size of shadow buffer sampling area.");
615 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
617 prop= RNA_def_property(srna, "shadow_buffer_samples", PROP_INT, PROP_NONE);
618 RNA_def_property_int_sdna(prop, NULL, "samp");
619 RNA_def_property_range(prop, 1, 16);
620 RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples.");
621 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
623 prop= RNA_def_property(srna, "shadow_buffer_type", PROP_ENUM, PROP_NONE);
624 RNA_def_property_enum_sdna(prop, NULL, "buftype");
625 RNA_def_property_enum_items(prop, prop_shadbuftype_items);
626 RNA_def_property_ui_text(prop, "Shadow Buffer Type", "Type of shadow buffer.");
627 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING, NULL);
629 prop= RNA_def_property(srna, "auto_clip_start", PROP_BOOLEAN, PROP_NONE);
630 RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_START);
631 RNA_def_property_ui_text(prop, "Autoclip Start", "Automatic calculation of clipping-start, based on visible vertices.");
632 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
634 prop= RNA_def_property(srna, "auto_clip_end", PROP_BOOLEAN, PROP_NONE);
635 RNA_def_property_boolean_sdna(prop, NULL, "bufflag", LA_SHADBUF_AUTO_END);
636 RNA_def_property_ui_text(prop, "Autoclip End", "Automatic calculation of clipping-end, based on visible vertices.");
637 RNA_def_property_update(prop, NC_LAMP|ND_LIGHTING_DRAW, NULL);
640 static void rna_def_sun_lamp(BlenderRNA *brna)
645 srna= RNA_def_struct(brna, "SunLamp", "Lamp");
646 RNA_def_struct_sdna(srna, "Lamp");
647 RNA_def_struct_ui_text(srna, "Sun Lamp", "Constant direction parallel ray lamp.");
649 rna_def_lamp_shadow(srna, 0, 0);
652 prop= RNA_def_property(srna, "sky", PROP_POINTER, PROP_NEVER_NULL);
653 RNA_def_property_struct_type(prop, "LampSkySettings");
654 RNA_def_property_pointer_funcs(prop, "rna_Lamp_sky_settings_get", NULL, NULL);
655 RNA_def_property_ui_text(prop, "Sky Settings", "Sky related settings for sun lamps.");
657 rna_def_lamp_sky_settings(brna);
660 static void rna_def_hemi_lamp(BlenderRNA *brna)
664 srna= RNA_def_struct(brna, "HemiLamp", "Lamp");
665 RNA_def_struct_sdna(srna, "Lamp");
666 RNA_def_struct_ui_text(srna, "Hemi Lamp", "180 degree constant lamp.");
669 void RNA_def_lamp(BlenderRNA *brna)
672 rna_def_local_lamp(brna);
673 rna_def_area_lamp(brna);
674 rna_def_spot_lamp(brna);
675 rna_def_sun_lamp(brna);
676 rna_def_hemi_lamp(brna);
677 rna_def_lamp_mtex(brna);