Blender V4.3
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
9#include <cfloat>
10#include <cstdlib>
11
12#include "DNA_material_types.h"
13#include "DNA_mesh_types.h"
14#include "DNA_texture_types.h"
15
16#include "BLI_math_rotation.h"
17
18#include "BLT_translation.hh"
19
20#include "BKE_customdata.hh"
21
22#include "RNA_define.hh"
23#include "RNA_enum_types.hh"
24
25#include "rna_internal.hh"
26
27#include "WM_api.hh"
28#include "WM_types.hh"
29
31 {MA_RAMP_BLEND, "MIX", 0, "Mix", ""},
33 {MA_RAMP_DARK, "DARKEN", 0, "Darken", ""},
34 {MA_RAMP_MULT, "MULTIPLY", 0, "Multiply", ""},
35 {MA_RAMP_BURN, "BURN", 0, "Color Burn", ""},
37 {MA_RAMP_LIGHT, "LIGHTEN", 0, "Lighten", ""},
38 {MA_RAMP_SCREEN, "SCREEN", 0, "Screen", ""},
39 {MA_RAMP_DODGE, "DODGE", 0, "Color Dodge", ""},
40 {MA_RAMP_ADD, "ADD", 0, "Add", ""},
42 {MA_RAMP_OVERLAY, "OVERLAY", 0, "Overlay", ""},
43 {MA_RAMP_SOFT, "SOFT_LIGHT", 0, "Soft Light", ""},
44 {MA_RAMP_LINEAR, "LINEAR_LIGHT", 0, "Linear Light", ""},
46 {MA_RAMP_DIFF, "DIFFERENCE", 0, "Difference", ""},
47 {MA_RAMP_EXCLUSION, "EXCLUSION", 0, "Exclusion", ""},
48 {MA_RAMP_SUB, "SUBTRACT", 0, "Subtract", ""},
49 {MA_RAMP_DIV, "DIVIDE", 0, "Divide", ""},
51 {MA_RAMP_HUE, "HUE", 0, "Hue", ""},
52 {MA_RAMP_SAT, "SATURATION", 0, "Saturation", ""},
53 {MA_RAMP_COLOR, "COLOR", 0, "Color", ""},
54 {MA_RAMP_VAL, "VALUE", 0, "Value", ""},
55 {0, nullptr, 0, nullptr, nullptr},
56};
57
58#ifdef RNA_RUNTIME
59
60# include "MEM_guardedalloc.h"
61
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.h"
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_GPENCIL_LEGACY) {
114 bGPdata *gpd = (bGPdata *)ob->data;
116 }
117 if (ob->type == OB_GREASE_PENCIL) {
118 GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
119 DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
120 }
121 }
122
124}
125
126static void rna_MaterialLineArt_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
127{
128 Material *ma = (Material *)ptr->owner_id;
129 /* Need to tag geometry for line art modifier updates. */
132}
133
134static std::optional<std::string> rna_MaterialLineArt_path(const PointerRNA * /*ptr*/)
135{
136 return "lineart";
137}
138
139static void rna_Material_draw_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
140{
141 Material *ma = (Material *)ptr->owner_id;
142
145}
146
147static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
148{
149 Material *ma = (Material *)ptr->data;
151 iter, (void *)ma->texpaintslot, sizeof(TexPaintSlot), ma->tot_slots, 0, nullptr);
152}
153
154static void rna_Material_active_paint_texture_index_update(bContext *C, PointerRNA *ptr)
155{
156 Main *bmain = CTX_data_main(C);
157 Material *ma = (Material *)ptr->owner_id;
158
159 if (ma->use_nodes && ma->nodetree) {
160 bNode *node = BKE_texpaint_slot_material_find_node(ma, ma->paint_active_slot);
161
162 if (node) {
163 blender::bke::node_set_active(ma->nodetree, node);
164 }
165 }
166
167 if (ma->texpaintslot && (ma->tot_slots > ma->paint_active_slot)) {
168 TexPaintSlot *slot = &ma->texpaintslot[ma->paint_active_slot];
169 Image *image = slot->ima;
170 if (image) {
171 ED_space_image_sync(bmain, image, false);
172 }
173
174 /* For compatibility reasons with vertex paint we activate the color attribute. */
175 if (slot->attribute_name) {
177 if (ob != nullptr && ob->type == OB_MESH) {
178 Mesh *mesh = static_cast<Mesh *>(ob->data);
179 const CustomDataLayer *layer = BKE_id_attributes_color_find(&mesh->id,
180 slot->attribute_name);
181 if (layer != nullptr) {
182 BKE_id_attributes_active_color_set(&mesh->id, layer->name);
183 }
184 DEG_id_tag_update(&ob->id, 0);
186 }
187 }
188 }
189
190 DEG_id_tag_update(&ma->id, 0);
192}
193
194static int rna_Material_blend_method_get(PointerRNA *ptr)
195{
196 Material *material = (Material *)ptr->owner_id;
197 switch (material->surface_render_method) {
199 return MA_BM_HASHED;
201 return MA_BM_BLEND;
202 }
203 return MA_BM_HASHED;
204}
205
206static void rna_Material_blend_method_set(PointerRNA *ptr, int new_blend_method)
207{
208 Material *material = (Material *)ptr->owner_id;
209 switch (new_blend_method) {
210 case MA_BM_SOLID:
211 case MA_BM_CLIP:
212 case MA_BM_HASHED:
213 material->surface_render_method = MA_SURFACE_METHOD_DEFERRED;
214 break;
215 case MA_BM_BLEND:
216 material->surface_render_method = MA_SURFACE_METHOD_FORWARD;
217 break;
218 }
219}
220
221static void rna_Material_render_method_set(PointerRNA *ptr, int new_render_method)
222{
223 Material *material = (Material *)ptr->owner_id;
224 material->surface_render_method = new_render_method;
225
226 /* Still sets the legacy property for forward compatibility. */
227 switch (new_render_method) {
229 material->blend_method = MA_BM_HASHED;
230 break;
232 material->blend_method = MA_BM_BLEND;
233 break;
234 }
235}
236static void rna_Material_transparent_shadow_set(PointerRNA *ptr, bool new_value)
237{
238 Material *material = (Material *)ptr->owner_id;
239 SET_FLAG_FROM_TEST(material->blend_flag, new_value, MA_BL_TRANSPARENT_SHADOW);
240 /* Still sets the legacy property for forward compatibility. */
241 material->blend_shadow = new_value ? MA_BS_HASHED : MA_BS_SOLID;
242}
243
244static void rna_Material_use_nodes_update(bContext *C, PointerRNA *ptr)
245{
246 Material *ma = (Material *)ptr->data;
247 Main *bmain = CTX_data_main(C);
248
249 if (ma->use_nodes && ma->nodetree == nullptr) {
250 ED_node_shader_default(C, &ma->id);
251 }
252
255 rna_Material_draw_update(bmain, CTX_data_scene(C), ptr);
256}
257
259{
260 MTex *mtex = BKE_texture_mtex_add_id(self_id, -1);
261 if (mtex == nullptr) {
262 BKE_reportf(reports, RPT_ERROR, "Maximum number of textures added %d", MAX_MTEX);
263 return nullptr;
264 }
265
266 /* for redraw only */
268
269 return mtex;
270}
271
272MTex *rna_mtex_texture_slots_create(ID *self_id, bContext *C, ReportList *reports, int index)
273{
274 MTex *mtex;
275
276 if (index < 0 || index >= MAX_MTEX) {
277 BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
278 return nullptr;
279 }
280
281 mtex = BKE_texture_mtex_add_id(self_id, index);
282
283 /* for redraw only */
285
286 return mtex;
287}
288
289void rna_mtex_texture_slots_clear(ID *self_id, bContext *C, ReportList *reports, int index)
290{
291 MTex **mtex_ar;
292 short act;
293
294 give_active_mtex(self_id, &mtex_ar, &act);
295
296 if (mtex_ar == nullptr) {
297 BKE_report(reports, RPT_ERROR, "Mtex not found for this type");
298 return;
299 }
300
301 if (index < 0 || index >= MAX_MTEX) {
302 BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
303 return;
304 }
305
306 if (mtex_ar[index]) {
307 id_us_min((ID *)mtex_ar[index]->tex);
308 MEM_freeN(mtex_ar[index]);
309 mtex_ar[index] = nullptr;
310 DEG_id_tag_update(self_id, 0);
311 }
312
313 /* for redraw only */
315}
316
317static void rna_TexPaintSlot_uv_layer_get(PointerRNA *ptr, char *value)
318{
319 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
320
321 if (data->uvname != nullptr) {
322 strcpy(value, data->uvname);
323 }
324 else {
325 value[0] = '\0';
326 }
327}
328
329static int rna_TexPaintSlot_uv_layer_length(PointerRNA *ptr)
330{
331 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
332 return data->uvname == nullptr ? 0 : strlen(data->uvname);
333}
334
335static void rna_TexPaintSlot_uv_layer_set(PointerRNA *ptr, const char *value)
336{
337 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
338
339 if (data->uvname != nullptr) {
340 BLI_strncpy_utf8(data->uvname, value, 64);
341 }
342}
343
344static void rna_TexPaintSlot_name_get(PointerRNA *ptr, char *value)
345{
346 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
347
348 if (data->ima != nullptr) {
349 strcpy(value, data->ima->id.name + 2);
350 return;
351 }
352
353 if (data->attribute_name != nullptr) {
354 strcpy(value, data->attribute_name);
355 return;
356 }
357
358 value[0] = '\0';
359}
360
361static int rna_TexPaintSlot_name_length(PointerRNA *ptr)
362{
363 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
364 if (data->ima != nullptr) {
365 return strlen(data->ima->id.name) - 2;
366 }
367 if (data->attribute_name != nullptr) {
368 return strlen(data->attribute_name);
369 }
370
371 return 0;
372}
373
374static int rna_TexPaintSlot_icon_get(PointerRNA *ptr)
375{
376 TexPaintSlot *data = (TexPaintSlot *)(ptr->data);
377 if (data->ima != nullptr) {
378 return ICON_IMAGE;
379 }
380 if (data->attribute_name != nullptr) {
381 return ICON_COLOR;
382 }
383
384 return ICON_NONE;
385}
386
387static bool rna_is_grease_pencil_get(PointerRNA *ptr)
388{
389 Material *ma = (Material *)ptr->data;
390 if (ma->gp_style != nullptr) {
391 return true;
392 }
393
394 return false;
395}
396
397static std::optional<std::string> rna_GpencilColorData_path(const PointerRNA * /*ptr*/)
398{
399 return "grease_pencil";
400}
401
402static bool rna_GpencilColorData_is_stroke_visible_get(PointerRNA *ptr)
403{
404 MaterialGPencilStyle *pcolor = static_cast<MaterialGPencilStyle *>(ptr->data);
405 return (pcolor->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH);
406}
407
408static bool rna_GpencilColorData_is_fill_visible_get(PointerRNA *ptr)
409{
411 return ((pcolor->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (pcolor->fill_style > 0));
412}
413
414static void rna_GpencilColorData_stroke_image_set(PointerRNA *ptr,
415 PointerRNA value,
416 ReportList * /*reports*/)
417{
418 MaterialGPencilStyle *pcolor = static_cast<MaterialGPencilStyle *>(ptr->data);
419 ID *id = static_cast<ID *>(value.data);
420
421 id_us_plus(id);
422 pcolor->sima = (Image *)id;
423}
424
425static void rna_GpencilColorData_fill_image_set(PointerRNA *ptr,
426 PointerRNA value,
427 ReportList * /*reports*/)
428{
430 ID *id = static_cast<ID *>(value.data);
431
432 id_us_plus(id);
433 pcolor->ima = (Image *)id;
434}
435
436#else
437
439{
440 PropertyRNA *prop;
441
442 prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
443 RNA_def_property_float_sdna(prop, nullptr, "r");
444 RNA_def_property_array(prop, 4);
446 RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material");
447 /* See #82514 for details, for now re-define defaults here. Keep in sync with
448 * #DNA_material_defaults.h */
449 static float diffuse_color_default[4] = {0.8f, 0.8f, 0.8f, 1.0f};
450 RNA_def_property_float_array_default(prop, diffuse_color_default);
451 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
452
453 prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR);
454 RNA_def_property_float_sdna(prop, nullptr, "specr");
455 RNA_def_property_array(prop, 3);
457 RNA_def_property_ui_text(prop, "Specular Color", "Specular color of the material");
458 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
459
460 prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_FACTOR);
461 RNA_def_property_float_sdna(prop, nullptr, "roughness");
462 RNA_def_property_range(prop, 0, 1);
464 RNA_def_property_ui_text(prop, "Roughness", "Roughness of the material");
465 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
466
467 prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR);
468 RNA_def_property_float_sdna(prop, nullptr, "spec");
469 RNA_def_property_range(prop, 0, 1);
471 RNA_def_property_ui_text(prop, "Specular", "How intense (bright) the specular reflection is");
472 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
473
474 prop = RNA_def_property(srna, "metallic", PROP_FLOAT, PROP_FACTOR);
475 RNA_def_property_float_sdna(prop, nullptr, "metallic");
476 RNA_def_property_range(prop, 0.0f, 1.0f);
478 RNA_def_property_ui_text(prop, "Metallic", "Amount of mirror reflection for raytrace");
479 RNA_def_property_update(prop, 0, "rna_Material_update");
480
481 /* Freestyle line color */
482 prop = RNA_def_property(srna, "line_color", PROP_FLOAT, PROP_COLOR);
483 RNA_def_property_float_sdna(prop, nullptr, "line_col");
484 RNA_def_property_array(prop, 4);
485 RNA_def_property_ui_text(prop, "Line Color", "Line color used for Freestyle line rendering");
486 RNA_def_property_update(prop, 0, "rna_Material_update");
487
488 prop = RNA_def_property(srna, "line_priority", PROP_INT, PROP_NONE);
489 RNA_def_property_int_sdna(prop, nullptr, "line_priority");
490 RNA_def_property_range(prop, 0, 32767);
492 prop, "Line Priority", "The line color of a higher priority is used at material boundaries");
493 RNA_def_property_update(prop, 0, "rna_Material_update");
494}
495
497{
498 StructRNA *srna;
499 PropertyRNA *prop;
500
501 /* mode type styles */
502 static EnumPropertyItem gpcolordata_mode_types_items[] = {
503 {GP_MATERIAL_MODE_LINE, "LINE", 0, "Line", "Draw strokes using a continuous line"},
504 {GP_MATERIAL_MODE_DOT, "DOTS", 0, "Dots", "Draw strokes using separated dots"},
505 {GP_MATERIAL_MODE_SQUARE, "BOX", 0, "Squares", "Draw strokes using separated squares"},
506 {0, nullptr, 0, nullptr, nullptr},
507 };
508
509 /* stroke styles */
510 static EnumPropertyItem stroke_style_items[] = {
511 {GP_MATERIAL_STROKE_STYLE_SOLID, "SOLID", 0, "Solid", "Draw strokes with solid color"},
512 {GP_MATERIAL_STROKE_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Draw strokes using texture"},
513 {0, nullptr, 0, nullptr, nullptr},
514 };
515
516 /* fill styles */
517 static EnumPropertyItem fill_style_items[] = {
518 {GP_MATERIAL_FILL_STYLE_SOLID, "SOLID", 0, "Solid", "Fill area with solid color"},
520 "GRADIENT",
521 0,
522 "Gradient",
523 "Fill area with gradient color"},
524 {GP_MATERIAL_FILL_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Fill area with image texture"},
525 {0, nullptr, 0, nullptr, nullptr},
526 };
527
528 static EnumPropertyItem fill_gradient_items[] = {
529 {GP_MATERIAL_GRADIENT_LINEAR, "LINEAR", 0, "Linear", "Fill area with gradient color"},
530 {GP_MATERIAL_GRADIENT_RADIAL, "RADIAL", 0, "Radial", "Fill area with radial gradient"},
531 {0, nullptr, 0, nullptr, nullptr},
532 };
533
534 static EnumPropertyItem alignment_draw_items[] = {
536 "PATH",
537 0,
538 "Path",
539 "Follow stroke drawing path and object rotation"},
540 {GP_MATERIAL_FOLLOW_OBJ, "OBJECT", 0, "Object", "Follow object rotation only"},
542 "FIXED",
543 0,
544 "Fixed",
545 "Do not follow drawing path or object rotation and keeps aligned with viewport"},
546 {0, nullptr, 0, nullptr, nullptr},
547 };
548
549 srna = RNA_def_struct(brna, "MaterialGPencilStyle", nullptr);
550 RNA_def_struct_sdna(srna, "MaterialGPencilStyle");
551 RNA_def_struct_ui_text(srna, "Grease Pencil Color", "");
552 RNA_def_struct_path_func(srna, "rna_GpencilColorData_path");
553
554 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
555 RNA_def_property_range(prop, 0.0, 1.0);
556 RNA_def_property_float_sdna(prop, nullptr, "stroke_rgba");
557 RNA_def_property_array(prop, 4);
558 RNA_def_property_ui_text(prop, "Color", "");
559 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
560
561 /* Fill Drawing Color */
562 prop = RNA_def_property(srna, "fill_color", PROP_FLOAT, PROP_COLOR);
563 RNA_def_property_float_sdna(prop, nullptr, "fill_rgba");
564 RNA_def_property_array(prop, 4);
565 RNA_def_property_range(prop, 0.0f, 1.0f);
566 RNA_def_property_ui_text(prop, "Fill Color", "Color for filling region bounded by each stroke");
567 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
568
569 /* Secondary Drawing Color */
570 prop = RNA_def_property(srna, "mix_color", PROP_FLOAT, PROP_COLOR);
571 RNA_def_property_float_sdna(prop, nullptr, "mix_rgba");
572 RNA_def_property_array(prop, 4);
573 RNA_def_property_range(prop, 0.0f, 1.0f);
574 RNA_def_property_ui_text(prop, "Mix Color", "Color for mixing with primary filling color");
575 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
576
577 /* Mix factor */
578 prop = RNA_def_property(srna, "mix_factor", PROP_FLOAT, PROP_FACTOR);
579 RNA_def_property_float_sdna(prop, nullptr, "mix_factor");
580 RNA_def_property_range(prop, 0.0f, 1.0f);
581 RNA_def_property_ui_text(prop, "Mix", "Mix Factor");
583 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
584
585 /* Stroke Mix factor */
586 prop = RNA_def_property(srna, "mix_stroke_factor", PROP_FLOAT, PROP_FACTOR);
587 RNA_def_property_float_sdna(prop, nullptr, "mix_stroke_factor");
588 RNA_def_property_range(prop, 0.0f, 1.0f);
589 RNA_def_property_ui_text(prop, "Mix", "Mix Stroke Factor");
591 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
592
593 /* Texture angle */
594 prop = RNA_def_property(srna, "texture_angle", PROP_FLOAT, PROP_ANGLE);
595 RNA_def_property_float_sdna(prop, nullptr, "texture_angle");
596 RNA_def_property_ui_text(prop, "Angle", "Texture Orientation Angle");
597 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
598
599 /* Scale factor for texture */
600 prop = RNA_def_property(srna, "texture_scale", PROP_FLOAT, PROP_COORDS);
601 RNA_def_property_float_sdna(prop, nullptr, "texture_scale");
602 RNA_def_property_array(prop, 2);
603 RNA_def_property_ui_text(prop, "Scale", "Scale Factor for Texture");
604 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
605
606 /* Shift factor to move texture in 2d space */
607 prop = RNA_def_property(srna, "texture_offset", PROP_FLOAT, PROP_COORDS);
608 RNA_def_property_float_sdna(prop, nullptr, "texture_offset");
609 RNA_def_property_array(prop, 2);
610 RNA_def_property_ui_text(prop, "Offset", "Shift Texture in 2d Space");
611 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
612
613 /* texture pixsize factor (used for UV along the stroke) */
614 prop = RNA_def_property(srna, "pixel_size", PROP_FLOAT, PROP_NONE);
615 RNA_def_property_float_sdna(prop, nullptr, "texture_pixsize");
616 RNA_def_property_range(prop, 1, 5000);
617 RNA_def_property_ui_text(prop, "UV Factor", "Texture Pixel Size factor along the stroke");
618 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
619
620 /* Flags */
621 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
622 RNA_def_property_boolean_sdna(prop, nullptr, "flag", GP_MATERIAL_HIDE);
623 RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
624 RNA_def_property_ui_text(prop, "Hide", "Set color Visibility");
625 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
626
627 prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
629 RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
631 prop, "Locked", "Protect color from further editing and/or frame changes");
632 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
633
634 prop = RNA_def_property(srna, "ghost", PROP_BOOLEAN, PROP_NONE);
636 RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0);
638 prop, "Show in Ghosts", "Display strokes using this color when showing onion skins");
639 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
640
641 prop = RNA_def_property(srna, "texture_clamp", PROP_BOOLEAN, PROP_NONE);
643 RNA_def_property_ui_text(prop, "Clamp", "Do not repeat texture and clamp to one instance only");
644 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
645
646 prop = RNA_def_property(srna, "flip", PROP_BOOLEAN, PROP_NONE);
648 RNA_def_property_ui_text(prop, "Flip", "Flip filling colors");
649 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
650
651 prop = RNA_def_property(srna, "use_overlap_strokes", PROP_BOOLEAN, PROP_NONE);
654 prop, "Self Overlap", "Disable stencil and overlap self intersections with alpha materials");
655 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
656
657 prop = RNA_def_property(srna, "use_stroke_holdout", PROP_BOOLEAN, PROP_NONE);
660 prop, "Holdout", "Remove the color from underneath this stroke by using it as a mask");
661 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
662
663 prop = RNA_def_property(srna, "use_fill_holdout", PROP_BOOLEAN, PROP_NONE);
666 prop, "Holdout", "Remove the color from underneath this stroke by using it as a mask");
667 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
668
669 prop = RNA_def_property(srna, "show_stroke", PROP_BOOLEAN, PROP_NONE);
671 RNA_def_property_ui_text(prop, "Show Stroke", "Show stroke lines of this material");
672 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
673
674 prop = RNA_def_property(srna, "show_fill", PROP_BOOLEAN, PROP_NONE);
676 RNA_def_property_ui_text(prop, "Show Fill", "Show stroke fills of this material");
677 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
678
679 /* Mode to align Dots and Boxes to drawing path and object rotation */
680 prop = RNA_def_property(srna, "alignment_mode", PROP_ENUM, PROP_NONE);
681 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "alignment_mode");
682 RNA_def_property_enum_items(prop, alignment_draw_items);
684 prop, "Alignment", "Defines how align Dots and Boxes with drawing path and object rotation");
685 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
686
687 /* Rotation of texture for Dots or Strokes. */
688 prop = RNA_def_property(srna, "alignment_rotation", PROP_FLOAT, PROP_ANGLE);
689 RNA_def_property_float_sdna(prop, nullptr, "alignment_rotation");
691 RNA_def_property_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f));
692 RNA_def_property_ui_range(prop, -DEG2RADF(90.0f), DEG2RADF(90.0f), 10, 3);
694 "Rotation",
695 "Additional rotation applied to dots and square texture of strokes. "
696 "Only applies in texture shading mode.");
697 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
698
699 /* pass index for future compositing and editing tools */
700 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
701 RNA_def_property_int_sdna(prop, nullptr, "index");
702 RNA_def_property_ui_text(prop, "Pass Index", "Index number for the \"Color Index\" pass");
703 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
704
705 /* mode type */
706 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
707 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "mode");
708 RNA_def_property_enum_items(prop, gpcolordata_mode_types_items);
709 RNA_def_property_ui_text(prop, "Line Type", "Select line type for strokes");
710 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
711
712 /* stroke style */
713 prop = RNA_def_property(srna, "stroke_style", PROP_ENUM, PROP_NONE);
714 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "stroke_style");
715 RNA_def_property_enum_items(prop, stroke_style_items);
716 RNA_def_property_ui_text(prop, "Stroke Style", "Select style used to draw strokes");
718 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
719
720 /* stroke image texture */
721 prop = RNA_def_property(srna, "stroke_image", PROP_POINTER, PROP_NONE);
722 RNA_def_property_pointer_sdna(prop, nullptr, "sima");
724 prop, nullptr, "rna_GpencilColorData_stroke_image_set", nullptr, nullptr);
727 RNA_def_property_ui_text(prop, "Image", "");
728 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
729
730 /* fill style */
731 prop = RNA_def_property(srna, "fill_style", PROP_ENUM, PROP_NONE);
732 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "fill_style");
733 RNA_def_property_enum_items(prop, fill_style_items);
734 RNA_def_property_ui_text(prop, "Fill Style", "Select style used to fill strokes");
736 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
737
738 /* gradient type */
739 prop = RNA_def_property(srna, "gradient_type", PROP_ENUM, PROP_NONE);
740 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "gradient_type");
741 RNA_def_property_enum_items(prop, fill_gradient_items);
742 RNA_def_property_ui_text(prop, "Gradient Type", "Select type of gradient used to fill strokes");
743 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
744
745 /* fill image texture */
746 prop = RNA_def_property(srna, "fill_image", PROP_POINTER, PROP_NONE);
747 RNA_def_property_pointer_sdna(prop, nullptr, "ima");
749 prop, nullptr, "rna_GpencilColorData_fill_image_set", nullptr, nullptr);
752 RNA_def_property_ui_text(prop, "Image", "");
753 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
754
755 /* Read-only state props (for simpler UI code) */
756 prop = RNA_def_property(srna, "is_stroke_visible", PROP_BOOLEAN, PROP_NONE);
757 RNA_def_property_boolean_funcs(prop, "rna_GpencilColorData_is_stroke_visible_get", nullptr);
760 prop, "Is Stroke Visible", "True when opacity of stroke is set high enough to be visible");
761
762 prop = RNA_def_property(srna, "is_fill_visible", PROP_BOOLEAN, PROP_NONE);
763 RNA_def_property_boolean_funcs(prop, "rna_GpencilColorData_is_fill_visible_get", nullptr);
766 prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible");
767}
769{
770 StructRNA *srna;
771 PropertyRNA *prop;
772
773 srna = RNA_def_struct(brna, "MaterialLineArt", nullptr);
774 RNA_def_struct_sdna(srna, "MaterialLineArt");
775 RNA_def_struct_ui_text(srna, "Material Line Art", "");
776 RNA_def_struct_path_func(srna, "rna_MaterialLineArt_path");
777
778 prop = RNA_def_property(srna, "use_material_mask", PROP_BOOLEAN, PROP_NONE);
782 prop, "Use Material Mask", "Use material masks to filter out occluded strokes");
783 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
784
785 prop = RNA_def_property(srna, "use_material_mask_bits", PROP_BOOLEAN, PROP_NONE);
787 RNA_def_property_boolean_sdna(prop, nullptr, "material_mask_bits", 1);
788 RNA_def_property_array(prop, 8);
789 RNA_def_property_ui_text(prop, "Mask", "");
790 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
791
792 prop = RNA_def_property(srna, "mat_occlusion", PROP_INT, PROP_NONE);
794 RNA_def_property_ui_range(prop, 0.0f, 5.0f, 1.0f, 1);
796 prop,
797 "Effectiveness",
798 "Faces with this material will behave as if it has set number of layers in occlusion");
799 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
800
801 prop = RNA_def_property(srna, "intersection_priority", PROP_INT, PROP_NONE);
802 RNA_def_property_range(prop, 0, 255);
804 "Intersection Priority",
805 "The intersection line will be included into the object with the "
806 "higher intersection priority value");
807 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
808
809 prop = RNA_def_property(srna, "use_intersection_priority_override", PROP_BOOLEAN, PROP_NONE);
813 "Use Intersection Priority",
814 "Override object and collection intersection priority value");
815 RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
816}
817
819{
820 StructRNA *srna;
821 PropertyRNA *prop;
822
823 /* Render Preview Types */
824 static const EnumPropertyItem preview_type_items[] = {
825 {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"},
826 {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Sphere"},
827 {MA_CUBE, "CUBE", ICON_MATCUBE, "Cube", "Cube"},
828 {MA_HAIR, "HAIR", ICON_CURVES, "Hair", "Hair strands"},
829 {MA_SHADERBALL, "SHADERBALL", ICON_MATSHADERBALL, "Shader Ball", "Shader ball"},
830 {MA_CLOTH, "CLOTH", ICON_MATCLOTH, "Cloth", "Cloth"},
831 {MA_FLUID, "FLUID", ICON_MATFLUID, "Fluid", "Fluid"},
832 {0, nullptr, 0, nullptr, nullptr},
833 };
834
835 static EnumPropertyItem prop_eevee_volume_isect_method_items[] = {
837 "FAST",
838 0,
839 "Fast",
840 "Each face is considered as a medium interface. Gives correct results for manifold "
841 "geometry that contains no inner parts."},
843 "ACCURATE",
844 0,
845 "Accurate",
846 "Faces are considered as medium interface only when they have different consecutive "
847 "facing. Gives correct results as long as the max ray depth is not exceeded. Have "
848 "significant memory overhead compared to the fast method."},
849 {0, nullptr, 0, nullptr, nullptr},
850 };
851
852 static EnumPropertyItem prop_eevee_thickness_method_items[] = {
854 "SPHERE",
855 0,
856 "Sphere",
857 "Approximate the object as a sphere whose diameter is equal to the thickness defined by "
858 "the node tree"},
860 "SLAB",
861 0,
862 "Slab",
863 "Approximate the object as an infinite slab of thickness defined by the node tree"},
864 {0, nullptr, 0, nullptr, nullptr},
865 };
866
867# if 1 /* Delete this section once we remove old eevee. */
868 static EnumPropertyItem prop_eevee_blend_items[] = {
869 {MA_BM_SOLID, "OPAQUE", 0, "Opaque", "Render surface without transparency"},
870 {MA_BM_CLIP,
871 "CLIP",
872 0,
873 "Alpha Clip",
874 "Use the alpha threshold to clip the visibility (binary visibility)"},
876 "HASHED",
877 0,
878 "Alpha Hashed",
879 "Use noise to dither the binary visibility (works well with multi-samples)"},
881 "BLEND",
882 0,
883 "Alpha Blend",
884 "Render polygon transparent, depending on alpha channel of the texture"},
885 {0, nullptr, 0, nullptr, nullptr},
886 };
887# endif
888
889 static EnumPropertyItem prop_eevee_surface_render_method_items[] = {
891 "DITHERED",
892 0,
893 "Dithered",
894 "Allows for grayscale hashed transparency, and compatible with render passes and "
895 "raytracing. Also known as deferred rendering."},
897 "BLENDED",
898 0,
899 "Blended",
900 "Allows for colored transparency, but incompatible with render passes and raytracing. Also "
901 "known as forward rendering."},
902 {0, nullptr, 0, nullptr, nullptr},
903 };
904
905 static EnumPropertyItem prop_displacement_method_items[] = {
907 "BUMP",
908 0,
909 "Bump Only",
910 "Bump mapping to simulate the appearance of displacement"},
912 "DISPLACEMENT",
913 0,
914 "Displacement Only",
915 "Use true displacement of surface only, requires fine subdivision"},
917 "BOTH",
918 0,
919 "Displacement and Bump",
920 "Combination of true displacement and bump mapping for finer detail"},
921 {0, nullptr, 0, nullptr, nullptr},
922 };
923
924 srna = RNA_def_struct(brna, "Material", "ID");
926 srna,
927 "Material",
928 "Material data-block to define the appearance of geometric objects for rendering");
929 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
930
931 prop = RNA_def_property(srna, "surface_render_method", PROP_ENUM, PROP_NONE);
932 RNA_def_property_enum_items(prop, prop_eevee_surface_render_method_items);
934 "Surface Render Method",
935 "Controls the blending and the compatibility with certain features");
936 /* Setter function for forward compatibility. */
937 RNA_def_property_enum_funcs(prop, nullptr, "rna_Material_render_method_set", nullptr);
938 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
939
940 prop = RNA_def_property(srna, "displacement_method", PROP_ENUM, PROP_NONE);
941 RNA_def_property_enum_items(prop, prop_displacement_method_items);
942 RNA_def_property_ui_text(prop, "Displacement Method", "Method to use for the displacement");
943 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
944
945# if 1 /* Delete this section once we remove old eevee. */
946 /* Blending (only Eevee for now) */
947 prop = RNA_def_property(srna, "blend_method", PROP_ENUM, PROP_NONE);
948 RNA_def_property_enum_items(prop, prop_eevee_blend_items);
950 prop,
951 "Blend Mode",
952 "Blend Mode for Transparent Faces (Deprecated: use 'surface_render_method')");
954 prop, "rna_Material_blend_method_get", "rna_Material_blend_method_set", nullptr);
956 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
957
958 prop = RNA_def_property(srna, "alpha_threshold", PROP_FLOAT, PROP_FACTOR);
959 RNA_def_property_range(prop, 0, 1);
961 "Clip Threshold",
962 "A pixel is rendered only if its alpha value is above this threshold");
963 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
964# endif
965
966 prop = RNA_def_property(srna, "use_transparency_overlap", PROP_BOOLEAN, PROP_NONE);
969 "Use Transparency Overlap",
970 "Render multiple transparent layers "
971 "(may introduce transparency sorting problems)");
972
973# if 1 /* This should be deleted in Blender 4.5 */
974 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
975 prop = RNA_def_property(srna, "show_transparent_back", PROP_BOOLEAN, PROP_NONE);
978 prop,
979 "Show Backface",
980 "Render multiple transparent layers "
981 "(may introduce transparency sorting problems) (Deprecated: use 'use_tranparency_overlap')");
982 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
983# endif
984
985 prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
986 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_CULL_BACKFACE);
988 prop, "Backface Culling", "Use back face culling to hide the back side of faces");
989 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
990
991 prop = RNA_def_property(srna, "use_backface_culling_shadow", PROP_BOOLEAN, PROP_NONE);
992 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_CULL_BACKFACE_SHADOW);
994 prop, "Shadow Backface Culling", "Use back face culling when casting shadows");
995 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
996
997 prop = RNA_def_property(srna, "use_backface_culling_lightprobe_volume", PROP_BOOLEAN, PROP_NONE);
999 prop, nullptr, "blend_flag", MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED);
1001 prop,
1002 "Light Probe Volume Backface Culling",
1003 "Consider material single sided for light probe volume capture. "
1004 "Additionally helps rejecting probes inside the object to avoid light leaks.");
1005 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1006
1007 prop = RNA_def_property(srna, "use_transparent_shadow", PROP_BOOLEAN, PROP_NONE);
1008 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_TRANSPARENT_SHADOW);
1009 RNA_def_property_boolean_funcs(prop, nullptr, "rna_Material_transparent_shadow_set");
1011 prop,
1012 "Transparent Shadows",
1013 "Use transparent shadows for this material if it contains a Transparent BSDF, "
1014 "disabling will render faster but not give accurate shadows");
1015 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1016
1017 prop = RNA_def_property(srna, "use_raytrace_refraction", PROP_BOOLEAN, PROP_NONE);
1018 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_SS_REFRACTION);
1020 prop,
1021 "Raytrace Transmission",
1022 "Use raytracing to determine transmitted color instead of using only light probes. "
1023 "This prevents the surface from contributing to the lighting of surfaces not using this "
1024 "setting.");
1025 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1026
1027# if 1 /* This should be deleted in Blender 4.5 */
1028 prop = RNA_def_property(srna, "use_screen_refraction", PROP_BOOLEAN, PROP_NONE);
1029 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_SS_REFRACTION);
1031 prop,
1032 "Raytrace Transmission",
1033 "Use raytracing to determine transmitted color instead of using only light probes. "
1034 "This prevents the surface from contributing to the lighting of surfaces not using this "
1035 "setting. Deprecated: use 'use_raytrace_refraction'.");
1036 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1037
1038 prop = RNA_def_property(srna, "use_sss_translucency", PROP_BOOLEAN, PROP_NONE);
1039 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_TRANSLUCENCY);
1041 prop, "Subsurface Translucency", "Add translucency effect to subsurface (Deprecated)");
1042 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1043
1044 prop = RNA_def_property(srna, "refraction_depth", PROP_FLOAT, PROP_DISTANCE);
1045 RNA_def_property_float_sdna(prop, nullptr, "refract_depth");
1046 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1048 "Refraction Depth",
1049 "Approximate the thickness of the object to compute two refraction "
1050 "events (0 is disabled) (Deprecated)");
1051 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1052# endif
1053
1054 prop = RNA_def_property(srna, "thickness_mode", PROP_ENUM, PROP_NONE);
1055 RNA_def_property_enum_items(prop, prop_eevee_thickness_method_items);
1057 "Thickness Mode",
1058 "Approximation used to model the light interactions inside the object");
1059 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1060
1061 prop = RNA_def_property(srna, "use_thickness_from_shadow", PROP_BOOLEAN, PROP_NONE);
1062 RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_THICKNESS_FROM_SHADOW);
1064 "Thickness From Shadow",
1065 "Use the shadow maps from shadow casting lights "
1066 "to refine the thickness defined by the material node tree");
1067 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1068
1069 prop = RNA_def_property(srna, "volume_intersection_method", PROP_ENUM, PROP_NONE);
1070 RNA_def_property_enum_items(prop, prop_eevee_volume_isect_method_items);
1072 prop,
1073 "Volume Intersection Method",
1074 "Determines which inner part of the mesh will produce volumetric effect");
1075 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1076
1077 prop = RNA_def_property(srna, "max_vertex_displacement", PROP_FLOAT, PROP_DISTANCE);
1078 RNA_def_property_float_sdna(prop, nullptr, "inflate_bounds");
1079 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1081 "Max Vertex Displacement",
1082 "The max distance a vertex can be displaced. "
1083 "Displacements over this threshold may cause visibility issues.");
1084 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1085
1086 /* For Preview Render */
1087 prop = RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE);
1088 RNA_def_property_enum_sdna(prop, nullptr, "pr_type");
1089 RNA_def_property_enum_items(prop, preview_type_items);
1090 RNA_def_property_ui_text(prop, "Preview Render Type", "Type of preview render");
1092 RNA_def_property_update(prop, 0, "rna_Material_update_previews");
1093
1094 prop = RNA_def_property(srna, "use_preview_world", PROP_BOOLEAN, PROP_NONE);
1095 RNA_def_property_boolean_sdna(prop, nullptr, "pr_flag", MA_PREVIEW_WORLD);
1097 prop, "Preview World", "Use the current world background to light the preview render");
1098 RNA_def_property_update(prop, 0, "rna_Material_update_previews");
1099
1100 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
1101 RNA_def_property_int_sdna(prop, nullptr, "index");
1103 prop, "Pass Index", "Index number for the \"Material Index\" render pass");
1104 RNA_def_property_update(prop, NC_OBJECT, "rna_Material_update");
1105
1106 /* nodetree */
1107 prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
1108 RNA_def_property_pointer_sdna(prop, nullptr, "nodetree");
1111 RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based materials");
1112
1113 prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
1114 RNA_def_property_boolean_sdna(prop, nullptr, "use_nodes", 1);
1117 RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material");
1118 RNA_def_property_update(prop, 0, "rna_Material_use_nodes_update");
1119
1120 /* common */
1122 rna_def_texpaint_slots(brna, srna);
1123
1125
1126 /* grease pencil */
1127 prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
1128 RNA_def_property_pointer_sdna(prop, nullptr, "gp_style");
1130 prop, "Grease Pencil Settings", "Grease pencil color settings for material");
1131
1132 prop = RNA_def_property(srna, "is_grease_pencil", PROP_BOOLEAN, PROP_NONE);
1133 RNA_def_property_boolean_funcs(prop, "rna_is_grease_pencil_get", nullptr);
1136 prop, "Is Grease Pencil", "True if this material has grease pencil data");
1137
1138 /* line art */
1139 prop = RNA_def_property(srna, "lineart", PROP_POINTER, PROP_NONE);
1140 RNA_def_property_pointer_sdna(prop, nullptr, "lineart");
1141 RNA_def_property_ui_text(prop, "Line Art Settings", "Line Art settings for material");
1142
1145
1146 RNA_api_material(srna);
1147}
1148
1150 PropertyRNA *cprop,
1151 const char *structname,
1152 const char *structname_slots)
1153{
1154 StructRNA *srna;
1155
1156 FunctionRNA *func;
1157 PropertyRNA *parm;
1158
1159 RNA_def_property_srna(cprop, structname_slots);
1160 srna = RNA_def_struct(brna, structname_slots, nullptr);
1161 RNA_def_struct_sdna(srna, "ID");
1162 RNA_def_struct_ui_text(srna, "Texture Slots", "Collection of texture slots");
1163
1164 /* functions */
1165 func = RNA_def_function(srna, "add", "rna_mtex_texture_slots_add");
1168 parm = RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
1169 RNA_def_function_return(func, parm);
1170
1171 func = RNA_def_function(srna, "create", "rna_mtex_texture_slots_create");
1174 parm = RNA_def_int(
1175 func, "index", 0, 0, INT_MAX, "Index", "Slot index to initialize", 0, INT_MAX);
1177 parm = RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
1178 RNA_def_function_return(func, parm);
1179
1180 func = RNA_def_function(srna, "clear", "rna_mtex_texture_slots_clear");
1183 parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to clear", 0, INT_MAX);
1185}
1186
1188 StructRNA *srna,
1189 const char *begin,
1190 const char *activeget,
1191 const char *activeset,
1192 const char *activeeditable,
1193 const char *structname,
1194 const char *structname_slots,
1195 const char *update,
1196 const char *update_index)
1197{
1198 PropertyRNA *prop;
1199
1200 /* mtex */
1201 prop = RNA_def_property(srna, "texture_slots", PROP_COLLECTION, PROP_NONE);
1202 RNA_def_property_struct_type(prop, structname);
1204 begin,
1205 "rna_iterator_array_next",
1206 "rna_iterator_array_end",
1207 "rna_iterator_array_dereference_get",
1208 nullptr,
1209 nullptr,
1210 nullptr,
1211 nullptr);
1213 prop, "Textures", "Texture slots defining the mapping and influence of textures");
1214 rna_def_texture_slots(brna, prop, structname, structname_slots);
1215
1216 prop = RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE);
1217 RNA_def_property_struct_type(prop, "Texture");
1219 if (activeeditable) {
1220 RNA_def_property_editable_func(prop, activeeditable);
1221 }
1222 RNA_def_property_pointer_funcs(prop, activeget, activeset, nullptr, nullptr);
1223 RNA_def_property_ui_text(prop, "Active Texture", "Active texture slot being displayed");
1225
1226 prop = RNA_def_property(srna, "active_texture_index", PROP_INT, PROP_UNSIGNED);
1227 RNA_def_property_int_sdna(prop, nullptr, "texact");
1228 RNA_def_property_range(prop, 0, MAX_MTEX - 1);
1229 RNA_def_property_ui_text(prop, "Active Texture Index", "Index of active texture slot");
1231}
1232
1234{
1235 StructRNA *srna;
1236 PropertyRNA *prop;
1237
1238 srna = RNA_def_struct(brna, "TexPaintSlot", nullptr);
1240 srna, "Texture Paint Slot", "Slot that contains information about texture painting");
1241
1242 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1245 prop, "rna_TexPaintSlot_name_get", "rna_TexPaintSlot_name_length", nullptr);
1246 RNA_def_property_ui_text(prop, "Name", "Name of the slot");
1247 RNA_def_struct_name_property(srna, prop);
1248
1249 prop = RNA_def_property(srna, "icon_value", PROP_INT, PROP_NONE);
1251 RNA_def_property_int_funcs(prop, "rna_TexPaintSlot_icon_get", nullptr, nullptr);
1252 RNA_def_property_ui_text(prop, "Icon", "Paint slot icon");
1253
1254 prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
1255 RNA_def_property_string_maxlength(prop, 64); /* 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, const char *name)
void BKE_id_attributes_active_color_set(struct ID *id, const char *name)
Definition attribute.cc:965
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:351
void id_us_min(ID *id)
Definition lib_id.cc:359
General operations, lookup, etc. for materials.
struct bNode * BKE_texpaint_slot_material_find_node(struct Material *ma, short texpaint_slot)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
bool give_active_mtex(struct ID *id, struct MTex ***mtex_ar, short *act)
Definition texture.cc:493
struct MTex * BKE_texture_mtex_add_id(struct ID *id, int slot)
Definition texture.cc:412
#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)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_SHADING
Definition DNA_ID.h:1061
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1085
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
@ 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_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_SURFACE_METHOD_DEFERRED
@ MA_SURFACE_METHOD_FORWARD
@ MA_SHADERBALL
@ MA_SPHERE
@ GP_MATERIAL_FILL_STYLE_GRADIENT
@ GP_MATERIAL_FILL_STYLE_TEXTURE
@ GP_MATERIAL_FILL_STYLE_SOLID
@ MA_DISPLACEMENT_BOTH
@ MA_DISPLACEMENT_BUMP
@ MA_DISPLACEMENT_DISPLACE
@ GP_MATERIAL_FOLLOW_OBJ
@ GP_MATERIAL_FOLLOW_PATH
@ GP_MATERIAL_FOLLOW_FIXED
@ MA_BS_HASHED
@ MA_BS_SOLID
@ MA_VOLUME_ISECT_ACCURATE
@ MA_VOLUME_ISECT_FAST
@ GP_MATERIAL_STROKE_STYLE_SOLID
@ GP_MATERIAL_STROKE_STYLE_TEXTURE
@ 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
@ LRT_MATERIAL_CUSTOM_INTERSECTION_PRIORITY
@ LRT_MATERIAL_MASK_ENABLED
@ GP_MATERIAL_MODE_SQUARE
@ GP_MATERIAL_MODE_DOT
@ GP_MATERIAL_MODE_LINE
@ GP_MATERIAL_GRADIENT_RADIAL
@ GP_MATERIAL_GRADIENT_LINEAR
@ MA_THICKNESS_SLAB
@ MA_THICKNESS_SPHERE
@ MA_BM_CLIP
@ MA_BM_HASHED
@ MA_BM_SOLID
@ MA_BM_BLEND
Object is a sort of wrapper for general info.
@ OB_GREASE_PENCIL
@ OB_MESH
@ OB_GPENCIL_LEGACY
void ED_space_image_sync(Main *bmain, Image *image, bool ignore_render_viewer)
Definition image_edit.cc:70
void ED_node_shader_default(const bContext *C, ID *id)
Definition node_edit.cc:549
Read Guarded memory(de)allocation.
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_NO_SELF
Definition RNA_types.hh:673
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:528
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:355
PropertyFlag
Definition RNA_types.hh:201
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:296
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:284
@ PROP_DISTANCE
Definition RNA_types.hh:159
@ PROP_COLOR
Definition RNA_types.hh:163
@ PROP_ANGLE
Definition RNA_types.hh:155
@ PROP_COORDS
Definition RNA_types.hh:177
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_FACTOR
Definition RNA_types.hh:154
@ PROP_UNSIGNED
Definition RNA_types.hh:152
#define MAX_MTEX
Definition Stroke.h:33
#define ND_SHADING
Definition WM_types.hh:444
#define NC_GEOM
Definition WM_types.hh:360
#define ND_DATA
Definition WM_types.hh:475
#define ND_SHADING_PREVIEW
Definition WM_types.hh:447
#define NC_MATERIAL
Definition WM_types.hh:347
#define NC_GPENCIL
Definition WM_types.hh:366
#define NC_TEXTURE
Definition WM_types.hh:348
#define NC_OBJECT
Definition WM_types.hh:346
#define ND_SHADING_LINKS
Definition WM_types.hh:446
#define ND_SHADING_DRAW
Definition WM_types.hh:445
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void node_set_active(bNodeTree *ntree, bNode *node)
Definition node.cc:3896
static void update(bNodeTree *ntree)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, bool free_ptr, IteratorSkipFunc skip)
void rna_def_animdata_common(StructRNA *srna)
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_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
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_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_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:413
ID * owner_id
Definition RNA_types.hh:40
void * data
Definition RNA_types.hh:42
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:4126