2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2008), Nathan Letwory
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/intern/rna_material.c
30 #include "DNA_material_types.h"
31 #include "DNA_texture_types.h"
33 #include "RNA_define.h"
34 #include "RNA_enum_types.h"
36 #include "rna_internal.h"
41 static EnumPropertyItem prop_texture_coordinates_items[] = {
42 {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"},
43 {TEXCO_OBJECT, "OBJECT", 0, "Object", "Use linked object's coordinates for texture coordinates"},
44 {TEXCO_UV, "UV", 0, "UV", "Use UV coordinates for texture coordinates"},
45 {TEXCO_ORCO, "ORCO", 0, "Generated", "Use the original undeformed coordinates of the object"},
46 {TEXCO_STRAND, "STRAND", 0, "Strand / Particle",
47 "Use normalized strand texture coordinate (1D) or particle age (X) and trail position (Y)"},
48 {TEXCO_WINDOW, "WINDOW", 0, "Window", "Use screen coordinates as texture coordinates"},
49 {TEXCO_NORM, "NORMAL", 0, "Normal", "Use normal vector as texture coordinates"},
50 {TEXCO_REFL, "REFLECTION", 0, "Reflection", "Use reflection vector as texture coordinates"},
51 {TEXCO_STRESS, "STRESS", 0, "Stress",
52 "Use the difference of edge lengths compared to original coordinates of the mesh"},
53 {TEXCO_TANGENT, "TANGENT", 0, "Tangent", "Use the optional tangent vector as texture coordinates"},
54 {0, NULL, 0, NULL, NULL}
57 EnumPropertyItem ramp_blend_items[] = {
58 {MA_RAMP_BLEND, "MIX", 0, "Mix", ""},
59 {MA_RAMP_ADD, "ADD", 0, "Add", ""},
60 {MA_RAMP_MULT, "MULTIPLY", 0, "Multiply", ""},
61 {MA_RAMP_SUB, "SUBTRACT", 0, "Subtract", ""},
62 {MA_RAMP_SCREEN, "SCREEN", 0, "Screen", ""},
63 {MA_RAMP_DIV, "DIVIDE", 0, "Divide", ""},
64 {MA_RAMP_DIFF, "DIFFERENCE", 0, "Difference", ""},
65 {MA_RAMP_DARK, "DARKEN", 0, "Darken", ""},
66 {MA_RAMP_LIGHT, "LIGHTEN", 0, "Lighten", ""},
67 {MA_RAMP_OVERLAY, "OVERLAY", 0, "Overlay", ""},
68 {MA_RAMP_DODGE, "DODGE", 0, "Dodge", ""},
69 {MA_RAMP_BURN, "BURN", 0, "Burn", ""},
70 {MA_RAMP_HUE, "HUE", 0, "Hue", ""},
71 {MA_RAMP_SAT, "SATURATION", 0, "Saturation", ""},
72 {MA_RAMP_VAL, "VALUE", 0, "Value", ""},
73 {MA_RAMP_COLOR, "COLOR", 0, "Color", ""},
74 {MA_RAMP_SOFT, "SOFT_LIGHT", 0, "Soft Light", ""},
75 {MA_RAMP_LINEAR, "LINEAR_LIGHT", 0, "Linear Light", ""},
76 {0, NULL, 0, NULL, NULL}
81 #include "MEM_guardedalloc.h"
83 #include "DNA_node_types.h"
84 #include "DNA_object_types.h"
86 #include "BKE_context.h"
87 #include "BKE_depsgraph.h"
89 #include "BKE_material.h"
90 #include "BKE_texture.h"
92 #include "BKE_paint.h"
96 static void rna_Material_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
98 Material *ma = ptr->id.data;
100 DAG_id_tag_update(&ma->id, 0);
101 WM_main_add_notifier(NC_MATERIAL | ND_SHADING, ma);
104 static void rna_Material_update_previews(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
106 Material *ma = ptr->id.data;
109 BKE_node_preview_clear_tree(ma->nodetree);
111 WM_main_add_notifier(NC_MATERIAL | ND_SHADING_PREVIEW, ma);
114 static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
116 Material *ma = ptr->id.data;
118 DAG_id_tag_update(&ma->id, 0);
119 WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, ma);
122 static PointerRNA rna_Material_mirror_get(PointerRNA *ptr)
124 return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceMirror, ptr->id.data);
127 static PointerRNA rna_Material_transp_get(PointerRNA *ptr)
129 return rna_pointer_inherit_refine(ptr, &RNA_MaterialRaytraceTransparency, ptr->id.data);
132 static PointerRNA rna_Material_halo_get(PointerRNA *ptr)
134 return rna_pointer_inherit_refine(ptr, &RNA_MaterialHalo, ptr->id.data);
137 static PointerRNA rna_Material_sss_get(PointerRNA *ptr)
139 return rna_pointer_inherit_refine(ptr, &RNA_MaterialSubsurfaceScattering, ptr->id.data);
142 static PointerRNA rna_Material_strand_get(PointerRNA *ptr)
144 return rna_pointer_inherit_refine(ptr, &RNA_MaterialStrand, ptr->id.data);
147 static PointerRNA rna_Material_physics_get(PointerRNA *ptr)
149 return rna_pointer_inherit_refine(ptr, &RNA_MaterialPhysics, ptr->id.data);
152 static void rna_Material_type_set(PointerRNA *ptr, int value)
154 Material *ma = (Material *)ptr->data;
156 if (ma->material_type == MA_TYPE_HALO && value != MA_TYPE_HALO)
157 ma->mode &= ~(MA_STAR | MA_HALO_XALPHA | MA_ZINV | MA_ENV);
159 ma->material_type = value;
162 static void rna_Material_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
164 Material *ma = (Material *)ptr->data;
165 rna_iterator_array_begin(iter, (void *)ma->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
168 static PointerRNA rna_Material_active_texture_get(PointerRNA *ptr)
170 Material *ma = (Material *)ptr->data;
173 tex = give_current_material_texture(ma);
174 return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
177 static void rna_Material_active_texture_set(PointerRNA *ptr, PointerRNA value)
179 Material *ma = (Material *)ptr->data;
181 set_current_material_texture(ma, value.data);
184 static int rna_Material_active_texture_editable(PointerRNA *ptr)
186 Material *ma = (Material *)ptr->id.data;
188 return has_current_material_texture(ma);
191 static PointerRNA rna_Material_active_node_material_get(PointerRNA *ptr)
193 Material *ma = give_node_material((Material *)ptr->data);
194 return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
197 static void rna_Material_active_node_material_set(PointerRNA *ptr, PointerRNA value)
199 Material *ma = (Material *)ptr->data;
200 Material *ma_act = value.data;
202 nodeSetActiveID(ma->nodetree, ID_MA, &ma_act->id);
205 static void rna_MaterialStrand_start_size_range(PointerRNA *ptr, float *min, float *max,
206 float *UNUSED(softmin), float *UNUSED(softmax))
208 Material *ma = (Material *)ptr->id.data;
210 if (ma->mode & MA_STR_B_UNITS) {
220 static void rna_MaterialStrand_end_size_range(PointerRNA *ptr, float *min, float *max,
221 float *UNUSED(softmin), float *UNUSED(softmax))
223 Material *ma = (Material *)ptr->id.data;
225 if (ma->mode & MA_STR_B_UNITS) {
235 static int rna_MaterialTextureSlot_use_get(PointerRNA *ptr)
237 Material *ma = (Material *)ptr->id.data;
238 MTex *mtex = (MTex *)ptr->data;
241 for (a = 0; a < MAX_MTEX; a++)
242 if (ma->mtex[a] == mtex)
243 return (ma->septex & (1 << a)) == 0;
248 static void rna_MaterialTextureSlot_use_set(PointerRNA *ptr, int value)
250 Material *ma = (Material *)ptr->id.data;
251 MTex *mtex = (MTex *)ptr->data;
254 for (a = 0; a < MAX_MTEX; a++) {
255 if (ma->mtex[a] == mtex) {
257 ma->septex &= ~(1 << a);
259 ma->septex |= (1 << a);
264 static void rna_Material_use_diffuse_ramp_set(PointerRNA *ptr, int value)
266 Material *ma = (Material *)ptr->data;
268 if (value) ma->mode |= MA_RAMP_COL;
269 else ma->mode &= ~MA_RAMP_COL;
271 if ((ma->mode & MA_RAMP_COL) && ma->ramp_col == NULL)
272 ma->ramp_col = add_colorband(false);
275 static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value)
277 Material *ma = (Material *)ptr->data;
279 if (value) ma->mode |= MA_RAMP_SPEC;
280 else ma->mode &= ~MA_RAMP_SPEC;
282 if ((ma->mode & MA_RAMP_SPEC) && ma->ramp_spec == NULL)
283 ma->ramp_spec = add_colorband(false);
286 static void rna_Material_use_nodes_update(bContext *C, PointerRNA *ptr)
288 Material *ma = (Material *)ptr->data;
290 if (ma->use_nodes && ma->nodetree == NULL)
291 ED_node_shader_default(C, &ma->id);
293 rna_Material_update(CTX_data_main(C), CTX_data_scene(C), ptr);
296 static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *UNUSED(C), PointerRNA *ptr,
297 PropertyRNA *UNUSED(prop), bool *r_free)
299 Material *ma = (Material *)ptr->id.data;
300 EnumPropertyItem *item = NULL;
303 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_GLOB);
304 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_OBJECT);
305 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_ORCO);
307 if (ma->material_type == MA_TYPE_VOLUME) {
310 else if (ELEM3(ma->material_type, MA_TYPE_SURFACE, MA_TYPE_HALO, MA_TYPE_WIRE)) {
311 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_UV);
312 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRAND);
313 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_WINDOW);
314 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_NORM);
315 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_REFL);
316 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_STRESS);
317 RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_TANGENT);
320 RNA_enum_item_end(&item, &totitem);
326 MTex *rna_mtex_texture_slots_add(ID *self_id, struct bContext *C, ReportList *reports)
328 MTex *mtex = add_mtex_id(self_id, -1);
330 BKE_reportf(reports, RPT_ERROR, "Maximum number of textures added %d", MAX_MTEX);
334 /* for redraw only */
335 WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
340 MTex *rna_mtex_texture_slots_create(ID *self_id, struct bContext *C, ReportList *reports, int index)
344 if (index < 0 || index >= MAX_MTEX) {
345 BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
349 mtex = add_mtex_id(self_id, index);
351 /* for redraw only */
352 WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
357 void rna_mtex_texture_slots_clear(ID *self_id, struct bContext *C, ReportList *reports, int index)
362 give_active_mtex(self_id, &mtex_ar, &act);
364 if (mtex_ar == NULL) {
365 BKE_report(reports, RPT_ERROR, "Mtex not found for this type");
369 if (index < 0 || index >= MAX_MTEX) {
370 BKE_reportf(reports, RPT_ERROR, "Index %d is invalid", index);
374 if (mtex_ar[index]) {
375 id_us_min((ID *)mtex_ar[index]->tex);
376 MEM_freeN(mtex_ar[index]);
377 mtex_ar[index] = NULL;
380 /* for redraw only */
381 WM_event_add_notifier(C, NC_TEXTURE, CTX_data_scene(C));
386 static void rna_def_material_mtex(BlenderRNA *brna)
391 static EnumPropertyItem prop_mapping_items[] = {
392 {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
393 {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
394 {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
395 {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
396 {0, NULL, 0, NULL, NULL}
399 static EnumPropertyItem prop_x_mapping_items[] = {
400 {0, "NONE", 0, "None", ""},
401 {1, "X", 0, "X", ""},
402 {2, "Y", 0, "Y", ""},
403 {3, "Z", 0, "Z", ""},
404 {0, NULL, 0, NULL, NULL}
407 static EnumPropertyItem prop_y_mapping_items[] = {
408 {0, "NONE", 0, "None", ""},
409 {1, "X", 0, "X", ""},
410 {2, "Y", 0, "Y", ""},
411 {3, "Z", 0, "Z", ""},
412 {0, NULL, 0, NULL, NULL}
415 static EnumPropertyItem prop_z_mapping_items[] = {
416 {0, "NONE", 0, "None", ""},
417 {1, "X", 0, "X", ""},
418 {2, "Y", 0, "Y", ""},
419 {3, "Z", 0, "Z", ""},
420 {0, NULL, 0, NULL, NULL}
423 static EnumPropertyItem prop_normal_map_space_items[] = {
424 {MTEX_NSPACE_CAMERA, "CAMERA", 0, "Camera", ""},
425 {MTEX_NSPACE_WORLD, "WORLD", 0, "World", ""},
426 {MTEX_NSPACE_OBJECT, "OBJECT", 0, "Object", ""},
427 {MTEX_NSPACE_TANGENT, "TANGENT", 0, "Tangent", ""},
428 {0, NULL, 0, NULL, NULL}
431 static EnumPropertyItem prop_bump_method_items[] = {
432 {0, "BUMP_ORIGINAL", 0, "Original", ""},
433 {MTEX_COMPAT_BUMP, "BUMP_COMPATIBLE", 0, "Compatible", ""},
434 {MTEX_3TAP_BUMP, "BUMP_LOW_QUALITY", 0, "Low Quality", "Use 3 tap filtering"},
435 {MTEX_5TAP_BUMP, "BUMP_MEDIUM_QUALITY", 0, "Medium Quality", "Use 5 tap filtering"},
436 {MTEX_BICUBIC_BUMP, "BUMP_BEST_QUALITY", 0,
437 "Best Quality", "Use bicubic filtering (requires OpenGL 3.0+, it will fall back on "
438 "medium setting for other systems)"},
439 {0, NULL, 0, NULL, NULL}
442 static EnumPropertyItem prop_bump_space_items[] = {
443 {0, "BUMP_VIEWSPACE", 0, "ViewSpace", ""},
444 {MTEX_BUMP_OBJECTSPACE, "BUMP_OBJECTSPACE", 0, "ObjectSpace", ""},
445 {MTEX_BUMP_TEXTURESPACE, "BUMP_TEXTURESPACE", 0, "TextureSpace", ""},
446 {0, NULL, 0, NULL, NULL}
449 srna = RNA_def_struct(brna, "MaterialTextureSlot", "TextureSlot");
450 RNA_def_struct_sdna(srna, "MTex");
451 RNA_def_struct_ui_text(srna, "Material Texture Slot", "Texture slot for textures in a Material datablock");
453 prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
454 RNA_def_property_enum_sdna(prop, NULL, "texco");
455 RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
456 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Material_texture_coordinates_itemf");
457 RNA_def_property_ui_text(prop, "Texture Coordinates", "");
458 RNA_def_property_update(prop, 0, "rna_Material_update");
460 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
461 RNA_def_property_pointer_sdna(prop, NULL, "object");
462 RNA_def_property_struct_type(prop, "Object");
463 RNA_def_property_flag(prop, PROP_EDITABLE);
464 RNA_def_property_ui_text(prop, "Object", "Object to use for mapping with Object texture coordinates");
465 RNA_def_property_update(prop, 0, "rna_Material_update");
467 prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
468 RNA_def_property_string_sdna(prop, NULL, "uvname");
469 RNA_def_property_ui_text(prop, "UV Map", "UV map to use for mapping with UV texture coordinates");
470 RNA_def_property_update(prop, 0, "rna_Material_update");
472 prop = RNA_def_property(srna, "use_from_dupli", PROP_BOOLEAN, PROP_NONE);
473 RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_DUPLI_MAPTO);
474 RNA_def_property_ui_text(prop, "From Dupli",
475 "Dupli's instanced from verts, faces or particles, inherit texture coordinate "
476 "from their parent");
477 RNA_def_property_update(prop, 0, "rna_Material_update");
479 prop = RNA_def_property(srna, "use_map_to_bounds", PROP_BOOLEAN, PROP_NONE);
480 RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_MAPTO_BOUNDS);
481 RNA_def_property_ui_text(prop, "Map to Bounds",
482 "Map coordinates in object bounds");
483 RNA_def_property_update(prop, 0, "rna_Material_update");
485 prop = RNA_def_property(srna, "use_from_original", PROP_BOOLEAN, PROP_NONE);
486 RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_OB_DUPLI_ORIG);
487 RNA_def_property_ui_text(prop, "From Original",
488 "Dupli's derive their object coordinates from the original object's transformation");
489 RNA_def_property_update(prop, 0, "rna_Material_update");
491 prop = RNA_def_property(srna, "use_map_color_diffuse", PROP_BOOLEAN, PROP_NONE);
492 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COL);
493 RNA_def_property_ui_text(prop, "Diffuse Color", "The texture affects basic color of the material");
494 RNA_def_property_update(prop, 0, "rna_Material_update");
496 prop = RNA_def_property(srna, "use_map_normal", PROP_BOOLEAN, PROP_NONE);
497 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_NORM);
498 RNA_def_property_ui_text(prop, "Normal", "The texture affects the rendered normal");
499 RNA_def_property_update(prop, 0, "rna_Material_update");
501 prop = RNA_def_property(srna, "use_map_color_spec", PROP_BOOLEAN, PROP_NONE);
502 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLSPEC);
503 RNA_def_property_ui_text(prop, "Specular Color", "The texture affects the specularity color");
504 RNA_def_property_update(prop, 0, "rna_Material_update");
506 prop = RNA_def_property(srna, "use_map_mirror", PROP_BOOLEAN, PROP_NONE);
507 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_COLMIR);
508 RNA_def_property_ui_text(prop, "Mirror", "The texture affects the mirror color");
509 RNA_def_property_update(prop, 0, "rna_Material_update");
511 prop = RNA_def_property(srna, "use_map_diffuse", PROP_BOOLEAN, PROP_NONE);
512 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REF);
513 RNA_def_property_ui_text(prop, "Diffuse", "The texture affects the value of diffuse reflectivity");
514 RNA_def_property_update(prop, 0, "rna_Material_update");
516 prop = RNA_def_property(srna, "use_map_specular", PROP_BOOLEAN, PROP_NONE);
517 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SPEC);
518 RNA_def_property_ui_text(prop, "Specular", "The texture affects the value of specular reflectivity");
519 RNA_def_property_update(prop, 0, "rna_Material_update");
521 prop = RNA_def_property(srna, "use_map_ambient", PROP_BOOLEAN, PROP_NONE);
522 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_AMB);
523 RNA_def_property_ui_text(prop, "Ambient", "The texture affects the value of ambient");
524 RNA_def_property_update(prop, 0, "rna_Material_update");
526 prop = RNA_def_property(srna, "use_map_hardness", PROP_BOOLEAN, PROP_NONE);
527 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_HAR);
528 RNA_def_property_ui_text(prop, "Hardness", "The texture affects the hardness value");
529 RNA_def_property_update(prop, 0, "rna_Material_update");
531 prop = RNA_def_property(srna, "use_map_raymir", PROP_BOOLEAN, PROP_NONE);
532 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_RAYMIRR);
533 RNA_def_property_ui_text(prop, "Ray-Mirror", "The texture affects the ray-mirror value");
534 RNA_def_property_update(prop, 0, "rna_Material_update");
536 prop = RNA_def_property(srna, "use_map_alpha", PROP_BOOLEAN, PROP_NONE);
537 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_ALPHA);
538 RNA_def_property_ui_text(prop, "Alpha", "The texture affects the alpha value");
539 RNA_def_property_update(prop, 0, "rna_Material_update");
541 prop = RNA_def_property(srna, "use_map_emit", PROP_BOOLEAN, PROP_NONE);
542 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMIT);
543 RNA_def_property_ui_text(prop, "Emit", "The texture affects the emit value");
544 RNA_def_property_update(prop, 0, "rna_Material_update");
546 prop = RNA_def_property(srna, "use_map_translucency", PROP_BOOLEAN, PROP_NONE);
547 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_TRANSLU);
548 RNA_def_property_ui_text(prop, "Translucency", "The texture affects the translucency value");
549 RNA_def_property_update(prop, 0, "rna_Material_update");
551 prop = RNA_def_property(srna, "use_map_displacement", PROP_BOOLEAN, PROP_NONE);
552 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DISPLACE);
553 RNA_def_property_ui_text(prop, "Displacement", "Let the texture displace the surface");
554 RNA_def_property_update(prop, 0, "rna_Material_update");
556 prop = RNA_def_property(srna, "use_map_warp", PROP_BOOLEAN, PROP_NONE);
557 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_WARP);
558 RNA_def_property_ui_text(prop, "Warp", "Let the texture warp texture coordinates of next channels");
559 RNA_def_property_update(prop, 0, "rna_Material_update");
561 prop = RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
562 RNA_def_property_enum_sdna(prop, NULL, "projx");
563 RNA_def_property_enum_items(prop, prop_x_mapping_items);
564 RNA_def_property_ui_text(prop, "X Mapping", "");
565 RNA_def_property_update(prop, 0, "rna_Material_update");
567 prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
568 RNA_def_property_enum_sdna(prop, NULL, "projy");
569 RNA_def_property_enum_items(prop, prop_y_mapping_items);
570 RNA_def_property_ui_text(prop, "Y Mapping", "");
571 RNA_def_property_update(prop, 0, "rna_Material_update");
573 prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
574 RNA_def_property_enum_sdna(prop, NULL, "projz");
575 RNA_def_property_enum_items(prop, prop_z_mapping_items);
576 RNA_def_property_ui_text(prop, "Z Mapping", "");
577 RNA_def_property_update(prop, 0, "rna_Material_update");
579 prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
580 RNA_def_property_enum_items(prop, prop_mapping_items);
581 RNA_def_property_ui_text(prop, "Mapping", "");
582 RNA_def_property_update(prop, 0, "rna_Material_update");
584 prop = RNA_def_property(srna, "normal_map_space", PROP_ENUM, PROP_NONE);
585 RNA_def_property_enum_sdna(prop, NULL, "normapspace");
586 RNA_def_property_enum_items(prop, prop_normal_map_space_items);
587 RNA_def_property_ui_text(prop, "Normal Map Space", "Set space of normal map image");
588 RNA_def_property_update(prop, 0, "rna_Material_update");
590 prop = RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_NONE);
591 RNA_def_property_float_sdna(prop, NULL, "norfac");
592 RNA_def_property_ui_range(prop, -5, 5, 10, 3);
593 RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values");
594 RNA_def_property_update(prop, 0, "rna_Material_update");
596 prop = RNA_def_property(srna, "displacement_factor", PROP_FLOAT, PROP_NONE);
597 RNA_def_property_float_sdna(prop, NULL, "dispfac");
598 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
599 RNA_def_property_ui_text(prop, "Displacement Factor", "Amount texture displaces the surface");
600 RNA_def_property_update(prop, 0, "rna_Material_update");
602 prop = RNA_def_property(srna, "warp_factor", PROP_FLOAT, PROP_NONE);
603 RNA_def_property_float_sdna(prop, NULL, "warpfac");
604 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
605 RNA_def_property_ui_text(prop, "Warp Factor", "Amount texture affects texture coordinates of next channels");
606 RNA_def_property_update(prop, 0, "rna_Material_update");
608 prop = RNA_def_property(srna, "specular_color_factor", PROP_FLOAT, PROP_NONE);
609 RNA_def_property_float_sdna(prop, NULL, "colspecfac");
610 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
611 RNA_def_property_ui_text(prop, "Specular Color Factor", "Amount texture affects specular color");
612 RNA_def_property_update(prop, 0, "rna_Material_update");
614 prop = RNA_def_property(srna, "diffuse_color_factor", PROP_FLOAT, PROP_NONE);
615 RNA_def_property_float_sdna(prop, NULL, "colfac");
616 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
617 RNA_def_property_ui_text(prop, "Diffuse Color Factor", "Amount texture affects diffuse color");
618 RNA_def_property_update(prop, 0, "rna_Material_update");
620 prop = RNA_def_property(srna, "mirror_factor", PROP_FLOAT, PROP_NONE);
621 RNA_def_property_float_sdna(prop, NULL, "mirrfac");
622 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
623 RNA_def_property_ui_text(prop, "Mirror Factor", "Amount texture affects mirror color");
624 RNA_def_property_update(prop, 0, "rna_Material_update");
626 prop = RNA_def_property(srna, "alpha_factor", PROP_FLOAT, PROP_NONE);
627 RNA_def_property_float_sdna(prop, NULL, "alphafac");
628 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
629 RNA_def_property_ui_text(prop, "Alpha Factor", "Amount texture affects alpha");
630 RNA_def_property_update(prop, 0, "rna_Material_update");
632 prop = RNA_def_property(srna, "diffuse_factor", PROP_FLOAT, PROP_NONE);
633 RNA_def_property_float_sdna(prop, NULL, "difffac");
634 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
635 RNA_def_property_ui_text(prop, "Diffuse Factor", "Amount texture affects diffuse reflectivity");
636 RNA_def_property_update(prop, 0, "rna_Material_update");
638 prop = RNA_def_property(srna, "specular_factor", PROP_FLOAT, PROP_NONE);
639 RNA_def_property_float_sdna(prop, NULL, "specfac");
640 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
641 RNA_def_property_ui_text(prop, "Specular Factor", "Amount texture affects specular reflectivity");
642 RNA_def_property_update(prop, 0, "rna_Material_update");
644 prop = RNA_def_property(srna, "emit_factor", PROP_FLOAT, PROP_NONE);
645 RNA_def_property_float_sdna(prop, NULL, "emitfac");
646 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
647 RNA_def_property_ui_text(prop, "Emit Factor", "Amount texture affects emission");
648 RNA_def_property_update(prop, 0, "rna_Material_update");
650 prop = RNA_def_property(srna, "hardness_factor", PROP_FLOAT, PROP_NONE);
651 RNA_def_property_float_sdna(prop, NULL, "hardfac");
652 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
653 RNA_def_property_ui_text(prop, "Hardness Factor", "Amount texture affects hardness");
654 RNA_def_property_update(prop, 0, "rna_Material_update");
656 prop = RNA_def_property(srna, "raymir_factor", PROP_FLOAT, PROP_NONE);
657 RNA_def_property_float_sdna(prop, NULL, "raymirrfac");
658 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
659 RNA_def_property_ui_text(prop, "Ray Mirror Factor", "Amount texture affects ray mirror");
660 RNA_def_property_update(prop, 0, "rna_Material_update");
662 prop = RNA_def_property(srna, "translucency_factor", PROP_FLOAT, PROP_NONE);
663 RNA_def_property_float_sdna(prop, NULL, "translfac");
664 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
665 RNA_def_property_ui_text(prop, "Translucency Factor", "Amount texture affects translucency");
666 RNA_def_property_update(prop, 0, "rna_Material_update");
668 prop = RNA_def_property(srna, "ambient_factor", PROP_FLOAT, PROP_NONE);
669 RNA_def_property_float_sdna(prop, NULL, "ambfac");
670 RNA_def_property_ui_range(prop, -1, 1, 10, 3);
671 RNA_def_property_ui_text(prop, "Ambient Factor", "Amount texture affects ambient");
672 RNA_def_property_update(prop, 0, "rna_Material_update");
674 /* volume material */
675 prop = RNA_def_property(srna, "use_map_color_emission", PROP_BOOLEAN, PROP_NONE);
676 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION_COL);
677 RNA_def_property_ui_text(prop, "Emission Color", "The texture affects the color of emission");
678 RNA_def_property_update(prop, 0, "rna_Material_update");
680 prop = RNA_def_property(srna, "use_map_color_reflection", PROP_BOOLEAN, PROP_NONE);
681 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REFLECTION_COL);
682 RNA_def_property_ui_text(prop, "Reflection Color", "The texture affects the color of scattered light");
683 RNA_def_property_update(prop, 0, "rna_Material_update");
685 prop = RNA_def_property(srna, "use_map_color_transmission", PROP_BOOLEAN, PROP_NONE);
686 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_TRANSMISSION_COL);
687 RNA_def_property_ui_text(prop, "Transmission Color",
688 "The texture affects the result color after other light has been scattered/absorbed");
689 RNA_def_property_update(prop, NC_TEXTURE, NULL);
691 prop = RNA_def_property(srna, "use_map_density", PROP_BOOLEAN, PROP_NONE);
692 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_DENSITY);
693 RNA_def_property_ui_text(prop, "Density", "The texture affects the volume's density");
694 RNA_def_property_update(prop, 0, "rna_Material_update");
696 prop = RNA_def_property(srna, "use_map_emission", PROP_BOOLEAN, PROP_NONE);
697 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_EMISSION);
698 RNA_def_property_ui_text(prop, "Emission", "The texture affects the volume's emission");
699 RNA_def_property_update(prop, 0, "rna_Material_update");
701 prop = RNA_def_property(srna, "use_map_scatter", PROP_BOOLEAN, PROP_NONE);
702 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_SCATTERING);
703 RNA_def_property_ui_text(prop, "Scattering", "The texture affects the volume's scattering");
704 RNA_def_property_update(prop, 0, "rna_Material_update");
706 prop = RNA_def_property(srna, "use_map_reflect", PROP_BOOLEAN, PROP_NONE);
707 RNA_def_property_boolean_sdna(prop, NULL, "mapto", MAP_REFLECTION);
708 RNA_def_property_ui_text(prop, "Reflection", "The texture affects the reflected light's brightness");
709 RNA_def_property_update(prop, NC_TEXTURE, NULL);
711 prop = RNA_def_property(srna, "emission_color_factor", PROP_FLOAT, PROP_NONE);
712 RNA_def_property_float_sdna(prop, NULL, "colemitfac");
713 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
714 RNA_def_property_ui_text(prop, "Emission Color Factor", "Amount texture affects emission color");
715 RNA_def_property_update(prop, 0, "rna_Material_update");
717 prop = RNA_def_property(srna, "reflection_color_factor", PROP_FLOAT, PROP_NONE);
718 RNA_def_property_float_sdna(prop, NULL, "colreflfac");
719 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
720 RNA_def_property_ui_text(prop, "Reflection Color Factor", "Amount texture affects color of out-scattered light");
721 RNA_def_property_update(prop, 0, "rna_Material_update");
723 prop = RNA_def_property(srna, "transmission_color_factor", PROP_FLOAT, PROP_NONE);
724 RNA_def_property_float_sdna(prop, NULL, "coltransfac");
725 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
726 RNA_def_property_ui_text(prop, "Transmission Color Factor",
727 "Amount texture affects result color after light has been scattered/absorbed");
728 RNA_def_property_update(prop, NC_TEXTURE, NULL);
730 prop = RNA_def_property(srna, "density_factor", PROP_FLOAT, PROP_NONE);
731 RNA_def_property_float_sdna(prop, NULL, "densfac");
732 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
733 RNA_def_property_ui_text(prop, "Density Factor", "Amount texture affects density");
734 RNA_def_property_update(prop, 0, "rna_Material_update");
736 prop = RNA_def_property(srna, "emission_factor", PROP_FLOAT, PROP_NONE);
737 RNA_def_property_float_sdna(prop, NULL, "emitfac");
738 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
739 RNA_def_property_ui_text(prop, "Emission Factor", "Amount texture affects emission");
740 RNA_def_property_update(prop, 0, "rna_Material_update");
742 prop = RNA_def_property(srna, "scattering_factor", PROP_FLOAT, PROP_NONE);
743 RNA_def_property_float_sdna(prop, NULL, "scatterfac");
744 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
745 RNA_def_property_ui_text(prop, "Scattering Factor", "Amount texture affects scattering");
746 RNA_def_property_update(prop, 0, "rna_Material_update");
748 prop = RNA_def_property(srna, "reflection_factor", PROP_FLOAT, PROP_NONE);
749 RNA_def_property_float_sdna(prop, NULL, "reflfac");
750 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
751 RNA_def_property_ui_text(prop, "Reflection Factor", "Amount texture affects brightness of out-scattered light");
752 RNA_def_property_update(prop, 0, "rna_Material_update");
754 /* end volume material */
756 prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
757 RNA_def_property_boolean_funcs(prop, "rna_MaterialTextureSlot_use_get", "rna_MaterialTextureSlot_use_set");
758 RNA_def_property_ui_text(prop, "Enabled", "Enable this material texture slot");
759 RNA_def_property_update(prop, 0, "rna_Material_update");
761 prop = RNA_def_property(srna, "bump_method", PROP_ENUM, PROP_NONE);
762 RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag");
763 RNA_def_property_enum_items(prop, prop_bump_method_items);
764 RNA_def_property_ui_text(prop, "Bump Method", "Method to use for bump mapping");
765 RNA_def_property_update(prop, 0, "rna_Material_update");
767 prop = RNA_def_property(srna, "bump_objectspace", PROP_ENUM, PROP_NONE);
768 RNA_def_property_enum_bitflag_sdna(prop, NULL, "texflag");
769 RNA_def_property_enum_items(prop, prop_bump_space_items);
770 RNA_def_property_ui_text(prop, "Bump Space", "Space to apply bump mapping in");
771 RNA_def_property_update(prop, 0, "rna_Material_update");
774 static void rna_def_material_gamesettings(BlenderRNA *brna)
779 static EnumPropertyItem prop_alpha_blend_items[] = {
780 {GEMAT_SOLID, "OPAQUE", 0, "Opaque", "Render color of textured face as color"},
781 {GEMAT_ADD, "ADD", 0, "Add", "Render face transparent and add color of face"},
782 {GEMAT_CLIP, "CLIP", 0, "Alpha Clip", "Use the image alpha values clipped with no blending (binary alpha)"},
783 {GEMAT_ALPHA, "ALPHA", 0, "Alpha Blend",
784 "Render polygon transparent, depending on alpha channel of the texture"},
785 {GEMAT_ALPHA_SORT, "ALPHA_SORT", 0, "Alpha Sort",
786 "Sort faces for correct alpha drawing (slow, use Alpha Clip instead when possible)"},
787 {0, NULL, 0, NULL, NULL}
790 static EnumPropertyItem prop_face_orientation_items[] = {
791 {GEMAT_NORMAL, "NORMAL", 0, "Normal", "No transformation"},
792 {GEMAT_HALO, "HALO", 0, "Halo", "Screen aligned billboard"},
793 {GEMAT_BILLBOARD, "BILLBOARD", 0, "Billboard", "Billboard with Z-axis constraint"},
794 {GEMAT_SHADOW, "SHADOW", 0, "Shadow", "Faces are used for shadow"},
795 {0, NULL, 0, NULL, NULL}
798 srna = RNA_def_struct(brna, "MaterialGameSettings", NULL);
799 RNA_def_struct_sdna(srna, "GameSettings");
800 RNA_def_struct_nested(brna, srna, "Material");
801 RNA_def_struct_ui_text(srna, "Material Game Settings", "Game Engine settings for a Material datablock");
803 prop = RNA_def_property(srna, "use_backface_culling", PROP_BOOLEAN, PROP_NONE);
804 RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_BACKCULL); /* use bitflags */
805 RNA_def_property_ui_text(prop, "Backface Culling", "Hide Back of the face in Game Engine ");
806 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
808 prop = RNA_def_property(srna, "text", PROP_BOOLEAN, PROP_NONE);
809 RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_TEXT); /* use bitflags */
810 RNA_def_property_ui_text(prop, "Text", "Use material as text in Game Engine ");
811 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
813 prop = RNA_def_property(srna, "invisible", PROP_BOOLEAN, PROP_NONE);
814 RNA_def_property_boolean_sdna(prop, NULL, "flag", GEMAT_INVISIBLE); /* use bitflags */
815 RNA_def_property_ui_text(prop, "Invisible", "Make face invisible");
816 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
818 prop = RNA_def_property(srna, "alpha_blend", PROP_ENUM, PROP_NONE);
819 RNA_def_property_enum_sdna(prop, NULL, "alpha_blend");
820 RNA_def_property_enum_items(prop, prop_alpha_blend_items);
821 RNA_def_property_ui_text(prop, "Blend Mode", "Blend Mode for Transparent Faces");
822 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
824 prop = RNA_def_property(srna, "face_orientation", PROP_ENUM, PROP_NONE);
825 RNA_def_property_enum_items(prop, prop_face_orientation_items);
826 RNA_def_property_ui_text(prop, "Face Orientations", "Especial face orientation options");
828 prop = RNA_def_property(srna, "physics", PROP_BOOLEAN, PROP_NONE);
829 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GEMAT_NOPHYSICS); /* use bitflags */
830 RNA_def_property_ui_text(prop, "Physics", "Use physics properties of materials ");
833 static void rna_def_material_colors(StructRNA *srna)
837 static EnumPropertyItem prop_ramp_input_items[] = {
838 {MA_RAMP_IN_SHADER, "SHADER", 0, "Shader", ""},
839 {MA_RAMP_IN_ENERGY, "ENERGY", 0, "Energy", ""},
840 {MA_RAMP_IN_NOR, "NORMAL", 0, "Normal", ""},
841 {MA_RAMP_IN_RESULT, "RESULT", 0, "Result", ""},
842 {0, NULL, 0, NULL, NULL}
845 prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR);
846 RNA_def_property_float_sdna(prop, NULL, "r");
847 RNA_def_property_array(prop, 3);
848 RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material");
849 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
851 prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR);
852 RNA_def_property_float_sdna(prop, NULL, "specr");
853 RNA_def_property_array(prop, 3);
854 RNA_def_property_ui_text(prop, "Specular Color", "Specular color of the material");
855 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
857 prop = RNA_def_property(srna, "mirror_color", PROP_FLOAT, PROP_COLOR);
858 RNA_def_property_float_sdna(prop, NULL, "mirr");
859 RNA_def_property_array(prop, 3);
860 RNA_def_property_ui_text(prop, "Mirror Color", "Mirror color of the material");
861 RNA_def_property_update(prop, 0, "rna_Material_update");
863 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
864 RNA_def_property_range(prop, 0.0f, 1.0f);
865 RNA_def_property_ui_text(prop, "Alpha", "Alpha transparency of the material");
866 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
868 prop = RNA_def_property(srna, "specular_alpha", PROP_FLOAT, PROP_FACTOR);
869 RNA_def_property_float_sdna(prop, NULL, "spectra");
870 RNA_def_property_range(prop, 0.0f, 1.0f);
871 RNA_def_property_ui_text(prop, "Specular Alpha", "Alpha transparency for specular areas");
872 RNA_def_property_update(prop, 0, "rna_Material_update");
875 prop = RNA_def_property(srna, "use_diffuse_ramp", PROP_BOOLEAN, PROP_NONE);
876 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAMP_COL);
877 RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_diffuse_ramp_set");
878 RNA_def_property_ui_text(prop, "Use Diffuse Ramp", "Toggle diffuse ramp operations");
879 RNA_def_property_update(prop, 0, "rna_Material_update");
881 prop = RNA_def_property(srna, "diffuse_ramp", PROP_POINTER, PROP_NONE);
882 RNA_def_property_pointer_sdna(prop, NULL, "ramp_col");
883 RNA_def_property_struct_type(prop, "ColorRamp");
884 RNA_def_property_ui_text(prop, "Diffuse Ramp", "Color ramp used to affect diffuse shading");
885 RNA_def_property_update(prop, 0, "rna_Material_update");
887 prop = RNA_def_property(srna, "use_specular_ramp", PROP_BOOLEAN, PROP_NONE);
888 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAMP_SPEC);
889 RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_specular_ramp_set");
890 RNA_def_property_ui_text(prop, "Use Specular Ramp", "Toggle specular ramp operations");
891 RNA_def_property_update(prop, 0, "rna_Material_update");
893 prop = RNA_def_property(srna, "specular_ramp", PROP_POINTER, PROP_NONE);
894 RNA_def_property_pointer_sdna(prop, NULL, "ramp_spec");
895 RNA_def_property_struct_type(prop, "ColorRamp");
896 RNA_def_property_ui_text(prop, "Specular Ramp", "Color ramp used to affect specular shading");
897 RNA_def_property_update(prop, 0, "rna_Material_update");
899 prop = RNA_def_property(srna, "diffuse_ramp_blend", PROP_ENUM, PROP_NONE);
900 RNA_def_property_enum_sdna(prop, NULL, "rampblend_col");
901 RNA_def_property_enum_items(prop, ramp_blend_items);
902 RNA_def_property_ui_text(prop, "Diffuse Ramp Blend", "Blending method of the ramp and the diffuse color");
903 RNA_def_property_update(prop, 0, "rna_Material_update");
905 prop = RNA_def_property(srna, "specular_ramp_blend", PROP_ENUM, PROP_NONE);
906 RNA_def_property_enum_sdna(prop, NULL, "rampblend_spec");
907 RNA_def_property_enum_items(prop, ramp_blend_items);
908 RNA_def_property_ui_text(prop, "Specular Ramp Blend", "Blending method of the ramp and the specular color");
909 RNA_def_property_update(prop, 0, "rna_Material_update");
911 prop = RNA_def_property(srna, "diffuse_ramp_input", PROP_ENUM, PROP_NONE);
912 RNA_def_property_enum_sdna(prop, NULL, "rampin_col");
913 RNA_def_property_enum_items(prop, prop_ramp_input_items);
914 RNA_def_property_ui_text(prop, "Diffuse Ramp Input", "How the ramp maps on the surface");
915 RNA_def_property_update(prop, 0, "rna_Material_update");
917 prop = RNA_def_property(srna, "specular_ramp_input", PROP_ENUM, PROP_NONE);
918 RNA_def_property_enum_sdna(prop, NULL, "rampin_spec");
919 RNA_def_property_enum_items(prop, prop_ramp_input_items);
920 RNA_def_property_ui_text(prop, "Specular Ramp Input", "How the ramp maps on the surface");
921 RNA_def_property_update(prop, 0, "rna_Material_update");
923 prop = RNA_def_property(srna, "diffuse_ramp_factor", PROP_FLOAT, PROP_FACTOR);
924 RNA_def_property_float_sdna(prop, NULL, "rampfac_col");
925 RNA_def_property_range(prop, 0.0f, 1.0f);
926 RNA_def_property_ui_text(prop, "Diffuse Ramp Factor", "Blending factor (also uses alpha in Colorband)");
927 RNA_def_property_update(prop, 0, "rna_Material_update");
929 prop = RNA_def_property(srna, "specular_ramp_factor", PROP_FLOAT, PROP_FACTOR);
930 RNA_def_property_float_sdna(prop, NULL, "rampfac_spec");
931 RNA_def_property_range(prop, 0.0f, 1.0f);
932 RNA_def_property_ui_text(prop, "Specular Ramp Factor", "Blending factor (also uses alpha in Colorband)");
933 RNA_def_property_update(prop, 0, "rna_Material_update");
936 static void rna_def_material_diffuse(StructRNA *srna)
940 static EnumPropertyItem prop_diff_shader_items[] = {
941 {MA_DIFF_LAMBERT, "LAMBERT", 0, "Lambert", "Use a Lambertian shader"},
942 {MA_DIFF_ORENNAYAR, "OREN_NAYAR", 0, "Oren-Nayar", "Use an Oren-Nayar shader"},
943 {MA_DIFF_TOON, "TOON", 0, "Toon", "Use a toon shader"},
944 {MA_DIFF_MINNAERT, "MINNAERT", 0, "Minnaert", "Use a Minnaert shader"},
945 {MA_DIFF_FRESNEL, "FRESNEL", 0, "Fresnel", "Use a Fresnel shader"},
946 {0, NULL, 0, NULL, NULL}
949 prop = RNA_def_property(srna, "diffuse_shader", PROP_ENUM, PROP_NONE);
950 RNA_def_property_enum_sdna(prop, NULL, "diff_shader");
951 RNA_def_property_enum_items(prop, prop_diff_shader_items);
952 RNA_def_property_ui_text(prop, "Diffuse Shader Model", "");
953 RNA_def_property_update(prop, 0, "rna_Material_update");
955 prop = RNA_def_property(srna, "diffuse_intensity", PROP_FLOAT, PROP_FACTOR);
956 RNA_def_property_float_sdna(prop, NULL, "ref");
957 RNA_def_property_range(prop, 0.0f, 1.0f);
958 RNA_def_property_ui_text(prop, "Diffuse Intensity", "Amount of diffuse reflection");
959 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
961 prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_NONE);
962 RNA_def_property_range(prop, 0.0f, 3.14f);
963 RNA_def_property_ui_text(prop, "Roughness", "Oren-Nayar Roughness");
964 RNA_def_property_update(prop, 0, "rna_Material_update");
966 prop = RNA_def_property(srna, "diffuse_toon_size", PROP_FLOAT, PROP_NONE);
967 RNA_def_property_float_sdna(prop, NULL, "param[0]");
968 RNA_def_property_range(prop, 0.0f, 3.14f);
969 RNA_def_property_ui_text(prop, "Diffuse Toon Size", "Size of diffuse toon area");
970 RNA_def_property_update(prop, 0, "rna_Material_update");
972 prop = RNA_def_property(srna, "diffuse_toon_smooth", PROP_FLOAT, PROP_FACTOR);
973 RNA_def_property_float_sdna(prop, NULL, "param[1]");
974 RNA_def_property_range(prop, 0.0f, 1.0f);
975 RNA_def_property_ui_text(prop, "Diffuse Toon Smooth", "Smoothness of diffuse toon area");
976 RNA_def_property_update(prop, 0, "rna_Material_update");
978 prop = RNA_def_property(srna, "diffuse_fresnel", PROP_FLOAT, PROP_NONE);
979 RNA_def_property_float_sdna(prop, NULL, "param[1]");
980 RNA_def_property_range(prop, 0.0f, 5.0f);
981 RNA_def_property_ui_text(prop, "Diffuse Fresnel", "Power of Fresnel");
982 RNA_def_property_update(prop, 0, "rna_Material_update");
984 prop = RNA_def_property(srna, "diffuse_fresnel_factor", PROP_FLOAT, PROP_NONE);
985 RNA_def_property_float_sdna(prop, NULL, "param[0]");
986 RNA_def_property_range(prop, 0.0f, 5.0f);
987 RNA_def_property_ui_text(prop, "Diffuse Fresnel Factor", "Blending factor of Fresnel");
988 RNA_def_property_update(prop, 0, "rna_Material_update");
990 prop = RNA_def_property(srna, "darkness", PROP_FLOAT, PROP_NONE);
991 RNA_def_property_range(prop, 0.0f, 2.0f);
992 RNA_def_property_ui_text(prop, "Darkness", "Minnaert darkness");
993 RNA_def_property_update(prop, 0, "rna_Material_update");
996 static void rna_def_material_raymirror(BlenderRNA *brna)
1001 static EnumPropertyItem prop_fadeto_mir_items[] = {
1002 {MA_RAYMIR_FADETOSKY, "FADE_TO_SKY", 0, "Sky", ""},
1003 {MA_RAYMIR_FADETOMAT, "FADE_TO_MATERIAL", 0, "Material", ""},
1004 {0, NULL, 0, NULL, NULL}
1007 srna = RNA_def_struct(brna, "MaterialRaytraceMirror", NULL);
1008 RNA_def_struct_sdna(srna, "Material");
1009 RNA_def_struct_nested(brna, srna, "Material");
1010 RNA_def_struct_ui_text(srna, "Material Raytrace Mirror", "Raytraced reflection settings for a Material datablock");
1012 prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
1013 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYMIRROR); /* use bitflags */
1014 RNA_def_property_ui_text(prop, "Enabled", "Enable raytraced reflections");
1015 RNA_def_property_update(prop, 0, "rna_Material_update");
1017 prop = RNA_def_property(srna, "reflect_factor", PROP_FLOAT, PROP_FACTOR);
1018 RNA_def_property_float_sdna(prop, NULL, "ray_mirror");
1019 RNA_def_property_range(prop, 0.0f, 1.0f);
1020 RNA_def_property_ui_text(prop, "Reflectivity", "Amount of mirror reflection for raytrace");
1021 RNA_def_property_update(prop, 0, "rna_Material_update");
1023 prop = RNA_def_property(srna, "fresnel", PROP_FLOAT, PROP_NONE);
1024 RNA_def_property_float_sdna(prop, NULL, "fresnel_mir");
1025 RNA_def_property_range(prop, 0.0f, 5.0f);
1026 RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for mirror reflection");
1027 RNA_def_property_update(prop, 0, "rna_Material_update");
1029 prop = RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_FACTOR);
1030 RNA_def_property_float_sdna(prop, NULL, "fresnel_mir_i");
1031 RNA_def_property_range(prop, 0.0f, 5.0f);
1032 RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel");
1033 RNA_def_property_update(prop, 0, "rna_Material_update");
1035 prop = RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR);
1036 RNA_def_property_float_sdna(prop, NULL, "gloss_mir");
1037 RNA_def_property_range(prop, 0.0f, 1.0f);
1038 RNA_def_property_ui_text(prop, "Gloss Amount",
1039 "The shininess of the reflection (values < 1.0 give diffuse, blurry reflections)");
1040 RNA_def_property_update(prop, 0, "rna_Material_update");
1042 prop = RNA_def_property(srna, "gloss_anisotropic", PROP_FLOAT, PROP_FACTOR);
1043 RNA_def_property_float_sdna(prop, NULL, "aniso_gloss_mir");
1044 RNA_def_property_range(prop, 0.0f, 1.0f);
1045 RNA_def_property_ui_text(prop, "Gloss Anisotropy",
1046 "The shape of the reflection, from 0.0 (circular) to 1.0 "
1047 "(fully stretched along the tangent");
1048 RNA_def_property_update(prop, 0, "rna_Material_update");
1050 prop = RNA_def_property(srna, "gloss_samples", PROP_INT, PROP_NONE);
1051 RNA_def_property_int_sdna(prop, NULL, "samp_gloss_mir");
1052 RNA_def_property_range(prop, 0, 1024);
1053 RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry reflections");
1054 RNA_def_property_update(prop, 0, "rna_Material_update");
1056 prop = RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_FACTOR);
1057 RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_mir");
1058 RNA_def_property_range(prop, 0.0f, 1.0f);
1059 RNA_def_property_ui_text(prop, "Gloss Threshold",
1060 "Threshold for adaptive sampling (if a sample contributes less than "
1061 "this amount [as a percentage], sampling is stopped)");
1062 RNA_def_property_update(prop, 0, "rna_Material_update");
1064 prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
1065 RNA_def_property_int_sdna(prop, NULL, "ray_depth");
1066 RNA_def_property_ui_range(prop, 0, 100, 1, 3);
1067 RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-reflections");
1068 RNA_def_property_update(prop, 0, "rna_Material_update");
1070 prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
1071 RNA_def_property_float_sdna(prop, NULL, "dist_mir");
1072 RNA_def_property_range(prop, 0.0f, 10000.0f);
1073 RNA_def_property_ui_text(prop, "Maximum Distance",
1074 "Maximum distance of reflected rays (reflections further than this "
1075 "range fade to sky color or material color)");
1076 RNA_def_property_update(prop, 0, "rna_Material_update");
1078 prop = RNA_def_property(srna, "fade_to", PROP_ENUM, PROP_NONE);
1079 RNA_def_property_enum_sdna(prop, NULL, "fadeto_mir");
1080 RNA_def_property_enum_items(prop, prop_fadeto_mir_items);
1081 RNA_def_property_ui_text(prop, "Fade-out Color",
1082 "The color that rays with no intersection within the Max Distance take "
1083 "(material color can be best for indoor scenes, sky color for outdoor)");
1084 RNA_def_property_update(prop, 0, "rna_Material_update");
1087 static void rna_def_material_raytra(BlenderRNA *brna)
1092 srna = RNA_def_struct(brna, "MaterialRaytraceTransparency", NULL);
1093 RNA_def_struct_sdna(srna, "Material");
1094 RNA_def_struct_nested(brna, srna, "Material");
1095 RNA_def_struct_ui_text(srna, "Material Raytrace Transparency",
1096 "Raytraced refraction settings for a Material datablock");
1098 prop = RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE);
1099 RNA_def_property_float_sdna(prop, NULL, "ang");
1100 RNA_def_property_range(prop, 0.25f, 4.0f);
1101 RNA_def_property_ui_text(prop, "IOR", "Angular index of refraction for raytraced refraction");
1102 RNA_def_property_update(prop, 0, "rna_Material_update");
1104 prop = RNA_def_property(srna, "fresnel", PROP_FLOAT, PROP_NONE);
1105 RNA_def_property_float_sdna(prop, NULL, "fresnel_tra");
1106 RNA_def_property_range(prop, 0.0f, 5.0f);
1107 RNA_def_property_ui_text(prop, "Fresnel", "Power of Fresnel for transparency (Ray or ZTransp)");
1108 RNA_def_property_update(prop, 0, "rna_Material_update");
1110 prop = RNA_def_property(srna, "fresnel_factor", PROP_FLOAT, PROP_FACTOR);
1111 RNA_def_property_float_sdna(prop, NULL, "fresnel_tra_i");
1112 RNA_def_property_range(prop, 1.0f, 5.0f);
1113 RNA_def_property_ui_text(prop, "Fresnel Factor", "Blending factor for Fresnel");
1114 RNA_def_property_update(prop, 0, "rna_Material_update");
1116 prop = RNA_def_property(srna, "gloss_factor", PROP_FLOAT, PROP_FACTOR);
1117 RNA_def_property_float_sdna(prop, NULL, "gloss_tra");
1118 RNA_def_property_range(prop, 0.0f, 1.0f);
1119 RNA_def_property_ui_text(prop, "Gloss Amount",
1120 "The clarity of the refraction. Values < 1.0 give diffuse, blurry refractions");
1121 RNA_def_property_update(prop, 0, "rna_Material_update");
1123 prop = RNA_def_property(srna, "gloss_samples", PROP_INT, PROP_NONE);
1124 RNA_def_property_int_sdna(prop, NULL, "samp_gloss_tra");
1125 RNA_def_property_range(prop, 0, 1024);
1126 RNA_def_property_ui_text(prop, "Gloss Samples", "Number of cone samples averaged for blurry refractions");
1127 RNA_def_property_update(prop, 0, "rna_Material_update");
1129 prop = RNA_def_property(srna, "gloss_threshold", PROP_FLOAT, PROP_FACTOR);
1130 RNA_def_property_float_sdna(prop, NULL, "adapt_thresh_tra");
1131 RNA_def_property_range(prop, 0.0f, 1.0f);
1132 RNA_def_property_ui_text(prop, "Gloss Threshold",
1133 "Threshold for adaptive sampling. If a sample contributes less than "
1134 "this amount (as a percentage), sampling is stopped");
1135 RNA_def_property_update(prop, 0, "rna_Material_update");
1137 prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
1138 RNA_def_property_int_sdna(prop, NULL, "ray_depth_tra");
1139 RNA_def_property_ui_range(prop, 0, 100, 1, 3);
1140 RNA_def_property_ui_text(prop, "Depth", "Maximum allowed number of light inter-refractions");
1141 RNA_def_property_update(prop, 0, "rna_Material_update");
1143 prop = RNA_def_property(srna, "filter", PROP_FLOAT, PROP_FACTOR);
1144 RNA_def_property_float_sdna(prop, NULL, "filter");
1145 RNA_def_property_range(prop, 0.0f, 1.0f);
1146 RNA_def_property_ui_text(prop, "Filter",
1147 "Amount to blend in the material's diffuse color in raytraced "
1148 "transparency (simulating absorption)");
1149 RNA_def_property_update(prop, 0, "rna_Material_update");
1151 prop = RNA_def_property(srna, "depth_max", PROP_FLOAT, PROP_DISTANCE);
1152 RNA_def_property_float_sdna(prop, NULL, "tx_limit");
1153 RNA_def_property_range(prop, 0.0f, 100.0f);
1154 RNA_def_property_ui_text(prop, "Limit",
1155 "Maximum depth for light to travel through the transparent material "
1156 "before becoming fully filtered (0.0 is disabled)");
1157 RNA_def_property_update(prop, 0, "rna_Material_update");
1159 prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
1160 RNA_def_property_float_sdna(prop, NULL, "tx_falloff");
1161 RNA_def_property_range(prop, 0.1f, 10.0f);
1162 RNA_def_property_ui_text(prop, "Falloff", "Falloff power for transmissivity filter effect (1.0 is linear)");
1163 RNA_def_property_update(prop, 0, "rna_Material_update");
1166 static void rna_def_material_volume(BlenderRNA *brna)
1171 static EnumPropertyItem prop_lighting_items[] = {
1172 {MA_VOL_SHADE_SHADELESS, "SHADELESS", 0, "Shadeless", "Do not calculate lighting and shadows"},
1173 {MA_VOL_SHADE_SHADOWED, "SHADOWED", 0, "Shadowed", ""},
1174 {MA_VOL_SHADE_SHADED, "SHADED", 0, "Shaded", ""},
1175 {MA_VOL_SHADE_MULTIPLE, "MULTIPLE_SCATTERING", 0, "Multiple Scattering", ""},
1176 {MA_VOL_SHADE_SHADEDPLUSMULTIPLE, "SHADED_PLUS_MULTIPLE_SCATTERING", 0, "Shaded + Multiple Scattering", ""},
1177 {0, NULL, 0, NULL, NULL}
1180 static EnumPropertyItem prop_stepsize_items[] = {
1181 {MA_VOL_STEP_RANDOMIZED, "RANDOMIZED", 0, "Randomized", ""},
1182 {MA_VOL_STEP_CONSTANT, "CONSTANT", 0, "Constant", ""},
1183 /*{MA_VOL_STEP_ADAPTIVE, "ADAPTIVE", 0, "Adaptive", ""}, */
1184 {0, NULL, 0, NULL, NULL}
1187 srna = RNA_def_struct(brna, "MaterialVolume", NULL);
1188 RNA_def_struct_sdna(srna, "VolumeSettings");
1189 RNA_def_struct_nested(brna, srna, "Material");
1190 RNA_def_struct_ui_text(srna, "Material Volume", "Volume rendering settings for a Material datablock");
1192 prop = RNA_def_property(srna, "step_method", PROP_ENUM, PROP_NONE);
1193 RNA_def_property_enum_sdna(prop, NULL, "stepsize_type");
1194 RNA_def_property_enum_items(prop, prop_stepsize_items);
1195 RNA_def_property_ui_text(prop, "Step Calculation", "Method of calculating the steps through the volume");
1196 RNA_def_property_update(prop, 0, "rna_Material_update");
1198 prop = RNA_def_property(srna, "step_size", PROP_FLOAT, PROP_NONE);
1199 RNA_def_property_float_sdna(prop, NULL, "stepsize");
1200 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1201 RNA_def_property_ui_range(prop, 0.001f, 1.0f, 1, 3);
1202 RNA_def_property_ui_text(prop, "Step Size", "Distance between subsequent volume depth samples");
1203 RNA_def_property_update(prop, 0, "rna_Material_update");
1205 prop = RNA_def_property(srna, "light_method", PROP_ENUM, PROP_NONE);
1206 RNA_def_property_enum_sdna(prop, NULL, "shade_type");
1207 RNA_def_property_enum_items(prop, prop_lighting_items);
1208 RNA_def_property_ui_text(prop, "Lighting Mode",
1209 "Method of shading, attenuating, and scattering light through the volume");
1210 RNA_def_property_update(prop, 0, "rna_Material_update");
1212 prop = RNA_def_property(srna, "use_external_shadows", PROP_BOOLEAN, PROP_NONE);
1213 RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_RECV_EXT_SHADOW); /* use bitflags */
1214 RNA_def_property_ui_text(prop, "External Shadows", "Receive shadows from sources outside the volume (temporary)");
1215 RNA_def_property_update(prop, 0, "rna_Material_update");
1217 prop = RNA_def_property(srna, "use_light_cache", PROP_BOOLEAN, PROP_NONE);
1218 RNA_def_property_boolean_sdna(prop, NULL, "shadeflag", MA_VOL_PRECACHESHADING); /* use bitflags */
1219 RNA_def_property_ui_text(prop, "Light Cache",
1220 "Pre-calculate the shading information into a voxel grid, "
1221 "speeds up shading at slightly less accuracy");
1222 RNA_def_property_update(prop, 0, "rna_Material_update");
1224 prop = RNA_def_property(srna, "cache_resolution", PROP_INT, PROP_NONE);
1225 RNA_def_property_int_sdna(prop, NULL, "precache_resolution");
1226 RNA_def_property_range(prop, 1, 1024);
1227 RNA_def_property_ui_text(prop, "Resolution",
1228 "Resolution of the voxel grid, low resolutions are faster, "
1229 "high resolutions use more memory");
1230 RNA_def_property_update(prop, 0, "rna_Material_update");
1232 prop = RNA_def_property(srna, "ms_diffusion", PROP_FLOAT, PROP_NONE);
1233 RNA_def_property_float_sdna(prop, NULL, "ms_diff");
1234 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1235 RNA_def_property_ui_text(prop, "Diffusion", "Diffusion factor, the strength of the blurring effect");
1236 RNA_def_property_update(prop, 0, "rna_Material_update");
1238 prop = RNA_def_property(srna, "ms_spread", PROP_FLOAT, PROP_NONE);
1239 RNA_def_property_float_sdna(prop, NULL, "ms_spread");
1240 RNA_def_property_range(prop, 0, FLT_MAX);
1241 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
1242 RNA_def_property_ui_text(prop, "Spread", "Proportional distance over which the light is diffused");
1243 RNA_def_property_update(prop, 0, "rna_Material_update");
1245 prop = RNA_def_property(srna, "ms_intensity", PROP_FLOAT, PROP_NONE);
1246 RNA_def_property_float_sdna(prop, NULL, "ms_intensity");
1247 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1248 RNA_def_property_ui_text(prop, "Intensity", "Multiplier for multiple scattered light energy");
1249 RNA_def_property_update(prop, 0, "rna_Material_update");
1251 prop = RNA_def_property(srna, "depth_threshold", PROP_FLOAT, PROP_NONE);
1252 RNA_def_property_float_sdna(prop, NULL, "depth_cutoff");
1253 RNA_def_property_range(prop, 0.0f, 1.0f);
1254 RNA_def_property_ui_text(prop, "Depth Cutoff",
1255 "Stop ray marching early if transmission drops below this luminance - "
1256 "higher values give speedups in dense volumes at the expense of accuracy");
1257 RNA_def_property_update(prop, 0, "rna_Material_update");
1259 prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_FACTOR);
1260 RNA_def_property_float_sdna(prop, NULL, "density");
1261 RNA_def_property_range(prop, 0.0f, 1.0f);
1262 RNA_def_property_ui_text(prop, "Density", "The base density of the volume");
1263 RNA_def_property_update(prop, 0, "rna_Material_update");
1265 prop = RNA_def_property(srna, "density_scale", PROP_FLOAT, PROP_NONE);
1266 RNA_def_property_float_sdna(prop, NULL, "density_scale");
1267 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1268 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1269 RNA_def_property_ui_text(prop, "Density Scale", "Multiplier for the material's density");
1270 RNA_def_property_update(prop, 0, "rna_Material_update");
1272 prop = RNA_def_property(srna, "scattering", PROP_FLOAT, PROP_NONE);
1273 RNA_def_property_float_sdna(prop, NULL, "scattering");
1274 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1275 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1276 RNA_def_property_ui_text(prop, "Scattering",
1277 "Amount of light that gets scattered out by the volume - "
1278 "the more out-scattering, the shallower the light will penetrate");
1279 RNA_def_property_update(prop, 0, "rna_Material_update");
1281 prop = RNA_def_property(srna, "transmission_color", PROP_FLOAT, PROP_COLOR);
1282 RNA_def_property_float_sdna(prop, NULL, "transmission_col");
1283 RNA_def_property_array(prop, 3);
1284 RNA_def_property_ui_text(prop, "Transmission Color",
1285 "Result color of the volume, after other light has been scattered/absorbed");
1286 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1288 prop = RNA_def_property(srna, "reflection_color", PROP_FLOAT, PROP_COLOR);
1289 RNA_def_property_float_sdna(prop, NULL, "reflection_col");
1290 RNA_def_property_array(prop, 3);
1291 RNA_def_property_ui_text(prop, "Reflection Color",
1292 "Color of light scattered out of the volume (does not affect transmission)");
1293 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1295 prop = RNA_def_property(srna, "reflection", PROP_FLOAT, PROP_NONE);
1296 RNA_def_property_float_sdna(prop, NULL, "reflection");
1297 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1298 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1299 RNA_def_property_ui_text(prop, "Reflection",
1300 "Multiplier to make out-scattered light brighter or darker (non-physically correct)");
1301 RNA_def_property_update(prop, 0, "rna_Material_update");
1303 prop = RNA_def_property(srna, "emission_color", PROP_FLOAT, PROP_COLOR);
1304 RNA_def_property_float_sdna(prop, NULL, "emission_col");
1305 RNA_def_property_array(prop, 3);
1306 RNA_def_property_ui_text(prop, "Emission Color", "Color of emitted light");
1307 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1309 prop = RNA_def_property(srna, "emission", PROP_FLOAT, PROP_NONE);
1310 RNA_def_property_float_sdna(prop, NULL, "emission");
1311 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1312 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1313 RNA_def_property_ui_text(prop, "Emission", "Amount of light that gets emitted by the volume");
1314 RNA_def_property_update(prop, 0, "rna_Material_update");
1316 prop = RNA_def_property(srna, "asymmetry", PROP_FLOAT, PROP_NONE);
1317 RNA_def_property_float_sdna(prop, NULL, "asymmetry");
1318 RNA_def_property_range(prop, -1.0f, 1.0f);
1319 RNA_def_property_ui_text(prop, "Asymmetry",
1320 "Back scattering (-1.0) to Forward scattering (1.0) and the range in between");
1321 RNA_def_property_update(prop, 0, "rna_Material_update");
1325 static void rna_def_material_halo(BlenderRNA *brna)
1330 srna = RNA_def_struct(brna, "MaterialHalo", NULL);
1331 RNA_def_struct_sdna(srna, "Material");
1332 RNA_def_struct_nested(brna, srna, "Material");
1333 RNA_def_struct_ui_text(srna, "Material Halo", "Halo particle effect settings for a Material datablock");
1335 prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
1336 RNA_def_property_float_sdna(prop, NULL, "hasize");
1337 RNA_def_property_range(prop, 0.0f, 100.0f);
1338 RNA_def_property_ui_text(prop, "Size", "Dimension of the halo");
1339 RNA_def_property_update(prop, 0, "rna_Material_update");
1341 prop = RNA_def_property(srna, "hardness", PROP_INT, PROP_NONE);
1342 RNA_def_property_int_sdna(prop, NULL, "har");
1343 RNA_def_property_range(prop, 0, 127);
1344 RNA_def_property_ui_text(prop, "Hardness", "Hardness of the halo");
1345 RNA_def_property_update(prop, 0, "rna_Material_update");
1347 prop = RNA_def_property(srna, "add", PROP_FLOAT, PROP_FACTOR);
1348 RNA_def_property_float_sdna(prop, NULL, "add");
1349 RNA_def_property_range(prop, 0.0f, 1.0f);
1350 RNA_def_property_ui_text(prop, "Add", "Strength of the add effect");
1351 RNA_def_property_update(prop, 0, "rna_Material_update");
1353 prop = RNA_def_property(srna, "ring_count", PROP_INT, PROP_NONE);
1354 RNA_def_property_int_sdna(prop, NULL, "ringc");
1355 RNA_def_property_range(prop, 0, 24);
1356 RNA_def_property_ui_text(prop, "Rings", "Number of rings rendered over the halo");
1357 RNA_def_property_update(prop, 0, "rna_Material_update");
1359 prop = RNA_def_property(srna, "line_count", PROP_INT, PROP_NONE);
1360 RNA_def_property_int_sdna(prop, NULL, "linec");
1361 RNA_def_property_range(prop, 0, 250);
1362 RNA_def_property_ui_text(prop, "Line Number", "Number of star shaped lines rendered over the halo");
1363 RNA_def_property_update(prop, 0, "rna_Material_update");
1365 prop = RNA_def_property(srna, "star_tip_count", PROP_INT, PROP_NONE);
1366 RNA_def_property_int_sdna(prop, NULL, "starc");
1367 RNA_def_property_range(prop, 3, 50);
1368 RNA_def_property_ui_text(prop, "Star Tips", "Number of points on the star shaped halo");
1369 RNA_def_property_update(prop, 0, "rna_Material_update");
1371 prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
1372 RNA_def_property_int_sdna(prop, NULL, "seed1");
1373 RNA_def_property_range(prop, 0, 255);
1374 RNA_def_property_ui_text(prop, "Seed", "Randomize ring dimension and line location");
1375 RNA_def_property_update(prop, 0, "rna_Material_update");
1377 prop = RNA_def_property(srna, "use_flare_mode", PROP_BOOLEAN, PROP_NONE);
1378 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_FLARE); /* use bitflags */
1379 RNA_def_property_ui_text(prop, "Flare", "Render halo as a lens flare");
1380 RNA_def_property_update(prop, 0, "rna_Material_update");
1382 prop = RNA_def_property(srna, "flare_size", PROP_FLOAT, PROP_NONE);
1383 RNA_def_property_float_sdna(prop, NULL, "flaresize");
1384 RNA_def_property_range(prop, 0.1f, 25.0f);
1385 RNA_def_property_ui_text(prop, "Flare Size", "Factor by which the flare is larger than the halo");
1386 RNA_def_property_update(prop, 0, "rna_Material_update");
1388 prop = RNA_def_property(srna, "flare_subflare_size", PROP_FLOAT, PROP_NONE);
1389 RNA_def_property_float_sdna(prop, NULL, "subsize");
1390 RNA_def_property_range(prop, 0.1f, 25.0f);
1391 RNA_def_property_ui_text(prop, "Flare Subsize", "Dimension of the sub-flares, dots and circles");
1392 RNA_def_property_update(prop, 0, "rna_Material_update");
1394 prop = RNA_def_property(srna, "flare_boost", PROP_FLOAT, PROP_NONE);
1395 RNA_def_property_float_sdna(prop, NULL, "flareboost");
1396 RNA_def_property_range(prop, 0.1f, 10.0f);
1397 RNA_def_property_ui_text(prop, "Flare Boost", "Give the flare extra strength");
1398 RNA_def_property_update(prop, 0, "rna_Material_update");
1400 prop = RNA_def_property(srna, "flare_seed", PROP_INT, PROP_NONE);
1401 RNA_def_property_int_sdna(prop, NULL, "seed2");
1402 RNA_def_property_range(prop, 0, 255);
1403 RNA_def_property_ui_text(prop, "Flare Seed", "Offset in the flare seed table");
1404 RNA_def_property_update(prop, 0, "rna_Material_update");
1406 prop = RNA_def_property(srna, "flare_subflare_count", PROP_INT, PROP_NONE);
1407 RNA_def_property_int_sdna(prop, NULL, "flarec");
1408 RNA_def_property_range(prop, 1, 32);
1409 RNA_def_property_ui_text(prop, "Flares Sub", "Number of sub-flares");
1410 RNA_def_property_update(prop, 0, "rna_Material_update");
1412 prop = RNA_def_property(srna, "use_ring", PROP_BOOLEAN, PROP_NONE);
1413 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_RINGS);
1414 RNA_def_property_ui_text(prop, "Rings", "Render rings over halo");
1415 RNA_def_property_update(prop, 0, "rna_Material_update");
1417 prop = RNA_def_property(srna, "use_lines", PROP_BOOLEAN, PROP_NONE);
1418 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_LINES);
1419 RNA_def_property_ui_text(prop, "Lines", "Render star shaped lines over halo");
1420 RNA_def_property_update(prop, 0, "rna_Material_update");
1422 prop = RNA_def_property(srna, "use_star", PROP_BOOLEAN, PROP_NONE);
1423 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STAR);
1424 RNA_def_property_ui_text(prop, "Star", "Render halo as a star");
1425 RNA_def_property_update(prop, 0, "rna_Material_update");
1427 prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE);
1428 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALOTEX);
1429 RNA_def_property_ui_text(prop, "Texture", "Give halo a texture");
1430 RNA_def_property_update(prop, 0, "rna_Material_update");
1432 prop = RNA_def_property(srna, "use_vertex_normal", PROP_BOOLEAN, PROP_NONE);
1433 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALOPUNO);
1434 RNA_def_property_ui_text(prop, "Vertex Normal", "Use the vertex normal to specify the dimension of the halo");
1435 RNA_def_property_update(prop, 0, "rna_Material_update");
1437 prop = RNA_def_property(srna, "use_extreme_alpha", PROP_BOOLEAN, PROP_NONE);
1438 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_XALPHA);
1439 RNA_def_property_ui_text(prop, "Extreme Alpha", "Use extreme alpha");
1440 RNA_def_property_update(prop, 0, "rna_Material_update");
1442 prop = RNA_def_property(srna, "use_shaded", PROP_BOOLEAN, PROP_NONE);
1443 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_SHADE);
1444 RNA_def_property_ui_text(prop, "Shaded", "Let halo receive light and shadows from external objects");
1445 RNA_def_property_update(prop, 0, "rna_Material_update");
1447 prop = RNA_def_property(srna, "use_soft", PROP_BOOLEAN, PROP_NONE);
1448 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_HALO_SOFT);
1449 RNA_def_property_ui_text(prop, "Soft", "Soften the edges of halos at intersections with other geometry");
1450 RNA_def_property_update(prop, 0, "rna_Material_update");
1453 static void rna_def_material_sss(BlenderRNA *brna)
1458 srna = RNA_def_struct(brna, "MaterialSubsurfaceScattering", NULL);
1459 RNA_def_struct_sdna(srna, "Material");
1460 RNA_def_struct_nested(brna, srna, "Material");
1461 RNA_def_struct_ui_text(srna, "Material Subsurface Scattering",
1462 "Diffuse subsurface scattering settings for a Material datablock");
1464 prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_COLOR | PROP_UNIT_LENGTH);
1465 RNA_def_property_float_sdna(prop, NULL, "sss_radius");
1466 RNA_def_property_range(prop, 0.001, FLT_MAX);
1467 RNA_def_property_ui_range(prop, 0.001, 10000, 1, 3);
1468 RNA_def_property_ui_text(prop, "Radius", "Mean red/green/blue scattering path length");
1469 RNA_def_property_update(prop, 0, "rna_Material_update");
1471 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1472 RNA_def_property_float_sdna(prop, NULL, "sss_col");
1473 RNA_def_property_ui_text(prop, "Color", "Scattering color");
1474 RNA_def_property_update(prop, 0, "rna_Material_update");
1476 prop = RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE);
1477 RNA_def_property_float_sdna(prop, NULL, "sss_error");
1478 RNA_def_property_ui_range(prop, 0.0001, 10, 1, 3);
1479 RNA_def_property_ui_text(prop, "Error Tolerance", "Error tolerance (low values are slower and higher quality)");
1480 RNA_def_property_update(prop, 0, "rna_Material_update");
1482 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
1483 RNA_def_property_float_sdna(prop, NULL, "sss_scale");
1484 RNA_def_property_ui_range(prop, 0.001, 1000, 1, 3);
1485 RNA_def_property_ui_text(prop, "Scale", "Object scale factor");
1486 RNA_def_property_update(prop, 0, "rna_Material_update");
1488 prop = RNA_def_property(srna, "ior", PROP_FLOAT, PROP_NONE);
1489 RNA_def_property_float_sdna(prop, NULL, "sss_ior");
1490 RNA_def_property_ui_range(prop, 0.1, 2, 1, 3);
1491 RNA_def_property_ui_text(prop, "IOR", "Index of refraction (higher values are denser)");
1492 RNA_def_property_update(prop, 0, "rna_Material_update");
1494 prop = RNA_def_property(srna, "color_factor", PROP_FLOAT, PROP_FACTOR);
1495 RNA_def_property_float_sdna(prop, NULL, "sss_colfac");
1496 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
1497 RNA_def_property_ui_text(prop, "Color Factor", "Blend factor for SSS colors");
1498 RNA_def_property_update(prop, 0, "rna_Material_update");
1500 prop = RNA_def_property(srna, "texture_factor", PROP_FLOAT, PROP_FACTOR);
1501 RNA_def_property_float_sdna(prop, NULL, "sss_texfac");
1502 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
1503 RNA_def_property_ui_text(prop, "Texture Factor", "Texture scattering blend factor");
1504 RNA_def_property_update(prop, 0, "rna_Material_update");
1506 prop = RNA_def_property(srna, "front", PROP_FLOAT, PROP_NONE);
1507 RNA_def_property_float_sdna(prop, NULL, "sss_front");
1508 RNA_def_property_range(prop, 0, 2);
1509 RNA_def_property_ui_text(prop, "Front", "Front scattering weight");
1510 RNA_def_property_update(prop, 0, "rna_Material_update");
1512 prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE);
1513 RNA_def_property_float_sdna(prop, NULL, "sss_back");
1514 RNA_def_property_range(prop, 0, 10);
1515 RNA_def_property_ui_text(prop, "Back", "Back scattering weight");
1516 RNA_def_property_update(prop, 0, "rna_Material_update");
1518 prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
1519 RNA_def_property_boolean_sdna(prop, NULL, "sss_flag", MA_DIFF_SSS);
1520 RNA_def_property_ui_text(prop, "Enabled", "Enable diffuse subsurface scatting effects in a material");
1521 RNA_def_property_update(prop, 0, "rna_Material_update");
1524 static void rna_def_material_specularity(StructRNA *srna)
1528 static EnumPropertyItem prop_specular_shader_items[] = {
1529 {MA_SPEC_COOKTORR, "COOKTORR", 0, "CookTorr", "Use a Cook-Torrance shader"},
1530 {MA_SPEC_PHONG, "PHONG", 0, "Phong", "Use a Phong shader"},
1531 {MA_SPEC_BLINN, "BLINN", 0, "Blinn", "Use a Blinn shader"},
1532 {MA_SPEC_TOON, "TOON", 0, "Toon", "Use a toon shader"},
1533 {MA_SPEC_WARDISO, "WARDISO", 0, "WardIso", "Use a Ward anisotropic shader"},
1534 {0, NULL, 0, NULL, NULL}
1537 prop = RNA_def_property(srna, "specular_shader", PROP_ENUM, PROP_NONE);
1538 RNA_def_property_enum_sdna(prop, NULL, "spec_shader");
1539 RNA_def_property_enum_items(prop, prop_specular_shader_items);
1540 RNA_def_property_ui_text(prop, "Specular Shader Model", "");
1541 RNA_def_property_update(prop, 0, "rna_Material_update");
1543 prop = RNA_def_property(srna, "specular_intensity", PROP_FLOAT, PROP_FACTOR);
1544 RNA_def_property_float_sdna(prop, NULL, "spec");
1545 RNA_def_property_range(prop, 0, 1);
1546 RNA_def_property_ui_text(prop, "Specular Intensity", "How intense (bright) the specular reflection is");
1547 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1549 /* NOTE: "har", "param", etc are used for multiple purposes depending on
1550 * settings. This should be fixed in DNA once, for RNA we just expose them
1551 * multiple times, which may give somewhat strange changes in the outliner,
1552 * but in the UI they are never visible at the same time. */
1554 prop = RNA_def_property(srna, "specular_hardness", PROP_INT, PROP_NONE);
1555 RNA_def_property_int_sdna(prop, NULL, "har");
1556 RNA_def_property_range(prop, 1, 511);
1557 RNA_def_property_ui_text(prop, "Specular Hardness", "How hard (sharp) the specular reflection is");
1558 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1560 prop = RNA_def_property(srna, "specular_ior", PROP_FLOAT, PROP_NONE);
1561 RNA_def_property_float_sdna(prop, NULL, "refrac");
1562 RNA_def_property_range(prop, 1, 10);
1563 RNA_def_property_ui_text(prop, "Specular IOR", "Specular index of refraction");
1564 RNA_def_property_update(prop, 0, "rna_Material_update");
1566 prop = RNA_def_property(srna, "specular_toon_size", PROP_FLOAT, PROP_NONE);
1567 RNA_def_property_float_sdna(prop, NULL, "param[2]");
1568 RNA_def_property_range(prop, 0.0f, 1.53f);
1569 RNA_def_property_ui_text(prop, "Specular Toon Size", "Size of specular toon area");
1570 RNA_def_property_update(prop, 0, "rna_Material_update");
1572 prop = RNA_def_property(srna, "specular_toon_smooth", PROP_FLOAT, PROP_FACTOR);
1573 RNA_def_property_float_sdna(prop, NULL, "param[3]");
1574 RNA_def_property_range(prop, 0.0f, 1.0f);
1575 RNA_def_property_ui_text(prop, "Specular Toon Smooth", "Smoothness of specular toon area");
1576 RNA_def_property_update(prop, 0, "rna_Material_update");
1578 prop = RNA_def_property(srna, "specular_slope", PROP_FLOAT, PROP_FACTOR);
1579 RNA_def_property_float_sdna(prop, NULL, "rms");
1580 RNA_def_property_range(prop, 0, 0.4);
1581 RNA_def_property_ui_text(prop, "Specular Slope", "The standard deviation of surface slope");
1582 RNA_def_property_update(prop, 0, "rna_Material_update");
1585 static void rna_def_material_strand(BlenderRNA *brna)
1590 srna = RNA_def_struct(brna, "MaterialStrand", NULL);
1591 RNA_def_struct_sdna(srna, "Material");
1592 RNA_def_struct_nested(brna, srna, "Material");
1593 RNA_def_struct_ui_text(srna, "Material Strand", "Strand settings for a Material datablock");
1595 prop = RNA_def_property(srna, "use_tangent_shading", PROP_BOOLEAN, PROP_NONE);
1596 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_STR);
1597 RNA_def_property_ui_text(prop, "Tangent Shading", "Use direction of strands as normal for tangent-shading");
1598 RNA_def_property_update(prop, 0, "rna_Material_update");
1600 /* this flag is only set when rendering, not to be edited manually */
1601 prop = RNA_def_property(srna, "use_surface_diffuse", PROP_BOOLEAN, PROP_NONE);
1602 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_SURFDIFF);
1603 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1604 RNA_def_property_ui_text(prop, "Surface Diffuse", "Make diffuse shading more similar to shading the surface");
1605 RNA_def_property_update(prop, 0, "rna_Material_update");
1607 prop = RNA_def_property(srna, "blend_distance", PROP_FLOAT, PROP_DISTANCE);
1608 RNA_def_property_float_sdna(prop, NULL, "strand_surfnor");
1609 RNA_def_property_range(prop, 0, 10);
1610 RNA_def_property_ui_text(prop, "Blend Distance", "Worldspace distance over which to blend in the surface normal");
1611 RNA_def_property_update(prop, 0, "rna_Material_update");
1613 prop = RNA_def_property(srna, "use_blender_units", PROP_BOOLEAN, PROP_NONE);
1614 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_STR_B_UNITS);
1615 RNA_def_property_ui_text(prop, "Blender Units", "Use Blender units for widths instead of pixels");
1616 RNA_def_property_update(prop, 0, "rna_Material_update");
1618 prop = RNA_def_property(srna, "root_size", PROP_FLOAT, PROP_UNSIGNED);
1619 RNA_def_property_float_sdna(prop, NULL, "strand_sta");
1620 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_start_size_range");
1621 RNA_def_property_ui_range(prop, 0, 10.0f, 10, 5);
1622 RNA_def_property_ui_text(prop, "Root Size", "Start size of strands in pixels or Blender units");
1623 RNA_def_property_update(prop, 0, "rna_Material_update");
1625 prop = RNA_def_property(srna, "tip_size", PROP_FLOAT, PROP_UNSIGNED);
1626 RNA_def_property_float_sdna(prop, NULL, "strand_end");
1627 RNA_def_property_ui_range(prop, 0, 10.0f, 10, 5);
1628 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_MaterialStrand_end_size_range");
1629 RNA_def_property_ui_text(prop, "Tip Size", "End size of strands in pixels or Blender units");
1630 RNA_def_property_update(prop, 0, "rna_Material_update");
1632 prop = RNA_def_property(srna, "size_min", PROP_FLOAT, PROP_UNSIGNED);
1633 RNA_def_property_float_sdna(prop, NULL, "strand_min");
1634 RNA_def_property_range(prop, 0.001, 10);
1635 RNA_def_property_ui_text(prop, "Minimum Size", "Minimum size of strands in pixels");
1636 RNA_def_property_update(prop, 0, "rna_Material_update");
1638 prop = RNA_def_property(srna, "shape", PROP_FLOAT, PROP_NONE);
1639 RNA_def_property_float_sdna(prop, NULL, "strand_ease");
1640 RNA_def_property_range(prop, -0.9, 0.9);
1641 RNA_def_property_ui_text(prop, "Shape", "Positive values make strands rounder, negative ones make strands spiky");
1642 RNA_def_property_update(prop, 0, "rna_Material_update");
1644 prop = RNA_def_property(srna, "width_fade", PROP_FLOAT, PROP_NONE);
1645 RNA_def_property_float_sdna(prop, NULL, "strand_widthfade");
1646 RNA_def_property_range(prop, 0, 2);
1647 RNA_def_property_ui_text(prop, "Width Fade", "Transparency along the width of the strand");
1648 RNA_def_property_update(prop, 0, "rna_Material_update");
1650 prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
1651 RNA_def_property_string_sdna(prop, NULL, "strand_uvname");
1652 RNA_def_property_ui_text(prop, "UV Map", "Name of UV map to override");
1653 RNA_def_property_update(prop, 0, "rna_Material_update");
1656 static void rna_def_material_physics(BlenderRNA *brna)
1661 srna = RNA_def_struct(brna, "MaterialPhysics", NULL);
1662 RNA_def_struct_sdna(srna, "Material");
1663 RNA_def_struct_nested(brna, srna, "Material");
1664 RNA_def_struct_ui_text(srna, "Material Physics", "Physics settings for a Material datablock");
1666 prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE);
1667 RNA_def_property_float_sdna(prop, NULL, "friction");
1668 RNA_def_property_range(prop, 0, 100);
1669 RNA_def_property_ui_text(prop, "Friction", "Coulomb friction coefficient, when inside the physics distance area");
1671 prop = RNA_def_property(srna, "elasticity", PROP_FLOAT, PROP_NONE);
1672 RNA_def_property_float_sdna(prop, NULL, "reflect");
1673 RNA_def_property_range(prop, 0, 1);
1674 RNA_def_property_ui_text(prop, "Elasticity", "Elasticity of collisions");
1676 /* FH/Force Field Settings */
1677 prop = RNA_def_property(srna, "use_fh_normal", PROP_BOOLEAN, PROP_NONE);
1678 RNA_def_property_boolean_sdna(prop, NULL, "dynamode", MA_FH_NOR);
1679 RNA_def_property_ui_text(prop, "Align to Normal",
1680 "Align dynamic game objects along the surface normal, "
1681 "when inside the physics distance area");
1683 prop = RNA_def_property(srna, "fh_force", PROP_FLOAT, PROP_NONE);
1684 RNA_def_property_float_sdna(prop, NULL, "fh");
1685 RNA_def_property_range(prop, 0, 1);
1686 RNA_def_property_ui_range(prop, 0.0, 1.0, 10, 2);
1687 RNA_def_property_ui_text(prop, "Force", "Upward spring force, when inside the physics distance area");
1689 prop = RNA_def_property(srna, "fh_distance", PROP_FLOAT, PROP_NONE);
1690 RNA_def_property_float_sdna(prop, NULL, "fhdist");
1691 RNA_def_property_range(prop, 0, 20);
1692 RNA_def_property_ui_text(prop, "Distance", "Distance of the physics area");
1694 prop = RNA_def_property(srna, "fh_damping", PROP_FLOAT, PROP_NONE);
1695 RNA_def_property_float_sdna(prop, NULL, "xyfrict");
1696 RNA_def_property_range(prop, 0, 1);
1697 RNA_def_property_ui_text(prop, "Damping", "Damping of the spring force, when inside the physics distance area");
1700 void RNA_def_material(BlenderRNA *brna)
1705 static EnumPropertyItem prop_type_items[] = {
1706 {MA_TYPE_SURFACE, "SURFACE", 0, "Surface", "Render object as a surface"},
1707 {MA_TYPE_WIRE, "WIRE", 0, "Wire", "Render the edges of faces as wires (not supported in raytracing)"},
1708 {MA_TYPE_VOLUME, "VOLUME", 0, "Volume", "Render object as a volume"},
1709 {MA_TYPE_HALO, "HALO", 0, "Halo", "Render object as halo particles"},
1710 {0, NULL, 0, NULL, NULL}
1712 static EnumPropertyItem transparency_items[] = {
1713 {0, "MASK", 0, "Mask", "Mask the background"},
1714 {MA_ZTRANSP, "Z_TRANSPARENCY", 0, "Z Transparency", "Use alpha buffer for transparent faces"},
1715 {MA_RAYTRANSP, "RAYTRACE", 0, "Raytrace", "Use raytracing for transparent refraction rendering"},
1716 {0, NULL, 0, NULL, NULL}
1719 /* Render Preview Types */
1720 static EnumPropertyItem preview_type_items[] = {
1721 {MA_FLAT, "FLAT", ICON_MATPLANE, "Flat", "Flat XY plane"},
1722 {MA_SPHERE, "SPHERE", ICON_MATSPHERE, "Sphere", "Sphere"},
1723 {MA_CUBE, "CUBE", ICON_MATCUBE, "Cube", "Cube"},
1724 {MA_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Monkey"},
1725 {MA_HAIR, "HAIR", ICON_HAIR, "Hair", "Hair strands"},
1726 {MA_SPHERE_A, "SPHERE_A", ICON_MAT_SPHERE_SKY, "World Sphere", "Large sphere with sky"},
1727 {0, NULL, 0, NULL, NULL}
1730 static EnumPropertyItem prop_shadows_only_items[] = {
1731 {MA_SO_OLD, "SHADOW_ONLY_OLD", 0, "Shadow and Distance", "Old shadow only method"},
1732 {MA_SO_SHADOW, "SHADOW_ONLY", 0, "Shadow Only", "Improved shadow only method"},
1733 {MA_SO_SHADED, "SHADOW_ONLY_SHADED", 0, "Shadow and Shading",
1734 "Improved shadow only method which also renders lightless areas as shadows"},
1735 {0, NULL, 0, NULL, NULL}
1738 srna = RNA_def_struct(brna, "Material", "ID");
1739 RNA_def_struct_ui_text(srna, "Material",
1740 "Material datablock to define the appearance of geometric objects for rendering");
1741 RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
1743 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1744 RNA_def_property_enum_sdna(prop, NULL, "material_type");
1745 RNA_def_property_enum_items(prop, prop_type_items);
1746 RNA_def_property_ui_text(prop, "Type", "Material type defining how the object is rendered");
1747 RNA_def_property_enum_funcs(prop, NULL, "rna_Material_type_set", NULL);
1748 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1750 prop = RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE);
1751 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRANSP);
1752 RNA_def_property_ui_text(prop, "Transparency", "Render material as transparent");
1753 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1755 prop = RNA_def_property(srna, "transparency_method", PROP_ENUM, PROP_NONE);
1756 RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode");
1757 RNA_def_property_enum_items(prop, transparency_items);
1758 RNA_def_property_ui_text(prop, "Transparency Method", "Method to use for rendering transparency");
1759 RNA_def_property_update(prop, 0, "rna_Material_update");
1761 /* For Preview Render */
1762 prop = RNA_def_property(srna, "preview_render_type", PROP_ENUM, PROP_NONE);
1763 RNA_def_property_enum_sdna(prop, NULL, "pr_type");
1764 RNA_def_property_enum_items(prop, preview_type_items);
1765 RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render");
1766 RNA_def_property_update(prop, 0, "rna_Material_update_previews");
1768 prop = RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR);
1769 RNA_def_property_float_sdna(prop, NULL, "amb");
1770 RNA_def_property_range(prop, 0, 1);
1771 RNA_def_property_ui_text(prop, "Ambient", "Amount of global ambient color the material receives");
1772 RNA_def_property_update(prop, 0, "rna_Material_update");
1774 prop = RNA_def_property(srna, "emit", PROP_FLOAT, PROP_NONE);
1775 RNA_def_property_range(prop, 0, FLT_MAX);
1776 RNA_def_property_ui_range(prop, 0, 2.0f, 1, 2);
1777 RNA_def_property_ui_text(prop, "Emit", "Amount of light to emit");
1778 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1780 prop = RNA_def_property(srna, "translucency", PROP_FLOAT, PROP_FACTOR);
1781 RNA_def_property_range(prop, 0, 1);
1782 RNA_def_property_ui_text(prop, "Translucency", "Amount of diffuse shading on the back side");
1783 RNA_def_property_update(prop, 0, "rna_Material_update");
1785 prop = RNA_def_property(srna, "use_cubic", PROP_BOOLEAN, PROP_NONE);
1786 RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_CUBIC);
1787 RNA_def_property_ui_text(prop, "Cubic Interpolation",
1788 "Use cubic interpolation for diffuse values, for smoother transitions");
1789 RNA_def_property_update(prop, 0, "rna_Material_update");
1791 prop = RNA_def_property(srna, "use_object_color", PROP_BOOLEAN, PROP_NONE);
1792 RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_OBCOLOR);
1793 RNA_def_property_ui_text(prop, "Object Color", "Modulate the result with a per-object color");
1794 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1796 prop = RNA_def_property(srna, "shadow_ray_bias", PROP_FLOAT, PROP_NONE);
1797 RNA_def_property_float_sdna(prop, NULL, "sbias");
1798 RNA_def_property_range(prop, 0, 0.25);
1799 RNA_def_property_ui_text(prop, "Shadow Ray Bias",
1800 "Shadow raytracing bias to prevent terminator problems on shadow boundary");
1802 prop = RNA_def_property(srna, "shadow_buffer_bias", PROP_FLOAT, PROP_NONE);
1803 RNA_def_property_float_sdna(prop, NULL, "lbias");
1804 RNA_def_property_range(prop, 0, 10);
1805 RNA_def_property_ui_text(prop, "Shadow Buffer Bias", "Factor to multiply shadow buffer bias with (0 is ignore)");
1807 prop = RNA_def_property(srna, "shadow_cast_alpha", PROP_FLOAT, PROP_FACTOR);
1808 RNA_def_property_float_sdna(prop, NULL, "shad_alpha");
1809 RNA_def_property_range(prop, 0.001, 1);
1810 RNA_def_property_ui_text(prop, "Shadow Casting Alpha",
1811 "Shadow casting alpha, in use for Irregular and Deep shadow buffer");
1812 RNA_def_property_update(prop, 0, "rna_Material_update");
1814 prop = RNA_def_property(srna, "light_group", PROP_POINTER, PROP_NONE);
1815 RNA_def_property_pointer_sdna(prop, NULL, "group");
1816 RNA_def_property_struct_type(prop, "Group");
1817 RNA_def_property_flag(prop, PROP_EDITABLE);
1818 RNA_def_property_ui_text(prop, "Light Group", "Limit lighting to lamps in this Group");
1819 RNA_def_property_update(prop, 0, "rna_Material_update");
1821 prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
1822 RNA_def_property_int_sdna(prop, NULL, "index");
1823 RNA_def_property_ui_text(prop, "Pass Index", "Index number for the IndexMA render pass");
1824 RNA_def_property_update(prop, NC_OBJECT, "rna_Material_update");
1828 prop = RNA_def_property(srna, "use_light_group_exclusive", PROP_BOOLEAN, PROP_NONE);
1829 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_GROUP_NOLAY);
1830 RNA_def_property_ui_text(prop, "Light Group Exclusive",
1831 "Material uses the light group exclusively - these lamps are excluded "
1832 "from other scene lighting");
1833 RNA_def_property_update(prop, 0, "rna_Material_update");
1835 prop = RNA_def_property(srna, "use_light_group_local", PROP_BOOLEAN, PROP_NONE);
1836 RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_GROUP_LOCAL);
1837 RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, material uses local light group with the same name");
1838 RNA_def_property_update(prop, 0, "rna_Material_update");
1840 prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE);
1841 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRACEBLE);
1842 RNA_def_property_ui_text(prop, "Traceable",
1843 "Include this material and geometry that uses it in raytracing calculations");
1844 RNA_def_property_update(prop, 0, "rna_Material_update");
1846 prop = RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE);
1847 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW);
1848 RNA_def_property_ui_text(prop, "Shadows", "Allow this material to receive shadows");
1849 RNA_def_property_update(prop, 0, "rna_Material_update");
1851 prop = RNA_def_property(srna, "use_shadeless", PROP_BOOLEAN, PROP_NONE);
1852 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHLESS);
1853 RNA_def_property_ui_text(prop, "Shadeless", "Make this material insensitive to light or shadow");
1854 RNA_def_property_update(prop, 0, "rna_Material_draw_update");
1856 prop = RNA_def_property(srna, "use_vertex_color_light", PROP_BOOLEAN, PROP_NONE);
1857 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOL);
1858 RNA_def_property_ui_text(prop, "Vertex Color Light", "Add vertex colors as additional lighting");
1859 RNA_def_property_update(prop, 0, "rna_Material_update");
1861 prop = RNA_def_property(srna, "use_vertex_color_paint", PROP_BOOLEAN, PROP_NONE);
1862 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_VERTEXCOLP);
1863 RNA_def_property_ui_text(prop, "Vertex Color Paint",
1864 "Replace object base color with vertex colors (multiply with "
1865 "'texture face' face assigned textures)");
1866 RNA_def_property_update(prop, 0, "rna_Material_update");
1868 prop = RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE);
1869 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ZINV);
1870 RNA_def_property_ui_text(prop, "Invert Z Depth",
1871 "Render material's faces with an inverted Z buffer (scanline only)");
1872 RNA_def_property_update(prop, 0, "rna_Material_update");
1874 prop = RNA_def_property(srna, "offset_z", PROP_FLOAT, PROP_NONE);
1875 RNA_def_property_float_sdna(prop, NULL, "zoffs");
1876 RNA_def_property_ui_text(prop, "Z Offset", "Give faces an artificial offset in the Z buffer for Z transparency");
1877 RNA_def_property_update(prop, 0, "rna_Material_update");
1879 prop = RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE);
1880 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ENV);
1881 RNA_def_property_ui_text(prop, "Sky",
1882 "Render this material with zero alpha, with sky background in place (scanline only)");
1883 RNA_def_property_update(prop, 0, "rna_Material_update");
1885 prop = RNA_def_property(srna, "use_only_shadow", PROP_BOOLEAN, PROP_NONE);
1886 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYSHADOW);
1887 RNA_def_property_ui_text(prop, "Only Shadow",
1888 "Render shadows as the material's alpha value, making the material "
1889 "transparent except for shadowed areas");
1890 RNA_def_property_update(prop, 0, "rna_Material_update");
1892 prop = RNA_def_property(srna, "shadow_only_type", PROP_ENUM, PROP_NONE);
1893 RNA_def_property_enum_bitflag_sdna(prop, NULL, "shadowonly_flag");
1894 RNA_def_property_enum_items(prop, prop_shadows_only_items);
1895 RNA_def_property_ui_text(prop, "Shadow Type", "How to draw shadows");
1896 RNA_def_property_update(prop, 0, "rna_Material_update");
1898 prop = RNA_def_property(srna, "use_face_texture", PROP_BOOLEAN, PROP_NONE);
1899 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FACETEXTURE);
1900 RNA_def_property_ui_text(prop, "Face Textures",
1901 "Replace the object's base color with color from UV map image textures");
1902 RNA_def_property_update(prop, 0, "rna_Material_update");
1904 prop = RNA_def_property(srna, "use_face_texture_alpha", PROP_BOOLEAN, PROP_NONE);
1905 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FACETEXTURE_ALPHA);
1906 RNA_def_property_ui_text(prop, "Face Textures Alpha",
1907 "Replace the object's base alpha value with alpha from UV map image textures");
1908 RNA_def_property_update(prop, 0, "rna_Material_update");
1910 prop = RNA_def_property(srna, "use_cast_shadows", PROP_BOOLEAN, PROP_NONE);
1911 RNA_def_property_boolean_sdna(prop, NULL, "mode2", MA_CASTSHADOW);
1912 RNA_def_property_ui_text(prop, "Cast Shadows",
1913 "Allow this material to cast shadows");
1914 RNA_def_property_update(prop, 0, "rna_Material_update");
1916 prop = RNA_def_property(srna, "use_cast_shadows_only", PROP_BOOLEAN, PROP_NONE);
1917 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_ONLYCAST);
1918 RNA_def_property_ui_text(prop, "Cast Shadows Only",
1919 "Make objects with this material appear invisible (not rendered), only casting shadows");
1920 RNA_def_property_update(prop, 0, "rna_Material_update");
1922 prop = RNA_def_property(srna, "use_mist", PROP_BOOLEAN, PROP_NONE);
1923 RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", MA_NOMIST);
1924 RNA_def_property_ui_text(prop, "Use Mist", "Use mist with this material (in world settings)");
1925 RNA_def_property_update(prop, 0, "rna_Material_update");
1927 prop = RNA_def_property(srna, "use_transparent_shadows", PROP_BOOLEAN, PROP_NONE);
1928 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADOW_TRA);
1929 RNA_def_property_ui_text(prop, "Receive Transparent Shadows",
1930 "Allow this object to receive transparent shadows cast through other objects");
1931 RNA_def_property_update(prop, 0, "rna_Material_update");
1933 prop = RNA_def_property(srna, "use_ray_shadow_bias", PROP_BOOLEAN, PROP_NONE);
1934 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_RAYBIAS);
1935 RNA_def_property_ui_text(prop, "Ray Shadow Bias",
1936 "Prevent raytraced shadow errors on surfaces with smooth shaded normals "
1937 "(terminator problem)");
1938 RNA_def_property_update(prop, 0, "rna_Material_update");
1940 prop = RNA_def_property(srna, "use_full_oversampling", PROP_BOOLEAN, PROP_NONE);
1941 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_FULL_OSA);
1942 RNA_def_property_ui_text(prop, "Full Oversampling",
1943 "Force this material to render full shading/textures for all anti-aliasing samples");
1944 RNA_def_property_update(prop, 0, "rna_Material_update");
1946 prop = RNA_def_property(srna, "use_cast_buffer_shadows", PROP_BOOLEAN, PROP_NONE);
1947 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADBUF);
1948 RNA_def_property_ui_text(prop, "Cast Buffer Shadows",
1949 "Allow this material to cast shadows from shadow buffer lamps");
1950 RNA_def_property_update(prop, 0, "rna_Material_update");
1952 prop = RNA_def_property(srna, "use_cast_approximate", PROP_BOOLEAN, PROP_NONE);
1953 RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_APPROX_OCCLUSION);
1954 RNA_def_property_ui_text(prop, "Cast Approximate",
1955 "Allow this material to cast shadows when using approximate ambient occlusion");
1956 RNA_def_property_update(prop, 0, "rna_Material_update");
1958 prop = RNA_def_property(srna, "use_tangent_shading", PROP_BOOLEAN, PROP_NONE);
1959 RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_V);
1960 RNA_def_property_ui_text(prop, "Tangent Shading",
1961 "Use the material's tangent vector instead of the normal for shading "
1962 "- for anisotropic shading effects");
1963 RNA_def_property_update(prop, 0, "rna_Material_update");
1965 prop = RNA_def_property(srna, "use_uv_project", PROP_BOOLEAN, PROP_NONE);
1966 RNA_def_property_boolean_sdna(prop, NULL, "mapflag", MA_MAPFLAG_UVPROJECT);
1967 RNA_def_property_ui_text(prop, "UV Project",
1968 "Use to ensure UV interpolation is correct for camera projections (use with UV project modifier)");
1969 RNA_def_property_update(prop, 0, "rna_Material_update");
1971 /* nested structs */
1972 prop = RNA_def_property(srna, "raytrace_mirror", PROP_POINTER, PROP_NONE);
1973 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1974 RNA_def_property_struct_type(prop, "MaterialRaytraceMirror");
1975 RNA_def_property_pointer_funcs(prop, "rna_Material_mirror_get", NULL, NULL, NULL);
1976 RNA_def_property_ui_text(prop, "Raytrace Mirror", "Raytraced reflection settings for the material");
1978 prop = RNA_def_property(srna, "raytrace_transparency", PROP_POINTER, PROP_NONE);
1979 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1980 RNA_def_property_struct_type(prop, "MaterialRaytraceTransparency");
1981 RNA_def_property_pointer_funcs(prop, "rna_Material_transp_get", NULL, NULL, NULL);
1982 RNA_def_property_ui_text(prop, "Raytrace Transparency", "Raytraced transparency settings for the material");
1984 prop = RNA_def_property(srna, "volume", PROP_POINTER, PROP_NONE);
1985 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1986 RNA_def_property_pointer_sdna(prop, NULL, "vol");
1987 RNA_def_property_struct_type(prop, "MaterialVolume");
1988 RNA_def_property_ui_text(prop, "Volume", "Volume settings for the material");
1990 prop = RNA_def_property(srna, "halo", PROP_POINTER, PROP_NONE);
1991 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1992 RNA_def_property_struct_type(prop, "MaterialHalo");
1993 RNA_def_property_pointer_funcs(prop, "rna_Material_halo_get", NULL, NULL, NULL);
1994 RNA_def_property_ui_text(prop, "Halo", "Halo settings for the material");
1996 prop = RNA_def_property(srna, "subsurface_scattering", PROP_POINTER, PROP_NONE);
1997 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1998 RNA_def_property_struct_type(prop, "MaterialSubsurfaceScattering");
1999 RNA_def_property_pointer_funcs(prop, "rna_Material_sss_get", NULL, NULL, NULL);
2000 RNA_def_property_ui_text(prop, "Subsurface Scattering", "Subsurface scattering settings for the material");
2002 prop = RNA_def_property(srna, "strand", PROP_POINTER, PROP_NONE);
2003 RNA_def_property_flag(prop, PROP_NEVER_NULL);
2004 RNA_def_property_struct_type(prop, "MaterialStrand");
2005 RNA_def_property_pointer_funcs(prop, "rna_Material_strand_get", NULL, NULL, NULL);
2006 RNA_def_property_ui_text(prop, "Strand", "Strand settings for the material");
2008 prop = RNA_def_property(srna, "physics", PROP_POINTER, PROP_NONE);
2009 RNA_def_property_flag(prop, PROP_NEVER_NULL);
2010 RNA_def_property_struct_type(prop, "MaterialPhysics");
2011 RNA_def_property_pointer_funcs(prop, "rna_Material_physics_get", NULL, NULL, NULL);
2012 RNA_def_property_ui_text(prop, "Physics", "Game physics settings");
2015 prop = RNA_def_property(srna, "game_settings", PROP_POINTER, PROP_NONE);
2016 RNA_def_property_flag(prop, PROP_NEVER_NULL);
2017 RNA_def_property_pointer_sdna(prop, NULL, "game");
2018 RNA_def_property_struct_type(prop, "MaterialGameSettings");
2019 RNA_def_property_ui_text(prop, "Game Settings", "Game material settings");
2022 prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
2023 RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
2024 RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node based materials");
2026 prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
2027 RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
2028 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2029 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
2030 RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material");
2031 RNA_def_property_update(prop, 0, "rna_Material_use_nodes_update");
2033 prop = RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
2034 RNA_def_property_struct_type(prop, "Material");
2035 RNA_def_property_flag(prop, PROP_EDITABLE);
2036 RNA_def_property_pointer_funcs(prop, "rna_Material_active_node_material_get",
2037 "rna_Material_active_node_material_set", NULL, NULL);
2038 RNA_def_property_ui_text(prop, "Material", "Active node material");
2039 RNA_def_property_update(prop, NC_MATERIAL, NULL);
2042 rna_def_animdata_common(srna);
2043 rna_def_mtex_common(brna, srna, "rna_Material_mtex_begin", "rna_Material_active_texture_get",
2044 "rna_Material_active_texture_set", "rna_Material_active_texture_editable",
2045 "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update");
2047 /* only material has this one */
2048 prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE);
2049 RNA_def_property_boolean_negative_sdna(prop, NULL, "septex", 1);
2050 RNA_def_property_array(prop, 18);
2051 RNA_def_property_ui_text(prop, "Use Textures", "Enable/Disable each texture");
2052 RNA_def_property_update(prop, 0, "rna_Material_update");
2054 rna_def_material_colors(srna);
2055 rna_def_material_diffuse(srna);
2056 rna_def_material_specularity(srna);
2058 /* nested structs */
2059 rna_def_material_raymirror(brna);
2060 rna_def_material_raytra(brna);
2061 rna_def_material_volume(brna);
2062 rna_def_material_halo(brna);
2063 rna_def_material_sss(brna);
2064 rna_def_material_mtex(brna);
2065 rna_def_material_strand(brna);
2066 rna_def_material_physics(brna);
2067 rna_def_material_gamesettings(brna);
2069 RNA_api_material(srna);
2073 static void rna_def_texture_slots(BlenderRNA *brna, PropertyRNA *cprop, const char *structname,
2074 const char *structname_slots)
2081 RNA_def_property_srna(cprop, structname_slots);
2082 srna = RNA_def_struct(brna, structname_slots, NULL);
2083 RNA_def_struct_sdna(srna, "ID");
2084 RNA_def_struct_ui_text(srna, "Texture Slots", "Collection of texture slots");
2087 func = RNA_def_function(srna, "add", "rna_mtex_texture_slots_add");
2088 RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2089 parm = RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
2090 RNA_def_function_return(func, parm);
2092 func = RNA_def_function(srna, "create", "rna_mtex_texture_slots_create");
2093 RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2094 parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to initialize", 0, INT_MAX);
2095 RNA_def_property_flag(parm, PROP_REQUIRED);
2096 parm = RNA_def_pointer(func, "mtex", structname, "", "The newly initialized mtex");
2097 RNA_def_function_return(func, parm);
2099 func = RNA_def_function(srna, "clear", "rna_mtex_texture_slots_clear");
2100 RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_NO_SELF | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
2101 parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Slot index to clear", 0, INT_MAX);
2102 RNA_def_property_flag(parm, PROP_REQUIRED);
2105 void rna_def_mtex_common(BlenderRNA *brna, StructRNA *srna, const char *begin,
2106 const char *activeget, const char *activeset, const char *activeeditable,
2107 const char *structname, const char *structname_slots, const char *update)
2112 prop = RNA_def_property(srna, "texture_slots", PROP_COLLECTION, PROP_NONE);
2113 RNA_def_property_struct_type(prop, structname);
2114 RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end",
2115 "rna_iterator_array_dereference_get", NULL, NULL, NULL, NULL);
2116 RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures");
2117 rna_def_texture_slots(brna, prop, structname, structname_slots);
2119 prop = RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE);
2120 RNA_def_property_struct_type(prop, "Texture");
2121 RNA_def_property_flag(prop, PROP_EDITABLE);
2123 RNA_def_property_editable_func(prop, activeeditable);
2124 RNA_def_property_pointer_funcs(prop, activeget, activeset, NULL, NULL);
2125 RNA_def_property_ui_text(prop, "Active Texture", "Active texture slot being displayed");
2126 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, update);
2128 prop = RNA_def_property(srna, "active_texture_index", PROP_INT, PROP_UNSIGNED);
2129 RNA_def_property_int_sdna(prop, NULL, "texact");
2130 RNA_def_property_range(prop, 0, MAX_MTEX - 1);
2131 RNA_def_property_ui_text(prop, "Active Texture Index", "Index of active texture slot");
2132 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, update);