Blender  V2.93
rna_light.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stdlib.h>
22 
23 #include "BLI_math_base.h"
24 #include "BLI_math_rotation.h"
25 #include "BLI_sys_types.h"
26 
27 #include "BLT_translation.h"
28 
29 #include "RNA_define.h"
30 #include "RNA_enum_types.h"
31 #include "rna_internal.h"
32 
33 #include "DNA_light_types.h"
34 #include "DNA_material_types.h"
35 #include "DNA_texture_types.h"
36 
37 #ifdef RNA_RUNTIME
38 
39 # include "MEM_guardedalloc.h"
40 
41 # include "BKE_context.h"
42 # include "BKE_main.h"
43 # include "BKE_texture.h"
44 
45 # include "DEG_depsgraph.h"
46 
47 # include "ED_node.h"
48 # include "WM_api.h"
49 # include "WM_types.h"
50 
51 static void rna_Light_buffer_size_set(PointerRNA *ptr, int value)
52 {
53  Light *la = (Light *)ptr->data;
54 
55  CLAMP(value, 128, 10240);
56  la->bufsize = value;
57  la->bufsize &= (~15); /* round to multiple of 16 */
58 }
59 
60 static StructRNA *rna_Light_refine(struct PointerRNA *ptr)
61 {
62  Light *la = (Light *)ptr->data;
63 
64  switch (la->type) {
65  case LA_LOCAL:
66  return &RNA_PointLight;
67  case LA_SUN:
68  return &RNA_SunLight;
69  case LA_SPOT:
70  return &RNA_SpotLight;
71  case LA_AREA:
72  return &RNA_AreaLight;
73  default:
74  return &RNA_Light;
75  }
76 }
77 
78 static void rna_Light_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
79 {
80  Light *la = (Light *)ptr->owner_id;
81 
82  DEG_id_tag_update(&la->id, 0);
84 }
85 
86 static void rna_Light_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
87 {
88  Light *la = (Light *)ptr->owner_id;
89 
90  DEG_id_tag_update(&la->id, 0);
92 }
93 
94 static void rna_Light_use_nodes_update(bContext *C, PointerRNA *ptr)
95 {
96  Light *la = (Light *)ptr->data;
97 
98  if (la->use_nodes && la->nodetree == NULL) {
100  }
101 
102  rna_Light_update(CTX_data_main(C), CTX_data_scene(C), ptr);
103 }
104 
105 #else
106 /* Don't define icons here, so they don't show up in the Light UI (properties Editor) - DingTo */
108  {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"},
109  {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"},
110  {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"},
111  {LA_AREA, "AREA", 0, "Area", "Directional area light source"},
112  {0, NULL, 0, NULL, NULL},
113 };
114 
115 static void rna_def_light(BlenderRNA *brna)
116 {
117  StructRNA *srna;
118  PropertyRNA *prop;
119  static float default_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
120 
121  srna = RNA_def_struct(brna, "Light", "ID");
122  RNA_def_struct_sdna(srna, "Light");
123  RNA_def_struct_refine_func(srna, "rna_Light_refine");
124  RNA_def_struct_ui_text(srna, "Light", "Light data-block for lighting a scene");
126  RNA_def_struct_ui_icon(srna, ICON_LIGHT_DATA);
127 
128  prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
130  RNA_def_property_ui_text(prop, "Type", "Type of light");
132  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
133 
134  prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
135  RNA_def_property_float_sdna(prop, NULL, "dist");
136  RNA_def_property_range(prop, 0, INT_MAX);
137  RNA_def_property_ui_range(prop, 0, 1000, 1, 3);
139  prop,
140  "Distance",
141  "Falloff distance - the light is at half the original intensity at this point");
142  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
143 
144  prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
145  RNA_def_property_float_sdna(prop, NULL, "r");
146  RNA_def_property_array(prop, 3);
147  RNA_def_property_float_array_default(prop, default_color);
148  RNA_def_property_ui_text(prop, "Color", "Light color");
149  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
150 
151  prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR);
152  RNA_def_property_float_sdna(prop, NULL, "spec_fac");
153  RNA_def_property_range(prop, 0.0f, FLT_MAX);
154  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
155  RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier");
156  RNA_def_property_update(prop, 0, "rna_Light_update");
157 
158  prop = RNA_def_property(srna, "diffuse_factor", PROP_FLOAT, PROP_FACTOR);
159  RNA_def_property_float_sdna(prop, NULL, "diff_fac");
160  RNA_def_property_range(prop, 0.0f, FLT_MAX);
161  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
162  RNA_def_property_ui_text(prop, "Diffuse Factor", "Diffuse reflection multiplier");
163  RNA_def_property_update(prop, 0, "rna_Light_update");
164 
165  prop = RNA_def_property(srna, "volume_factor", PROP_FLOAT, PROP_FACTOR);
166  RNA_def_property_float_sdna(prop, NULL, "volume_fac");
167  RNA_def_property_range(prop, 0.0f, FLT_MAX);
168  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
169  RNA_def_property_ui_text(prop, "Volume Factor", "Volume light multiplier");
170  RNA_def_property_update(prop, 0, "rna_Light_update");
171 
172  prop = RNA_def_property(srna, "use_custom_distance", PROP_BOOLEAN, PROP_NONE);
175  "Custom Attenuation",
176  "Use custom attenuation distance instead of global light threshold");
177  RNA_def_property_update(prop, 0, "rna_Light_update");
178 
179  prop = RNA_def_property(srna, "cutoff_distance", PROP_FLOAT, PROP_DISTANCE);
180  RNA_def_property_float_sdna(prop, NULL, "att_dist");
181  RNA_def_property_range(prop, 0.0f, FLT_MAX);
182  RNA_def_property_ui_range(prop, 0.01f, 100.0f, 1.0, 2);
184  prop, "Cutoff Distance", "Distance at which the light influence will be set to 0");
185  RNA_def_property_update(prop, 0, "rna_Light_update");
186 
187  /* nodes */
188  prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
189  RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
191  RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lights");
192 
193  prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
194  RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
197  RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the light");
198  RNA_def_property_update(prop, 0, "rna_Light_use_nodes_update");
199 
200  /* common */
202 }
203 
204 static void rna_def_light_energy(StructRNA *srna, const short light_type)
205 {
206  PropertyRNA *prop;
207 
208  switch (light_type) {
209  case LA_SUN: {
210  /* Distant light strength has no unit defined,
211  * it's proportional to 'watt/m^2' and is not sensitive to scene unit scale. */
212  prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
213  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
215  prop, "Strength", "Sunlight strength in watts per meter squared (W/m^2)");
216  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
217  break;
218  }
219  case LA_SPOT: {
220  /* Lights with a location have power in Watts,
221  * which is sensitive to scene unit scale. */
222  prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_POWER);
223  RNA_def_property_ui_range(prop, 0.0f, 1000000.0f, 10, 5);
225  "Power",
226  "The energy this light would emit over its entire area "
227  "if it wasn't limited by the spot angle");
228  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
229  break;
230  }
231  default: {
232  /* Lights with a location have power in Watts,
233  * which is sensitive to scene unit scale. */
234  prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_POWER);
235  RNA_def_property_ui_range(prop, 0.0f, 1000000.0f, 10, 5);
237  prop,
238  "Power",
239  "Light energy emitted over the entire area of the light in all directions");
240  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
241  break;
242  }
243  }
244 }
245 
247 {
248  PropertyRNA *prop;
249 
250  static const EnumPropertyItem prop_fallofftype_items[] = {
251  {LA_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", ""},
252  {LA_FALLOFF_INVLINEAR, "INVERSE_LINEAR", 0, "Inverse Linear", ""},
253  {LA_FALLOFF_INVSQUARE, "INVERSE_SQUARE", 0, "Inverse Square", ""},
254  {LA_FALLOFF_INVCOEFFICIENTS, "INVERSE_COEFFICIENTS", 0, "Inverse Coefficients", ""},
255  {LA_FALLOFF_CURVE, "CUSTOM_CURVE", 0, "Custom Curve", ""},
256  {LA_FALLOFF_SLIDERS, "LINEAR_QUADRATIC_WEIGHTED", 0, "Lin/Quad Weighted", ""},
257  {0, NULL, 0, NULL, NULL},
258  };
259 
260  prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
261  RNA_def_property_enum_items(prop, prop_fallofftype_items);
262  RNA_def_property_ui_text(prop, "Falloff Type", "Intensity Decay with distance");
263  RNA_def_property_update(prop, 0, "rna_Light_update");
264 
265  prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
266  RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
267  RNA_def_property_ui_text(prop, "Falloff Curve", "Custom light falloff curve");
268  RNA_def_property_update(prop, 0, "rna_Light_update");
269 
270  prop = RNA_def_property(srna, "linear_attenuation", PROP_FLOAT, PROP_FACTOR);
271  RNA_def_property_float_sdna(prop, NULL, "att1");
272  RNA_def_property_range(prop, 0.0f, 1.0f);
273  RNA_def_property_ui_text(prop, "Linear Attenuation", "Linear distance attenuation");
274  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
275 
276  prop = RNA_def_property(srna, "quadratic_attenuation", PROP_FLOAT, PROP_FACTOR);
277  RNA_def_property_float_sdna(prop, NULL, "att2");
278  RNA_def_property_range(prop, 0.0f, 1.0f);
279  RNA_def_property_ui_text(prop, "Quadratic Attenuation", "Quadratic distance attenuation");
280  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
281 
282  prop = RNA_def_property(srna, "constant_coefficient", PROP_FLOAT, PROP_NONE);
283  RNA_def_property_float_sdna(prop, NULL, "coeff_const");
284  RNA_def_property_range(prop, 0.0f, FLT_MAX);
286  prop, "Constant Coefficient", "Constant distance attenuation coefficient");
287  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
288 
289  prop = RNA_def_property(srna, "linear_coefficient", PROP_FLOAT, PROP_NONE);
290  RNA_def_property_float_sdna(prop, NULL, "coeff_lin");
291  RNA_def_property_range(prop, 0.0f, FLT_MAX);
292  RNA_def_property_ui_text(prop, "Linear Coefficient", "Linear distance attenuation coefficient");
293  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
294 
295  prop = RNA_def_property(srna, "quadratic_coefficient", PROP_FLOAT, PROP_NONE);
296  RNA_def_property_float_sdna(prop, NULL, "coeff_quad");
297  RNA_def_property_range(prop, 0.0f, FLT_MAX);
299  prop, "Quadratic Coefficient", "Quadratic distance attenuation coefficient");
300  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
301 }
302 
303 static void rna_def_light_shadow(StructRNA *srna, bool sun)
304 {
305  PropertyRNA *prop;
306 
307  prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE);
309  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
310 
311  prop = RNA_def_property(srna, "shadow_buffer_size", PROP_INT, PROP_NONE);
312  RNA_def_property_int_sdna(prop, NULL, "bufsize");
313  RNA_def_property_range(prop, 128, 10240);
315  "Shadow Buffer Size",
316  "Resolution of the shadow buffer, higher values give crisper shadows "
317  "but use more memory");
318  RNA_def_property_int_funcs(prop, NULL, "rna_Light_buffer_size_set", NULL);
319  RNA_def_property_update(prop, 0, "rna_Light_update");
320 
321  prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE);
322  RNA_def_property_float_sdna(prop, NULL, "clipsta");
323  RNA_def_property_range(prop, 1e-6f, FLT_MAX);
324  RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
326  "Shadow Buffer Clip Start",
327  "Shadow map clip start, below which objects will not generate shadows");
328  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
329 
330  prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE);
331  RNA_def_property_float_sdna(prop, NULL, "bias");
332  RNA_def_property_range(prop, 0.0f, FLT_MAX);
333  RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3);
334  RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Bias for reducing self shadowing");
335  RNA_def_property_update(prop, 0, "rna_Light_update");
336 
337  prop = RNA_def_property(srna, "shadow_buffer_samples", PROP_INT, PROP_NONE);
338  RNA_def_property_int_sdna(prop, NULL, "samp");
339  RNA_def_property_range(prop, 1, 16);
340  RNA_def_property_ui_text(prop, "Samples", "Number of shadow buffer samples");
341  RNA_def_property_update(prop, 0, "rna_Light_update");
342 
343  prop = RNA_def_property(srna, "shadow_color", PROP_FLOAT, PROP_COLOR);
344  RNA_def_property_float_sdna(prop, NULL, "shdwr");
345  RNA_def_property_array(prop, 3);
346  RNA_def_property_ui_text(prop, "Shadow Color", "Color of shadows cast by the light");
347  RNA_def_property_update(prop, 0, "rna_Light_update");
348 
349  prop = RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE);
350  RNA_def_property_float_sdna(prop, NULL, "area_size");
351  RNA_def_property_range(prop, 0.0f, FLT_MAX);
352  RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
354  prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)");
355  RNA_def_property_update(prop, 0, "rna_Light_update");
356 
357  /* Eevee */
358  prop = RNA_def_property(srna, "use_contact_shadow", PROP_BOOLEAN, PROP_NONE);
361  "Contact Shadow",
362  "Use screen space raytracing to have correct shadowing "
363  "near occluder, or for small features that does not appear "
364  "in shadow maps");
365  RNA_def_property_update(prop, 0, "rna_Light_update");
366 
367  prop = RNA_def_property(srna, "contact_shadow_distance", PROP_FLOAT, PROP_DISTANCE);
368  RNA_def_property_float_sdna(prop, NULL, "contact_dist");
369  RNA_def_property_range(prop, 0.0f, 9999.0f);
371  "Contact Shadow Distance",
372  "World space distance in which to search for "
373  "screen space occluder");
374  RNA_def_property_update(prop, 0, "rna_Light_update");
375 
376  prop = RNA_def_property(srna, "contact_shadow_bias", PROP_FLOAT, PROP_NONE);
377  RNA_def_property_float_sdna(prop, NULL, "contact_bias");
378  RNA_def_property_range(prop, 0.001f, 9999.0f);
379  RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3);
380  RNA_def_property_ui_text(prop, "Contact Shadow Bias", "Bias to avoid self shadowing");
381  RNA_def_property_update(prop, 0, "rna_Light_update");
382 
383  prop = RNA_def_property(srna, "contact_shadow_thickness", PROP_FLOAT, PROP_DISTANCE);
384  RNA_def_property_float_sdna(prop, NULL, "contact_thickness");
385  RNA_def_property_range(prop, 0.0f, 9999.0f);
386  RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
388  prop, "Contact Shadow Thickness", "Pixel thickness used to detect occlusion");
389  RNA_def_property_update(prop, 0, "rna_Light_update");
390 
391  if (sun) {
392  prop = RNA_def_property(srna, "shadow_cascade_max_distance", PROP_FLOAT, PROP_DISTANCE);
393  RNA_def_property_float_sdna(prop, NULL, "cascade_max_dist");
394  RNA_def_property_range(prop, 0.0f, FLT_MAX);
396  "Cascade Max Distance",
397  "End distance of the cascaded shadow map (only in perspective view)");
398  RNA_def_property_update(prop, 0, "rna_Light_update");
399 
400  prop = RNA_def_property(srna, "shadow_cascade_count", PROP_INT, PROP_NONE);
401  RNA_def_property_int_sdna(prop, NULL, "cascade_count");
402  RNA_def_property_range(prop, 1, 4);
404  prop, "Cascade Count", "Number of texture used by the cascaded shadow map");
405  RNA_def_property_update(prop, 0, "rna_Light_update");
406 
407  prop = RNA_def_property(srna, "shadow_cascade_exponent", PROP_FLOAT, PROP_FACTOR);
408  RNA_def_property_float_sdna(prop, NULL, "cascade_exponent");
409  RNA_def_property_range(prop, 0.0f, 1.0f);
411  "Exponential Distribution",
412  "Higher value increase resolution towards the viewpoint");
413  RNA_def_property_update(prop, 0, "rna_Light_update");
414 
415  prop = RNA_def_property(srna, "shadow_cascade_fade", PROP_FLOAT, PROP_FACTOR);
416  RNA_def_property_float_sdna(prop, NULL, "cascade_fade");
417  RNA_def_property_range(prop, 0.0f, 1.0f);
419  prop, "Cascade Fade", "How smooth is the transition between each cascade");
420  RNA_def_property_update(prop, 0, "rna_Light_update");
421  }
422 }
423 
424 static void rna_def_point_light(BlenderRNA *brna)
425 {
426  StructRNA *srna;
427 
428  srna = RNA_def_struct(brna, "PointLight", "Light");
429  RNA_def_struct_sdna(srna, "Light");
430  RNA_def_struct_ui_text(srna, "Point Light", "Omnidirectional point Light");
431  RNA_def_struct_ui_icon(srna, ICON_LIGHT_POINT);
432 
434  rna_def_light_falloff(srna);
435  rna_def_light_shadow(srna, false);
436 }
437 
438 static void rna_def_area_light(BlenderRNA *brna)
439 {
440  StructRNA *srna;
441  PropertyRNA *prop;
442 
443  static const EnumPropertyItem prop_areashape_items[] = {
444  {LA_AREA_SQUARE, "SQUARE", 0, "Square", ""},
445  {LA_AREA_RECT, "RECTANGLE", 0, "Rectangle", ""},
446  {LA_AREA_DISK, "DISK", 0, "Disk", ""},
447  {LA_AREA_ELLIPSE, "ELLIPSE", 0, "Ellipse", ""},
448  {0, NULL, 0, NULL, NULL},
449  };
450 
451  srna = RNA_def_struct(brna, "AreaLight", "Light");
452  RNA_def_struct_sdna(srna, "Light");
453  RNA_def_struct_ui_text(srna, "Area Light", "Directional area Light");
454  RNA_def_struct_ui_icon(srna, ICON_LIGHT_AREA);
455 
457  rna_def_light_shadow(srna, false);
458  rna_def_light_falloff(srna);
459 
460  prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
461  RNA_def_property_enum_sdna(prop, NULL, "area_shape");
462  RNA_def_property_enum_items(prop, prop_areashape_items);
463  RNA_def_property_ui_text(prop, "Shape", "Shape of the area Light");
464  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
465 
466  prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE);
467  RNA_def_property_float_sdna(prop, NULL, "area_size");
468  RNA_def_property_range(prop, 0.0f, FLT_MAX);
469  RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
471  prop, "Size", "Size of the area of the area light, X direction size for rectangle shapes");
472  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
473 
474  prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE);
475  RNA_def_property_float_sdna(prop, NULL, "area_sizey");
476  RNA_def_property_range(prop, 0.0f, FLT_MAX);
477  RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
479  prop,
480  "Size Y",
481  "Size of the area of the area light in the Y direction for rectangle shapes");
482  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
483 
484  prop = RNA_def_property(srna, "spread", PROP_FLOAT, PROP_ANGLE);
485  RNA_def_property_float_sdna(prop, NULL, "area_spread");
486  RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f));
488  prop,
489  "Spread",
490  "How widely the emitted light fans out, as in the case of a gridded softbox");
491  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
492 }
493 
494 static void rna_def_spot_light(BlenderRNA *brna)
495 {
496  StructRNA *srna;
497  PropertyRNA *prop;
498 
499  srna = RNA_def_struct(brna, "SpotLight", "Light");
500  RNA_def_struct_sdna(srna, "Light");
501  RNA_def_struct_ui_text(srna, "Spot Light", "Directional cone Light");
502  RNA_def_struct_ui_icon(srna, ICON_LIGHT_SPOT);
503 
505  rna_def_light_falloff(srna);
506  rna_def_light_shadow(srna, false);
507 
508  prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE);
510  RNA_def_property_ui_text(prop, "Square", "Cast a square spot light shape");
511  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
512 
513  prop = RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE);
514  RNA_def_property_float_sdna(prop, NULL, "spotblend");
515  RNA_def_property_range(prop, 0.0f, 1.0f);
516  RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge");
517  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
518 
519  prop = RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE);
520  RNA_def_property_float_sdna(prop, NULL, "spotsize");
521  RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f));
522  RNA_def_property_ui_text(prop, "Spot Size", "Angle of the spotlight beam");
523  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
524 
525  prop = RNA_def_property(srna, "show_cone", PROP_BOOLEAN, PROP_NONE);
528  prop,
529  "Show Cone",
530  "Display transparent cone in 3D view to visualize which objects are contained in it");
531  RNA_def_property_update(prop, 0, "rna_Light_draw_update");
532 }
533 
534 static void rna_def_sun_light(BlenderRNA *brna)
535 {
536  StructRNA *srna;
537  PropertyRNA *prop;
538 
539  srna = RNA_def_struct(brna, "SunLight", "Light");
540  RNA_def_struct_sdna(srna, "Light");
541  RNA_def_struct_ui_text(srna, "Sun Light", "Constant direction parallel ray Light");
542  RNA_def_struct_ui_icon(srna, ICON_LIGHT_SUN);
543 
544  prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
545  RNA_def_property_float_sdna(prop, NULL, "sun_angle");
546  RNA_def_property_range(prop, DEG2RADF(0.0f), DEG2RADF(180.0f));
547  RNA_def_property_ui_text(prop, "Angle", "Angular diameter of the Sun as seen from the Earth");
548  RNA_def_property_update(prop, 0, "rna_Light_update");
549 
551  rna_def_light_shadow(srna, true);
552 }
553 
555 {
556  rna_def_light(brna);
557  rna_def_point_light(brna);
558  rna_def_area_light(brna);
559  rna_def_spot_light(brna);
560  rna_def_sun_light(brna);
561 }
562 
563 #endif
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
#define DEG2RADF(_deg)
#define UNUSED(x)
#define BLT_I18NCONTEXT_ID_LIGHT
void DEG_id_tag_update(struct ID *id, int flag)
#define LA_AREA
#define LA_FALLOFF_SLIDERS
#define LA_FALLOFF_INVCOEFFICIENTS
#define LA_FALLOFF_CONSTANT
#define LA_SPOT
#define LA_AREA_SQUARE
#define LA_AREA_ELLIPSE
#define LA_SUN
#define LA_SHADOW
#define LA_SQUARE
#define LA_LOCAL
#define LA_FALLOFF_INVSQUARE
#define LA_CUSTOM_ATTENUATION
#define LA_SHOW_CONE
#define LA_AREA_DISK
#define LA_AREA_RECT
#define LA_FALLOFF_INVLINEAR
#define LA_FALLOFF_CURVE
#define LA_SHAD_CONTACT
void ED_node_shader_default(const struct bContext *C, struct ID *id)
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera CLAMP
StructRNA RNA_AreaLight
StructRNA RNA_PointLight
StructRNA RNA_Light
StructRNA RNA_SunLight
StructRNA RNA_SpotLight
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_ENUM
Definition: RNA_types.h:77
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_CONTEXT_UPDATE
Definition: RNA_types.h:254
@ PROP_ANIMATABLE
Definition: RNA_types.h:188
@ PROP_PTR_NO_OWNERSHIP
Definition: RNA_types.h:242
@ PROP_DISTANCE
Definition: RNA_types.h:135
@ PROP_POWER
Definition: RNA_types.h:160
@ PROP_COLOR
Definition: RNA_types.h:139
@ PROP_ANGLE
Definition: RNA_types.h:132
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_FACTOR
Definition: RNA_types.h:131
#define C
Definition: RandGen.cpp:39
#define ND_LIGHTING_DRAW
Definition: WM_types.h:384
#define NC_LAMP
Definition: WM_types.h:283
#define ND_LIGHTING
Definition: WM_types.h:383
Scene scene
void rna_def_animdata_common(StructRNA *srna)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
Definition: rna_define.c:1167
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2762
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2257
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1892
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1067
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1568
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1757
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2927
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2623
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3055
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1267
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
Definition: rna_define.c:2870
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2515
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
Definition: rna_define.c:1706
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2364
void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
Definition: rna_define.c:1272
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
Definition: rna_define.c:2064
static void rna_def_area_light(BlenderRNA *brna)
Definition: rna_light.c:438
void RNA_def_light(BlenderRNA *brna)
Definition: rna_light.c:554
static void rna_def_sun_light(BlenderRNA *brna)
Definition: rna_light.c:534
static void rna_def_light_shadow(StructRNA *srna, bool sun)
Definition: rna_light.c:303
static void rna_def_light_falloff(StructRNA *srna)
Definition: rna_light.c:246
const EnumPropertyItem rna_enum_light_type_items[]
Definition: rna_light.c:107
static void rna_def_point_light(BlenderRNA *brna)
Definition: rna_light.c:424
static void rna_def_light_energy(StructRNA *srna, const short light_type)
Definition: rna_light.c:204
static void rna_def_spot_light(BlenderRNA *brna)
Definition: rna_light.c:494
static void rna_def_light(BlenderRNA *brna)
Definition: rna_light.c:115
short bufsize
short use_nodes
struct bNodeTree * nodetree
short type
Definition: BKE_main.h:116
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3157