Blender V5.0
rna_material.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 <cfloat>
10#include <cstdlib>
11
12#include "DNA_material_types.h"
13#include "DNA_mesh_types.h"
14
15#include "BLI_math_rotation.h"
16
17#include "BLT_translation.hh"
18
19#include "BKE_customdata.hh"
20
21#include "RNA_define.hh"
22#include "RNA_enum_types.hh"
23
24#include "rna_internal.hh"
25
26#include "WM_api.hh"
27#include "WM_types.hh"
28
30 {MA_RAMP_BLEND, "MIX", 0, "Mix", ""},
32 {MA_RAMP_DARK, "DARKEN", 0, "Darken", ""},
33 {MA_RAMP_MULT, "MULTIPLY", 0, "Multiply", ""},
34 {MA_RAMP_BURN, "BURN", 0, "Color Burn", ""},
36 {MA_RAMP_LIGHT, "LIGHTEN", 0, "Lighten", ""},
37 {MA_RAMP_SCREEN, "SCREEN", 0, "Screen", ""},
38 {MA_RAMP_DODGE, "DODGE", 0, "Color Dodge", ""},
39 {MA_RAMP_ADD, "ADD", 0, "Add", ""},
41 {MA_RAMP_OVERLAY, "OVERLAY", 0, "Overlay", ""},
42 {MA_RAMP_SOFT, "SOFT_LIGHT", 0, "Soft Light", ""},
43 {MA_RAMP_LINEAR, "LINEAR_LIGHT", 0, "Linear Light", ""},
45 {MA_RAMP_DIFF, "DIFFERENCE", 0, "Difference", ""},
46 {MA_RAMP_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""},
47 {MA_RAMP_SUB, "SUBTRACT", 0, "Subtract", ""},
48 {MA_RAMP_DIV, "DIVIDE", 0, "Divide", ""},
50 {MA_RAMP_HUE, "HUE", 0, "Hue", ""},
51 {MA_RAMP_SAT, "SATURATION", 0, "Saturation", ""},
52 {MA_RAMP_COLOR, "COLOR", 0, "Color", ""},
53 {MA_RAMP_VAL, "VALUE", 0, "Value", ""},
54 {0, nullptr, 0, nullptr, nullptr},
55};
56
57#ifdef RNA_RUNTIME
58
59# include "MEM_guardedalloc.h"
60
62# include "DNA_meshdata_types.h"
63# include "DNA_node_types.h"
64# include "DNA_object_types.h"
65# include "DNA_screen_types.h"
66# include "DNA_space_types.h"
67
68# include "BKE_attribute.hh"
69# include "BKE_colorband.hh"
70# include "BKE_context.hh"
71# include "BKE_gpencil_legacy.h"
72# include "BKE_grease_pencil.hh"
73# include "BKE_main.hh"
74# include "BKE_material.hh"
75# include "BKE_node.hh"
76# include "BKE_paint.hh"
77# include "BKE_scene.hh"
78# include "BKE_texture.h"
79# include "BKE_workspace.hh"
80
81# include "DEG_depsgraph.hh"
82# include "DEG_depsgraph_build.hh"
83
84# include "ED_gpencil_legacy.hh"
85# include "ED_image.hh"
86# include "ED_node.hh"
87# include "ED_screen.hh"
88
89static void rna_Material_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
90{
91 Material *ma = (Material *)ptr->owner_id;
92
95}
96
97static void rna_Material_update_previews(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
98{
99 Material *ma = (Material *)ptr->owner_id;
100
102}
103
104static void rna_MaterialGpencil_update(Main *bmain, Scene *scene, PointerRNA *ptr)
105{
106 Material *ma = (Material *)ptr->owner_id;
107 rna_Material_update(bmain, scene, ptr);
108
109 /* Need set all caches as dirty. */
110 for (Object *ob = static_cast<Object *>(bmain->objects.first); ob;
111 ob = static_cast<Object *>(ob->id.next))
112 {
113 if (ob->type == OB_GREASE_PENCIL) {
114 GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
115 DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
116 }
117 }
118
120}
121
122static void rna_MaterialLineArt_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
123{
124 Material *ma = (Material *)ptr->owner_id;
125 /* Need to tag geometry for line art modifier updates. */
128}
129
130static std::optional<std::string> rna_MaterialLineArt_path(const PointerRNA * /*ptr*/)
131{
132 return "lineart";
133}
134
135static void rna_Material_draw_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
136{
137 Material *ma = (Material *)ptr->owner_id;
138
141}
142
143static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
144{
145 Material *ma = (Material *)ptr->data;
147 iter, ptr, (void *)ma->texpaintslot, sizeof(TexPaintSlot), ma->tot_slots, 0, nullptr);
148}
149
150static void rna_Material_active_paint_texture_index_update(bContext *C, PointerRNA *ptr)
151{
152 Main *bmain = CTX_data_main(C);
153 Material *ma = (Material *)ptr->owner_id;
154
155 if (ma->nodetree) {
156 bNode *node = BKE_texpaint_slot_material_find_node(ma, ma->paint_active_slot);
157
158 if (node) {
159 blender::bke::node_set_active(*ma->nodetree, *node);
160 }
161 }
162
163 if (ma->texpaintslot && (ma->tot_slots > ma->paint_active_slot)) {
164 TexPaintSlot *slot = &ma->texpaintslot[ma->paint_active_slot];
165 Image *image = slot->ima;
166 if (image) {
167 ED_space_image_sync(bmain, image, false);
168 }
169
170 /* For compatibility reasons with vertex paint we activate the color attribute. */
171 if (slot->attribute_name) {
173 if (ob != nullptr && ob->type == OB_MESH) {
174 Mesh *mesh = static_cast<Mesh *>(ob->data);
175 const CustomDataLayer *layer = BKE_id_attributes_color_find(&mesh->id,
176 slot->attribute_name);
177 if (layer != nullptr) {
179 }
180 DEG_id_tag_update(&ob->id, 0);
182 }
183 }
184 }
185
186 DEG_id_tag_update(&ma->id, 0);
188}
189
190static int rna_Material_blend_method_get(PointerRNA *ptr)
191{
192 Material *material = (Material *)ptr->owner_id;
193 switch (material->surface_render_method) {
195 return MA_BM_HASHED;
197 return MA_BM_BLEND;
198 }
199 return MA_BM_HASHED;
200}
201
202static void rna_Material_blend_method_set(PointerRNA *ptr, int new_blend_method)
203{
204 Material *material = (Material *)ptr->owner_id;
205 switch (new_blend_method) {
206 case MA_BM_SOLID:
207 case MA_BM_CLIP:
208 case MA_BM_HASHED:
209 material->surface_render_method = MA_SURFACE_METHOD_DEFERRED;
210 break;
211 case MA_BM_BLEND:
212 material->surface_render_method = MA_SURFACE_METHOD_FORWARD;
213 break;
214 }
215}
216
217static void rna_Material_render_method_set(PointerRNA *ptr, int new_render_method)
218{
219 Material *material = (Material *)ptr->owner_id;
220 material->surface_render_method = new_render_method;
221
222 /* Still sets the legacy property for forward compatibility. */
223 switch (new_render_method) {
225 material->blend_method = MA_BM_HASHED;
226 break;
228 material->blend_method = MA_BM_BLEND;
229 break;
230 }
231}
232static void rna_Material_transparent_shadow_set(PointerRNA *ptr, bool new_value)
233{
234 Material *material = (Material *)ptr->owner_id;
235 SET_FLAG_FROM_TEST(material->blend_flag, new_value, MA_BL_TRANSPARENT_SHADOW);
236 /* Still sets the legacy property for forward compatibility. */
237 material->blend_shadow = new_value ? MA_BS_HASHED : MA_BS_SOLID;
238}
239
240static bool rna_Material_use_nodes_get(PointerRNA * /*ptr*/)
241{
242 /* #use_nodes is deprecated. All materials now use nodes. */
243 return true;
244}
245
246static void rna_Material_use_nodes_set(PointerRNA * /*ptr*/, bool /*new_value*/)
247{
248 /* #use_nodes is deprecated. Setting the property has no effect.
249 * Note: Users will get a warning through the RNA deprecation warning, so no need to log a
250 * warning here. */
251 return;
252}
253
255{
256 MTex *mtex = BKE_texture_mtex_add_id(self_id, -1);
257 if (mtex == nullptr) {
258 BKE_reportf(reports, RPT_ERROR, "Maximum number of textures added %d", MAX_MTEX);
259 return nullptr;
260 }
261
262 /* for redraw only */
264
265 return mtex;
266}
267
268MTex *rna_mtex_texture_slots_create(ID *self_id, bContext *C, ReportList *reports, int index)
269{
270 MTex *mtex;
271
272 if (index < 0 || index >= MAX_MTEX) {
273 BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
274 return nullptr;
275 }
276
277 mtex = BKE_texture_mtex_add_id(self_id, index);
278
279 /* for redraw only */
281
282 return mtex;
283}
284
285void rna_mtex_texture_slots_clear(ID *self_id, bContext *C, ReportList *reports, int index)
286{
287 MTex **mtex_ar;
288 short act;
289
290 give_active_mtex(self_id, &mtex_ar, &act);
291
292 if (mtex_ar == nullptr) {
293 BKE_report(reports, RPT_ERROR, "Mtex not found for this type");
294 return;
295 }
296
297 if (index < 0 || index >= MAX_MTEX) {
298 BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
299 return;
300 }
301
302 if (mtex_ar[index]) {
303 id_us_min((ID *)mtex_ar[index]->tex);
304 MEM_freeN(mtex_ar[index]);
305 mtex_ar[index] = nullptr;
306 DEG_id_tag_update(self_id, 0);
307 }
308
309 /* for redraw only */
311}
312
313static void rna_TexPaintSlot_uv_layer_get(PointerRNA *ptr, char *value)
314{
315 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
316
317 if (data->uvname != nullptr) {
318 strcpy(value, data->uvname);
319 }
320 else {
321 value[0] = '\0';
322 }
323}
324
325static int rna_TexPaintSlot_uv_layer_length(PointerRNA *ptr)
326{
327 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
328 return data->uvname == nullptr ? 0 : strlen(data->uvname);
329}
330
331static void rna_TexPaintSlot_uv_layer_set(PointerRNA *ptr, const char *value)
332{
333 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
334
335 if (data->uvname != nullptr) {
337 }
338}
339
340static void rna_TexPaintSlot_name_get(PointerRNA *ptr, char *value)
341{
342 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
343
344 if (data->ima != nullptr) {
345 strcpy(value, data->ima->id.name + 2);
346 return;
347 }
348
349 if (data->attribute_name != nullptr) {
350 strcpy(value, data->attribute_name);
351 return;
352 }
353
354 value[0] = '\0';
355}
356
357static int rna_TexPaintSlot_name_length(PointerRNA *ptr)
358{
359 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
360 if (data->ima != nullptr) {
361 return strlen(data->ima->id.name) - 2;
362 }
363 if (data->attribute_name != nullptr) {
364 return strlen(data->attribute_name);
365 }
366
367 return 0;
368}
369
370static int rna_TexPaintSlot_icon_get(PointerRNA *ptr)
371{
372 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
373 if (data->ima != nullptr) {
374 return ICON_IMAGE;
375 }
376 if (data->attribute_name != nullptr) {
377 return ICON_COLOR;
378 }
379
380 return ICON_NONE;
381}
382
383static bool rna_is_grease_pencil_get(PointerRNA *ptr)
384{
385 Material *ma = (Material *)ptr->data;
386 if (ma->gp_style != nullptr) {
387 return true;
388 }
389
390 return false;
391}
392
393static std::optional<std::string> rna_GpencilColorData_path(const PointerRNA * /*ptr*/)
394{
395 return "grease_pencil";
396}
397
398static bool rna_GpencilColorData_is_stroke_visible_get(PointerRNA *ptr)
399{
400 MaterialGPencilStyle *pcolor = static_cast<MaterialGPencilStyle *>(ptr->data);
401 return (pcolor->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH);
402}
403
404static bool rna_GpencilColorData_is_fill_visible_get(PointerRNA *ptr)
405{
407 return ((pcolor->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (pcolor->fill_style > 0));
408}
409
410static void rna_GpencilColorData_stroke_image_set(PointerRNA *ptr,
411 PointerRNA value,
412 ReportList * /*reports*/)
413{
414 MaterialGPencilStyle *pcolor = static_cast<MaterialGPencilStyle *>(ptr->data);
415 ID *id = static_cast<ID *>(value.data);
416
417 id_us_plus(id);
418 pcolor->sima = (Image *)id;
419}
420
421static void rna_GpencilColorData_fill_image_set(PointerRNA *ptr,
422 PointerRNA value,
423 ReportList * /*reports*/)
424{
426 ID *id = static_cast<ID *>(value.data);
427
428 id_us_plus(id);
429 pcolor->ima = (Image *)id;
430}
431
432#else
433
435{
436 PropertyRNA *prop;
437
438 prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
439 RNA_def_property_float_sdna(prop, nullptr, "r");
440 RNA_def_property_array(prop, 4);
442 RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material");
443 /* See #82514 for details, for now re-define defaults here. Keep in sync with
444 * #DNA_material_defaults.h */
445 static const float diffuse_color_default[4] = {0.8f, 0.8f, 0.8f, 1.0f};
446 RNA_def_property_float_array_default(prop, diffuse_color_default);
447 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
448
449 prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR);
450 RNA_def_property_float_sdna(prop, nullptr, "specr");
451 RNA_def_property_array(prop, 3);
453 RNA_def_property_ui_text(prop, "Specular Color", "Specular color of the material");
454 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
455
456 prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_FACTOR);
457 RNA_def_property_float_sdna(prop, nullptr, "roughness");
458 RNA_def_property_range(prop, 0, 1);
460 RNA_def_property_ui_text(prop, "Roughness", "Roughness of the material");
461 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
462
463 prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR);
464 RNA_def_property_float_sdna(prop, nullptr, "spec");
465 RNA_def_property_range(prop, 0, 1);
467 RNA_def_property_ui_text(prop, "Specular", "How intense (bright) the specular reflection is");
468 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
469
470 prop = RNA_def_property(srna, "metallic", PROP_FLOAT, PROP_FACTOR);
471 RNA_def_property_float_sdna(prop, nullptr, "metallic");
472 RNA_def_property_range(prop, 0.0f, 1.0f);
474 RNA_def_property_ui_text(prop, "Metallic", "Amount of mirror reflection for raytrace");
475 RNA_def_property_update(prop, 0, "rna_Material_update");
476
477 /* Freestyle line color */
478 prop = RNA_def_property(srna, "line_color", PROP_FLOAT, PROP_COLOR);
479 RNA_def_property_float_sdna(prop, nullptr, "line_col");
480 RNA_def_property_array(prop, 4);
481 RNA_def_property_ui_text(prop, "Line Color", "Line color used for Freestyle line rendering");
482 RNA_def_property_update(prop, 0, "rna_Material_update");
483
484 prop = RNA_def_property(srna, "line_priority", PROP_INT, PROP_NONE);
485 RNA_def_property_int_sdna(prop, nullptr, "line_priority");
486 RNA_def_property_range(prop, 0, 32767);
488 prop, "Line Priority", "The line color of a higher priority is used at material boundaries");
489 RNA_def_property_update(prop, 0, "rna_Material_update");
490}
491
493{
494 StructRNA *srna;
495 PropertyRNA *prop;
496
497 /* mode type styles */
498 static const EnumPropertyItem gpcolordata_mode_types_items[] = {
499 {GP_MATERIAL_MODE_LINE, "LINE", 0, "Line", "Draw strokes using a continuous line"},
500 {GP_MATERIAL_MODE_DOT, "DOTS", 0, "Dots", "Draw strokes using separated dots"},
501 {GP_MATERIAL_MODE_SQUARE, "BOX", 0, "Squares", "Draw strokes using separated squares"},
502 {0, nullptr, 0, nullptr, nullptr},
503 };
504
505 /* stroke styles */
506 static const EnumPropertyItem stroke_style_items[] = {
507 {GP_MATERIAL_STROKE_STYLE_SOLID, "SOLID", 0, "Solid", "Draw strokes with solid color"},
508 {GP_MATERIAL_STROKE_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Draw strokes using texture"},
509 {0, nullptr, 0, nullptr, nullptr},
510 };
511
512 /* fill styles */
513 static const EnumPropertyItem fill_style_items[] = {
514 {GP_MATERIAL_FILL_STYLE_SOLID, "SOLID", 0, "Solid", "Fill area with solid color"},
516 "GRADIENT",
517 0,
518 "Gradient",
519 "Fill area with gradient color"},
520 {GP_MATERIAL_FILL_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Fill area with image texture"},
521 {0, nullptr, 0, nullptr, nullptr},
522 };
523
524 static const EnumPropertyItem fill_gradient_items[] = {
525 {GP_MATERIAL_GRADIENT_LINEAR, "LINEAR", 0, "Linear", "Fill area with gradient color"},
526 {GP_MATERIAL_GRADIENT_RADIAL, "RADIAL", 0, "Radial", "Fill area with radial gradient"},
527 {0, nullptr, 0, nullptr, nullptr},
528 };
529
530 static const EnumPropertyItem alignment_draw_items[] = {
532 "PATH",
533 0,
534 "Path",
535 "Follow stroke drawing path and object rotation"},
536 {GP_MATERIAL_FOLLOW_OBJ, "OBJECT", 0, "Object", "Follow object rotation only"},
538 "FIXED",
539 0,
540 "Fixed",
541 "Do not follow drawing path or object rotation and keeps aligned with viewport"},
542 {0, nullptr, 0, nullptr, nullptr},
543 };
544
545 srna = RNA_def_struct(brna, "MaterialGPencilStyle", nullptr);
546 RNA_def_struct_sdna(srna, "MaterialGPencilStyle");
547 RNA_def_struct_ui_text(srna, "Grease Pencil Color", "");
548 RNA_def_struct_path_func(srna, "rna_GpencilColorData_path");
549
550 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
551 RNA_def_property_range(prop, 0.0, 1.0);
552 RNA_def_property_float_sdna(prop, nullptr, "stroke_rgba");
553 RNA_def_property_array(prop, 4);
554 RNA_def_property_ui_text(prop, "Color", "");
555 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
556
557 /* Fill Drawing Color */
558 prop = RNA_def_property(srna, "fill_color", PROP_FLOAT, PROP_COLOR);
559 RNA_def_property_float_sdna(prop, nullptr, "fill_rgba");
560 RNA_def_property_array(prop, 4);
561 RNA_def_property_range(prop, 0.0f, 1.0f);
562 RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region bounded by each stroke");
563 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
564
565 /* Secondary Drawing Color */
566 prop = RNA_def_property(srna, "mix_color", PROP_FLOAT, PROP_COLOR);
567 RNA_def_property_float_sdna(prop, nullptr, "mix_rgba");
568 RNA_def_property_array(prop, 4);
569 RNA_def_property_range(prop, 0.0f, 1.0f);
570 RNA_def_property_ui_text(prop, "Mix Color", "Color for mixing with primary filling color");
571 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
572
573 /* Mix factor */
574 prop = RNA_def_property(srna, "mix_factor", PROP_FLOAT, PROP_FACTOR);
575 RNA_def_property_float_sdna(prop, nullptr, "mix_factor");
576 RNA_def_property_range(prop, 0.0f, 1.0f);
577 RNA_def_property_ui_text(prop, "Mix", "Mix Factor");
579 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
580
581 /* Stroke Mix factor */
582 prop = RNA_def_property(srna, "mix_stroke_factor", PROP_FLOAT, PROP_FACTOR);
583 RNA_def_property_float_sdna(prop, nullptr, "mix_stroke_factor");
584 RNA_def_property_range(prop, 0.0f, 1.0f);
585 RNA_def_property_ui_text(prop, "Mix", "Mix Stroke Factor");
587 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
588
589 /* Texture angle */
590 prop = RNA_def_property(srna, "texture_angle", PROP_FLOAT, PROP_ANGLE);
591 RNA_def_property_float_sdna(prop, nullptr, "texture_angle");
592 RNA_def_property_ui_text(prop, "Angle", "Texture Orientation Angle");
593 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
594
595 /* Scale factor for texture */
596 prop = RNA_def_property(srna, "texture_scale", PROP_FLOAT, PROP_COORDS);
597 RNA_def_property_float_sdna(prop, nullptr, "texture_scale");
598 RNA_def_property_array(prop, 2);
599 RNA_def_property_ui_text(prop, "Scale", "Scale Factor for Texture");
600 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
601
602 /* Shift factor to move texture in 2d space */
603 prop = RNA_def_property(srna, "texture_offset", PROP_FLOAT, PROP_COORDS);
604 RNA_def_property_float_sdna(prop, nullptr, "texture_offset");
605 RNA_def_property_array(prop, 2);
606 RNA_def_property_ui_text(prop, "Offset", "Shift Texture in 2d Space");
607 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
608
609 /* texture pixsize factor (used for UV along the stroke) */
610 prop = RNA_def_property(srna, "pixel_size", PROP_FLOAT, PROP_NONE);
611 RNA_def_property_float_sdna(prop, nullptr, "texture_pixsize");
612 RNA_def_property_range(prop, 1, 5000);
613 RNA_def_property_ui_text(prop, "UV Factor", "Texture Pixel Size factor along the stroke");
614 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
615
616 /* Flags */
617 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
618 RNA_def_property_boolean_sdna(prop, nullptr, "flag", GP_MATERIAL_HIDE);
619 RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
620 RNA_def_property_ui_text(prop, "Hide", "Set color Visibility");
621 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
622
623 prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
625 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
627 prop, "Locked", "Protect color from further editing and/or frame changes");
628 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
629
630 prop = RNA_def_property(srna, "ghost", PROP_BOOLEAN, PROP_NONE);
632 RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
634 prop, "Show in Ghosts", "Display strokes using this color when showing onion skins");
635 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
636
637 prop = RNA_def_property(srna, "texture_clamp", PROP_BOOLEAN, PROP_NONE);
639 RNA_def_property_ui_text(prop, "Clamp", "Do not repeat texture and clamp to one instance only");
640 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
641
642 prop = RNA_def_property(srna, "flip", PROP_BOOLEAN, PROP_NONE);
644 RNA_def_property_ui_text(prop, "Flip", "Flip filling colors");
645 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
646
647 prop = RNA_def_property(srna, "use_overlap_strokes", PROP_BOOLEAN, PROP_NONE);
650 prop, "Self Overlap", "Disable stencil and overlap self intersections with alpha materials");
651 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
652
653 prop = RNA_def_property(srna, "use_stroke_holdout", PROP_BOOLEAN, PROP_NONE);
656 prop, "Holdout", "Remove the color from underneath this stroke by using it as a mask");
657 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
658
659 prop = RNA_def_property(srna, "use_fill_holdout", PROP_BOOLEAN, PROP_NONE);
662 prop, "Holdout", "Remove the color from underneath this stroke by using it as a mask");
663 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
664
665 prop = RNA_def_property(srna, "show_stroke", PROP_BOOLEAN, PROP_NONE);
667 RNA_def_property_ui_text(prop, "Show Stroke", "Show stroke lines of this material");
668 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
669
670 prop = RNA_def_property(srna, "show_fill", PROP_BOOLEAN, PROP_NONE);
672 RNA_def_property_ui_text(prop, "Show Fill", "Show stroke fills of this material");
673 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
674
675 /* Mode to align Dots and Boxes to drawing path and object rotation */
676 prop = RNA_def_property(srna, "alignment_mode", PROP_ENUM, PROP_NONE);
677 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "alignment_mode");
678 RNA_def_property_enum_items(prop, alignment_draw_items);
680 prop, "Alignment", "Defines how align Dots and Boxes with drawing path and object rotation");
681 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
682
683 /* Rotation of texture for Dots or Strokes. */
684 prop = RNA_def_property(srna, "alignment_rotation", PROP_FLOAT, PROP_ANGLE);
685 RNA_def_property_float_sdna(prop, nullptr, "alignment_rotation");
687 RNA_def_property_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f));
688 RNA_def_property_ui_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f), 10, 3);
690 "Rotation",
691 "Additional rotation applied to dots and square texture of strokes. "
692 "Only applies in texture shading mode.");
693 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
694
695 /* pass index for future compositing and editing tools */
696 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
697 RNA_def_property_int_sdna(prop, nullptr, "index");
698 RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Color Index\" pass");
699 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
700
701 /* mode type */
702 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
703 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "mode");
704 RNA_def_property_enum_items(prop, gpcolordata_mode_types_items);
705 RNA_def_property_ui_text(prop, "Line Type", "Select line type for strokes");
706 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
707
708 /* stroke style */
709 prop = RNA_def_property(srna, "stroke_style", PROP_ENUM, PROP_NONE);
710 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "stroke_style");
711 RNA_def_property_enum_items(prop, stroke_style_items);
712 RNA_def_property_ui_text(prop, "Stroke Style", "Select style used to draw strokes");
714 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
715
716 /* stroke image texture */
717 prop = RNA_def_property(srna, "stroke_image", PROP_POINTER, PROP_NONE);
718 RNA_def_property_pointer_sdna(prop, nullptr, "sima");
720 prop, nullptr, "rna_GpencilColorData_stroke_image_set", nullptr, nullptr);
723 RNA_def_property_ui_text(prop, "Image", "");
724 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
725
726 /* fill style */
727 prop = RNA_def_property(srna, "fill_style", PROP_ENUM, PROP_NONE);
728 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "fill_style");
729 RNA_def_property_enum_items(prop, fill_style_items);
730 RNA_def_property_ui_text(prop, "Fill Style", "Select style used to fill strokes");
732 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
733
734 /* gradient type */
735 prop = RNA_def_property(srna, "gradient_type", PROP_ENUM, PROP_NONE);
736 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "gradient_type");
737 RNA_def_property_enum_items(prop, fill_gradient_items);
738 RNA_def_property_ui_text(prop, "Gradient Type", "Select type of gradient used to fill strokes");
739 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
740
741 /* fill image texture */
742 prop = RNA_def_property(srna, "fill_image", PROP_POINTER, PROP_NONE);
743 RNA_def_property_pointer_sdna(prop, nullptr, "ima");
745 prop, nullptr, "rna_GpencilColorData_fill_image_set", nullptr, nullptr);
748 RNA_def_property_ui_text(prop, "Image", "");
749 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
750
751 /* Read-only state props (for simpler UI code) */
752 prop = RNA_def_property(srna, "is_stroke_visible", PROP_BOOLEAN, PROP_NONE);
753 RNA_def_property_boolean_funcs(prop, "rna_GpencilColorData_is_stroke_visible_get", nullptr);
756 prop, "Is Stroke Visible", "True when opacity of stroke is set high enough to be visible");
757
758 prop = RNA_def_property(srna, "is_fill_visible", PROP_BOOLEAN, PROP_NONE);
759 RNA_def_property_boolean_funcs(prop, "rna_GpencilColorData_is_fill_visible_get", nullptr);
762 prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible");
763}
765{
766 StructRNA *srna;
767 PropertyRNA *prop;
768
769 srna = RNA_def_struct(brna, "MaterialLineArt", nullptr);
770 RNA_def_struct_sdna(srna, "MaterialLineArt");
771 RNA_def_struct_ui_text(srna, "Material Line Art", "");
772 RNA_def_struct_path_func(srna, "rna_MaterialLineArt_path");
773
774 prop = RNA_def_property(srna, "use_material_mask", PROP_BOOLEAN, PROP_NONE);
778 prop, "Use Material Mask", "Use material masks to filter out occluded strokes");
779 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
780
781 prop = RNA_def_property(srna, "use_material_mask_bits", PROP_BOOLEAN, PROP_NONE);
783 RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "material_mask_bits", 1 << 0, 8);
784 RNA_def_property_ui_text(prop, "Mask", "");
785 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
786
787 prop = RNA_def_property(srna, "mat_occlusion", PROP_INT, PROP_NONE);
789 RNA_def_property_ui_range(prop, 0.0f, 5.0f, 1.0f, 1);
791 prop,
792 "Effectiveness",
793 "Faces with this material will behave as if it has set number of layers in occlusion");
794 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
795
796 prop = RNA_def_property(srna, "intersection_priority", PROP_INT, PROP_NONE);
797 RNA_def_property_range(prop, 0, 255);
799 "Intersection Priority",
800 "The intersection line will be included into the object with the "
801 "higher intersection priority value");
802 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
803
804 prop = RNA_def_property(srna, "use_intersection_priority_override", PROP_BOOLEAN, PROP_NONE);
808 "Use Intersection Priority",
809 "Override object and collection intersection priority value");
810 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
811}
812
814{
815 StructRNA *srna;
816 PropertyRNA *prop;
817
818 /* Render Preview Types */
819 static const EnumPropertyItem preview_type_items[] = {
820 {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"},
821 {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Sphere"},
822 {MA_CUBE, "CUBE", ICON_MATCUBE, "Cube", "Cube"},
823 {MA_HAIR, "HAIR", ICON_CURVES, "Hair", "Hair strands"},
824 {MA_SHADERBALL, "SHADERBALL", ICON_MATSHADERBALL, "Shader Ball", "Shader ball"},
825 {MA_CLOTH, "CLOTH", ICON_MATCLOTH, "Cloth", "Cloth"},
826 {MA_FLUID, "FLUID", ICON_MATFLUID, "Fluid", "Fluid"},
827 {0, nullptr, 0, nullptr, nullptr},
828 };
829
830 static const EnumPropertyItem prop_eevee_volume_isect_method_items[] = {
832 "FAST",
833 0,
834 "Fast",
835 "Each face is considered as a medium interface. Gives correct results for manifold "
836 "geometry that contains no inner parts."},
838 "ACCURATE",
839 0,
840 "Accurate",
841 "Faces are considered as medium interface only when they have different consecutive "
842 "facing. Gives correct results as long as the max ray depth is not exceeded. Have "
843 "significant memory overhead compared to the fast method."},
844 {0, nullptr, 0, nullptr, nullptr},
845 };
846
847 static const EnumPropertyItem prop_eevee_thickness_method_items[] = {
849 "SPHERE",
850 0,
851 "Sphere",
852 "Approximate the object as a sphere whose diameter is equal to the thickness defined by "
853 "the node tree"},
855 "SLAB",
856 0,
857 "Slab",
858 "Approximate the object as an infinite slab of thickness defined by the node tree"},
859 {0, nullptr, 0, nullptr, nullptr},
860 };
861
862# if 1 /* Delete this section once we remove old eevee. */
863 static const EnumPropertyItem prop_eevee_blend_items[] = {
864 {MA_BM_SOLID, "OPAQUE", 0, "Opaque", "Render surface without transparency"},
865 {MA_BM_CLIP,
866 "CLIP",
867 0,
868 "Alpha Clip",
869 "Use the alpha threshold to clip the visibility (binary visibility)"},
871 "HASHED",
872 0,
873 "Alpha Hashed",
874 "Use noise to dither the binary visibility (works well with multi-samples)"},
876 "BLEND",
877 0,
878 "Alpha Blend",
879 "Render polygon transparent, depending on alpha channel of the texture"},
880 {0, nullptr, 0, nullptr, nullptr},
881 };
882# endif
883
884 static const EnumPropertyItem prop_eevee_surface_render_method_items[] = {
886 "DITHERED",
887 0,
888 "Dithered",
889 "Allows for grayscale hashed transparency, and compatible with render passes and "
890 "raytracing. Also known as deferred rendering."},
892 "BLENDED",
893 0,
894 "Blended",
895 "Allows for colored transparency, but incompatible with render passes and raytracing. Also "
896 "known as forward rendering."},
897 {0, nullptr, 0, nullptr, nullptr},
898 };
899
900 static const EnumPropertyItem prop_displacement_method_items[] = {
902 "BUMP",
903 0,
904 "Bump Only",
905 "Bump mapping to simulate the appearance of displacement"},
907 "DISPLACEMENT",
908 0,
909 "Displacement Only",
910 "Use true displacement of surface only, requires fine subdivision"},
912 "BOTH",
913 0,
914 "Displacement and Bump",
915 "Combination of true displacement and bump mapping for finer detail"},
916 {0, nullptr, 0, nullptr, nullptr},
917 };
918
919 srna = RNA_def_struct(brna, "Material", "ID");
921 srna,
922 "Material",
923 "Material data-block to define the appearance of geometric objects for rendering");
924 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
925
926 prop = RNA_def_property(srna, "surface_render_method", PROP_ENUM, PROP_NONE);
927 RNA_def_property_enum_items(prop, prop_eevee_surface_render_method_items);
929 "Surface Render Method",
930 "Controls the blending and the compatibility with certain features");
931 /* Setter function for forward compatibility. */
932 RNA_def_property_enum_funcs(prop, nullptr, "rna_Material_render_method_set", nullptr);
933 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
934
935 prop = RNA_def_property(srna, "displacement_method", PROP_ENUM, PROP_NONE);
936 RNA_def_property_enum_items(prop, prop_displacement_method_items);
937 RNA_def_property_ui_text(prop, "Displacement Method", "Method to use for the displacement");
938 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
939
940# if 1 /* Delete this section once we remove old eevee. */
941 /* Blending (only Eevee for now) */
942 prop = RNA_def_property(srna, "blend_method", PROP_ENUM, PROP_NONE);
943 RNA_def_property_enum_items(prop, prop_eevee_blend_items);
945 prop,
946 "Blend Mode",
947 "Blend Mode for Transparent Faces (Deprecated: use 'surface_render_method')");
949 prop, "rna_Material_blend_method_get", "rna_Material_blend_method_set", nullptr);
951 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
952
953 prop = RNA_def_property(srna, "alpha_threshold", PROP_FLOAT, PROP_FACTOR);
954 RNA_def_property_range(prop, 0, 1);
956 "Clip Threshold",
957 "A pixel is rendered only if its alpha value is above this threshold");
958 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
959# endif
960
961 prop = RNA_def_property(srna, "use_transparency_overlap", PROP_BOOLEAN, PROP_NONE);
964 "Use Transparency Overlap",
965 "Render multiple transparent layers "
966 "(may introduce transparency sorting problems)");
967
968# if 1 /* This should be deleted in Blender 4.5 */
969 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
970 prop = RNA_def_property(srna, "show_transparent_back", PROP_BOOLEAN, PROP_NONE);
973 prop,
974 "Show Backface",
975 "Render multiple transparent layers "
976 "(may introduce transparency sorting problems) (Deprecated: use 'use_tranparency_overlap')");
977 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
978# endif
979
980 prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
981 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_CULL_BACKFACE);
983 prop, "Backface Culling", "Use back face culling to hide the back side of faces");
984 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
985
986 prop = RNA_def_property(srna, "use_backface_culling_shadow", PROP_BOOLEAN, PROP_NONE);
987 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_CULL_BACKFACE_SHADOW);
989 prop, "Shadow Backface Culling", "Use back face culling when casting shadows");
990 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
991
992 prop = RNA_def_property(srna, "use_backface_culling_lightprobe_volume", PROP_BOOLEAN, PROP_NONE);
994 prop, nullptr, "blend_flag", MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED);
996 prop,
997 "Light Probe Volume Backface Culling",
998 "Consider material single sided for light probe volume capture. "
999 "Additionally helps rejecting probes inside the object to avoid light leaks.");
1000 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1001
1002 prop = RNA_def_property(srna, "use_transparent_shadow", PROP_BOOLEAN, PROP_NONE);
1003 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_TRANSPARENT_SHADOW);
1004 RNA_def_property_boolean_funcs(prop, nullptr, "rna_Material_transparent_shadow_set");
1006 prop,
1007 "Transparent Shadows",
1008 "Use transparent shadows for this material if it contains a Transparent BSDF, "
1009 "disabling will render faster but not give accurate shadows");
1010 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1011
1012 prop = RNA_def_property(srna, "use_raytrace_refraction", PROP_BOOLEAN, PROP_NONE);
1013 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_SS_REFRACTION);
1015 prop,
1016 "Raytrace Transmission",
1017 "Use raytracing to determine transmitted color instead of using only light probes. "
1018 "This prevents the surface from contributing to the lighting of surfaces not using this "
1019 "setting.");
1020 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1021
1022# if 1 /* This should be deleted in Blender 4.5 */
1023 prop = RNA_def_property(srna, "use_screen_refraction", PROP_BOOLEAN, PROP_NONE);
1024 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_SS_REFRACTION);
1026 prop,
1027 "Raytrace Transmission",
1028 "Use raytracing to determine transmitted color instead of using only light probes. "
1029 "This prevents the surface from contributing to the lighting of surfaces not using this "
1030 "setting. Deprecated: use 'use_raytrace_refraction'.");
1031 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1032
1033 prop = RNA_def_property(srna, "use_sss_translucency", PROP_BOOLEAN, PROP_NONE);
1034 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_TRANSLUCENCY);
1036 prop, "Subsurface Translucency", "Add translucency effect to subsurface (Deprecated)");
1037 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1038
1039 prop = RNA_def_property(srna, "refraction_depth", PROP_FLOAT, PROP_DISTANCE);
1040 RNA_def_property_float_sdna(prop, nullptr, "refract_depth");
1041 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1043 "Refraction Depth",
1044 "Approximate the thickness of the object to compute two refraction "
1045 "events (0 is disabled) (Deprecated)");
1046 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1047# endif
1048
1049 prop = RNA_def_property(srna, "thickness_mode", PROP_ENUM, PROP_NONE);
1050 RNA_def_property_enum_items(prop, prop_eevee_thickness_method_items);
1052 "Thickness Mode",
1053 "Approximation used to model the light interactions inside the object");
1054 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1055
1056 prop = RNA_def_property(srna, "use_thickness_from_shadow", PROP_BOOLEAN, PROP_NONE);
1057 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_THICKNESS_FROM_SHADOW);
1059 "Thickness From Shadow",
1060 "Use the shadow maps from shadow casting lights "
1061 "to refine the thickness defined by the material node tree");
1062 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1063
1064 prop = RNA_def_property(srna, "volume_intersection_method", PROP_ENUM, PROP_NONE);
1065 RNA_def_property_enum_items(prop, prop_eevee_volume_isect_method_items);
1067 prop,
1068 "Volume Intersection Method",
1069 "Determines which inner part of the mesh will produce volumetric effect");
1070 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1071
1072 prop = RNA_def_property(srna, "max_vertex_displacement", PROP_FLOAT, PROP_DISTANCE);
1073 RNA_def_property_float_sdna(prop, nullptr, "inflate_bounds");
1074 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1076 "Max Vertex Displacement",
1077 "The max distance a vertex can be displaced. "
1078 "Displacements over this threshold may cause visibility issues.");
1079 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1080
1081 /* For Preview Render */
1082 prop = RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE);
1083 RNA_def_property_enum_sdna(prop, nullptr, "pr_type");
1084 RNA_def_property_enum_items(prop, preview_type_items);
1085 RNA_def_property_ui_text(prop, "Preview Render Type", "Type of preview render");
1087 RNA_def_property_update(prop, 0, "rna_Material_update_previews");
1088
1089 prop = RNA_def_property(srna, "use_preview_world", PROP_BOOLEAN, PROP_NONE);
1090 RNA_def_property_boolean_sdna(prop, nullptr, "pr_flag", MA_PREVIEW_WORLD);
1092 prop, "Preview World", "Use the current world background to light the preview render");
1093 RNA_def_property_update(prop, 0, "rna_Material_update_previews");
1094
1095 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
1096 RNA_def_property_int_sdna(prop, nullptr, "index");
1098 prop, "Pass Index", "Index number for the \"Material Index\" render pass");
1099 RNA_def_property_update(prop, NC_OBJECT, "rna_Material_update");
1100
1101 /* nodetree */
1102 prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
1103 RNA_def_property_pointer_sdna(prop, nullptr, "nodetree");
1106 RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based materials");
1107
1108 prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
1109 RNA_def_property_boolean_sdna(prop, nullptr, "use_nodes", 1);
1111 RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material");
1112 RNA_def_property_boolean_funcs(prop, "rna_Material_use_nodes_get", "rna_Material_use_nodes_set");
1114 "Unused but kept for compatibility reasons. Setting the property "
1115 "has no effect, and getting it always returns True.",
1116 500,
1117 600);
1118
1119 /* common */
1121 rna_def_texpaint_slots(brna, srna);
1122
1124
1125 /* grease pencil */
1126 prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
1127 RNA_def_property_pointer_sdna(prop, nullptr, "gp_style");
1129 prop, "Grease Pencil Settings", "Grease Pencil color settings for material");
1130
1131 prop = RNA_def_property(srna, "is_grease_pencil", PROP_BOOLEAN, PROP_NONE);
1132 RNA_def_property_boolean_funcs(prop, "rna_is_grease_pencil_get", nullptr);
1135 prop, "Is Grease Pencil", "True if this material has Grease Pencil data");
1136
1137 /* line art */
1138 prop = RNA_def_property(srna, "lineart", PROP_POINTER, PROP_NONE);
1139 RNA_def_property_pointer_sdna(prop, nullptr, "lineart");
1140 RNA_def_property_ui_text(prop, "Line Art Settings", "Line Art settings for material");
1141
1144
1145 RNA_api_material(srna);
1146}
1147
1149 PropertyRNA *cprop,
1150 const char *structname,
1151 const char *structname_slots)
1152{
1153 StructRNA *srna;
1154
1155 FunctionRNA *func;
1156 PropertyRNA *parm;
1157
1158 RNA_def_property_srna(cprop, structname_slots);
1159 srna = RNA_def_struct(brna, structname_slots, nullptr);
1160 RNA_def_struct_sdna(srna, "ID");
1161 RNA_def_struct_ui_text(srna, "Texture Slots", "Collection of texture slots");
1162
1163 /* functions */
1164 func = RNA_def_function(srna, "add", "rna_mtex_texture_slots_add");
1167 parm = RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
1168 RNA_def_function_return(func, parm);
1169
1170 func = RNA_def_function(srna, "create", "rna_mtex_texture_slots_create");
1173 parm = RNA_def_int(
1174 func, "index", 0, 0, INT_MAX, "Index", "Slot index to initialize", 0, INT_MAX);
1176 parm = RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
1177 RNA_def_function_return(func, parm);
1178
1179 func = RNA_def_function(srna, "clear", "rna_mtex_texture_slots_clear");
1182 parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to clear", 0, INT_MAX);
1184}
1185
1187 StructRNA *srna,
1188 const char *begin,
1189 const char *activeget,
1190 const char *activeset,
1191 const char *activeeditable,
1192 const char *structname,
1193 const char *structname_slots,
1194 const char *update,
1195 const char *update_index)
1196{
1197 PropertyRNA *prop;
1198
1199 /* mtex */
1200 prop = RNA_def_property(srna, "texture_slots", PROP_COLLECTION, PROP_NONE);
1201 RNA_def_property_struct_type(prop, structname);
1203 begin,
1204 "rna_iterator_array_next",
1205 "rna_iterator_array_end",
1206 "rna_iterator_array_dereference_get",
1207 nullptr,
1208 nullptr,
1209 nullptr,
1210 nullptr);
1212 prop, "Textures", "Texture slots defining the mapping and influence of textures");
1213 rna_def_texture_slots(brna, prop, structname, structname_slots);
1214
1215 prop = RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE);
1216 RNA_def_property_struct_type(prop, "Texture");
1218 if (activeeditable) {
1219 RNA_def_property_editable_func(prop, activeeditable);
1220 }
1221 RNA_def_property_pointer_funcs(prop, activeget, activeset, nullptr, nullptr);
1222 RNA_def_property_ui_text(prop, "Active Texture", "Active texture slot being displayed");
1224
1225 prop = RNA_def_property(srna, "active_texture_index", PROP_INT, PROP_UNSIGNED);
1226 RNA_def_property_int_sdna(prop, nullptr, "texact");
1227 RNA_def_property_range(prop, 0, MAX_MTEX - 1);
1228 RNA_def_property_ui_text(prop, "Active Texture Index", "Index of active texture slot");
1230}
1231
1233{
1234 StructRNA *srna;
1235 PropertyRNA *prop;
1236
1237 srna = RNA_def_struct(brna, "TexPaintSlot", nullptr);
1239 srna, "Texture Paint Slot", "Slot that contains information about texture painting");
1240
1241 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1244 prop, "rna_TexPaintSlot_name_get", "rna_TexPaintSlot_name_length", nullptr);
1245 RNA_def_property_ui_text(prop, "Name", "Name of the slot");
1246 RNA_def_struct_name_property(srna, prop);
1247
1248 prop = RNA_def_property(srna, "icon_value", PROP_INT, PROP_NONE);
1250 RNA_def_property_int_funcs(prop, "rna_TexPaintSlot_icon_get", nullptr, nullptr);
1251 RNA_def_property_ui_text(prop, "Icon", "Paint slot icon");
1252
1253 prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
1255 prop, MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX); /* Else it uses the pointer size! */
1256 RNA_def_property_string_sdna(prop, nullptr, "uvname");
1258 "rna_TexPaintSlot_uv_layer_get",
1259 "rna_TexPaintSlot_uv_layer_length",
1260 "rna_TexPaintSlot_uv_layer_set");
1261 RNA_def_property_ui_text(prop, "UV Map", "Name of UV map");
1262 RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Material_update");
1263
1264 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1265 RNA_def_property_boolean_sdna(prop, nullptr, "valid", 1);
1267 RNA_def_property_ui_text(prop, "Valid", "Slot has a valid image and UV map");
1268}
1269
1271{
1272 PropertyRNA *prop;
1273
1274 rna_def_tex_slot(brna);
1275
1276 /* mtex */
1277 prop = RNA_def_property(srna, "texture_paint_images", PROP_COLLECTION, PROP_NONE);
1278 RNA_def_property_collection_sdna(prop, nullptr, "texpaintslot", nullptr);
1280 "rna_Material_texpaint_begin",
1281 "rna_iterator_array_next",
1282 "rna_iterator_array_end",
1283 "rna_iterator_array_dereference_get",
1284 nullptr,
1285 nullptr,
1286 nullptr,
1287 nullptr);
1288 RNA_def_property_struct_type(prop, "Image");
1290 prop, "Texture Slot Images", "Texture images used for texture painting");
1291
1292 prop = RNA_def_property(srna, "texture_paint_slots", PROP_COLLECTION, PROP_NONE);
1294 "rna_Material_texpaint_begin",
1295 "rna_iterator_array_next",
1296 "rna_iterator_array_end",
1297 "rna_iterator_array_get",
1298 nullptr,
1299 nullptr,
1300 nullptr,
1301 nullptr);
1302 RNA_def_property_struct_type(prop, "TexPaintSlot");
1304 prop, "Texture Slots", "Texture slots defining the mapping and influence of textures");
1305
1306 prop = RNA_def_property(srna, "paint_active_slot", PROP_INT, PROP_UNSIGNED);
1307 RNA_def_property_range(prop, 0, SHRT_MAX);
1309 prop, "Active Paint Texture Index", "Index of active texture paint slot");
1312 prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_Material_active_paint_texture_index_update");
1313
1314 prop = RNA_def_property(srna, "paint_clone_slot", PROP_INT, PROP_UNSIGNED);
1315 RNA_def_property_range(prop, 0, SHRT_MAX);
1316 RNA_def_property_ui_text(prop, "Clone Paint Texture Index", "Index of clone texture paint slot");
1318}
1319
1320#endif
const struct CustomDataLayer * BKE_id_attributes_color_find(const struct ID *id, blender::StringRef name)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
Definition attribute.cc:985
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
#define GPENCIL_ALPHA_OPACITY_THRESH
Low-level operations for grease pencil.
void id_us_plus(ID *id)
Definition lib_id.cc:358
void id_us_min(ID *id)
Definition lib_id.cc:366
General operations, lookup, etc. for materials.
bNode * BKE_texpaint_slot_material_find_node(Material *ma, short texpaint_slot)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
@ RPT_ERROR
Definition BKE_report.hh:39
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:153
bool give_active_mtex(struct ID *id, struct MTex ***mtex_ar, short *act)
Definition texture.cc:480
struct MTex * BKE_texture_mtex_add_id(struct ID *id, int slot)
Definition texture.cc:399
#define DEG2RADF(_deg)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define SET_FLAG_FROM_TEST(value, test, flag)
#define BLT_I18NCONTEXT_ID_GPENCIL
#define BLT_I18NCONTEXT_ID_MATERIAL
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_SHADING
Definition DNA_ID.h:1094
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
#define MAX_CUSTOMDATA_LAYER_NAME_NO_PREFIX
@ GP_MATERIAL_STROKE_STYLE_SOLID
@ GP_MATERIAL_STROKE_STYLE_TEXTURE
@ MA_BL_TRANSPARENT_SHADOW
@ MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED
@ MA_BL_THICKNESS_FROM_SHADOW
@ MA_BL_CULL_BACKFACE
@ MA_BL_TRANSLUCENCY
@ MA_BL_SS_REFRACTION
@ MA_BL_CULL_BACKFACE_SHADOW
@ MA_BL_HIDE_BACKFACE
@ MA_SHADERBALL
@ MA_SPHERE
@ MA_SURFACE_METHOD_DEFERRED
@ MA_SURFACE_METHOD_FORWARD
@ MA_BM_CLIP
@ MA_BM_HASHED
@ MA_BM_SOLID
@ MA_BM_BLEND
@ MA_BS_HASHED
@ MA_BS_SOLID
@ GP_MATERIAL_FOLLOW_OBJ
@ GP_MATERIAL_FOLLOW_PATH
@ GP_MATERIAL_FOLLOW_FIXED
@ MA_PREVIEW_WORLD
@ GP_MATERIAL_LOCKED
@ GP_MATERIAL_FLIP_FILL
@ GP_MATERIAL_HIDE_ONIONSKIN
@ GP_MATERIAL_HIDE
@ GP_MATERIAL_DISABLE_STENCIL
@ GP_MATERIAL_IS_STROKE_HOLDOUT
@ GP_MATERIAL_STROKE_SHOW
@ GP_MATERIAL_IS_FILL_HOLDOUT
@ GP_MATERIAL_FILL_SHOW
@ GP_MATERIAL_TEX_CLAMP
@ GP_MATERIAL_GRADIENT_RADIAL
@ GP_MATERIAL_GRADIENT_LINEAR
@ LRT_MATERIAL_CUSTOM_INTERSECTION_PRIORITY
@ LRT_MATERIAL_MASK_ENABLED
@ MA_THICKNESS_SLAB
@ MA_THICKNESS_SPHERE
@ GP_MATERIAL_MODE_SQUARE
@ GP_MATERIAL_MODE_DOT
@ GP_MATERIAL_MODE_LINE
@ MA_RAMP_LIGHT
@ MA_RAMP_COLOR
@ MA_RAMP_SAT
@ MA_RAMP_HUE
@ MA_RAMP_LINEAR
@ MA_RAMP_DIV
@ MA_RAMP_EXCLUSION
@ MA_RAMP_ADD
@ MA_RAMP_DODGE
@ MA_RAMP_SUB
@ MA_RAMP_SCREEN
@ MA_RAMP_SOFT
@ MA_RAMP_DARK
@ MA_RAMP_BURN
@ MA_RAMP_BLEND
@ MA_RAMP_VAL
@ MA_RAMP_OVERLAY
@ MA_RAMP_MULT
@ MA_RAMP_DIFF
@ MA_DISPLACEMENT_BOTH
@ MA_DISPLACEMENT_BUMP
@ MA_DISPLACEMENT_DISPLACE
@ MA_VOLUME_ISECT_ACCURATE
@ MA_VOLUME_ISECT_FAST
@ GP_MATERIAL_FILL_STYLE_GRADIENT
@ GP_MATERIAL_FILL_STYLE_TEXTURE
@ GP_MATERIAL_FILL_STYLE_SOLID
Object is a sort of wrapper for general info.
@ OB_GREASE_PENCIL
@ OB_MESH
void ED_space_image_sync(Main *bmain, Image *image, bool ignore_render_viewer)
Definition image_edit.cc:70
Read Guarded memory(de)allocation.
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_NO_SELF
Definition RNA_types.hh:907
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:913
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:889
@ PROP_FLOAT
Definition RNA_types.hh:164
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:676
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:503
PropertyFlag
Definition RNA_types.hh:300
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:407
@ PROP_ANIMATABLE
Definition RNA_types.hh:319
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:395
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:364
@ PROP_DISTANCE
Definition RNA_types.hh:256
@ PROP_COLOR
Definition RNA_types.hh:260
@ PROP_ANGLE
Definition RNA_types.hh:252
@ PROP_COORDS
Definition RNA_types.hh:274
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_FACTOR
Definition RNA_types.hh:251
@ PROP_UNSIGNED
Definition RNA_types.hh:249
#define C
Definition RandGen.cpp:29
#define MAX_MTEX
Definition Stroke.h:31
#define ND_SHADING
Definition WM_types.hh:477
#define NC_GEOM
Definition WM_types.hh:393
#define ND_DATA
Definition WM_types.hh:509
#define ND_SHADING_PREVIEW
Definition WM_types.hh:480
#define NC_MATERIAL
Definition WM_types.hh:380
#define NC_GPENCIL
Definition WM_types.hh:399
#define NC_TEXTURE
Definition WM_types.hh:381
#define NC_OBJECT
Definition WM_types.hh:379
#define ND_SHADING_LINKS
Definition WM_types.hh:479
#define ND_SHADING_DRAW
Definition WM_types.hh:478
iter begin(iter)
BMesh const char void * data
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
void node_set_active(bNodeTree &ntree, bNode &node)
Definition node.cc:4724
static void update(bNodeTree *ntree)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, void *data, size_t itemsize, int64_t length, bool free_ptr, IteratorSkipFunc skip)
void rna_def_animdata_common(StructRNA *srna)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_property_deprecated(PropertyRNA *prop, const char *note, const short version, const short removal_version)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_bitset_array_sdna(PropertyRNA *prop, const char *structname, const char *propname, const int64_t booleanbit, const int length)
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_int_default(PropertyRNA *prop, int value)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void rna_mtex_texture_slots_clear(ID *self, bContext *C, ReportList *reports, int index)
void RNA_api_material(StructRNA *srna)
MTex * rna_mtex_texture_slots_add(ID *self, bContext *C, ReportList *reports)
MTex * rna_mtex_texture_slots_create(ID *self, bContext *C, ReportList *reports, int index)
static void rna_def_material_greasepencil(BlenderRNA *brna)
static void rna_def_texture_slots(BlenderRNA *brna, PropertyRNA *cprop, const char *structname, const char *structname_slots)
const EnumPropertyItem rna_enum_ramp_blend_items[]
void RNA_def_material(BlenderRNA *brna)
void rna_def_texpaint_slots(BlenderRNA *brna, StructRNA *srna)
static void rna_def_tex_slot(BlenderRNA *brna)
static void rna_def_material_lineart(BlenderRNA *brna)
void rna_def_mtex_common(BlenderRNA *brna, StructRNA *srna, const char *begin, const char *activeget, const char *activeset, const char *activeeditable, const char *structname, const char *structname_slots, const char *update, const char *update_index)
static void rna_def_material_display(StructRNA *srna)
#define FLT_MAX
Definition stdcycles.h:14
Definition DNA_ID.h:414
void * data
Definition RNA_types.hh:53
struct Image * ima
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4238