Blender V5.3
rna_light.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
12
13#include "BLT_translation.hh"
14
15#include "RNA_define.hh"
16#include "RNA_enum_types.hh"
17#include "RNA_types.hh"
18#include "rna_internal.hh"
19
20#include "DNA_light_types.h"
21
23
24#ifdef RNA_RUNTIME
25
26# include "MEM_guardedalloc.h"
27
29
30# include "BKE_context.hh"
31# include "BKE_light.h"
32# include "BKE_main.hh"
33# include "BKE_texture.h"
34
35# include "DEG_depsgraph.hh"
36
37# include "NOD_defaults.hh"
38
39# include "WM_api.hh"
40# include "WM_types.hh"
41
42# include "ED_node.hh"
43
44namespace blender {
45
46static StructRNA *rna_Light_refine(PointerRNA *ptr)
47{
48 Light *la = static_cast<Light *>(ptr->data);
49
50 switch (la->type) {
51 case LA_LOCAL:
52 return RNA_PointLight;
53 case LA_SUN:
54 return RNA_SunLight;
55 case LA_SPOT:
56 return RNA_SpotLight;
57 case LA_AREA:
58 return RNA_AreaLight;
59 default:
60 return RNA_Light;
61 }
62}
63
64static void rna_Light_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
65{
66 Light *la = id_cast<Light *>(ptr->owner_id);
67
68 DEG_id_tag_update(&la->id, 0);
70}
71
72static void rna_Light_draw_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
73{
74 Light *la = id_cast<Light *>(ptr->owner_id);
75
76 DEG_id_tag_update(&la->id, 0);
78}
79
80static bool rna_Light_use_nodes_get(PointerRNA * /*ptr*/)
81{
82 /* #use_nodes is deprecated. All lights now use nodes. */
83 return true;
84}
85
86static void rna_Light_use_nodes_set(PointerRNA * /*ptr*/, bool /*new_value*/)
87{
88 /* #use_nodes is deprecated. Setting the property has no effect.
89 * Note: Users will get a warning through the RNA deprecation warning, so no need to log a
90 * warning here. */
91 return;
92}
93
94static void rna_Light_temperature_color_get(PointerRNA *ptr, float *color)
95{
96 Light *la = static_cast<Light *>(ptr->data);
97
98 if (la->mode & LA_USE_TEMPERATURE) {
99 float rgb[4];
101
102 color[0] = rgb[0];
103 color[1] = rgb[1];
104 color[2] = rgb[2];
105 }
106 else {
107 copy_v3_fl(color, 1.0f);
108 }
109}
110
111static float rna_Light_area(Light *light, const float matrix_world[16])
112{
113 float4x4 mat(matrix_world);
114 return BKE_light_area(*light, mat);
115}
116
117} // namespace blender
118
119#else
120
121namespace blender {
122
123/* NOTE(@dingto): Don't define icons here,
124 * so they don't show up in the Light UI (properties editor). */
125
127 {LA_LOCAL, "POINT", 0, "Point", "Omnidirectional point light source"},
128 {LA_SUN, "SUN", 0, "Sun", "Constant direction parallel ray light source"},
129 {LA_SPOT, "SPOT", 0, "Spot", "Directional cone light source"},
130 {LA_AREA, "AREA", 0, "Area", "Directional area light source"},
131 {0, nullptr, 0, nullptr, nullptr},
132};
133
134static void rna_def_light_api(StructRNA *srna)
135{
136 FunctionRNA *func = RNA_def_function(srna, "area", "rna_Light_area");
138 "Compute light area based on type and shape. The normalize "
139 "option divides light intensity by this area");
140 PropertyRNA *parm = RNA_def_property(func, "matrix_world", PROP_FLOAT, PROP_MATRIX);
142 RNA_def_property_ui_text(parm, "", "Object to world space transformation matrix");
143 parm = RNA_def_property(func, "area", PROP_FLOAT, PROP_NONE);
144 RNA_def_function_return(func, parm);
145}
146
147static void rna_def_light(BlenderRNA *brna)
148{
149 StructRNA *srna;
150 PropertyRNA *prop;
151 static const float default_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
152
153 srna = RNA_def_struct(brna, "Light", "ID");
154 RNA_def_struct_sdna(srna, "Light");
155 RNA_def_struct_refine_func(srna, "rna_Light_refine");
156 RNA_def_struct_ui_text(srna, "Light", "Light data-block for lighting a scene");
158 RNA_def_struct_ui_icon(srna, ICON_LIGHT_DATA);
159
160 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
162 RNA_def_property_ui_text(prop, "Type", "Type of light");
164 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
165
167
168 prop = RNA_def_property(srna, "use_temperature", PROP_BOOLEAN, PROP_NONE);
171 prop, "Use Temperature", "Use blackbody temperature to define a natural light color");
173 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
174
175 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
176 RNA_def_property_float_sdna(prop, nullptr, "r");
177 RNA_def_property_array(prop, 3);
178 RNA_def_property_float_array_default(prop, default_color);
179 RNA_def_property_ui_text(prop, "Color", "Light color");
180 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
181
182 prop = RNA_def_property(srna, "temperature", PROP_FLOAT, PROP_COLOR_TEMPERATURE);
183 RNA_def_property_float_sdna(prop, nullptr, "temperature");
184 RNA_def_property_range(prop, 800.0f, 20000.0f);
185 RNA_def_property_ui_range(prop, 800.0f, 20000.0f, 400.0f, 1);
186 RNA_def_property_ui_text(prop, "Temperature", "Light color temperature in Kelvin");
187 RNA_def_property_update(prop, 0, "rna_Light_update");
188
190
191 /* Excluded from being overridable because it's a read-only property with a
192 * dynamically-generated value based on the 'temperature' property above. */
193 prop = RNA_def_property(srna, "temperature_color", PROP_FLOAT, PROP_COLOR);
194 RNA_def_property_array(prop, 3);
196 RNA_def_property_float_funcs(prop, "rna_Light_temperature_color_get", nullptr, nullptr);
197 RNA_def_property_ui_text(prop, "Temperature Color", "Color from Temperature");
198 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
199
201
202 prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_FACTOR);
203 RNA_def_property_float_sdna(prop, nullptr, "spec_fac");
204 RNA_def_property_range(prop, 0.0f, FLT_MAX);
205 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
206 RNA_def_property_ui_text(prop, "Specular Factor", "Specular reflection multiplier");
207 RNA_def_property_update(prop, 0, "rna_Light_update");
208
209 prop = RNA_def_property(srna, "diffuse_factor", PROP_FLOAT, PROP_FACTOR);
210 RNA_def_property_float_sdna(prop, nullptr, "diff_fac");
211 RNA_def_property_range(prop, 0.0f, FLT_MAX);
212 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
213 RNA_def_property_ui_text(prop, "Diffuse Factor", "Diffuse reflection multiplier");
214 RNA_def_property_update(prop, 0, "rna_Light_update");
215
216 prop = RNA_def_property(srna, "transmission_factor", PROP_FLOAT, PROP_FACTOR);
217 RNA_def_property_float_sdna(prop, nullptr, "transmission_fac");
218 RNA_def_property_range(prop, 0.0f, FLT_MAX);
219 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
220 RNA_def_property_ui_text(prop, "Transmission Factor", "Transmission light multiplier");
221 RNA_def_property_update(prop, 0, "rna_Light_update");
222
223 prop = RNA_def_property(srna, "volume_factor", PROP_FLOAT, PROP_FACTOR);
224 RNA_def_property_float_sdna(prop, nullptr, "volume_fac");
225 RNA_def_property_range(prop, 0.0f, FLT_MAX);
226 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 2);
227 RNA_def_property_ui_text(prop, "Volume Factor", "Volume light multiplier");
228 RNA_def_property_update(prop, 0, "rna_Light_update");
229
230 prop = RNA_def_property(srna, "use_custom_distance", PROP_BOOLEAN, PROP_NONE);
233 "Custom Attenuation",
234 "Use custom attenuation distance instead of global light threshold");
235 RNA_def_property_update(prop, 0, "rna_Light_update");
236
237 prop = RNA_def_property(srna, "cutoff_distance", PROP_FLOAT, PROP_DISTANCE);
238 RNA_def_property_float_sdna(prop, nullptr, "att_dist");
239 RNA_def_property_range(prop, 0.0f, FLT_MAX);
240 RNA_def_property_ui_range(prop, 0.01f, 100.0f, 1.0, 2);
242 prop, "Cutoff Distance", "Distance at which the light influence will be set to 0");
243 RNA_def_property_update(prop, 0, "rna_Light_update");
244
245 prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE);
246 RNA_def_property_boolean_sdna(prop, nullptr, "mode", LA_SHADOW);
247 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
248
249 prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_FACTOR);
251 RNA_def_property_range(prop, -32.0f, 32.0f);
252 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 1, 3);
254 prop,
255 "Exposure",
256 "Scales the power of the light exponentially, multiplying the intensity by 2^exposure");
257 RNA_def_property_update(prop, 0, "rna_Light_update");
258
259 prop = RNA_def_property(srna, "normalize", PROP_BOOLEAN, PROP_NONE);
263 "Normalize",
264 "Normalize intensity by light area, for consistent total light "
265 "output regardless of size and shape");
266 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
267
269
270 /* nodes */
271 prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
272 RNA_def_property_pointer_sdna(prop, nullptr, "nodetree");
275 RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based lights");
276
277 prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
278 RNA_def_property_boolean_sdna(prop, nullptr, "use_nodes", 1);
280 RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the light");
281 RNA_def_property_boolean_funcs(prop, "rna_Light_use_nodes_get", "rna_Light_use_nodes_set");
283 "Unused but kept for compatibility reasons. Setting the property "
284 "has no effect, and getting it always returns True.",
285 501,
286 600);
287
288 /* common */
290 rna_def_light_api(srna);
291}
292
293static void rna_def_light_energy(StructRNA *srna, const short light_type)
294{
295 PropertyRNA *prop;
296
298
299 switch (light_type) {
300 case LA_SUN: {
301 /* Distant light strength has no unit defined,
302 * it's proportional to 'watt/m^2' and is not sensitive to scene unit scale. */
303 prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
304 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
306 prop, "Strength", "Sunlight strength in watts per meter squared (W/m²)");
308 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
309 break;
310 }
311 case LA_SPOT: {
312 /* Lights with a location have radiometric power in Watts,
313 * which is sensitive to scene unit scale. */
314 prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
315 RNA_def_property_ui_range(prop, 0.0f, 1000000.0f, 10, 3);
317 prop,
318 "Power",
319 "The energy this light would emit over its entire area "
320 "if it wasn't limited by the spot angle, in units of radiant power (W)");
322 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
323 break;
324 }
325 default: {
326 /* Lights with a location have radiometric power in Watts,
327 * which is sensitive to scene unit scale. */
328 prop = RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
329 RNA_def_property_ui_range(prop, 0.0f, 1000000.0f, 10, 3);
331 "Power",
332 "Light energy emitted over the entire area of the light in all "
333 "directions, in units of radiant power (W)");
335 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
336 break;
337 }
338 }
339
341}
342
343static void rna_def_light_shadow(StructRNA *srna, bool sun)
344{
345 PropertyRNA *prop;
346
348
349 prop = RNA_def_property(srna, "shadow_buffer_clip_start", PROP_FLOAT, PROP_DISTANCE);
350 RNA_def_property_float_sdna(prop, nullptr, "clipsta");
351 RNA_def_property_range(prop, 1e-6f, FLT_MAX);
352 RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
354 "Shadow Buffer Clip Start",
355 "Shadow map clip start, below which objects will not generate shadows");
356 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
357
358 prop = RNA_def_property(srna, "shadow_soft_size", PROP_FLOAT, PROP_DISTANCE);
359 RNA_def_property_float_sdna(prop, nullptr, "radius");
360 RNA_def_property_range(prop, 0.0f, FLT_MAX);
361 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
363 prop, "Shadow Soft Size", "Light size for ray shadow sampling (Raytraced shadows)");
364 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
365
366 /* Eevee */
367 prop = RNA_def_property(srna, "shadow_filter_radius", PROP_FLOAT, PROP_NONE);
368 RNA_def_property_range(prop, 0.0f, FLT_MAX);
369 RNA_def_property_ui_range(prop, 0.0f, 5.0f, 1.0f, 2);
371 prop, "Shadow Filter Radius", "Blur shadow aliasing using Percentage Closer Filtering");
372 RNA_def_property_update(prop, 0, "rna_Light_update");
373
374 prop = RNA_def_property(srna, "shadow_maximum_resolution", PROP_FLOAT, PROP_DISTANCE);
375 RNA_def_property_range(prop, 0.0f, FLT_MAX);
376 RNA_def_property_ui_range(prop, 0.0001f, 0.020f, 0.05f, 4);
378 "Shadows Resolution Limit",
379 "Minimum size of a shadow map pixel. Higher values use less memory at "
380 "the cost of shadow quality.");
381 RNA_def_property_update(prop, 0, "rna_Light_update");
382
383 prop = RNA_def_property(srna, "use_shadow_jitter", PROP_BOOLEAN, PROP_NONE);
384 RNA_def_property_boolean_sdna(prop, nullptr, "mode", LA_SHADOW_JITTER);
386 prop,
387 "Shadow Jitter",
388 "Enable jittered soft shadows to increase shadow precision (disabled in viewport unless "
389 "enabled in the render settings). Has a high performance impact.");
390 RNA_def_property_update(prop, 0, "rna_Light_update");
391
392 prop = RNA_def_property(srna, "shadow_jitter_overblur", PROP_FLOAT, PROP_PERCENTAGE);
393 RNA_def_property_range(prop, 0.0f, 100.0f);
394 RNA_def_property_ui_range(prop, 0.0f, 20.0f, 10.0f, 0);
396 prop,
397 "Shadow Jitter Overblur",
398 "Apply shadow tracing to each jittered sample to reduce under-sampling artifacts");
399 RNA_def_property_update(prop, 0, "rna_Light_update");
400
401 if (sun) {
402 prop = RNA_def_property(srna, "shadow_cascade_max_distance", PROP_FLOAT, PROP_DISTANCE);
403 RNA_def_property_float_sdna(prop, nullptr, "cascade_max_dist");
404 RNA_def_property_range(prop, 0.0f, FLT_MAX);
406 "Cascade Max Distance",
407 "End distance of the cascaded shadow map (only in perspective view)");
408 RNA_def_property_update(prop, 0, "rna_Light_update");
409
410 prop = RNA_def_property(srna, "shadow_cascade_count", PROP_INT, PROP_NONE);
411 RNA_def_property_int_sdna(prop, nullptr, "cascade_count");
412 RNA_def_property_range(prop, 1, 4);
414 prop, "Cascade Count", "Number of texture used by the cascaded shadow map");
415 RNA_def_property_update(prop, 0, "rna_Light_update");
416
417 prop = RNA_def_property(srna, "shadow_cascade_exponent", PROP_FLOAT, PROP_FACTOR);
418 RNA_def_property_float_sdna(prop, nullptr, "cascade_exponent");
419 RNA_def_property_range(prop, 0.0f, 1.0f);
421 "Exponential Distribution",
422 "Higher value increase resolution towards the viewpoint");
423 RNA_def_property_update(prop, 0, "rna_Light_update");
424
425 prop = RNA_def_property(srna, "shadow_cascade_fade", PROP_FLOAT, PROP_FACTOR);
426 RNA_def_property_float_sdna(prop, nullptr, "cascade_fade");
427 RNA_def_property_range(prop, 0.0f, 1.0f);
429 prop, "Cascade Fade", "How smooth is the transition between each cascade");
430 RNA_def_property_update(prop, 0, "rna_Light_update");
431 }
432 else {
433 prop = RNA_def_property(srna, "use_absolute_resolution", PROP_BOOLEAN, PROP_NONE);
436 "Absolute Resolution Limit",
437 "Limit the resolution at 1 unit from the light origin instead of "
438 "relative to the shadowed pixel");
439 RNA_def_property_update(prop, 0, "rna_Light_update");
440 }
441
443}
444
446{
447 StructRNA *srna;
448
449 srna = RNA_def_struct(brna, "PointLight", "Light");
450 RNA_def_struct_sdna(srna, "Light");
451 RNA_def_struct_ui_text(srna, "Point Light", "Omnidirectional point Light");
452 RNA_def_struct_ui_icon(srna, ICON_LIGHT_POINT);
453
454 PropertyRNA *prop;
455 prop = RNA_def_property(srna, "use_soft_falloff", PROP_BOOLEAN, PROP_NONE);
458 prop,
459 "Soft Falloff",
460 "Apply falloff to avoid sharp edges when the light geometry intersects with other objects");
462 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
463
465 rna_def_light_shadow(srna, false);
466}
467
469{
470 StructRNA *srna;
471 PropertyRNA *prop;
472
473 static const EnumPropertyItem prop_areashape_items[] = {
474 {LA_AREA_SQUARE, "SQUARE", 0, "Square", ""},
475 {LA_AREA_RECT, "RECTANGLE", 0, "Rectangle", ""},
476 {LA_AREA_DISK, "DISK", 0, "Disk", ""},
477 {LA_AREA_ELLIPSE, "ELLIPSE", 0, "Ellipse", ""},
478 {0, nullptr, 0, nullptr, nullptr},
479 };
480
481 srna = RNA_def_struct(brna, "AreaLight", "Light");
482 RNA_def_struct_sdna(srna, "Light");
483 RNA_def_struct_ui_text(srna, "Area Light", "Directional area Light");
484 RNA_def_struct_ui_icon(srna, ICON_LIGHT_AREA);
485
487 rna_def_light_shadow(srna, false);
488
490
491 prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
492 RNA_def_property_enum_sdna(prop, nullptr, "area_shape");
493 RNA_def_property_enum_items(prop, prop_areashape_items);
494 RNA_def_property_ui_text(prop, "Shape", "Shape of the area Light");
495 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
496
497 prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_DISTANCE);
498 RNA_def_property_float_sdna(prop, nullptr, "area_size");
499 RNA_def_property_range(prop, 0.0f, FLT_MAX);
500 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
502 prop, "Size", "Size of the area of the area light, X direction size for rectangle shapes");
503 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
504
505 prop = RNA_def_property(srna, "size_y", PROP_FLOAT, PROP_DISTANCE);
506 RNA_def_property_float_sdna(prop, nullptr, "area_sizey");
507 RNA_def_property_range(prop, 0.0f, FLT_MAX);
508 RNA_def_property_ui_range(prop, 0, 100, 0.1, 3);
510 prop,
511 "Size Y",
512 "Size of the area of the area light in the Y direction for rectangle shapes");
513 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
514
515 prop = RNA_def_property(srna, "spread", PROP_FLOAT, PROP_ANGLE);
516 RNA_def_property_float_sdna(prop, nullptr, "area_spread");
517 RNA_def_property_range(prop, DEG2RADF(0.0f), DEG2RADF(180.0f));
519 prop,
520 "Spread",
521 "How widely the emitted light fans out, as in the case of a gridded softbox");
522 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
523
525}
526
528{
529 StructRNA *srna;
530 PropertyRNA *prop;
531
532 srna = RNA_def_struct(brna, "SpotLight", "Light");
533 RNA_def_struct_sdna(srna, "Light");
534 RNA_def_struct_ui_text(srna, "Spot Light", "Directional cone Light");
535 RNA_def_struct_ui_icon(srna, ICON_LIGHT_SPOT);
536
538 rna_def_light_shadow(srna, false);
539
541
542 prop = RNA_def_property(srna, "use_square", PROP_BOOLEAN, PROP_NONE);
543 RNA_def_property_boolean_sdna(prop, nullptr, "mode", LA_SQUARE);
544 RNA_def_property_ui_text(prop, "Square", "Cast a square spot light shape");
545 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
546
547 prop = RNA_def_property(srna, "spot_blend", PROP_FLOAT, PROP_NONE);
548 RNA_def_property_float_sdna(prop, nullptr, "spotblend");
549 RNA_def_property_range(prop, 0.0f, 1.0f);
550 RNA_def_property_ui_text(prop, "Spot Blend", "The softness of the spotlight edge");
551 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
552
553 prop = RNA_def_property(srna, "spot_size", PROP_FLOAT, PROP_ANGLE);
554 RNA_def_property_float_sdna(prop, nullptr, "spotsize");
555 RNA_def_property_range(prop, DEG2RADF(1.0f), DEG2RADF(180.0f));
556 RNA_def_property_ui_text(prop, "Beam Angle", "Angular diameter of the spotlight beam");
557 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
558
559 prop = RNA_def_property(srna, "show_cone", PROP_BOOLEAN, PROP_NONE);
560 RNA_def_property_boolean_sdna(prop, nullptr, "mode", LA_SHOW_CONE);
562 prop,
563 "Show Cone",
564 "Display transparent cone in 3D view to visualize which objects are contained in it");
565 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
566
567 prop = RNA_def_property(srna, "use_soft_falloff", PROP_BOOLEAN, PROP_NONE);
570 prop,
571 "Soft Falloff",
572 "Apply falloff to avoid sharp edges when the light geometry intersects with other objects");
573 RNA_def_property_update(prop, 0, "rna_Light_draw_update");
574
576}
577
579{
580 StructRNA *srna;
581 PropertyRNA *prop;
582
583 srna = RNA_def_struct(brna, "SunLight", "Light");
584 RNA_def_struct_sdna(srna, "Light");
585 RNA_def_struct_ui_text(srna, "Sun Light", "Constant direction parallel ray Light");
586 RNA_def_struct_ui_icon(srna, ICON_LIGHT_SUN);
587
588 prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
589 RNA_def_property_float_sdna(prop, nullptr, "sun_angle");
590 RNA_def_property_range(prop, DEG2RADF(0.0f), DEG2RADF(180.0f));
591 RNA_def_property_ui_text(prop, "Angle", "Angular diameter of the Sun as seen from the Earth");
593 RNA_def_property_update(prop, 0, "rna_Light_update");
594
596 rna_def_light_shadow(srna, true);
597}
598
600{
601 rna_def_light(brna);
603 rna_def_area_light(brna);
604 rna_def_spot_light(brna);
605 rna_def_sun_light(brna);
606}
607
608} // namespace blender
609
610#endif
General operations, lookup, etc. for blender lights.
#define DEG2RADF(_deg)
#define BLT_I18NCONTEXT_ID_LIGHT
Read Blender memory allocation and freeing.
#define ND_LIGHTING_DRAW
Definition WM_types.hh:527
#define NC_LAMP
Definition WM_types.hh:395
#define ND_LIGHTING
Definition WM_types.hh:526
#define FLT_MAX
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_deprecated(PropertyRNA *prop, const char *note, const short version, const short removal_version)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
static void rna_def_light_api(StructRNA *srna)
Definition rna_light.cc:134
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_light(BlenderRNA *brna)
Definition rna_light.cc:599
void RNA_define_lib_overridable(const bool make_overridable)
const EnumPropertyItem rna_enum_light_type_items[]
MatBase< float, 4, 4 > float4x4
static void rna_def_point_light(BlenderRNA *brna)
Definition rna_light.cc:445
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:588
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void rna_def_animdata_common(StructRNA *srna)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
void DEG_id_tag_update(ID *id, unsigned int flags)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
static void rna_def_area_light(BlenderRNA *brna)
Definition rna_light.cc:468
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void IMB_colormanagement_blackbody_temperature_to_rgb(float r_dest[4], float value)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
MINLINE void copy_v3_fl(float r[3], float f)
static void rna_def_sun_light(BlenderRNA *brna)
Definition rna_light.cc:578
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:465
@ PROP_ANIMATABLE
Definition RNA_types.hh:389
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
float BKE_light_area(const Light &light, const float4x4 &object_to_world)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
static void rna_def_light(BlenderRNA *brna)
Definition rna_light.cc:147
static void rna_def_spot_light(BlenderRNA *brna)
Definition rna_light.cc:527
@ LA_CUSTOM_ATTENUATION
@ LA_SHAD_RES_ABSOLUTE
@ LA_USE_SOFT_FALLOFF
@ PROP_PERCENTAGE
Definition RNA_types.hh:307
@ PROP_FACTOR
Definition RNA_types.hh:308
@ PROP_MATRIX
Definition RNA_types.hh:322
@ PROP_DISTANCE
Definition RNA_types.hh:313
@ PROP_COLOR_TEMPERATURE
Definition RNA_types.hh:347
static void rna_def_light_shadow(StructRNA *srna, bool sun)
Definition rna_light.cc:343
void RNA_def_property_array(PropertyRNA *prop, int length)
const int rna_matrix_dimsize_4x4[]
static void rna_def_light_energy(StructRNA *srna, const short light_type)
Definition rna_light.cc:293
const NodeType * type
Definition graph/node.h:179