Blender V5.3
rna_lightprobe.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
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13
14#include "rna_internal.hh"
15
17
18#include "WM_types.hh"
19
20#ifdef RNA_RUNTIME
21
22# include "MEM_guardedalloc.h"
23
24# include "BKE_main.hh"
25# include "DEG_depsgraph.hh"
26
27# include "DNA_collection_types.h"
28# include "DNA_object_types.h"
29
30# include "WM_api.hh"
31
32namespace blender {
33
34static StructRNA *rna_LightProbe_refine(PointerRNA *ptr)
35{
36 LightProbe *probe = static_cast<LightProbe *>(ptr->data);
37 switch (probe->type) {
39 return RNA_LightProbePlane;
41 return RNA_LightProbeSphere;
43 return RNA_LightProbeVolume;
44 default:
45 return RNA_LightProbe;
46 }
47}
48
49static void rna_LightProbe_recalc(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
50{
52}
53
54} // namespace blender
55
56#else
57
58namespace blender {
59
61 {LIGHTPROBE_SHAPE_ELLIPSOID, "ELIPSOID", ICON_NONE, "Sphere", ""},
62 {LIGHTPROBE_SHAPE_BOX, "BOX", ICON_NONE, "Box", ""},
63 {0, nullptr, 0, nullptr, nullptr},
64};
65
68 "SPHERE",
69 ICON_LIGHTPROBE_SPHERE,
70 "Sphere",
71 "Light probe that captures precise lighting from all directions at a single point in space"},
73 "PLANE",
74 ICON_LIGHTPROBE_PLANE,
75 "Plane",
76 "Light probe that captures incoming light from a single direction on a plane"},
78 "VOLUME",
79 ICON_LIGHTPROBE_VOLUME,
80 "Volume",
81 "Light probe that captures low frequency lighting inside a volume"},
82 {0, nullptr, 0, nullptr, nullptr},
83};
84
86{
87 StructRNA *srna;
88 PropertyRNA *prop;
89
90 srna = RNA_def_struct(brna, "LightProbe", "ID");
91 RNA_def_struct_refine_func(srna, "rna_LightProbe_refine");
93 srna, "LightProbe", "Light Probe data-block for lighting capture objects");
94 RNA_def_struct_ui_icon(srna, ICON_OUTLINER_DATA_LIGHTPROBE);
95
96 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
98 RNA_def_property_ui_text(prop, "Type", "Type of light probe");
100
101 prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
102 RNA_def_property_float_sdna(prop, nullptr, "clipsta");
103 RNA_def_property_range(prop, 1e-6f, FLT_MAX);
104 RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
106 prop, "Clip Start", "Probe clip start, below which objects will not appear in reflections");
107 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
108
109 prop = RNA_def_property(srna, "show_clip", PROP_BOOLEAN, PROP_NONE);
111 RNA_def_property_ui_text(prop, "Clipping", "Show the clipping distances in the 3D view");
113
114 prop = RNA_def_property(srna, "show_influence", PROP_BOOLEAN, PROP_NONE);
116 RNA_def_property_ui_text(prop, "Influence", "Show the influence volume in the 3D view");
118
119 prop = RNA_def_property(srna, "influence_distance", PROP_FLOAT, PROP_DISTANCE);
120 RNA_def_property_float_sdna(prop, nullptr, "distinf");
121 RNA_def_property_range(prop, 0.0f, FLT_MAX);
122 RNA_def_property_ui_text(prop, "Influence Distance", "Influence distance of the probe");
124
125# if 1 /* Deprecated: Remove in Blender 4.5 */
126 prop = RNA_def_property(srna, "visibility_buffer_bias", PROP_FLOAT, PROP_NONE);
127 RNA_def_property_float_sdna(prop, nullptr, "vis_bias");
128 RNA_def_property_range(prop, 0.001f, 9999.0f);
129 RNA_def_property_ui_range(prop, 0.001f, 5.0f, 1.0, 3);
131 prop, "Visibility Bias", "Bias for reducing self shadowing (Deprecated)");
133
134 prop = RNA_def_property(srna, "visibility_bleed_bias", PROP_FLOAT, PROP_FACTOR);
135 RNA_def_property_float_sdna(prop, nullptr, "vis_bleedbias");
136 RNA_def_property_range(prop, 0.0f, 1.0f);
138 "Visibility Bleed Bias",
139 "Bias for reducing light-bleed on variance shadow maps (Deprecated)");
141
142 prop = RNA_def_property(srna, "visibility_blur", PROP_FLOAT, PROP_FACTOR);
143 RNA_def_property_float_sdna(prop, nullptr, "vis_blur");
144 RNA_def_property_range(prop, 0.0f, 1.0f);
146 prop, "Visibility Blur", "Filter size of the visibility blur (Deprecated)");
147 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
148
149 prop = RNA_def_property(srna, "visibility_collection", PROP_POINTER, PROP_NONE);
150 RNA_def_property_struct_type(prop, "Collection");
151 RNA_def_property_pointer_sdna(prop, nullptr, "visibility_grp");
155 prop, "Visibility Collection", "Restrict objects visible for this probe (Deprecated)");
156 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
157
158 prop = RNA_def_property(srna, "invert_visibility_collection", PROP_BOOLEAN, PROP_NONE);
161 RNA_def_property_ui_text(prop, "Invert Collection", "Invert visibility collection (Deprecated)");
162 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
163# endif
164
165 /* Data preview */
166 prop = RNA_def_property(srna, "show_data", PROP_BOOLEAN, PROP_NONE);
168 RNA_def_property_ui_icon(prop, ICON_HIDE_ON, 1);
170 prop, "Display Data (Deprecated)", "Deprecated, use use_data_display instead");
173
174 prop = RNA_def_property(srna, "use_data_display", PROP_BOOLEAN, PROP_NONE);
177 prop, "Display Data", "Display sampled data in the viewport to debug captured light");
180
181 prop = RNA_def_property(srna, "data_display_size", PROP_FLOAT, PROP_FACTOR);
182 RNA_def_property_float_sdna(prop, nullptr, "data_display_size");
183 RNA_def_property_range(prop, 0.0f, FLT_MAX);
184 RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 3);
185 RNA_def_property_ui_text(prop, "Display Data Size", "Viewport display size of the sampled data");
187
188 /* common */
190}
191
193{
194 StructRNA *srna;
195 PropertyRNA *prop;
196
197 srna = RNA_def_struct(brna, "LightProbePlane", "LightProbe");
198 RNA_def_struct_sdna(srna, "LightProbe");
200 srna,
201 "Planar Probe",
202 "Light probe that captures incoming light from a single direction on a plane");
203 RNA_def_struct_ui_icon(srna, ICON_LIGHTPROBE_PLANE);
204
205 prop = RNA_def_property(srna, "parallax_distance", PROP_FLOAT, PROP_DISTANCE);
206 RNA_def_property_float_sdna(prop, nullptr, "distpar");
207 RNA_def_property_range(prop, 0.0f, FLT_MAX);
209 "Parallax Radius",
210 "Amount of parallax to use for reflections on Blended materials or "
211 "Shader To RGB evaluation");
213}
214
216{
217 StructRNA *srna;
218 PropertyRNA *prop;
219
220 srna = RNA_def_struct(brna, "LightProbeSphere", "LightProbe");
221 RNA_def_struct_sdna(srna, "LightProbe");
223 srna,
224 "Spherical Probe",
225 "Light probe that captures precise lighting from all directions at a single point in space");
226 RNA_def_struct_ui_icon(srna, ICON_LIGHTPROBE_SPHERE);
227
228 prop = RNA_def_property(srna, "influence_type", PROP_ENUM, PROP_NONE);
229 RNA_def_property_enum_sdna(prop, nullptr, "attenuation_type");
231 RNA_def_property_ui_text(prop, "Type", "Type of influence volume");
233
234 prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_FACTOR);
235 RNA_def_property_range(prop, 0.0f, 1.0f);
236 RNA_def_property_ui_text(prop, "Falloff", "Control how fast the probe influence decreases");
238
239 prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
240 RNA_def_property_float_sdna(prop, nullptr, "clipend");
241 RNA_def_property_range(prop, 1e-6f, FLT_MAX);
242 RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
244 prop, "Clip End", "Probe clip end, beyond which objects will not appear in reflections");
245 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
246
247 /* Custom parallax */
248 prop = RNA_def_property(srna, "use_custom_parallax", PROP_BOOLEAN, PROP_NONE);
251 prop, "Use Custom Parallax", "Enable custom settings for the parallax correction volume");
253
254 prop = RNA_def_property(srna, "show_parallax", PROP_BOOLEAN, PROP_NONE);
256 RNA_def_property_ui_text(prop, "Parallax", "Show the parallax correction volume in the 3D view");
258
259 prop = RNA_def_property(srna, "parallax_type", PROP_ENUM, PROP_NONE);
261 RNA_def_property_ui_text(prop, "Type", "Type of parallax volume");
263
264 prop = RNA_def_property(srna, "parallax_distance", PROP_FLOAT, PROP_DISTANCE);
265 RNA_def_property_float_sdna(prop, nullptr, "distpar");
266 RNA_def_property_range(prop, 0.0f, FLT_MAX);
267 RNA_def_property_ui_text(prop, "Parallax Radius", "Lowest corner of the parallax bounding box");
269}
270
272{
273 StructRNA *srna;
274 PropertyRNA *prop;
275
276 srna = RNA_def_struct(brna, "LightProbeVolume", "LightProbe");
277 RNA_def_struct_sdna(srna, "LightProbe");
279 srna, "Volume Probe", "Light probe that captures low frequency lighting inside a volume");
280 RNA_def_struct_ui_icon(srna, ICON_LIGHTPROBE_VOLUME);
281
282 prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
283 RNA_def_property_float_sdna(prop, nullptr, "intensity");
284 RNA_def_property_range(prop, 0.0f, FLT_MAX);
285 RNA_def_property_ui_range(prop, 0.0f, 3.0f, 1.0, 3);
287 prop, "Intensity", "Modify the intensity of the lighting captured by this probe");
288 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
289
290 /* Irradiance grid */
291 prop = RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE);
292 RNA_def_property_int_sdna(prop, nullptr, "grid_resolution_x");
293 RNA_def_property_range(prop, 1, 256);
295 prop, "Resolution X", "Number of samples along the x axis of the volume");
296 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
297
298 prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE);
299 RNA_def_property_int_sdna(prop, nullptr, "grid_resolution_y");
300 RNA_def_property_range(prop, 1, 256);
302 prop, "Resolution Y", "Number of samples along the y axis of the volume");
303 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
304
305 prop = RNA_def_property(srna, "resolution_z", PROP_INT, PROP_NONE);
306 RNA_def_property_int_sdna(prop, nullptr, "grid_resolution_z");
307 RNA_def_property_range(prop, 1, 256);
309 prop, "Resolution Z", "Number of samples along the z axis of the volume");
310 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
311
312 /* NOTE: We reuse the same DNA for this property for historical reason, but we want a different
313 * name and tooltip for it. */
314 prop = RNA_def_property(srna, "capture_distance", PROP_FLOAT, PROP_DISTANCE);
315 RNA_def_property_float_sdna(prop, nullptr, "clipend");
316 RNA_def_property_range(prop, 1e-6f, FLT_MAX);
317 RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 1);
319 "Capture Distance",
320 "Distance around the probe volume that will be considered "
321 "during the bake");
322 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
323
324 prop = RNA_def_property(srna, "normal_bias", PROP_FLOAT, PROP_FACTOR);
325 RNA_def_property_float_sdna(prop, nullptr, "grid_normal_bias");
327 "Normal Bias",
328 "Offset sampling of the irradiance grid in "
329 "the surface normal direction to reduce light bleeding");
330 RNA_def_property_range(prop, 0.0f, FLT_MAX);
331 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
332 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
333
334 prop = RNA_def_property(srna, "view_bias", PROP_FLOAT, PROP_FACTOR);
335 RNA_def_property_float_sdna(prop, nullptr, "grid_view_bias");
337 "View Bias",
338 "Offset sampling of the irradiance grid in "
339 "the viewing direction to reduce light bleeding");
340 RNA_def_property_range(prop, 0.0f, FLT_MAX);
341 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
342 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
343
344 prop = RNA_def_property(srna, "facing_bias", PROP_FLOAT, PROP_FACTOR);
345 RNA_def_property_float_sdna(prop, nullptr, "grid_facing_bias");
347 prop, "Facing Bias", "Smoother irradiance interpolation but introduce light bleeding");
348 RNA_def_property_range(prop, 0.0f, FLT_MAX);
349 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
350 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
351
352 prop = RNA_def_property(srna, "bake_samples", PROP_INT, PROP_NONE);
353 RNA_def_property_int_sdna(prop, nullptr, "grid_bake_samples");
355 prop, "Bake Samples", "Number of ray directions to evaluate when baking");
357 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
358
359 prop = RNA_def_property(srna, "surface_bias", PROP_FLOAT, PROP_FACTOR);
360 RNA_def_property_float_sdna(prop, nullptr, "grid_surface_bias");
362 prop, "Surface Offset", "Moves capture points away from surfaces to prevent artifacts");
363 RNA_def_property_range(prop, 0.0f, 1.0f);
364 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
365
366 prop = RNA_def_property(srna, "escape_bias", PROP_FLOAT, PROP_FACTOR);
367 RNA_def_property_float_sdna(prop, nullptr, "grid_escape_bias");
369 "Search Distance",
370 "Distance to search for valid capture positions to prevent "
371 "lighting artifacts");
372 RNA_def_property_range(prop, 0.0f, 1.0f);
373 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
374
375 prop = RNA_def_property(srna, "surfel_density", PROP_INT, PROP_NONE);
376 RNA_def_property_int_sdna(prop, nullptr, "grid_surfel_density");
379 prop,
380 "Surfel Resolution",
381 "Number of surfels to spawn in one local unit distance (higher values improve quality)");
382 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
383
384 prop = RNA_def_property(srna, "validity_threshold", PROP_FLOAT, PROP_FACTOR);
385 RNA_def_property_float_sdna(prop, nullptr, "grid_validity_threshold");
387 "Validity Threshold",
388 "Ratio of front-facing surface hits under which a grid sample will "
389 "not be considered for lighting");
390 RNA_def_property_range(prop, 0.0f, 1.0f);
391 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
392 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
393
394 prop = RNA_def_property(srna, "dilation_threshold", PROP_FLOAT, PROP_FACTOR);
395 RNA_def_property_float_sdna(prop, nullptr, "grid_dilation_threshold");
397 "Dilation Threshold",
398 "Ratio of front-facing surface hits under which a grid sample will "
399 "reuse neighbors grid sample lighting");
400 RNA_def_property_range(prop, 0.0f, 1.0f);
401 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
402 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
403
404 prop = RNA_def_property(srna, "dilation_radius", PROP_FLOAT, PROP_FACTOR);
405 RNA_def_property_float_sdna(prop, nullptr, "grid_dilation_radius");
407 prop,
408 "Dilation Radius",
409 "Radius in grid sample to search valid grid samples to copy into invalid grid samples");
410 RNA_def_property_range(prop, 1.0f, 5.0f);
411 RNA_def_property_ui_range(prop, 1.0f, 5.0f, 1, 2);
412 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
413
414 prop = RNA_def_property(srna, "capture_world", PROP_BOOLEAN, PROP_NONE);
417 prop,
418 "Capture World",
419 "Bake incoming light from the world instead of just the visibility "
420 "for more accurate lighting, but lose correct blending to surrounding irradiance volumes");
422
423 prop = RNA_def_property(srna, "capture_indirect", PROP_BOOLEAN, PROP_NONE);
426 "Capture Indirect",
427 "Bake light bounces from light sources for more accurate lighting");
429
430 prop = RNA_def_property(srna, "capture_emission", PROP_BOOLEAN, PROP_NONE);
433 prop, "Capture Emission", "Bake emissive surfaces for more accurate lighting");
435
436 prop = RNA_def_property(srna, "clamp_direct", PROP_FLOAT, PROP_NONE);
437 RNA_def_property_float_sdna(prop, nullptr, "grid_clamp_direct");
438 RNA_def_property_range(prop, 0.0f, FLT_MAX);
439 RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 2);
441 prop, "Clamp Direct", "Clamp the direct lighting intensity to reduce noise (0 to disable)");
442 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
443
444 prop = RNA_def_property(srna, "clamp_indirect", PROP_FLOAT, PROP_NONE);
445 RNA_def_property_float_sdna(prop, nullptr, "grid_clamp_indirect");
446 RNA_def_property_range(prop, 0.0f, FLT_MAX);
447 RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, 2);
449 "Clamp Indirect",
450 "Clamp the indirect lighting intensity to reduce noise (0 to disable)");
451 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
452}
453
461
462} // namespace blender
463
464#endif
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define ND_SHADING
Definition WM_types.hh:520
#define NC_MATERIAL
Definition WM_types.hh:393
#define FLT_MAX
#define INT_MAX
BMesh Iterators.
static EnumPropertyItem parallax_type_items[]
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_struct_ui_icon(StructRNA *srna, int icon)
static EnumPropertyItem lightprobe_type_items[]
static void rna_def_lightprobe_volume(BlenderRNA *brna)
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_lightprobe(BlenderRNA *brna)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
static void rna_def_lightprobe_sphere(BlenderRNA *brna)
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_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_lightprobe_plane(BlenderRNA *brna)
void RNA_def_lightprobe(BlenderRNA *brna)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
@ LIGHTPROBE_GRID_CAPTURE_INDIRECT
@ LIGHTPROBE_GRID_CAPTURE_EMISSION
@ LIGHTPROBE_GRID_CAPTURE_WORLD
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ PROP_EDITABLE
Definition RNA_types.hh:376
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
@ PROP_FACTOR
Definition RNA_types.hh:308
@ PROP_DISTANCE
Definition RNA_types.hh:313
@ LIGHTPROBE_FLAG_SHOW_PARALLAX
@ LIGHTPROBE_FLAG_SHOW_CLIP_DIST
@ LIGHTPROBE_FLAG_CUSTOM_PARALLAX
@ LIGHTPROBE_FLAG_SHOW_INFLUENCE
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)