Blender V5.3
versioning_402.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#define DNA_DEPRECATED_ALLOW
10
11/* Define macros in `DNA_genfile.h`. */
12#define DNA_GENFILE_VERSIONING_MACROS
13
14#include "DNA_anim_types.h"
15#include "DNA_brush_types.h"
17#include "DNA_genfile.h"
18#include "DNA_light_types.h"
20#include "DNA_material_types.h"
21#include "DNA_sequence_types.h"
23#include "DNA_world_types.h"
24
25#undef DNA_GENFILE_VERSIONING_MACROS
26
27#include "BLI_listbase.hh"
28#include "BLI_math_vector_c.hh"
29#include "BLI_string.hh"
30#include "BLI_string_utf8.hh"
31
32#include "BKE_anim_data.hh"
33#include "BKE_colortools.hh"
34#include "BKE_customdata.hh"
35#include "BKE_grease_pencil.hh"
36#include "BKE_main.hh"
37#include "BKE_material.hh"
38#include "BKE_node.hh"
40#include "BKE_report.hh"
41
42#include "MOV_enums.hh"
43
44#include "SEQ_iterator.hh"
45#include "SEQ_sequencer.hh"
46
47#include "BLT_translation.hh"
48
49#include "BLO_read_write.hh"
50
51#include "readfile.hh"
52
53#include "versioning_common.hh"
54
55namespace blender {
56
62{
63 const StringRef rna_path = fcurve->rna_path();
64 constexpr char const *rna_path_prefix = "collections[";
65 if (!rna_path.startswith(rna_path_prefix)) {
66 return;
67 }
68
69 const std::string path_remainder(rna_path.drop_known_prefix(rna_path_prefix));
70 fcurve->rna_path_set_move(BLI_sprintfN("collections_all[%s", path_remainder.c_str()));
71}
72
74{
75 /* EEVEE no longer uses the Material::blend_shadow property.
76 * Instead, it uses Object::visibility_flag for disabling shadow casting. */
77
78 short *material_len = BKE_object_material_len_p(object);
79 if (!material_len) {
80 return;
81 }
82
83 bool hide_shadows = *material_len > 0;
84 for (int i : IndexRange(*material_len)) {
85 Material *material = BKE_object_material_get(object, i + 1);
86 if (!material || material->blend_shadow != MA_BS_NONE) {
87 hide_shadows = false;
88 }
89 }
90
91 /* Enable the hide_shadow flag only if there's not any shadow casting material. */
92 SET_FLAG_FROM_TEST(object->visibility_flag, hide_shadows, OB_HIDE_SHADOW);
93}
94
103 /* Alpha input is 0. */
105 /* Alpha input is 1. */
107 /* Alpha is between 0 and 1, from a graph input or the result of one blending operation. */
109 /* Alpha is unknown and the result of more than one blending operation. */
111 };
112
113 /* Socket that is the source of the potential semi-transparency. */
114 bNodeSocket *socket = nullptr;
115 /* State of the source. */
117 /* True if socket is transparency instead of alpha (e.g: `1-alpha`). */
118 bool is_transparency = false;
119
120 static AlphaSource alpha_source(bNodeSocket *fac, bool inverted = false)
121 {
122 return {fac, ALPHA_SEMI_TRANSPARENT, inverted};
123 }
125 {
126 return {nullptr, ALPHA_OPAQUE, false};
127 }
128 static AlphaSource fully_transparent(bNodeSocket *socket = nullptr, bool inverted = false)
129 {
131 }
133 {
134 return {nullptr, ALPHA_COMPLEX_MIX, false};
135 }
136
137 bool is_opaque() const
138 {
139 return state == ALPHA_OPAQUE;
140 }
142 {
144 }
145 bool is_transparent() const
146 {
147 return state != ALPHA_OPAQUE;
148 }
150 {
152 }
153 bool is_complex() const
154 {
155 return state == ALPHA_COMPLEX_MIX;
156 }
157
158 /* Combine two source together with a blending parameter. */
159 static AlphaSource mix(const AlphaSource &a, const AlphaSource &b, bNodeSocket *fac)
160 {
161 if (a.is_complex() || b.is_complex()) {
162 return complex_alpha();
163 }
164 if (a.is_semi_transparent() || b.is_semi_transparent()) {
165 return complex_alpha();
166 }
167 if (a.is_fully_transparent() && b.is_fully_transparent()) {
168 return fully_transparent();
169 }
170 if (a.is_opaque() && b.is_opaque()) {
171 return opaque();
172 }
173 /* Only one of them is fully transparent. */
174 return alpha_source(fac, !a.is_transparent());
175 }
176
177 /* Combine two source together with an additive blending parameter. */
178 static AlphaSource add(const AlphaSource &a, const AlphaSource &b)
179 {
180 if (a.is_complex() || b.is_complex()) {
181 return complex_alpha();
182 }
183 if (a.is_semi_transparent() && b.is_transparent()) {
184 return complex_alpha();
185 }
186 if (a.is_transparent() && b.is_semi_transparent()) {
187 return complex_alpha();
188 }
189 /* Either one of them is opaque or they are both opaque. */
190 return a.is_transparent() ? a : b;
191 }
192};
193
198{
199 if (depth > 100) {
200 /* Protection against infinite / very long recursion.
201 * Also a node-tree with that much depth is likely to not be compatible. */
203 }
204
205 if (socket->link == nullptr) {
206 /* Unconnected closure socket is always opaque black. */
207 return AlphaSource::opaque();
208 }
209
210 bNode *node = socket->link->fromnode;
211
212 switch (node->type_legacy) {
213 case NODE_REROUTE: {
215 static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 0)), depth + 1);
216 }
217
218 case NODE_GROUP: {
220 }
221
223 bNodeSocket *socket = bke::node_find_socket(*node, SOCK_IN, "Color"_ustr);
224 if (socket->link == nullptr) {
225 float *socket_color_value = version_cycles_node_socket_rgba_value(socket);
226 if ((socket_color_value[0] == 0.0f) && (socket_color_value[1] == 0.0f) &&
227 (socket_color_value[2] == 0.0f))
228 {
229 return AlphaSource::opaque();
230 }
231 if ((socket_color_value[0] == 1.0f) && (socket_color_value[1] == 1.0f) &&
232 (socket_color_value[2] == 1.0f))
233 {
234 return AlphaSource::fully_transparent(socket, true);
235 }
236 }
237 return AlphaSource::alpha_source(socket, true);
238 }
239
240 case SH_NODE_MIX_SHADER: {
241 bNodeSocket *socket = bke::node_find_socket(*node, SOCK_IN, "Fac"_ustr);
243 static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 1)), depth + 1);
245 static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 2)), depth + 1);
246
247 if (socket->link == nullptr) {
248 float socket_float_value = *version_cycles_node_socket_float_value(socket);
249 if (socket_float_value == 0.0f) {
250 return src0;
251 }
252 if (socket_float_value == 1.0f) {
253 return src1;
254 }
255 }
256 return AlphaSource::mix(src0, src1, socket);
257 }
258
259 case SH_NODE_ADD_SHADER: {
261 static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 0)), depth + 1);
263 static_cast<bNodeSocket *>(BLI_findlink(&node->inputs, 1)), depth + 1);
264 return AlphaSource::add(src0, src1);
265 }
266
268 bNodeSocket *socket = bke::node_find_socket(*node, SOCK_IN, "Alpha"_ustr);
269 if (socket->link == nullptr) {
270 float socket_value = *version_cycles_node_socket_float_value(socket);
271 if (socket_value == 0.0f) {
272 return AlphaSource::fully_transparent(socket);
273 }
274 if (socket_value == 1.0f) {
275 return AlphaSource::opaque();
276 }
277 }
278 return AlphaSource::alpha_source(socket);
279 }
280
282 bNodeSocket *socket = bke::node_find_socket(*node, SOCK_IN, "Transparency"_ustr);
283 if (socket->link == nullptr) {
284 float socket_value = *version_cycles_node_socket_float_value(socket);
285 if (socket_value == 0.0f) {
286 return AlphaSource::fully_transparent(socket, true);
287 }
288 if (socket_value == 1.0f) {
289 return AlphaSource::opaque();
290 }
291 }
292 return AlphaSource::alpha_source(socket, true);
293 }
294
295 default:
296 return AlphaSource::opaque();
297 }
298}
299
309{
311 if (output_node == nullptr) {
312 return true;
313 }
314 bNodeSocket *surface_socket = bke::node_find_socket(*output_node, SOCK_IN, "Surface"_ustr);
315
316 AlphaSource alpha = versioning_eevee_alpha_source_get(surface_socket);
317
318 if (alpha.is_complex()) {
319 return false;
320 }
321 if (alpha.socket == nullptr) {
322 return true;
323 }
324
325 bool is_opaque = (threshold == 2.0f);
326 if (is_opaque) {
327 if (alpha.socket->link != nullptr) {
328 bke::node_remove_link(ntree, *alpha.socket->link);
329 }
330
331 float value = (alpha.is_transparency) ? 0.0f : 1.0f;
332 float values[4] = {value, value, value, 1.0f};
333
334 /* Set default value to opaque. */
335 if (alpha.socket->type == SOCK_RGBA) {
337 }
338 else {
340 }
341 }
342 else {
343 if (alpha.socket->link != nullptr) {
344 /* Insert math node. */
345 bNode *to_node = alpha.socket->link->tonode;
346 bNode *from_node = alpha.socket->link->fromnode;
347 bNodeSocket *to_socket = alpha.socket->link->tosock;
348 bNodeSocket *from_socket = alpha.socket->link->fromsock;
349 bke::node_remove_link(ntree, *alpha.socket->link);
350
351 bNode *math_node = bke::node_add_node(nullptr, *ntree, "ShaderNodeMath"_ustr);
352 math_node->custom1 = NODE_MATH_GREATER_THAN;
353 math_node->flag |= NODE_COLLAPSED;
354 math_node->parent = to_node->parent;
355 math_node->locx_legacy = to_node->locx_legacy - math_node->width - 30;
356 math_node->locy_legacy = min_ff(to_node->locy_legacy, from_node->locy_legacy);
357
358 bNodeSocket *input_1 = static_cast<bNodeSocket *>(BLI_findlink(&math_node->inputs, 0));
359 bNodeSocket *input_2 = static_cast<bNodeSocket *>(BLI_findlink(&math_node->inputs, 1));
360 bNodeSocket *output = math_node->outputs.first();
361 bNodeSocket *alpha_sock = input_1;
362 bNodeSocket *threshold_sock = input_2;
363
364 bke::node_add_link(*ntree, *from_node, *from_socket, *math_node, *alpha_sock);
365 bke::node_add_link(*ntree, *math_node, *output, *to_node, *to_socket);
366
368 1.0f - threshold :
369 threshold;
370 }
371 else {
372 /* Modify alpha value directly. */
373 if (alpha.socket->type == SOCK_RGBA) {
374 float *default_value = version_cycles_node_socket_rgba_value(alpha.socket);
375 float sum = default_value[0] + default_value[1] + default_value[2];
376 /* Don't do the division if possible to avoid float imprecision. */
377 float avg = (sum >= 3.0f) ? 1.0f : (sum / 3.0f);
378 float value = float((alpha.is_transparency) ? (avg > 1.0f - threshold) :
379 (avg > threshold));
380 float values[4] = {value, value, value, 1.0f};
381 copy_v4_v4(default_value, values);
382 }
383 else {
384 float *default_value = version_cycles_node_socket_float_value(alpha.socket);
385 *default_value = float((alpha.is_transparency) ? (*default_value > 1.0f - threshold) :
386 (*default_value > threshold));
387 }
388 }
389 }
390 return true;
391}
392
394{
395 if (!material->use_nodes || material->nodetree == nullptr) {
396 return;
397 }
398 bNodeTree *ntree = material->nodetree;
399
402 if (output_node == nullptr) {
403 return;
404 }
405
406 bNodeSocket *existing_out_sock = bke::node_find_socket(*output_node, SOCK_IN, "Surface"_ustr);
407 bNodeSocket *volume_sock = bke::node_find_socket(*output_node, SOCK_IN, "Volume"_ustr);
408 if (existing_out_sock->link == nullptr && volume_sock->link) {
409 /* Don't apply versioning to a material that only has a volumetric input as this makes the
410 * object surface opaque to the camera, hiding the volume inside. */
411 return;
412 }
413
414 if (output_node->custom1 == SHD_OUTPUT_ALL) {
415 /* We do not want to affect Cycles. So we split the output into two specific outputs. */
416 output_node->custom1 = SHD_OUTPUT_CYCLES;
417
418 bNode *new_output = bke::node_add_node(nullptr, *ntree, "ShaderNodeOutputMaterial"_ustr);
419 new_output->custom1 = SHD_OUTPUT_EEVEE;
420 new_output->parent = output_node->parent;
421 new_output->locx_legacy = output_node->locx_legacy;
422 new_output->locy_legacy = output_node->locy_legacy - output_node->height - 120;
423
424 auto copy_link = [&](const char *socket_name) {
425 bNodeSocket *sock = bke::node_find_socket(*output_node, SOCK_IN, UString(socket_name));
426 if (sock && sock->link) {
427 bNodeLink *link = sock->link;
428 bNodeSocket *to_sock = bke::node_find_socket(*new_output, SOCK_IN, UString(socket_name));
429 bke::node_add_link(*ntree, *link->fromnode, *link->fromsock, *new_output, *to_sock);
430 }
431 };
432
433 /* Don't copy surface as that is handled later */
434 copy_link("Volume");
435 copy_link("Displacement");
436 copy_link("Thickness");
437
438 output_node = new_output;
439 }
440
441 bNodeSocket *out_sock = bke::node_find_socket(*output_node, SOCK_IN, "Surface"_ustr);
442 bNodeSocket *old_out_sock = bke::node_find_socket(*old_output_node, SOCK_IN, "Surface"_ustr);
443
444 /* Add mix node for mixing between original material, and transparent BSDF for shadows */
445 bNode *mix_node = bke::node_add_node(nullptr, *ntree, "ShaderNodeMixShader"_ustr);
446 STRNCPY(mix_node->label, "Disable Shadow");
447 mix_node->flag |= NODE_COLLAPSED;
448 mix_node->parent = output_node->parent;
449 mix_node->locx_legacy = output_node->locx_legacy;
450 mix_node->locy_legacy = output_node->locy_legacy - output_node->height - 120;
451 bNodeSocket *mix_fac = static_cast<bNodeSocket *>(BLI_findlink(&mix_node->inputs, 0));
452 bNodeSocket *mix_in_1 = static_cast<bNodeSocket *>(BLI_findlink(&mix_node->inputs, 1));
453 bNodeSocket *mix_in_2 = static_cast<bNodeSocket *>(BLI_findlink(&mix_node->inputs, 2));
454 bNodeSocket *mix_out = static_cast<bNodeSocket *>(BLI_findlink(&mix_node->outputs, 0));
455 if (old_out_sock->link != nullptr) {
456 bke::node_add_link(*ntree,
457 *old_out_sock->link->fromnode,
458 *old_out_sock->link->fromsock,
459 *mix_node,
460 *mix_in_1);
461 if (out_sock->link != nullptr) {
462 bke::node_remove_link(ntree, *out_sock->link);
463 }
464 }
465 bke::node_add_link(*ntree, *mix_node, *mix_out, *output_node, *out_sock);
466
467 /* Add light path node to control shadow visibility */
468 bNode *lp_node = bke::node_add_node(nullptr, *ntree, "ShaderNodeLightPath"_ustr);
469 lp_node->flag |= NODE_COLLAPSED;
470 lp_node->parent = output_node->parent;
471 lp_node->locx_legacy = output_node->locx_legacy;
472 lp_node->locy_legacy = mix_node->locy_legacy + 35;
473 bNodeSocket *is_shadow = bke::node_find_socket(*lp_node, SOCK_OUT, "Is Shadow Ray"_ustr);
474 bke::node_add_link(*ntree, *lp_node, *is_shadow, *mix_node, *mix_fac);
475 /* Hide unconnected sockets for cleaner look. */
476 for (bNodeSocket &sock : lp_node->outputs) {
477 if (&sock != is_shadow) {
478 sock.flag |= SOCK_HIDDEN;
479 }
480 }
481
482 /* Add transparent BSDF to make shadows transparent. */
483 bNode *bsdf_node = bke::node_add_node(nullptr, *ntree, "ShaderNodeBsdfTransparent"_ustr);
484 bsdf_node->flag |= NODE_COLLAPSED;
485 bsdf_node->parent = output_node->parent;
486 bsdf_node->locx_legacy = output_node->locx_legacy;
487 bsdf_node->locy_legacy = mix_node->locy_legacy - 35;
488 bNodeSocket *bsdf_out = bke::node_find_socket(*bsdf_node, SOCK_OUT, "BSDF"_ustr);
489 bke::node_add_link(*ntree, *bsdf_node, *bsdf_out, *mix_node, *mix_in_2);
490}
491
493{
494 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 15)) {
495 /* Change drivers and animation on "armature.collections" to
496 * ".collections_all", so that they are drawn correctly in the tree view,
497 * and keep working when the collection is moved around in the hierarchy. */
498 for (bArmature &arm : bmain->armatures) {
499 AnimData *adt = BKE_animdata_from_id(&arm.id);
500 if (!adt) {
501 continue;
502 }
503
504 for (FCurve &fcurve : adt->drivers) {
506 }
507 if (adt->action) {
508 for (FCurve &fcurve : adt->action->curves) {
510 }
511 }
512 }
513 }
514
515 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 23)) {
516 /* Shift animation data to accommodate the new Roughness input. */
519 }
520
521 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 50)) {
523 for (Object &object : bmain->objects) {
525 }
526 }
527 }
528
529 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 51)) {
530 /* Convert blend method to math nodes. */
532 for (Material &material : bmain->materials) {
533 if (!material.use_nodes || material.nodetree == nullptr) {
534 /* Nothing to version. */
535 }
536 else if (ELEM(material.blend_method, MA_BM_HASHED, MA_BM_BLEND)) {
537 /* Compatible modes. Nothing to change. */
538 }
539 else if (material.blend_shadow == MA_BS_NONE) {
540 /* No need to match the surface since shadows are disabled. */
541 }
542 else if (material.blend_shadow == MA_BS_SOLID) {
543 /* This is already versioned an transferred to `transparent_shadows`. */
544 }
545 else if ((material.blend_shadow == MA_BS_CLIP && material.blend_method != MA_BM_CLIP) ||
546 (material.blend_shadow == MA_BS_HASHED))
547 {
549 fd->reports,
551 RPT_("Material %s could not be converted because of different Blend Mode "
552 "and Shadow Mode (need manual adjustment)\n"),
553 material.id.name + 2);
554 }
555 else {
556 /* TODO(fclem): Check if threshold is driven or has animation. Bail out if needed? */
557
558 float threshold = (material.blend_method == MA_BM_CLIP) ? material.alpha_threshold :
559 2.0f;
560
561 if (!versioning_eevee_material_blend_mode_settings(material.nodetree, threshold)) {
564 RPT_("Material %s could not be converted because of non-trivial "
565 "alpha blending (need manual adjustment)\n"),
566 material.id.name + 2);
567 }
568 }
569
570 if (material.blend_shadow == MA_BS_NONE) {
572 }
573 /* Set blend_mode & blend_shadow for forward compatibility. */
574 material.blend_method = (material.blend_method != MA_BM_BLEND) ? MA_BM_HASHED :
576 material.blend_shadow = (material.blend_shadow == MA_BS_SOLID) ? MA_BS_SOLID :
578 }
579 }
580 }
581}
582
584{
585 /* R_IMF_IMTYPE_AVIRAW and R_IMF_IMTYPE_AVIJPEG. */
586 constexpr char deprecated_avi_raw_imtype = 15;
587 constexpr char deprecated_avi_jpeg_imtype = 16;
588 if (ELEM(scene->r.im_format.imtype, deprecated_avi_raw_imtype, deprecated_avi_jpeg_imtype)) {
590 }
591}
592
593/* The Hue Correct curve now wraps around by specifying CUMA_USE_WRAPPING, which means it no longer
594 * makes sense to have curve maps outside of the [0, 1] range, so enable clipping and reset the
595 * clip and view ranges. */
596static void hue_correct_set_wrapping(CurveMapping *curve_mapping)
597{
598 curve_mapping->flag |= CUMA_DO_CLIP;
599 curve_mapping->flag |= CUMA_USE_WRAPPING;
600
601 curve_mapping->clipr.xmin = 0.0f;
602 curve_mapping->clipr.xmax = 1.0f;
603 curve_mapping->clipr.ymin = 0.0f;
604 curve_mapping->clipr.ymax = 1.0f;
605
606 curve_mapping->curr.xmin = 0.0f;
607 curve_mapping->curr.xmax = 1.0f;
608 curve_mapping->curr.ymin = 0.0f;
609 curve_mapping->curr.ymax = 1.0f;
610}
611
612static bool strip_hue_correct_set_wrapping(Strip *strip, void * /*user_data*/)
613{
614 for (StripModifierData &smd : strip->modifiers) {
616 HueCorrectModifierData *hcmd = reinterpret_cast<HueCorrectModifierData *>(&smd);
617 CurveMapping *cumap = static_cast<CurveMapping *>(&hcmd->curve_mapping);
619 }
620 }
621 return true;
622}
623
625{
626 if (ntree->type == NTREE_COMPOSIT) {
627 for (bNode &node : ntree->nodes.items_mutable()) {
628
629 if (node.type_legacy == CMP_NODE_HUECORRECT) {
631 CurveMapping *cumap = static_cast<CurveMapping *>(node.storage);
633 }
634 }
635 }
636 }
637}
638
640{
641 for (bScreen &screen : bmain.screens) {
642 for (ScrArea &area : screen.areabase) {
643 for (SpaceLink &sl : area.spacedata) {
644 if (sl.spacetype != SPACE_IMAGE) {
645 continue;
646 }
647
648 ListBaseT<ARegion> *regionbase = (&sl == area.spacedata.first_) ? &area.regionbase :
649 &sl.regionbase;
650
651 if (ARegion *new_shelf_region = do_versions_add_region_if_not_found(
652 regionbase, RGN_TYPE_ASSET_SHELF, __func__, RGN_TYPE_TOOL_HEADER))
653 {
654 new_shelf_region->regiondata = MEM_new<RegionAssetShelf>(__func__);
655 new_shelf_region->alignment = RGN_ALIGN_BOTTOM;
656 new_shelf_region->flag |= RGN_FLAG_HIDDEN;
657 }
658 if (ARegion *new_shelf_header = do_versions_add_region_if_not_found(
660 {
661 new_shelf_header->alignment = RGN_ALIGN_BOTTOM | RGN_ALIGN_HIDE_WITH_PREV;
662 }
663 }
664 }
665 }
666}
667
668/* Convert EEVEE-Legacy refraction depth to EEVEE-Next thickness tree. */
669static void version_refraction_depth_to_thickness_value(bNodeTree *ntree, float thickness)
670{
671 for (bNode &node : ntree->nodes) {
672 if (node.type_legacy != SH_NODE_OUTPUT_MATERIAL) {
673 continue;
674 }
675
676 bNodeSocket *thickness_socket = bke::node_find_socket(node, SOCK_IN, "Thickness"_ustr);
677 if (thickness_socket == nullptr) {
678 continue;
679 }
680
681 bool has_link = false;
682 for (bNodeLink &link : ntree->links) {
683 if (link.tosock == thickness_socket) {
684 /* Something is already plugged in. Don't modify anything. */
685 has_link = true;
686 }
687 }
688
689 if (has_link) {
690 continue;
691 }
692 bNode *value_node = bke::node_add_static_node(nullptr, *ntree, SH_NODE_VALUE);
693 value_node->parent = node.parent;
694 value_node->locx_legacy = node.locx_legacy;
695 value_node->locy_legacy = node.locy_legacy - 160.0f;
696 bNodeSocket *socket_value = bke::node_find_socket(*value_node, SOCK_OUT, "Value"_ustr);
697
698 *version_cycles_node_socket_float_value(socket_value) = thickness;
699
700 bke::node_add_link(*ntree, *value_node, *socket_value, node, *thickness_socket);
701 }
702
704}
705
706static bool strip_text_data_update(Strip *strip, void * /*user_data*/)
707{
708 if (strip->type != STRIP_TYPE_TEXT || strip->effectdata == nullptr) {
709 return true;
710 }
711
712 TextVars *data = static_cast<TextVars *>(strip->effectdata);
713 if (data->shadow_angle == 0.0f) {
714 data->shadow_angle = DEG2RADF(65.0f);
715 data->shadow_offset = 0.04f;
716 data->shadow_blur = 0.0f;
717 }
718 if (data->outline_width == 0.0f) {
719 data->outline_color[3] = 0.7f;
720 data->outline_width = 0.05f;
721 }
722 return true;
723}
724
726{
727 for (GreasePencilDrawingBase *base : grease_pencil->drawings()) {
728 if (base->type != GP_DRAWING) {
729 continue;
730 }
731 bke::greasepencil::Drawing &drawing = reinterpret_cast<GreasePencilDrawing *>(base)->wrap();
732 const int layer_index = CustomData_get_named_layer_index(
733 &drawing.geometry.curve_data_legacy, CD_PROP_FLOAT, "hardness");
734 if (layer_index == -1) {
735 continue;
736 }
737 float *data = static_cast<float *>(
740 "hardness",
741 drawing.geometry.curve_num));
742 for (const int i : IndexRange(drawing.geometry.curve_num)) {
743 data[i] = 1.0f - data[i];
744 }
745 /* Rename the layer. */
746 STRNCPY_UTF8(drawing.geometry.curve_data_legacy.layers[layer_index].name, "softness");
747 }
748}
749
750void blo_do_versions_402(FileData *fd, Library * /*lib*/, Main *bmain)
751{
752 /* Keep point/spot light soft falloff for files created before 4.0. */
753 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 0)) {
754 for (Light &light : bmain->lights) {
755 if (ELEM(light.type, LA_LOCAL, LA_SPOT)) {
756 light.mode |= LA_USE_SOFT_FALLOFF;
757 }
758 }
759 }
760
761 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 1)) {
762 using namespace blender::bke::greasepencil;
763 /* Initialize newly added scale layer transform to one. */
765 for (Layer *layer : grease_pencil.layers_for_write()) {
766 copy_v3_fl(layer->scale, 1.0f);
767 }
768 }
769 }
770
771 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 2)) {
772 for (Scene &scene : bmain->scenes) {
773 bool is_cycles = STREQ(scene.r.engine, RE_engine_id_CYCLES);
774 if (is_cycles) {
775 if (IDProperty *cscene = version_cycles_properties_from_ID(&scene.id)) {
776 int cposition = version_cycles_property_int(cscene, "motion_blur_position", 1);
777 BLI_assert(cposition >= 0 && cposition < 3);
778 int order_conversion[3] = {SCE_MB_START, SCE_MB_CENTER, SCE_MB_END};
779 scene.r.motion_blur_position = order_conversion[std::clamp(cposition, 0, 2)];
780 }
781 }
782 else {
787 }
788 }
789 }
790
791 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 3)) {
792 constexpr int NTREE_EXECUTION_MODE_CPU = 0;
793 constexpr int NTREE_EXECUTION_MODE_FULL_FRAME = 1;
794
795 constexpr eNodeTree_Flag NTREE_COM_GROUPNODE_BUFFER = eNodeTree_Flag(1 << 3);
796 constexpr eNodeTree_Flag NTREE_COM_OPENCL = eNodeTree_Flag(1 << 1);
797
798 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
799 if (ntree->type != NTREE_COMPOSIT) {
800 continue;
801 }
802
803 ntree->flag &= ~(NTREE_COM_GROUPNODE_BUFFER | NTREE_COM_OPENCL);
804
805 if (ntree->execution_mode == NTREE_EXECUTION_MODE_FULL_FRAME) {
806 ntree->execution_mode = NTREE_EXECUTION_MODE_CPU;
807 }
808 }
810 }
811
812 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 4)) {
813 if (!DNA_struct_member_exists(fd->filesdna, "SpaceImage", "float", "stretch_opacity")) {
814 for (bScreen &screen : bmain->screens) {
815 for (ScrArea &area : screen.areabase) {
816 for (SpaceLink &sl : area.spacedata) {
817 if (sl.spacetype == SPACE_IMAGE) {
818 SpaceImage *sima = reinterpret_cast<SpaceImage *>(&sl);
819 sima->stretch_opacity = 0.9f;
820 }
821 }
822 }
823 }
824 }
825 }
826
827 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 5)) {
828 for (Scene &scene : bmain->scenes) {
830 }
831 }
832
833 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 6)) {
834 for (Brush &brush : bmain->brushes) {
835 if (BrushCurvesSculptSettings *settings = brush.curves_sculpt_settings) {
837 settings->curve_radius = 0.01f;
838 }
839 }
840 }
841
842 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 8)) {
843 for (Light &light : bmain->lights) {
844 light.shadow_filter_radius = 1.0f;
845 }
846 }
847
848 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 9)) {
849 const float default_snap_angle_increment = DEG2RADF(5.0f);
850 const float default_snap_angle_increment_precision = DEG2RADF(1.0f);
851 for (Scene &scene : bmain->scenes) {
852 scene.toolsettings->snap_angle_increment_2d = default_snap_angle_increment;
853 scene.toolsettings->snap_angle_increment_3d = default_snap_angle_increment;
855 default_snap_angle_increment_precision;
857 default_snap_angle_increment_precision;
858 }
859 }
860
861 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 10)) {
862 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "int", "gtao_resolution")) {
863 for (Scene &scene : bmain->scenes) {
864 scene.eevee.fast_gi_resolution = 2;
865 }
866 }
867 }
868
869 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 12)) {
870 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
872 }
874
875 for (Scene &scene : bmain->scenes) {
876 if (scene.ed != nullptr) {
878 }
879 }
880 }
881
882 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 14)) {
883 for (Object &ob : bmain->objects) {
884 if (bMotionPath *mpath = ob.mpath) {
885 mpath->color_post[0] = 0.1f;
886 mpath->color_post[1] = 1.0f;
887 mpath->color_post[2] = 0.1f;
888 }
889 if (!ob.pose) {
890 continue;
891 }
892 for (bPoseChannel &pchan : ob.pose->chanbase) {
893 if (bMotionPath *mpath = pchan.mpath) {
894 mpath->color_post[0] = 0.1f;
895 mpath->color_post[1] = 1.0f;
896 mpath->color_post[2] = 0.1f;
897 }
898 }
899 }
900 }
901
902 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 18)) {
903 if (!DNA_struct_member_exists(fd->filesdna, "Light", "float", "transmission_fac")) {
904 for (Light &light : bmain->lights) {
905 /* Refracted light was not supported in legacy EEVEE. Set it to zero for compatibility with
906 * older files. */
907 light.transmission_fac = 0.0f;
908 }
909 }
910 }
911
912 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 19)) {
913 for (Scene &scene : bmain->scenes) {
914 /* Keep legacy EEVEE old behavior. */
916 }
917
918 for (Scene &scene : bmain->scenes) {
919 scene.eevee.clamp_surface_indirect = 10.0f;
920 /* Make contribution of indirect lighting very small (but non-null) to avoid world lighting
921 * and volume lightprobe changing the appearance of volume objects. */
922 scene.eevee.clamp_volume_indirect = 1e-8f;
923 }
924 }
925
926 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 20)) {
927 for (Scene &scene : bmain->scenes) {
928 SequencerToolSettings *sequencer_tool_settings = seq::tool_settings_ensure(&scene);
929 sequencer_tool_settings->snap_mode |= SEQ_SNAP_TO_MARKERS;
930 }
931 }
932
933 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 21)) {
935 }
936
937 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 22)) {
938 /* Display missing media in sequencer by default. */
939 for (Scene &scene : bmain->scenes) {
940 if (scene.ed != nullptr) {
942 }
943 }
944 }
945
946 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 24)) {
947 if (!DNA_struct_member_exists(fd->filesdna, "Material", "char", "thickness_mode")) {
948 for (Material &material : bmain->materials) {
949 if (material.blend_flag & MA_BL_TRANSLUCENCY) {
950 /* EEVEE Legacy used thickness from shadow map when translucency was on. */
951 material.blend_flag |= MA_BL_THICKNESS_FROM_SHADOW;
952 }
953 if ((material.blend_flag & MA_BL_SS_REFRACTION) && material.use_nodes && material.nodetree)
954 {
955 /* EEVEE Legacy used slab assumption. */
956 material.thickness_mode = MA_THICKNESS_SLAB;
957 version_refraction_depth_to_thickness_value(material.nodetree, material.refract_depth);
958 }
959 }
960 }
961 }
962
963 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 25)) {
964 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
965 if (ntree->type != NTREE_COMPOSIT) {
966 continue;
967 }
968 for (bNode &node : ntree->nodes) {
969 if (node.type_legacy != CMP_NODE_BLUR) {
970 continue;
971 }
973 continue;
974 }
975
976 NodeBlurData &blur_data = *static_cast<NodeBlurData *>(node.storage);
977
978 if (blur_data.filtertype != CMP_NODE_BLUR_TYPE_FAST_GAUSS) {
979 continue;
980 }
981
982 /* The size of the Fast Gaussian mode of blur decreased by the following factor to match
983 * other blur sizes. So increase it back. */
984 const float size_factor = 3.0f / 2.0f;
985 blur_data.sizex *= size_factor;
986 blur_data.sizey *= size_factor;
987 blur_data.percentx *= size_factor;
988 blur_data.percenty *= size_factor;
989 }
990 }
992 }
993
994 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 26)) {
995 if (!DNA_struct_member_exists(fd->filesdna, "SceneEEVEE", "float", "shadow_resolution_scale"))
996 {
997 SceneEEVEE default_scene_eevee;
998 for (Scene &scene : bmain->scenes) {
999 scene.eevee.shadow_resolution_scale = default_scene_eevee.shadow_resolution_scale;
1000 }
1001 }
1002 }
1003
1004 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 27)) {
1005 for (Scene &scene : bmain->scenes) {
1006 if (scene.ed != nullptr) {
1009 }
1010 }
1011 for (bScreen &screen : bmain->screens) {
1012 for (ScrArea &area : screen.areabase) {
1013 for (SpaceLink &sl : area.spacedata) {
1014 if (sl.spacetype == SPACE_SEQ) {
1015 SpaceSeq *sseq = reinterpret_cast<SpaceSeq *>(&sl);
1017 }
1018 }
1019 }
1020 }
1021 }
1022
1023 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 29)) {
1024 for (Scene &scene : bmain->scenes) {
1025 if (scene.ed) {
1027 }
1028 }
1029 }
1030
1031 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 30)) {
1032 for (Scene &scene : bmain->scenes) {
1033 if (scene.nodetree) {
1034 scene.nodetree->flag &= ~NTREE_UNUSED_2;
1035 }
1036 }
1037 }
1038
1039 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 31)) {
1040 for (LightProbe &lightprobe : bmain->lightprobes) {
1041 /* Guess a somewhat correct density given the resolution. But very low resolution need
1042 * a decent enough density to work. */
1043 lightprobe.grid_surfel_density = max_ii(20,
1044 2 * std::max({lightprobe.grid_resolution_x,
1045 lightprobe.grid_resolution_y,
1046 lightprobe.grid_resolution_z}));
1047 }
1048 }
1049
1050 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 31)) {
1051 bool only_uses_eevee_legacy_or_workbench = true;
1052 for (Scene &scene : bmain->scenes) {
1054 only_uses_eevee_legacy_or_workbench = false;
1055 }
1056 }
1057 /* Mark old EEVEE world volumes for showing conversion operator. */
1058 for (World &world : bmain->worlds) {
1059 if (world.nodetree) {
1060 bNode *output_node = version_eevee_output_node_get(world.nodetree, SH_NODE_OUTPUT_WORLD);
1061 if (output_node) {
1062 bNodeSocket *volume_input_socket = static_cast<bNodeSocket *>(
1063 BLI_findlink(&output_node->inputs, 1));
1064 if (volume_input_socket) {
1065 for (bNodeLink &node_link : world.nodetree->links) {
1066 if (node_link.tonode == output_node && node_link.tosock == volume_input_socket) {
1067 world.flag |= WO_USE_EEVEE_FINITE_VOLUME;
1068 /* Only display a warning message if we are sure this can be used by EEVEE. */
1069 if (only_uses_eevee_legacy_or_workbench) {
1072 RPT_("%s contains a volume shader that might need to be "
1073 "converted to object (see world volume panel)\n"),
1074 world.id.name + 2);
1075 }
1076 }
1077 }
1078 }
1079 }
1080 }
1081 }
1082 }
1083
1084 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 33)) {
1085 constexpr int NTREE_EXECUTION_MODE_GPU = 2;
1086
1087 for (Scene &scene : bmain->scenes) {
1088 if (scene.nodetree) {
1089 if (scene.nodetree->execution_mode == NTREE_EXECUTION_MODE_GPU) {
1091 }
1093 }
1094 }
1095 }
1096
1097 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 34)) {
1098 float shadow_max_res_sun = 0.001f;
1099 float shadow_max_res_local = 0.001f;
1100 bool shadow_resolution_absolute = false;
1101 /* Try to get default resolution from scene setting. */
1102 for (Scene &scene : bmain->scenes) {
1103 shadow_max_res_local = (2.0f * M_SQRT2) / scene.eevee.shadow_cube_size_deprecated;
1104 /* Round to avoid weird numbers in the UI. */
1105 shadow_max_res_local = ceil(shadow_max_res_local * 1000.0f) / 1000.0f;
1106 shadow_resolution_absolute = true;
1107 break;
1108 }
1109
1110 for (Light &light : bmain->lights) {
1111 if (light.type == LA_SUN) {
1112 /* Sun are too complex to convert. Need user interaction. */
1113 light.shadow_maximum_resolution = shadow_max_res_sun;
1114 SET_FLAG_FROM_TEST(light.mode, false, LA_SHAD_RES_ABSOLUTE);
1115 }
1116 else {
1117 light.shadow_maximum_resolution = shadow_max_res_local;
1118 SET_FLAG_FROM_TEST(light.mode, shadow_resolution_absolute, LA_SHAD_RES_ABSOLUTE);
1119 }
1120 }
1121 }
1122
1123 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 36)) {
1124 for (Brush &brush : bmain->brushes) {
1125 /* Only for grease pencil brushes. */
1126 if (brush.gpencil_settings) {
1127 /* Use the `Scene` radius unit by default (confusingly named `BRUSH_LOCK_SIZE`).
1128 * Convert the radius to be the same visual size as in GPv2. */
1129 brush.flag |= BRUSH_LOCK_SIZE;
1131 }
1132 }
1133 }
1134
1135 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 37)) {
1136 const World default_world;
1137 for (World &world : bmain->worlds) {
1138 world.sun_threshold = default_world.sun_threshold;
1139 world.sun_angle = default_world.sun_angle;
1140 world.sun_shadow_maximum_resolution = default_world.sun_shadow_maximum_resolution;
1141 /* Having the sun extracted is mandatory to keep the same look and avoid too much light
1142 * leaking compared to EEVEE-Legacy. But adding shadows might create performance overhead and
1143 * change the result in a very different way. So we disable shadows in older file. */
1144 world.flag &= ~WO_USE_SUN_SHADOW;
1145 }
1146 }
1147
1148 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 38)) {
1149 for (GreasePencil &grease_pencil : bmain->grease_pencils) {
1151 }
1152 }
1153
1154 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 39)) {
1155 /* Unify cast shadow property with Cycles. */
1157 const Light default_light;
1158 for (Light &light : bmain->lights) {
1159 IDProperty *clight = version_cycles_properties_from_ID(&light.id);
1160 if (clight) {
1162 clight, "cast_shadow", default_light.mode & LA_SHADOW);
1163 SET_FLAG_FROM_TEST(light.mode, value, LA_SHADOW);
1164 }
1165 }
1166 }
1167 }
1168
1169 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 40)) {
1170 for (bNodeTree &ntree : bmain->nodetrees) {
1171 version_node_input_socket_name(&ntree, FN_NODE_COMBINE_TRANSFORM, "Location", "Translation");
1173 &ntree, FN_NODE_SEPARATE_TRANSFORM, "Location", "Translation");
1174 }
1175 }
1176
1177 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 41)) {
1178 const Light default_light;
1179 for (Light &light : bmain->lights) {
1180 light.shadow_jitter_overblur = default_light.shadow_jitter_overblur;
1181 }
1182 }
1183
1184 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 43)) {
1185 const World default_world;
1186 for (World &world : bmain->worlds) {
1187 world.sun_shadow_maximum_resolution = default_world.sun_shadow_maximum_resolution;
1189 }
1190 }
1191
1192 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 44)) {
1193 const Scene default_scene;
1194 for (Scene &scene : bmain->scenes) {
1195 scene.eevee.fast_gi_step_count = default_scene.eevee.fast_gi_step_count;
1196 scene.eevee.fast_gi_ray_count = default_scene.eevee.fast_gi_ray_count;
1197 }
1198 }
1199
1200 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 45)) {
1201 for (bScreen &screen : bmain->screens) {
1202 for (ScrArea &area : screen.areabase) {
1203 for (SpaceLink &sl : area.spacedata) {
1204 if (sl.spacetype == SPACE_VIEW3D) {
1205 View3D *v3d = reinterpret_cast<View3D *>(&sl);
1207 }
1208 }
1209 }
1210 }
1211 }
1212
1213 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 46)) {
1214 const Scene default_scene;
1215 for (Scene &scene : bmain->scenes) {
1217 }
1218 }
1219 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 48)) {
1220 for (Object &ob : bmain->objects) {
1221 if (!ob.pose) {
1222 continue;
1223 }
1224 for (bPoseChannel &pchan : ob.pose->chanbase) {
1225 pchan.custom_shape_wire_width = 1.0;
1226 }
1227 }
1228 }
1229
1230 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 49)) {
1231 for (bScreen &screen : bmain->screens) {
1232 for (ScrArea &area : screen.areabase) {
1233 for (SpaceLink &sl : area.spacedata) {
1234 if (sl.spacetype == SPACE_VIEW3D) {
1235 View3D *v3d = reinterpret_cast<View3D *>(&sl);
1237 }
1238 }
1239 }
1240 }
1241 }
1242
1243 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 50)) {
1244 for (bNodeTree &ntree : bmain->nodetrees) {
1245 if (ntree.type != NTREE_GEOMETRY) {
1246 continue;
1247 }
1248 for (bNode &node : ntree.nodes) {
1249 if (node.type_legacy != GEO_NODE_CAPTURE_ATTRIBUTE) {
1250 continue;
1251 }
1253 continue;
1254 }
1256 node.storage);
1257 if (storage->next_identifier > 0) {
1258 continue;
1259 }
1260 storage->capture_items_num = 1;
1261 storage->capture_items = MEM_new_array<NodeGeometryAttributeCaptureItem>(
1262 storage->capture_items_num, __func__);
1263 NodeGeometryAttributeCaptureItem &item = storage->capture_items[0];
1264 item.data_type = storage->data_type_legacy;
1265 item.identifier = storage->next_identifier++;
1266 item.name = BLI_strdup("Value");
1267 }
1268 }
1269 }
1270
1271 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 53)) {
1272 for (bScreen &screen : bmain->screens) {
1273 for (ScrArea &area : screen.areabase) {
1274 for (SpaceLink &sl : area.spacedata) {
1275 if (sl.spacetype == SPACE_NODE) {
1276 SpaceNode *snode = reinterpret_cast<SpaceNode *>(&sl);
1278 }
1279 }
1280 }
1281 }
1282 }
1283
1284 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 55)) {
1285 FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
1286 if (ntree->type != NTREE_COMPOSIT) {
1287 continue;
1288 }
1289 for (bNode &node : ntree->nodes) {
1290 if (node.type_legacy != CMP_NODE_CURVE_RGB) {
1291 continue;
1292 }
1294 continue;
1295 }
1296
1297 CurveMapping &curve_mapping = *static_cast<CurveMapping *>(node.storage);
1298
1299 /* Film-like tone only works with the combined curve, which is the fourth curve, so make
1300 * the combined curve current, as we now hide the rest of the curves since they no longer
1301 * have an effect. */
1302 if (curve_mapping.tone == CURVE_TONE_FILMLIKE) {
1303 curve_mapping.cur = 3;
1304 }
1305 }
1306 }
1308 }
1309
1310 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 60) ||
1311 (bmain->versionfile == 403 && !MAIN_VERSION_FILE_ATLEAST(bmain, 403, 3)))
1312 {
1313 /* Limit Rotation constraints from old files should use the legacy Limit
1314 * Rotation behavior. */
1315 for (Object &obj : bmain->objects) {
1316 for (bConstraint &constraint : obj.constraints) {
1317 if (constraint.type != CONSTRAINT_TYPE_ROTLIMIT) {
1318 continue;
1319 }
1320 static_cast<bRotLimitConstraint *>(constraint.data)->flag |= LIMIT_ROT_LEGACY_BEHAVIOR;
1321 }
1322
1323 if (!obj.pose) {
1324 continue;
1325 }
1326 for (bPoseChannel &pbone : obj.pose->chanbase) {
1327 for (bConstraint &constraint : pbone.constraints) {
1328 if (constraint.type != CONSTRAINT_TYPE_ROTLIMIT) {
1329 continue;
1330 }
1331 static_cast<bRotLimitConstraint *>(constraint.data)->flag |= LIMIT_ROT_LEGACY_BEHAVIOR;
1332 }
1333 }
1334 }
1335 }
1336
1337 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 61)) {
1338 /* LIGHT_PROBE_RESOLUTION_64 has been removed in EEVEE-Next as the tedrahedral mapping is to
1339 * low res to be usable. */
1340 for (Scene &scene : bmain->scenes) {
1341 scene.eevee.gi_cubemap_resolution = std::max(scene.eevee.gi_cubemap_resolution, 128);
1342 }
1343 }
1344
1345 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 64)) {
1347 /* Re-apply versioning made for EEVEE-Next in 4.1 before it got delayed. */
1348 for (Material &material : bmain->materials) {
1349 bool transparent_shadows = material.blend_shadow != MA_BS_SOLID;
1350 SET_FLAG_FROM_TEST(material.blend_flag, transparent_shadows, MA_BL_TRANSPARENT_SHADOW);
1351 }
1352 for (Material &mat : bmain->materials) {
1353 mat.surface_render_method = (mat.blend_method == MA_BM_BLEND) ? MA_SURFACE_METHOD_FORWARD :
1355 }
1356 }
1357 }
1358
1359 if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 65)) {
1360 FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
1361 if (node_tree->type != NTREE_COMPOSIT) {
1362 continue;
1363 }
1364 for (bNode &node : node_tree->nodes) {
1365 if (node.type_legacy == CMP_NODE_DENOISE) {
1366 if (node.storage == nullptr) {
1367 /* Some known files were saved without a valid storage. These are likely corrupt files
1368 * that have been produced by a non official blender release. The node type will be set
1369 * to Undefined during linking, see #ntree_set_typeinfo. However, a valid storage might
1370 * be needed for future versioning (before linking), see
1371 * #do_version_denoise_menus_to_inputs so we set a valid storage at this stage such
1372 * that the node becomes well defined. */
1373 NodeDenoise *ndg = MEM_new<NodeDenoise>(__func__);
1374 ndg->hdr = true;
1376 node.storage = ndg;
1377 }
1378 }
1379 }
1380 }
1382 }
1383}
1384
1385} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
Low-level operations for grease pencil.
#define MAIN_VERSION_FILE_ATLEAST(main, ver, subver)
Definition BKE_main.hh:949
General operations, lookup, etc. for materials.
#define NODE_REROUTE
Definition BKE_node.hh:867
#define FOREACH_NODETREE_END
Definition BKE_node.hh:936
#define NODE_GROUP
Definition BKE_node.hh:865
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
Definition BKE_node.hh:926
#define SH_NODE_MIX_SHADER
#define CMP_NODE_DENOISE
#define FN_NODE_SEPARATE_TRANSFORM
#define SH_NODE_OUTPUT_WORLD
#define SH_NODE_BSDF_PRINCIPLED
#define SH_NODE_ADD_SHADER
#define SH_NODE_SUBSURFACE_SCATTERING
#define SH_NODE_VALUE
#define CMP_NODE_HUECORRECT
#define SH_NODE_BSDF_TRANSPARENT
#define SH_NODE_OUTPUT_MATERIAL
#define CMP_NODE_CURVE_RGB
#define FN_NODE_COMBINE_TRANSFORM
#define SH_NODE_EEVEE_SPECULAR
#define GEO_NODE_CAPTURE_ATTRIBUTE
#define CMP_NODE_BLUR
#define DEG2RADF(_deg)
#define M_SQRT2
#define STR_ELEM(...)
#define STRNCPY_UTF8(dst, src)
#define RPT_(msgid)
blenloader genfile private function prototypes
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
#define STREQ(a, b)
#define output
constexpr IndexRange()=default
UString()=default
#define storage(slot, qualifiers)
#define layer
#define ceil
ccl_device_inline float3x3 inverted(const float3x3 m)
constexpr float LEGACY_RADIUS_CONVERSION_FACTOR
void node_remove_link(bNodeTree *ntree, bNodeLink &link)
Definition node.cc:4676
bNode * node_add_node(const bContext *C, bNodeTree &ntree, UString idname, std::optional< int > unique_identifier=std::nullopt)
Definition node.cc:4260
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
Definition node.cc:4283
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
Definition node.cc:4638
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, UString identifier)
Definition node.cc:3036
BLI_INLINE Texture * wrap(MTLTexture *texture)
void foreach_strip(ListBaseT< Strip > *seqbase, ForEachFunc callback, void *user_data)
Definition iterator.cc:60
SequencerToolSettings * tool_settings_ensure(Scene *scene)
Definition sequencer.cc:393
BMesh Iterators.
bool version_node_ensure_storage_or_invalidate(bNode &node)
MINLINE float min_ff(float a, float b)
static void versioning_node_hue_correct_set_wrappng(bNodeTree *ntree)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static void hue_correct_set_wrapping(CurveMapping *curve_mapping)
char * STRNCPY(char(&dst)[N], const char *src)
@ RPT_WARNING
Definition BKE_report.hh:40
static void image_settings_avi_to_ffmpeg(Scene *scene)
short * BKE_object_material_len_p(Object *ob)
@ RGN_TYPE_ASSET_SHELF_HEADER
Material * BKE_object_material_get(Object *ob, short act)
static bool versioning_eevee_material_blend_mode_settings(bNodeTree *ntree, float threshold)
static AlphaSource versioning_eevee_alpha_source_get(bNodeSocket *socket, int depth=0)
@ CURVE_TONE_FILMLIKE
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
@ NODE_MATH_GREATER_THAN
@ WO_USE_EEVEE_FINITE_VOLUME
const char * RE_engine_id_CYCLES
Definition scene.cc:1720
MINLINE int max_ii(int a, int b)
static bool strip_hue_correct_set_wrapping(Strip *strip, void *)
@ MA_BL_THICKNESS_FROM_SHADOW
float * version_cycles_node_socket_float_value(bNodeSocket *socket)
const char * RE_engine_id_BLENDER_WORKBENCH
Definition scene.cc:1719
@ V3D_SHOW_CAMERA_PASSEPARTOUT
@ BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_RADIUS
@ RGN_ALIGN_HIDE_WITH_PREV
const char * RE_engine_id_BLENDER_EEVEE
Definition scene.cc:1717
void do_versions_after_linking_402(FileData *fd, Main *bmain)
int version_cycles_property_int(IDProperty *idprop, const char *name, int default_value)
void version_socket_update_is_used(bNodeTree *ntree)
void version_node_output_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
@ SCE_EEVEE_MOTION_BLUR_ENABLED_DEPRECATED
@ SCE_EEVEE_VOLUME_CUSTOM_RANGE
@ CMP_NODE_BLUR_TYPE_FAST_GAUSS
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
float * version_cycles_node_socket_rgba_value(bNodeSocket *socket)
static bool strip_text_data_update(Strip *strip, void *)
@ SCE_COMPOSITOR_DEVICE_GPU
BMesh const char void * data
static void versioning_eevee_material_shadow_none(Material *material)
@ SEQ_CACHE_SHOW_FINAL_OUT
static void versioning_eevee_shadow_settings(Object *object)
bool all_scenes_use(Main *bmain, const Span< const char * > engines)
bNode * version_eevee_output_node_get(bNodeTree *ntree, int16_t node_type)
void BLO_reportf_wrap(BlendFileReadReport *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition readfile.cc:237
static void version_bonecollection_anim(FCurve *fcurve)
int CustomData_get_named_layer_index(const CustomData *data, eCustomDataType type, StringRef name)
static void convert_grease_pencil_stroke_hardness_to_softness(GreasePencil *grease_pencil)
bool version_cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
MINLINE void copy_v3_fl(float r[3], float f)
@ SEQ_EDIT_SHOW_MISSING_MEDIA
void blo_do_versions_402(FileData *fd, Library *lib, Main *bmain)
void version_node_input_socket_name(bNodeTree *ntree, const int node_type, const char *old_name, const char *new_name)
void * CustomData_get_layer_named_for_write(CustomData *data, eCustomDataType type, StringRef name, int totelem)
IDProperty * version_cycles_properties_from_ID(ID *id)
MINLINE void copy_v4_v4(float r[4], const float a[4])
ARegion * do_versions_add_region_if_not_found(ListBaseT< ARegion > *regionbase, int region_type, const char *, int link_after_region_type)
@ LA_SHAD_RES_ABSOLUTE
@ LA_USE_SOFT_FALLOFF
static void add_image_editor_asset_shelf(Main &bmain)
void version_node_socket_index_animdata(Main *bmain, const int node_tree_type, const int node_type, const int socket_index_orig, const int socket_index_offset, const int total_number_of_sockets)
@ CMP_NODE_DENOISE_PREFILTER_ACCURATE
@ eSeqModifierType_HueCorrect
static void version_refraction_depth_to_thickness_value(bNodeTree *ntree, float thickness)
@ SN_OVERLAY_SHOW_REROUTE_AUTO_LABELS
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bool is_transparent() const
static AlphaSource complex_alpha()
static AlphaSource alpha_source(bNodeSocket *fac, bool inverted=false)
bool is_semi_transparent() const
bool is_fully_transparent() const
static AlphaSource add(const AlphaSource &a, const AlphaSource &b)
static AlphaSource opaque()
static AlphaSource fully_transparent(bNodeSocket *socket=nullptr, bool inverted=false)
static AlphaSource mix(const AlphaSource &a, const AlphaSource &b, bNodeSocket *fac)
ListBaseT< FCurve > drivers
eCurveMappingTone tone
eCurveMappingFlags flag
eEditingShowMissingMediaFlag show_missing_media_flag
eEditingCacheFlag cache_flag
ListBaseT< Strip > seqbase
BlendFileReadReport * reports
Definition readfile.hh:208
std::unique_ptr< SDNA > filesdna
Definition readfile.hh:111
ListBaseT< bArmature > armatures
Definition BKE_main.hh:407
ListBaseT< bNodeTree > nodetrees
Definition BKE_main.hh:409
ListBaseT< Light > lights
Definition BKE_main.hh:396
ListBaseT< World > worlds
Definition BKE_main.hh:399
short versionfile
Definition BKE_main.hh:269
ListBaseT< Brush > brushes
Definition BKE_main.hh:410
ListBaseT< Material > materials
Definition BKE_main.hh:392
ListBaseT< Object > objects
Definition BKE_main.hh:388
ListBaseT< Scene > scenes
Definition BKE_main.hh:386
ListBaseT< GreasePencil > grease_pencils
Definition BKE_main.hh:418
ListBaseT< LightProbe > lightprobes
Definition BKE_main.hh:404
ListBaseT< bScreen > screens
Definition BKE_main.hh:400
DNA_DEPRECATED short filtertype
DNA_DEPRECATED float percentx
DNA_DEPRECATED short sizex
DNA_DEPRECATED float percenty
DNA_DEPRECATED short sizey
DNA_DEPRECATED char prefilter
DNA_DEPRECATED char hdr
ListBaseT< bConstraint > constraints
bMotionPath * mpath
struct bPose * pose
eCompositorPrecision compositor_precision
ImageFormatData im_format
eCompositorDevice compositor_device
DNA_DEPRECATED int shadow_cube_size_deprecated
DNA_DEPRECATED int motion_blur_position_deprecated
eSceneEEVEE_Flag flag
DNA_DEPRECATED float motion_blur_shutter_deprecated
struct Editing * ed
DNA_DEPRECATED struct bNodeTree * nodetree
struct RenderData r
struct SceneEEVEE eevee
struct ToolSettings * toolsettings
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
eSpaceSeq_SequencerCacheOverlay_Flag flag
eSpaceNodeOverlay_Flag flag
SpaceNodeOverlay overlay
struct SequencerCacheOverlay cache_overlay
eView3D_Flag2 flag2
ListBaseT< FCurve > curves
eNodeSocketDatatype type
struct bNodeLink * link
ListBaseT< bNodeLink > links
DNA_DEPRECATED int execution_mode
eNodeTree_Type type
eNodeTree_Flag flag
ListBaseT< bNode > nodes
DNA_DEPRECATED int precision
struct bNode * parent
ListBaseT< bNodeSocket > outputs
ListBaseT< bNodeSocket > inputs
ListBaseT< struct bConstraint > constraints
ListBaseT< bPoseChannel > chanbase
ListBaseT< struct ScrArea > areabase