1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 */
16
17 /** \file
18 * \ingroup RNA
19 */
20
21 #include <float.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 #include "DNA_brush_types.h"
26 #include "DNA_light_types.h"
27 #include "DNA_material_types.h"
28 #include "DNA_node_types.h"
29 #include "DNA_object_types.h"
30 #include "DNA_particle_types.h"
31 #include "DNA_scene_types.h" /* MAXFRAME only */
32 #include "DNA_texture_types.h"
33 #include "DNA_world_types.h"
34
35 #include "BLI_utildefines.h"
36
37 #include "BKE_node.h"
38 #include "BKE_paint.h"
39
40 #include "RNA_define.h"
41 #include "RNA_enum_types.h"
42
43 #include "rna_internal.h"
44
45 #include "WM_api.h"
46 #include "WM_types.h"
47
48 #ifndef RNA_RUNTIME
49 static const EnumPropertyItem texture_filter_items[] = {
50 {TXF_BOX, "BOX", 0, "Box", ""},
51 {TXF_EWA, "EWA", 0, "EWA", ""},
52 {TXF_FELINE, "FELINE", 0, "FELINE", ""},
53 {TXF_AREA, "AREA", 0, "Area", ""},
54 {0, NULL, 0, NULL, NULL},
55 };
56 #endif
57
58 const EnumPropertyItem rna_enum_texture_type_items[] = {
59 {0, "NONE", 0, "None", ""},
60 {TEX_BLEND, "BLEND", ICON_TEXTURE, "Blend", "Procedural - create a ramp texture"},
61 {TEX_CLOUDS,
62 "CLOUDS",
63 ICON_TEXTURE,
64 "Clouds",
65 "Procedural - create a cloud-like fractal noise texture"},
66 {TEX_DISTNOISE,
67 "DISTORTED_NOISE",
68 ICON_TEXTURE,
69 "Distorted Noise",
70 "Procedural - noise texture distorted by two noise algorithms"},
71 {TEX_IMAGE,
72 "IMAGE",
73 ICON_IMAGE_DATA,
74 "Image or Movie",
75 "Allow for images or movies to be used as textures"},
76 {TEX_MAGIC,
77 "MAGIC",
78 ICON_TEXTURE,
79 "Magic",
80 "Procedural - color texture based on trigonometric functions"},
81 {TEX_MARBLE,
82 "MARBLE",
83 ICON_TEXTURE,
84 "Marble",
85 "Procedural - marble-like noise texture with wave generated bands"},
86 {TEX_MUSGRAVE,
87 "MUSGRAVE",
88 ICON_TEXTURE,
89 "Musgrave",
90 "Procedural - highly flexible fractal noise texture"},
91 {TEX_NOISE,
92 "NOISE",
93 ICON_TEXTURE,
94 "Noise",
95 "Procedural - random noise, gives a different result every time, for every frame, for every "
96 "pixel"},
97 {TEX_STUCCI, "STUCCI", ICON_TEXTURE, "Stucci", "Procedural - create a fractal noise texture"},
98 {TEX_VORONOI,
99 "VORONOI",
100 ICON_TEXTURE,
101 "Voronoi",
102 "Procedural - create cell-like patterns based on Worley noise"},
103 {TEX_WOOD,
104 "WOOD",
105 ICON_TEXTURE,
106 "Wood",
107 "Procedural - wave generated bands or rings, with optional noise"},
108 {0, NULL, 0, NULL, NULL},
109 };
110
111 #ifndef RNA_RUNTIME
112 static const EnumPropertyItem blend_type_items[] = {
113 {MTEX_BLEND, "MIX", 0, "Mix", ""},
114 {0, "", ICON_NONE, NULL, NULL},
115 {MTEX_DARK, "DARKEN", 0, "Darken", ""},
116 {MTEX_MUL, "MULTIPLY", 0, "Multiply", ""},
117 {0, "", ICON_NONE, NULL, NULL},
118 {MTEX_LIGHT, "LIGHTEN", 0, "Lighten", ""},
119 {MTEX_SCREEN, "SCREEN", 0, "Screen", ""},
120 {MTEX_ADD, "ADD", 0, "Add", ""},
121 {0, "", ICON_NONE, NULL, NULL},
122 {MTEX_OVERLAY, "OVERLAY", 0, "Overlay", ""},
123 {MTEX_SOFT_LIGHT, "SOFT_LIGHT", 0, "Soft Light", ""},
124 {MTEX_LIN_LIGHT, "LINEAR_LIGHT", 0, "Linear Light", ""},
125 {0, "", ICON_NONE, NULL, NULL},
126 {MTEX_DIFF, "DIFFERENCE", 0, "Difference", ""},
127 {MTEX_SUB, "SUBTRACT", 0, "Subtract", ""},
128 {MTEX_DIV, "DIVIDE", 0, "Divide", ""},
129 {0, "", ICON_NONE, NULL, NULL},
130 {MTEX_BLEND_HUE, "HUE", 0, "Hue", ""},
131 {MTEX_BLEND_SAT, "SATURATION", 0, "Saturation", ""},
132 {MTEX_BLEND_COLOR, "COLOR", 0, "Color", ""},
133 {MTEX_BLEND_VAL, "VALUE", 0, "Value", ""},
134 {0, NULL, 0, NULL, NULL},
135 };
136 #endif
137
138 #ifdef RNA_RUNTIME
139
140 # include "MEM_guardedalloc.h"
141
142 # include "RNA_access.h"
143
144 # include "BKE_colorband.h"
145 # include "BKE_context.h"
146 # include "BKE_image.h"
147 # include "BKE_main.h"
148 # include "BKE_texture.h"
149
150 # include "DEG_depsgraph.h"
151
152 # include "ED_node.h"
153 # include "ED_render.h"
154
rna_Texture_refine(struct PointerRNA * ptr)155 static StructRNA *rna_Texture_refine(struct PointerRNA *ptr)
156 {
157 Tex *tex = (Tex *)ptr->data;
158
159 switch (tex->type) {
160 case TEX_BLEND:
161 return &RNA_BlendTexture;
162 case TEX_CLOUDS:
163 return &RNA_CloudsTexture;
164 case TEX_DISTNOISE:
165 return &RNA_DistortedNoiseTexture;
166 case TEX_IMAGE:
167 return &RNA_ImageTexture;
168 case TEX_MAGIC:
169 return &RNA_MagicTexture;
170 case TEX_MARBLE:
171 return &RNA_MarbleTexture;
172 case TEX_MUSGRAVE:
173 return &RNA_MusgraveTexture;
174 case TEX_NOISE:
175 return &RNA_NoiseTexture;
176 case TEX_STUCCI:
177 return &RNA_StucciTexture;
178 case TEX_VORONOI:
179 return &RNA_VoronoiTexture;
180 case TEX_WOOD:
181 return &RNA_WoodTexture;
182 default:
183 return &RNA_Texture;
184 }
185 }
186
rna_Texture_update(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)187 static void rna_Texture_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
188 {
189 ID *id = ptr->owner_id;
190
191 if (GS(id->name) == ID_TE) {
192 Tex *tex = (Tex *)ptr->owner_id;
193
194 DEG_id_tag_update(&tex->id, 0);
195 DEG_id_tag_update(&tex->id, ID_RECALC_EDITORS);
196 WM_main_add_notifier(NC_TEXTURE, tex);
197 WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, NULL);
198 }
199 else if (GS(id->name) == ID_NT) {
200 bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
201 ED_node_tag_update_nodetree(bmain, ntree, NULL);
202 }
203 }
204
rna_Texture_mapping_update(Main * bmain,Scene * scene,PointerRNA * ptr)205 static void rna_Texture_mapping_update(Main *bmain, Scene *scene, PointerRNA *ptr)
206 {
207 TexMapping *texmap = ptr->data;
208 BKE_texture_mapping_init(texmap);
209 rna_Texture_update(bmain, scene, ptr);
210 }
211
rna_Color_mapping_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * UNUSED (ptr))212 static void rna_Color_mapping_update(Main *UNUSED(bmain),
213 Scene *UNUSED(scene),
214 PointerRNA *UNUSED(ptr))
215 {
216 /* nothing to do */
217 }
218
219 /* Used for Texture Properties, used (also) for/in Nodes */
rna_Texture_nodes_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)220 static void rna_Texture_nodes_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
221 {
222 Tex *tex = (Tex *)ptr->owner_id;
223
224 DEG_id_tag_update(&tex->id, 0);
225 DEG_id_tag_update(&tex->id, ID_RECALC_EDITORS);
226 WM_main_add_notifier(NC_TEXTURE | ND_NODES, tex);
227 }
228
rna_Texture_type_set(PointerRNA * ptr,int value)229 static void rna_Texture_type_set(PointerRNA *ptr, int value)
230 {
231 Tex *tex = (Tex *)ptr->data;
232
233 BKE_texture_type_set(tex, value);
234 }
235
rna_TextureSlot_update(bContext * C,PointerRNA * ptr)236 void rna_TextureSlot_update(bContext *C, PointerRNA *ptr)
237 {
238 ID *id = ptr->owner_id;
239
240 DEG_id_tag_update(id, 0);
241
242 switch (GS(id->name)) {
243 case ID_MA:
244 WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id);
245 WM_main_add_notifier(NC_MATERIAL | ND_SHADING_DRAW, id);
246 break;
247 case ID_WO:
248 WM_main_add_notifier(NC_WORLD, id);
249 break;
250 case ID_LA:
251 WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id);
252 WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, id);
253 break;
254 case ID_BR: {
255 Scene *scene = CTX_data_scene(C);
256 MTex *mtex = ptr->data;
257 ViewLayer *view_layer = CTX_data_view_layer(C);
258 BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex);
259 WM_main_add_notifier(NC_BRUSH, id);
260 break;
261 }
262 case ID_LS:
263 WM_main_add_notifier(NC_LINESTYLE, id);
264 break;
265 case ID_PA: {
266 MTex *mtex = ptr->data;
267 int recalc = ID_RECALC_GEOMETRY;
268
269 if (mtex->mapto & PAMAP_INIT) {
270 recalc |= ID_RECALC_PSYS_RESET;
271 }
272 if (mtex->mapto & PAMAP_CHILD) {
273 recalc |= ID_RECALC_PSYS_CHILD;
274 }
275
276 DEG_id_tag_update(id, recalc);
277 WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
278 break;
279 }
280 default:
281 break;
282 }
283 }
284
rna_TextureSlot_path(PointerRNA * ptr)285 char *rna_TextureSlot_path(PointerRNA *ptr)
286 {
287 MTex *mtex = ptr->data;
288
289 /* if there is ID-data, resolve the path using the index instead of by name,
290 * since the name used is the name of the texture assigned, but the texture
291 * may be used multiple times in the same stack
292 */
293 if (ptr->owner_id) {
294 if (GS(ptr->owner_id->name) == ID_BR) {
295 return BLI_strdup("texture_slot");
296 }
297 else {
298 PointerRNA id_ptr;
299 PropertyRNA *prop;
300
301 /* find the 'textures' property of the ID-struct */
302 RNA_id_pointer_create(ptr->owner_id, &id_ptr);
303 prop = RNA_struct_find_property(&id_ptr, "texture_slots");
304
305 /* get an iterator for this property, and try to find the relevant index */
306 if (prop) {
307 int index = RNA_property_collection_lookup_index(&id_ptr, prop, ptr);
308
309 if (index != -1) {
310 return BLI_sprintfN("texture_slots[%d]", index);
311 }
312 }
313 }
314 }
315
316 /* this is a compromise for the remaining cases... */
317 if (mtex->tex) {
318 char name_esc[(sizeof(mtex->tex->id.name) - 2) * 2];
319
320 BLI_strescape(name_esc, mtex->tex->id.name + 2, sizeof(name_esc));
321 return BLI_sprintfN("texture_slots[\"%s\"]", name_esc);
322 }
323 else {
324 return BLI_strdup("texture_slots[0]");
325 }
326 }
327
rna_TextureSlot_name_length(PointerRNA * ptr)328 static int rna_TextureSlot_name_length(PointerRNA *ptr)
329 {
330 MTex *mtex = ptr->data;
331
332 if (mtex->tex) {
333 return strlen(mtex->tex->id.name + 2);
334 }
335
336 return 0;
337 }
338
rna_TextureSlot_name_get(PointerRNA * ptr,char * str)339 static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str)
340 {
341 MTex *mtex = ptr->data;
342
343 if (mtex->tex) {
344 strcpy(str, mtex->tex->id.name + 2);
345 }
346 else {
347 str[0] = '\0';
348 }
349 }
350
rna_TextureSlot_output_node_get(PointerRNA * ptr)351 static int rna_TextureSlot_output_node_get(PointerRNA *ptr)
352 {
353 MTex *mtex = ptr->data;
354 Tex *tex = mtex->tex;
355 int cur = mtex->which_output;
356
357 if (tex) {
358 bNodeTree *ntree = tex->nodetree;
359 bNode *node;
360 if (ntree) {
361 for (node = ntree->nodes.first; node; node = node->next) {
362 if (node->type == TEX_NODE_OUTPUT) {
363 if (cur == node->custom1) {
364 return cur;
365 }
366 }
367 }
368 }
369 }
370
371 mtex->which_output = 0;
372 return 0;
373 }
374
rna_TextureSlot_output_node_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * r_free)375 static const EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *UNUSED(C),
376 PointerRNA *ptr,
377 PropertyRNA *UNUSED(prop),
378 bool *r_free)
379 {
380 MTex *mtex = ptr->data;
381 Tex *tex = mtex->tex;
382 EnumPropertyItem *item = NULL;
383 int totitem = 0;
384
385 if (tex) {
386 bNodeTree *ntree = tex->nodetree;
387 if (ntree) {
388 EnumPropertyItem tmp = {0, "", 0, "", ""};
389 bNode *node;
390
391 tmp.value = 0;
392 tmp.name = "Not Specified";
393 tmp.identifier = "NOT_SPECIFIED";
394 RNA_enum_item_add(&item, &totitem, &tmp);
395
396 for (node = ntree->nodes.first; node; node = node->next) {
397 if (node->type == TEX_NODE_OUTPUT) {
398 tmp.value = node->custom1;
399 tmp.name = ((TexNodeOutput *)node->storage)->name;
400 tmp.identifier = tmp.name;
401 RNA_enum_item_add(&item, &totitem, &tmp);
402 }
403 }
404 }
405 }
406
407 RNA_enum_item_end(&item, &totitem);
408 *r_free = true;
409
410 return item;
411 }
412
rna_Texture_use_color_ramp_set(PointerRNA * ptr,bool value)413 static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, bool value)
414 {
415 Tex *tex = (Tex *)ptr->data;
416
417 if (value) {
418 tex->flag |= TEX_COLORBAND;
419 }
420 else {
421 tex->flag &= ~TEX_COLORBAND;
422 }
423
424 if ((tex->flag & TEX_COLORBAND) && tex->coba == NULL) {
425 tex->coba = BKE_colorband_add(false);
426 }
427 }
428
rna_Texture_use_nodes_update(bContext * C,PointerRNA * ptr)429 static void rna_Texture_use_nodes_update(bContext *C, PointerRNA *ptr)
430 {
431 Tex *tex = (Tex *)ptr->data;
432
433 if (tex->use_nodes) {
434 tex->type = 0;
435
436 if (tex->nodetree == NULL) {
437 ED_node_texture_default(C, tex);
438 }
439 }
440
441 rna_Texture_nodes_update(CTX_data_main(C), CTX_data_scene(C), ptr);
442 }
443
rna_ImageTexture_mipmap_set(PointerRNA * ptr,bool value)444 static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, bool value)
445 {
446 Tex *tex = (Tex *)ptr->data;
447
448 if (value) {
449 tex->imaflag |= TEX_MIPMAP;
450 }
451 else {
452 tex->imaflag &= ~TEX_MIPMAP;
453 }
454 }
455
456 #else
457
rna_def_texmapping(BlenderRNA * brna)458 static void rna_def_texmapping(BlenderRNA *brna)
459 {
460 static const EnumPropertyItem prop_mapping_items[] = {
461 {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
462 {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
463 {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
464 {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
465 {0, NULL, 0, NULL, NULL},
466 };
467
468 static const EnumPropertyItem prop_xyz_mapping_items[] = {
469 {0, "NONE", 0, "None", ""},
470 {1, "X", 0, "X", ""},
471 {2, "Y", 0, "Y", ""},
472 {3, "Z", 0, "Z", ""},
473 {0, NULL, 0, NULL, NULL},
474 };
475
476 StructRNA *srna;
477 PropertyRNA *prop;
478
479 srna = RNA_def_struct(brna, "TexMapping", NULL);
480 RNA_def_struct_ui_text(srna, "Texture Mapping", "Texture coordinate mapping settings");
481
482 prop = RNA_def_property(srna, "vector_type", PROP_ENUM, PROP_NONE);
483 RNA_def_property_enum_sdna(prop, NULL, "type");
484 RNA_def_property_enum_items(prop, rna_enum_mapping_type_items);
485 RNA_def_property_ui_text(prop, "Type", "Type of vector that the mapping transforms");
486 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
487
488 prop = RNA_def_property(srna, "translation", PROP_FLOAT, PROP_TRANSLATION);
489 RNA_def_property_float_sdna(prop, NULL, "loc");
490 RNA_def_property_ui_text(prop, "Location", "");
491 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
492 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
493
494 /* Not PROP_XYZ, this is now in radians, no more degrees */
495 prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER);
496 RNA_def_property_float_sdna(prop, NULL, "rot");
497 RNA_def_property_ui_text(prop, "Rotation", "");
498 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
499
500 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
501 RNA_def_property_float_sdna(prop, NULL, "size");
502 RNA_def_property_flag(prop, PROP_PROPORTIONAL);
503 RNA_def_property_ui_text(prop, "Scale", "");
504 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
505
506 prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_XYZ);
507 RNA_def_property_float_sdna(prop, NULL, "min");
508 RNA_def_property_ui_text(prop, "Minimum", "Minimum value for clipping");
509 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
510
511 prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_XYZ);
512 RNA_def_property_float_sdna(prop, NULL, "max");
513 RNA_def_property_ui_text(prop, "Maximum", "Maximum value for clipping");
514 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
515
516 prop = RNA_def_property(srna, "use_min", PROP_BOOLEAN, PROP_NONE);
517 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MIN);
518 RNA_def_property_ui_text(prop, "Has Minimum", "Whether to use minimum clipping value");
519 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
520
521 prop = RNA_def_property(srna, "use_max", PROP_BOOLEAN, PROP_NONE);
522 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEXMAP_CLIP_MAX);
523 RNA_def_property_ui_text(prop, "Has Maximum", "Whether to use maximum clipping value");
524 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
525
526 prop = RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
527 RNA_def_property_enum_sdna(prop, NULL, "projx");
528 RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
529 RNA_def_property_ui_text(prop, "X Mapping", "");
530 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
531
532 prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
533 RNA_def_property_enum_sdna(prop, NULL, "projy");
534 RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
535 RNA_def_property_ui_text(prop, "Y Mapping", "");
536 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
537
538 prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
539 RNA_def_property_enum_sdna(prop, NULL, "projz");
540 RNA_def_property_enum_items(prop, prop_xyz_mapping_items);
541 RNA_def_property_ui_text(prop, "Z Mapping", "");
542 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
543
544 prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
545 RNA_def_property_enum_items(prop, prop_mapping_items);
546 RNA_def_property_ui_text(prop, "Mapping", "");
547 RNA_def_property_update(prop, 0, "rna_Texture_mapping_update");
548 }
549
rna_def_colormapping(BlenderRNA * brna)550 static void rna_def_colormapping(BlenderRNA *brna)
551 {
552 StructRNA *srna;
553 PropertyRNA *prop;
554
555 srna = RNA_def_struct(brna, "ColorMapping", NULL);
556 RNA_def_struct_ui_text(srna, "Color Mapping", "Color mapping settings");
557
558 prop = RNA_def_property(srna, "use_color_ramp", PROP_BOOLEAN, PROP_NONE);
559 RNA_def_property_boolean_sdna(prop, NULL, "flag", COLORMAP_USE_RAMP);
560 RNA_def_property_ui_text(prop, "Use Color Ramp", "Toggle color ramp operations");
561 RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
562
563 prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL);
564 RNA_def_property_pointer_sdna(prop, NULL, "coba");
565 RNA_def_property_struct_type(prop, "ColorRamp");
566 RNA_def_property_ui_text(prop, "Color Ramp", "");
567 RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
568
569 prop = RNA_def_property(srna, "brightness", PROP_FLOAT, PROP_NONE);
570 RNA_def_property_float_sdna(prop, NULL, "bright");
571 RNA_def_property_range(prop, 0, 2);
572 RNA_def_property_ui_range(prop, 0, 2, 1, 3);
573 RNA_def_property_ui_text(prop, "Brightness", "Adjust the brightness of the texture");
574 RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
575
576 prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_NONE);
577 RNA_def_property_range(prop, 0.0, 5);
578 RNA_def_property_ui_range(prop, 0, 5, 1, 3);
579 RNA_def_property_ui_text(prop, "Contrast", "Adjust the contrast of the texture");
580 RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
581
582 prop = RNA_def_property(srna, "saturation", PROP_FLOAT, PROP_NONE);
583 RNA_def_property_range(prop, 0, 2);
584 RNA_def_property_ui_range(prop, 0, 2, 1, 3);
585 RNA_def_property_ui_text(prop, "Saturation", "Adjust the saturation of colors in the texture");
586 RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
587
588 prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
589 RNA_def_property_enum_items(prop, blend_type_items);
590 RNA_def_property_ui_text(prop, "Blend Type", "Mode used to mix with texture output color");
591 RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
592
593 prop = RNA_def_property(srna, "blend_color", PROP_FLOAT, PROP_COLOR);
594 RNA_def_property_array(prop, 3);
595 RNA_def_property_ui_text(prop, "Color", "Blend color to mix with texture output color");
596 RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
597
598 prop = RNA_def_property(srna, "blend_factor", PROP_FLOAT, PROP_NONE);
599 RNA_def_property_ui_text(prop, "Blend Factor", "");
600 RNA_def_property_update(prop, 0, "rna_Color_mapping_update");
601 }
602
rna_def_mtex(BlenderRNA * brna)603 static void rna_def_mtex(BlenderRNA *brna)
604 {
605 StructRNA *srna;
606 PropertyRNA *prop;
607
608 static const EnumPropertyItem output_node_items[] = {
609 {0, "DUMMY", 0, "Dummy", ""},
610 {0, NULL, 0, NULL, NULL},
611 };
612
613 srna = RNA_def_struct(brna, "TextureSlot", NULL);
614 RNA_def_struct_sdna(srna, "MTex");
615 RNA_def_struct_ui_text(
616 srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture");
617 RNA_def_struct_path_func(srna, "rna_TextureSlot_path");
618 RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA);
619
620 prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
621 RNA_def_property_pointer_sdna(prop, NULL, "tex");
622 RNA_def_property_struct_type(prop, "Texture");
623 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE);
624 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
625 RNA_def_property_ui_text(prop, "Texture", "Texture data-block used by this texture slot");
626 RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_TextureSlot_update");
627
628 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
629 RNA_def_property_string_funcs(
630 prop, "rna_TextureSlot_name_get", "rna_TextureSlot_name_length", NULL);
631 RNA_def_property_ui_text(prop, "Name", "Texture slot name");
632 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
633 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
634 RNA_def_struct_name_property(srna, prop);
635 RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
636
637 /* mapping */
638 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION);
639 RNA_def_property_float_sdna(prop, NULL, "ofs");
640 RNA_def_property_ui_range(prop, -10, 10, 10, RNA_TRANSLATION_PREC_DEFAULT);
641 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
642 RNA_def_property_ui_text(
643 prop, "Offset", "Fine tune of the texture mapping X, Y and Z locations");
644 RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
645
646 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
647 RNA_def_property_float_sdna(prop, NULL, "size");
648 RNA_def_property_flag(prop, PROP_PROPORTIONAL | PROP_CONTEXT_UPDATE);
649 RNA_def_property_ui_range(prop, -100, 100, 10, 2);
650 RNA_def_property_ui_text(prop, "Size", "Set scaling for the texture's X, Y and Z sizes");
651 RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
652
653 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
654 RNA_def_property_float_sdna(prop, NULL, "r");
655 RNA_def_property_array(prop, 3);
656 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
657 RNA_def_property_ui_text(
658 prop,
659 "Color",
660 "Default color for textures that don't return RGB or when RGB to intensity is enabled");
661 RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
662
663 prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
664 RNA_def_property_enum_sdna(prop, NULL, "blendtype");
665 RNA_def_property_enum_items(prop, blend_type_items);
666 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
667 RNA_def_property_ui_text(prop, "Blend Type", "Mode used to apply the texture");
668 RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
669
670 prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE);
671 RNA_def_property_float_sdna(prop, NULL, "def_var");
672 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
673 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
674 RNA_def_property_ui_text(
675 prop,
676 "Default Value",
677 "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard");
678 RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
679
680 prop = RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE);
681 RNA_def_property_enum_sdna(prop, NULL, "which_output");
682 RNA_def_property_enum_items(prop, output_node_items);
683 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
684 RNA_def_property_enum_funcs(
685 prop, "rna_TextureSlot_output_node_get", NULL, "rna_TextureSlot_output_node_itemf");
686 RNA_def_property_ui_text(
687 prop, "Output Node", "Which output node to use, for node-based textures");
688 RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
689 }
690
rna_def_filter_common(StructRNA * srna)691 static void rna_def_filter_common(StructRNA *srna)
692 {
693 PropertyRNA *prop;
694
695 prop = RNA_def_property(srna, "use_mipmap", PROP_BOOLEAN, PROP_NONE);
696 RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_MIPMAP);
697 RNA_def_property_boolean_funcs(prop, NULL, "rna_ImageTexture_mipmap_set");
698 RNA_def_property_ui_text(prop, "MIP Map", "Use auto-generated MIP maps for the image");
699 RNA_def_property_update(prop, 0, "rna_Texture_update");
700
701 prop = RNA_def_property(srna, "use_mipmap_gauss", PROP_BOOLEAN, PROP_NONE);
702 RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_GAUSS_MIP);
703 RNA_def_property_ui_text(
704 prop, "MIP Map Gaussian filter", "Use Gauss filter to sample down MIP maps");
705 RNA_def_property_update(prop, 0, "rna_Texture_update");
706
707 prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE);
708 RNA_def_property_enum_sdna(prop, NULL, "texfilter");
709 RNA_def_property_enum_items(prop, texture_filter_items);
710 RNA_def_property_ui_text(prop, "Filter", "Texture filter to use for sampling image");
711 RNA_def_property_update(prop, 0, "rna_Texture_update");
712
713 prop = RNA_def_property(srna, "filter_lightprobes", PROP_INT, PROP_NONE);
714 RNA_def_property_int_sdna(prop, NULL, "afmax");
715 RNA_def_property_range(prop, 1, 256);
716 RNA_def_property_ui_text(
717 prop,
718 "Filter Probes",
719 "Maximum number of samples (higher gives less blur at distant/oblique angles, "
720 "but is also slower)");
721 RNA_def_property_update(prop, 0, "rna_Texture_update");
722
723 prop = RNA_def_property(srna, "filter_eccentricity", PROP_INT, PROP_NONE);
724 RNA_def_property_int_sdna(prop, NULL, "afmax");
725 RNA_def_property_range(prop, 1, 256);
726 RNA_def_property_ui_text(
727 prop,
728 "Filter Eccentricity",
729 "Maximum eccentricity (higher gives less blur at distant/oblique angles, "
730 "but is also slower)");
731 RNA_def_property_update(prop, 0, "rna_Texture_update");
732
733 prop = RNA_def_property(srna, "use_filter_size_min", PROP_BOOLEAN, PROP_NONE);
734 RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_FILTER_MIN);
735 RNA_def_property_ui_text(
736 prop, "Minimum Filter Size", "Use Filter Size as a minimal filter value in pixels");
737 RNA_def_property_update(prop, 0, "rna_Texture_update");
738
739 prop = RNA_def_property(srna, "filter_size", PROP_FLOAT, PROP_NONE);
740 RNA_def_property_float_sdna(prop, NULL, "filtersize");
741 RNA_def_property_range(prop, 0.1, 50.0);
742 RNA_def_property_ui_range(prop, 0.1, 50.0, 1, 2);
743 RNA_def_property_ui_text(
744 prop, "Filter Size", "Multiply the filter size used by MIP Map and Interpolation");
745 RNA_def_property_update(prop, 0, "rna_Texture_update");
746 }
747
748 static const EnumPropertyItem prop_noise_basis_items[] = {
749 {TEX_BLENDER,
750 "BLENDER_ORIGINAL",
751 0,
752 "Blender Original",
753 "Noise algorithm - Blender original: Smooth interpolated noise"},
754 {TEX_STDPERLIN,
755 "ORIGINAL_PERLIN",
756 0,
757 "Original Perlin",
758 "Noise algorithm - Original Perlin: Smooth interpolated noise"},
759 {TEX_NEWPERLIN,
760 "IMPROVED_PERLIN",
761 0,
762 "Improved Perlin",
763 "Noise algorithm - Improved Perlin: Smooth interpolated noise"},
764 {TEX_VORONOI_F1,
765 "VORONOI_F1",
766 0,
767 "Voronoi F1",
768 "Noise algorithm - Voronoi F1: Returns distance to the closest feature point"},
769 {TEX_VORONOI_F2,
770 "VORONOI_F2",
771 0,
772 "Voronoi F2",
773 "Noise algorithm - Voronoi F2: Returns distance to the 2nd closest feature point"},
774 {TEX_VORONOI_F3,
775 "VORONOI_F3",
776 0,
777 "Voronoi F3",
778 "Noise algorithm - Voronoi F3: Returns distance to the 3rd closest feature point"},
779 {TEX_VORONOI_F4,
780 "VORONOI_F4",
781 0,
782 "Voronoi F4",
783 "Noise algorithm - Voronoi F4: Returns distance to the 4th closest feature point"},
784 {TEX_VORONOI_F2F1, "VORONOI_F2_F1", 0, "Voronoi F2-F1", "Noise algorithm - Voronoi F1-F2"},
785 {TEX_VORONOI_CRACKLE,
786 "VORONOI_CRACKLE",
787 0,
788 "Voronoi Crackle",
789 "Noise algorithm - Voronoi Crackle: Voronoi tessellation with sharp edges"},
790 {TEX_CELLNOISE,
791 "CELL_NOISE",
792 0,
793 "Cell Noise",
794 "Noise algorithm - Cell Noise: Square cell tessellation"},
795 {0, NULL, 0, NULL, NULL},
796 };
797
798 static const EnumPropertyItem prop_noise_type[] = {
799 {TEX_NOISESOFT, "SOFT_NOISE", 0, "Soft", "Generate soft noise (smooth transitions)"},
800 {TEX_NOISEPERL, "HARD_NOISE", 0, "Hard", "Generate hard noise (sharp transitions)"},
801 {0, NULL, 0, NULL, NULL},
802 };
803
rna_def_texture_clouds(BlenderRNA * brna)804 static void rna_def_texture_clouds(BlenderRNA *brna)
805 {
806 StructRNA *srna;
807 PropertyRNA *prop;
808
809 static const EnumPropertyItem prop_clouds_stype[] = {
810 {TEX_DEFAULT, "GRAYSCALE", 0, "Grayscale", ""},
811 {TEX_COLOR, "COLOR", 0, "Color", ""},
812 {0, NULL, 0, NULL, NULL},
813 };
814
815 srna = RNA_def_struct(brna, "CloudsTexture", "Texture");
816 RNA_def_struct_ui_text(srna, "Clouds Texture", "Procedural noise texture");
817 RNA_def_struct_sdna(srna, "Tex");
818
819 prop = RNA_def_property(srna, "noise_scale", PROP_FLOAT, PROP_NONE);
820 RNA_def_property_float_sdna(prop, NULL, "noisesize");
821 RNA_def_property_range(prop, 0.0001, FLT_MAX);
822 RNA_def_property_ui_range(prop, 0.0001, 2, 1, 2);
823 RNA_def_property_ui_text(prop, "Noise Size", "Scaling for noise input");
824 RNA_def_property_update(prop, 0, "rna_Texture_update");
825
826 prop = RNA_def_property(srna, "noise_depth", PROP_INT, PROP_NONE);
827 RNA_def_property_int_sdna(prop, NULL, "noisedepth");
828 RNA_def_property_range(prop, 0, 30);
829 RNA_def_property_ui_range(prop, 0, 24, 1, 2);
830 RNA_def_property_ui_text(prop, "Noise Depth", "Depth of the cloud calculation");
831 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
832
833 prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
834 RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
835 RNA_def_property_enum_items(prop, prop_noise_basis_items);
836 RNA_def_property_ui_text(prop, "Noise Basis", "Noise basis used for turbulence");
837 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
838
839 prop = RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
840 RNA_def_property_enum_sdna(prop, NULL, "noisetype");
841 RNA_def_property_enum_items(prop, prop_noise_type);
842 RNA_def_property_ui_text(prop, "Noise Type", "");
843 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
844
845 prop = RNA_def_property(srna, "cloud_type", PROP_ENUM, PROP_NONE);
846 RNA_def_property_enum_sdna(prop, NULL, "stype");
847 RNA_def_property_enum_items(prop, prop_clouds_stype);
848 RNA_def_property_ui_text(
849 prop, "Color", "Determine whether Noise returns grayscale or RGB values");
850 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
851
852 prop = RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
853 RNA_def_property_range(prop, 0.001, 0.1);
854 RNA_def_property_ui_range(prop, 0.001, 0.1, 1, 2);
855 RNA_def_property_ui_text(prop, "Nabla", "Size of derivative offset used for calculating normal");
856 RNA_def_property_update(prop, 0, "rna_Texture_update");
857 }
858
rna_def_texture_wood(BlenderRNA * brna)859 static void rna_def_texture_wood(BlenderRNA *brna)
860 {
861 StructRNA *srna;
862 PropertyRNA *prop;
863
864 static const EnumPropertyItem prop_wood_stype[] = {
865 {TEX_BAND, "BANDS", 0, "Bands", "Use standard wood texture in bands"},
866 {TEX_RING, "RINGS", 0, "Rings", "Use wood texture in rings"},
867 {TEX_BANDNOISE, "BANDNOISE", 0, "Band Noise", "Add noise to standard wood"},
868 {TEX_RINGNOISE, "RINGNOISE", 0, "Ring Noise", "Add noise to rings"},
869 {0, NULL, 0, NULL, NULL},
870 };
871
872 static const EnumPropertyItem prop_wood_noisebasis2[] = {
873 {TEX_SIN, "SIN", 0, "Sine", "Use a sine wave to produce bands"},
874 {TEX_SAW, "SAW", 0, "Saw", "Use a saw wave to produce bands"},
875 {TEX_TRI, "TRI", 0, "Tri", "Use a triangle wave to produce bands"},
876 {0, NULL, 0, NULL, NULL},
877 };
878
879 srna = RNA_def_struct(brna, "WoodTexture", "Texture");
880 RNA_def_struct_ui_text(srna, "Wood Texture", "Procedural noise texture");
881 RNA_def_struct_sdna(srna, "Tex");
882
883 prop = RNA_def_property(srna, "noise_scale", PROP_FLOAT, PROP_NONE);
884 RNA_def_property_float_sdna(prop, NULL, "noisesize");
885 RNA_def_property_range(prop, 0.0001, FLT_MAX);
886 RNA_def_property_ui_range(prop, 0.0001, 2, 1, 2);
887 RNA_def_property_ui_text(prop, "Noise Size", "Scaling for noise input");
888 RNA_def_property_update(prop, 0, "rna_Texture_update");
889
890 prop = RNA_def_property(srna, "turbulence", PROP_FLOAT, PROP_NONE);
891 RNA_def_property_float_sdna(prop, NULL, "turbul");
892 RNA_def_property_range(prop, 0.0001, FLT_MAX);
893 RNA_def_property_ui_range(prop, 0.0001, 200, 10, 2);
894 RNA_def_property_ui_text(prop, "Turbulence", "Turbulence of the bandnoise and ringnoise types");
895 RNA_def_property_update(prop, 0, "rna_Texture_update");
896
897 prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
898 RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
899 RNA_def_property_enum_items(prop, prop_noise_basis_items);
900 RNA_def_property_ui_text(prop, "Noise Basis", "Noise basis used for turbulence");
901 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
902
903 prop = RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
904 RNA_def_property_enum_sdna(prop, NULL, "noisetype");
905 RNA_def_property_enum_items(prop, prop_noise_type);
906 RNA_def_property_ui_text(prop, "Noise Type", "");
907 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
908
909 prop = RNA_def_property(srna, "wood_type", PROP_ENUM, PROP_NONE);
910 RNA_def_property_enum_sdna(prop, NULL, "stype");
911 RNA_def_property_enum_items(prop, prop_wood_stype);
912 RNA_def_property_ui_text(prop, "Pattern", "");
913 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
914
915 prop = RNA_def_property(srna, "noise_basis_2", PROP_ENUM, PROP_NONE);
916 RNA_def_property_enum_sdna(prop, NULL, "noisebasis2");
917 RNA_def_property_enum_items(prop, prop_wood_noisebasis2);
918 RNA_def_property_ui_text(prop, "Noise Basis 2", "");
919 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
920
921 prop = RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
922 RNA_def_property_range(prop, 0.001, 0.1);
923 RNA_def_property_ui_range(prop, 0.001, 0.1, 1, 2);
924 RNA_def_property_ui_text(prop, "Nabla", "Size of derivative offset used for calculating normal");
925 RNA_def_property_update(prop, 0, "rna_Texture_update");
926 }
927
rna_def_texture_marble(BlenderRNA * brna)928 static void rna_def_texture_marble(BlenderRNA *brna)
929 {
930 StructRNA *srna;
931 PropertyRNA *prop;
932
933 static const EnumPropertyItem prop_marble_stype[] = {
934 {TEX_SOFT, "SOFT", 0, "Soft", "Use soft marble"},
935 {TEX_SHARP, "SHARP", 0, "Sharp", "Use more clearly defined marble"},
936 {TEX_SHARPER, "SHARPER", 0, "Sharper", "Use very clearly defined marble"},
937 {0, NULL, 0, NULL, NULL},
938 };
939
940 static const EnumPropertyItem prop_marble_noisebasis2[] = {
941 {TEX_SIN, "SIN", 0, "Sin", "Use a sine wave to produce bands"},
942 {TEX_SAW, "SAW", 0, "Saw", "Use a saw wave to produce bands"},
943 {TEX_TRI, "TRI", 0, "Tri", "Use a triangle wave to produce bands"},
944 {0, NULL, 0, NULL, NULL},
945 };
946
947 srna = RNA_def_struct(brna, "MarbleTexture", "Texture");
948 RNA_def_struct_ui_text(srna, "Marble Texture", "Procedural noise texture");
949 RNA_def_struct_sdna(srna, "Tex");
950
951 prop = RNA_def_property(srna, "noise_scale", PROP_FLOAT, PROP_NONE);
952 RNA_def_property_float_sdna(prop, NULL, "noisesize");
953 RNA_def_property_range(prop, 0.0001, FLT_MAX);
954 RNA_def_property_ui_range(prop, 0.0001, 2, 1, 2);
955 RNA_def_property_ui_text(prop, "Noise Size", "Scaling for noise input");
956 RNA_def_property_update(prop, 0, "rna_Texture_update");
957
958 prop = RNA_def_property(srna, "turbulence", PROP_FLOAT, PROP_NONE);
959 RNA_def_property_float_sdna(prop, NULL, "turbul");
960 RNA_def_property_range(prop, 0.0001, FLT_MAX);
961 RNA_def_property_ui_range(prop, 0.0001, 200, 10, 2);
962 RNA_def_property_ui_text(prop, "Turbulence", "Turbulence of the bandnoise and ringnoise types");
963 RNA_def_property_update(prop, 0, "rna_Texture_update");
964
965 prop = RNA_def_property(srna, "noise_depth", PROP_INT, PROP_NONE);
966 RNA_def_property_int_sdna(prop, NULL, "noisedepth");
967 RNA_def_property_range(prop, 0, 30);
968 RNA_def_property_ui_range(prop, 0, 24, 1, 2);
969 RNA_def_property_ui_text(prop, "Noise Depth", "Depth of the cloud calculation");
970 RNA_def_property_update(prop, 0, "rna_Texture_update");
971
972 prop = RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
973 RNA_def_property_enum_sdna(prop, NULL, "noisetype");
974 RNA_def_property_enum_items(prop, prop_noise_type);
975 RNA_def_property_ui_text(prop, "Noise Type", "");
976 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
977
978 prop = RNA_def_property(srna, "marble_type", PROP_ENUM, PROP_NONE);
979 RNA_def_property_enum_sdna(prop, NULL, "stype");
980 RNA_def_property_enum_items(prop, prop_marble_stype);
981 RNA_def_property_ui_text(prop, "Pattern", "");
982 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
983
984 prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
985 RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
986 RNA_def_property_enum_items(prop, prop_noise_basis_items);
987 RNA_def_property_ui_text(prop, "Noise Basis", "Noise basis used for turbulence");
988 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
989
990 prop = RNA_def_property(srna, "noise_basis_2", PROP_ENUM, PROP_NONE);
991 RNA_def_property_enum_sdna(prop, NULL, "noisebasis2");
992 RNA_def_property_enum_items(prop, prop_marble_noisebasis2);
993 RNA_def_property_ui_text(prop, "Noise Basis 2", "");
994 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
995
996 prop = RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
997 RNA_def_property_range(prop, 0.001, 0.1);
998 RNA_def_property_ui_range(prop, 0.001, 0.1, 1, 2);
999 RNA_def_property_ui_text(prop, "Nabla", "Size of derivative offset used for calculating normal");
1000 RNA_def_property_update(prop, 0, "rna_Texture_update");
1001 }
1002
rna_def_texture_magic(BlenderRNA * brna)1003 static void rna_def_texture_magic(BlenderRNA *brna)
1004 {
1005 StructRNA *srna;
1006 PropertyRNA *prop;
1007
1008 srna = RNA_def_struct(brna, "MagicTexture", "Texture");
1009 RNA_def_struct_ui_text(srna, "Magic Texture", "Procedural noise texture");
1010 RNA_def_struct_sdna(srna, "Tex");
1011
1012 prop = RNA_def_property(srna, "turbulence", PROP_FLOAT, PROP_NONE);
1013 RNA_def_property_float_sdna(prop, NULL, "turbul");
1014 RNA_def_property_range(prop, 0.0001, FLT_MAX);
1015 RNA_def_property_ui_range(prop, 0.0001, 200, 10, 2);
1016 RNA_def_property_ui_text(prop, "Turbulence", "Turbulence of the noise");
1017 RNA_def_property_update(prop, 0, "rna_Texture_update");
1018
1019 prop = RNA_def_property(srna, "noise_depth", PROP_INT, PROP_NONE);
1020 RNA_def_property_int_sdna(prop, NULL, "noisedepth");
1021 RNA_def_property_range(prop, 0, 30);
1022 RNA_def_property_ui_range(prop, 0, 24, 1, 2);
1023 RNA_def_property_ui_text(prop, "Noise Depth", "Depth of the noise");
1024 RNA_def_property_update(prop, 0, "rna_Texture_update");
1025 }
1026
rna_def_texture_blend(BlenderRNA * brna)1027 static void rna_def_texture_blend(BlenderRNA *brna)
1028 {
1029 StructRNA *srna;
1030 PropertyRNA *prop;
1031
1032 static const EnumPropertyItem prop_blend_progression[] = {
1033 {TEX_LIN, "LINEAR", 0, "Linear", "Create a linear progression"},
1034 {TEX_QUAD, "QUADRATIC", 0, "Quadratic", "Create a quadratic progression"},
1035 {TEX_EASE, "EASING", 0, "Easing", "Create a progression easing from one step to the next"},
1036 {TEX_DIAG, "DIAGONAL", 0, "Diagonal", "Create a diagonal progression"},
1037 {TEX_SPHERE, "SPHERICAL", 0, "Spherical", "Create a spherical progression"},
1038 {TEX_HALO,
1039 "QUADRATIC_SPHERE",
1040 0,
1041 "Quadratic sphere",
1042 "Create a quadratic progression in the shape of a sphere"},
1043 {TEX_RAD, "RADIAL", 0, "Radial", "Create a radial progression"},
1044 {0, NULL, 0, NULL, NULL},
1045 };
1046
1047 static const EnumPropertyItem prop_flip_axis_items[] = {
1048 {0, "HORIZONTAL", 0, "Horizontal", "No flipping"},
1049 {TEX_FLIPBLEND, "VERTICAL", 0, "Vertical", "Flip the texture's X and Y axis"},
1050 {0, NULL, 0, NULL, NULL},
1051 };
1052
1053 srna = RNA_def_struct(brna, "BlendTexture", "Texture");
1054 RNA_def_struct_ui_text(srna, "Blend Texture", "Procedural color blending texture");
1055 RNA_def_struct_sdna(srna, "Tex");
1056
1057 prop = RNA_def_property(srna, "progression", PROP_ENUM, PROP_NONE);
1058 RNA_def_property_enum_sdna(prop, NULL, "stype");
1059 RNA_def_property_enum_items(prop, prop_blend_progression);
1060 RNA_def_property_ui_text(prop, "Progression", "Style of the color blending");
1061 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
1062
1063 prop = RNA_def_property(srna, "use_flip_axis", PROP_ENUM, PROP_NONE);
1064 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
1065 RNA_def_property_enum_items(prop, prop_flip_axis_items);
1066 RNA_def_property_ui_text(prop, "Flip Axis", "Flip the texture's X and Y axis");
1067 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
1068 }
1069
rna_def_texture_stucci(BlenderRNA * brna)1070 static void rna_def_texture_stucci(BlenderRNA *brna)
1071 {
1072 StructRNA *srna;
1073 PropertyRNA *prop;
1074
1075 static const EnumPropertyItem prop_stucci_stype[] = {
1076 {TEX_PLASTIC, "PLASTIC", 0, "Plastic", "Use standard stucci"},
1077 {TEX_WALLIN, "WALL_IN", 0, "Wall in", "Create Dimples"},
1078 {TEX_WALLOUT, "WALL_OUT", 0, "Wall out", "Create Ridges"},
1079 {0, NULL, 0, NULL, NULL},
1080 };
1081
1082 srna = RNA_def_struct(brna, "StucciTexture", "Texture");
1083 RNA_def_struct_ui_text(srna, "Stucci Texture", "Procedural noise texture");
1084 RNA_def_struct_sdna(srna, "Tex");
1085
1086 prop = RNA_def_property(srna, "turbulence", PROP_FLOAT, PROP_NONE);
1087 RNA_def_property_float_sdna(prop, NULL, "turbul");
1088 RNA_def_property_range(prop, 0.0001, FLT_MAX);
1089 RNA_def_property_ui_range(prop, 0.0001, 200, 10, 2);
1090 RNA_def_property_ui_text(prop, "Turbulence", "Turbulence of the noise");
1091 RNA_def_property_update(prop, 0, "rna_Texture_update");
1092
1093 prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
1094 RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
1095 RNA_def_property_enum_items(prop, prop_noise_basis_items);
1096 RNA_def_property_ui_text(prop, "Noise Basis", "Noise basis used for turbulence");
1097 RNA_def_property_update(prop, 0, "rna_Texture_update");
1098
1099 prop = RNA_def_property(srna, "noise_scale", PROP_FLOAT, PROP_NONE);
1100 RNA_def_property_float_sdna(prop, NULL, "noisesize");
1101 RNA_def_property_range(prop, 0.0001, FLT_MAX);
1102 RNA_def_property_ui_range(prop, 0.0001, 2, 1, 2);
1103 RNA_def_property_ui_text(prop, "Noise Size", "Scaling for noise input");
1104 RNA_def_property_update(prop, 0, "rna_Texture_update");
1105
1106 prop = RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
1107 RNA_def_property_enum_sdna(prop, NULL, "noisetype");
1108 RNA_def_property_enum_items(prop, prop_noise_type);
1109 RNA_def_property_ui_text(prop, "Noise Type", "");
1110 RNA_def_property_update(prop, 0, "rna_Texture_update");
1111
1112 prop = RNA_def_property(srna, "stucci_type", PROP_ENUM, PROP_NONE);
1113 RNA_def_property_enum_sdna(prop, NULL, "stype");
1114 RNA_def_property_enum_items(prop, prop_stucci_stype);
1115 RNA_def_property_ui_text(prop, "Pattern", "");
1116 RNA_def_property_update(prop, 0, "rna_Texture_update");
1117 }
1118
rna_def_texture_noise(BlenderRNA * brna)1119 static void rna_def_texture_noise(BlenderRNA *brna)
1120 {
1121 StructRNA *srna;
1122
1123 srna = RNA_def_struct(brna, "NoiseTexture", "Texture");
1124 RNA_def_struct_ui_text(srna, "Noise Texture", "Procedural noise texture");
1125 RNA_def_struct_sdna(srna, "Tex");
1126 }
1127
rna_def_texture_image(BlenderRNA * brna)1128 static void rna_def_texture_image(BlenderRNA *brna)
1129 {
1130 StructRNA *srna;
1131 PropertyRNA *prop;
1132
1133 static const EnumPropertyItem prop_image_extension[] = {
1134 {TEX_EXTEND, "EXTEND", 0, "Extend", "Extend by repeating edge pixels of the image"},
1135 {TEX_CLIP, "CLIP", 0, "Clip", "Clip to image size and set exterior pixels as transparent"},
1136 {TEX_CLIPCUBE,
1137 "CLIP_CUBE",
1138 0,
1139 "Clip Cube",
1140 "Clip to cubic-shaped area around the image and set exterior pixels as transparent"},
1141 {TEX_REPEAT, "REPEAT", 0, "Repeat", "Cause the image to repeat horizontally and vertically"},
1142 {TEX_CHECKER, "CHECKER", 0, "Checker", "Cause the image to repeat in checker board pattern"},
1143 {0, NULL, 0, NULL, NULL},
1144 };
1145
1146 srna = RNA_def_struct(brna, "ImageTexture", "Texture");
1147 RNA_def_struct_ui_text(srna, "Image Texture", "");
1148 RNA_def_struct_sdna(srna, "Tex");
1149
1150 prop = RNA_def_property(srna, "use_interpolation", PROP_BOOLEAN, PROP_NONE);
1151 RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_INTERPOL);
1152 RNA_def_property_ui_text(prop, "Interpolation", "Interpolate pixels using selected filter");
1153 RNA_def_property_update(prop, 0, "rna_Texture_update");
1154
1155 /* XXX: I think flip_axis should be a generic Texture property,
1156 * enabled for all the texture types. */
1157 prop = RNA_def_property(srna, "use_flip_axis", PROP_BOOLEAN, PROP_NONE);
1158 RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_IMAROT);
1159 RNA_def_property_ui_text(prop, "Flip Axis", "Flip the texture's X and Y axis");
1160 RNA_def_property_update(prop, 0, "rna_Texture_update");
1161
1162 prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
1163 RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_USEALPHA);
1164 RNA_def_property_ui_text(prop, "Use Alpha", "Use the alpha channel information in the image");
1165 RNA_def_property_update(prop, 0, "rna_Texture_update");
1166
1167 prop = RNA_def_property(srna, "use_calculate_alpha", PROP_BOOLEAN, PROP_NONE);
1168 RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_CALCALPHA);
1169 RNA_def_property_ui_text(
1170 prop, "Calculate Alpha", "Calculate an alpha channel based on RGB values in the image");
1171 RNA_def_property_update(prop, 0, "rna_Texture_update");
1172
1173 prop = RNA_def_property(srna, "invert_alpha", PROP_BOOLEAN, PROP_NONE);
1174 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_NEGALPHA);
1175 RNA_def_property_ui_text(prop, "Invert Alpha", "Invert all the alpha values in the image");
1176 RNA_def_property_update(prop, 0, "rna_Texture_update");
1177
1178 rna_def_filter_common(srna);
1179
1180 prop = RNA_def_property(srna, "extension", PROP_ENUM, PROP_NONE);
1181 RNA_def_property_enum_sdna(prop, NULL, "extend");
1182 RNA_def_property_enum_items(prop, prop_image_extension);
1183 RNA_def_property_ui_text(
1184 prop, "Extension", "How the image is extrapolated past its original bounds");
1185 RNA_def_property_update(prop, 0, "rna_Texture_update");
1186
1187 prop = RNA_def_property(srna, "repeat_x", PROP_INT, PROP_NONE);
1188 RNA_def_property_int_sdna(prop, NULL, "xrepeat");
1189 RNA_def_property_range(prop, 1, 512);
1190 RNA_def_property_ui_text(prop, "Repeat X", "Repetition multiplier in the X direction");
1191 RNA_def_property_update(prop, 0, "rna_Texture_update");
1192
1193 prop = RNA_def_property(srna, "repeat_y", PROP_INT, PROP_NONE);
1194 RNA_def_property_int_sdna(prop, NULL, "yrepeat");
1195 RNA_def_property_range(prop, 1, 512);
1196 RNA_def_property_ui_text(prop, "Repeat Y", "Repetition multiplier in the Y direction");
1197 RNA_def_property_update(prop, 0, "rna_Texture_update");
1198
1199 prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
1200 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_REPEAT_XMIR);
1201 RNA_def_property_ui_text(prop, "Mirror X", "Mirror the image repetition on the X direction");
1202 RNA_def_property_update(prop, 0, "rna_Texture_update");
1203
1204 prop = RNA_def_property(srna, "use_mirror_y", PROP_BOOLEAN, PROP_NONE);
1205 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_REPEAT_YMIR);
1206 RNA_def_property_ui_text(prop, "Mirror Y", "Mirror the image repetition on the Y direction");
1207 RNA_def_property_update(prop, 0, "rna_Texture_update");
1208
1209 prop = RNA_def_property(srna, "use_checker_odd", PROP_BOOLEAN, PROP_NONE);
1210 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_CHECKER_ODD);
1211 RNA_def_property_ui_text(prop, "Checker Odd", "Odd checker tiles");
1212 RNA_def_property_update(prop, 0, "rna_Texture_update");
1213
1214 prop = RNA_def_property(srna, "use_checker_even", PROP_BOOLEAN, PROP_NONE);
1215 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_CHECKER_EVEN);
1216 RNA_def_property_ui_text(prop, "Checker Even", "Even checker tiles");
1217 RNA_def_property_update(prop, 0, "rna_Texture_update");
1218
1219 prop = RNA_def_property(srna, "checker_distance", PROP_FLOAT, PROP_NONE);
1220 RNA_def_property_float_sdna(prop, NULL, "checkerdist");
1221 RNA_def_property_range(prop, 0.0, 0.99);
1222 RNA_def_property_ui_range(prop, 0.0, 0.99, 0.1, 2);
1223 RNA_def_property_ui_text(prop, "Checker Distance", "Distance between checker tiles");
1224 RNA_def_property_update(prop, 0, "rna_Texture_update");
1225
1226 # if 0
1227
1228 /* XXX: did this as an array, but needs better descriptions than "1 2 3 4"
1229 * perhaps a new subtype could be added?
1230 * --I actually used single values for this, maybe change later with a RNA_Rect thing? */
1231 prop = RNA_def_property(srna, "crop_rectangle", PROP_FLOAT, PROP_NONE);
1232 RNA_def_property_float_sdna(prop, NULL, "cropxmin");
1233 RNA_def_property_array(prop, 4);
1234 RNA_def_property_range(prop, -10, 10);
1235 RNA_def_property_ui_text(prop, "Crop Rectangle", "");
1236 RNA_def_property_update(prop, 0, "rna_Texture_update");
1237
1238 # endif
1239
1240 prop = RNA_def_property(srna, "crop_min_x", PROP_FLOAT, PROP_NONE);
1241 RNA_def_property_float_sdna(prop, NULL, "cropxmin");
1242 RNA_def_property_range(prop, -10.0, 10.0);
1243 RNA_def_property_ui_range(prop, -10.0, 10.0, 1, 2);
1244 RNA_def_property_ui_text(prop, "Crop Minimum X", "Minimum X value to crop the image");
1245 RNA_def_property_update(prop, 0, "rna_Texture_update");
1246
1247 prop = RNA_def_property(srna, "crop_min_y", PROP_FLOAT, PROP_NONE);
1248 RNA_def_property_float_sdna(prop, NULL, "cropymin");
1249 RNA_def_property_range(prop, -10.0, 10.0);
1250 RNA_def_property_ui_range(prop, -10.0, 10.0, 1, 2);
1251 RNA_def_property_ui_text(prop, "Crop Minimum Y", "Minimum Y value to crop the image");
1252 RNA_def_property_update(prop, 0, "rna_Texture_update");
1253
1254 prop = RNA_def_property(srna, "crop_max_x", PROP_FLOAT, PROP_NONE);
1255 RNA_def_property_float_sdna(prop, NULL, "cropxmax");
1256 RNA_def_property_range(prop, -10.0, 10.0);
1257 RNA_def_property_ui_range(prop, -10.0, 10.0, 1, 2);
1258 RNA_def_property_ui_text(prop, "Crop Maximum X", "Maximum X value to crop the image");
1259 RNA_def_property_update(prop, 0, "rna_Texture_update");
1260
1261 prop = RNA_def_property(srna, "crop_max_y", PROP_FLOAT, PROP_NONE);
1262 RNA_def_property_float_sdna(prop, NULL, "cropymax");
1263 RNA_def_property_range(prop, -10.0, 10.0);
1264 RNA_def_property_ui_range(prop, -10.0, 10.0, 1, 2);
1265 RNA_def_property_ui_text(prop, "Crop Maximum Y", "Maximum Y value to crop the image");
1266 RNA_def_property_update(prop, 0, "rna_Texture_update");
1267
1268 prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
1269 RNA_def_property_pointer_sdna(prop, NULL, "ima");
1270 RNA_def_property_struct_type(prop, "Image");
1271 RNA_def_property_flag(prop, PROP_EDITABLE);
1272 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
1273 RNA_def_property_ui_text(prop, "Image", "");
1274 RNA_def_property_update(prop, 0, "rna_Texture_update");
1275
1276 prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NEVER_NULL);
1277 RNA_def_property_pointer_sdna(prop, NULL, "iuser");
1278 RNA_def_property_ui_text(
1279 prop,
1280 "Image User",
1281 "Parameters defining which layer, pass and frame of the image is displayed");
1282 RNA_def_property_update(prop, 0, "rna_Texture_update");
1283
1284 /* Normal Map */
1285 prop = RNA_def_property(srna, "use_normal_map", PROP_BOOLEAN, PROP_NONE);
1286 RNA_def_property_boolean_sdna(prop, NULL, "imaflag", TEX_NORMALMAP);
1287 RNA_def_property_ui_text(prop, "Normal Map", "Use image RGB values for normal mapping");
1288 RNA_def_property_update(prop, 0, "rna_Texture_update");
1289 }
1290
rna_def_texture_musgrave(BlenderRNA * brna)1291 static void rna_def_texture_musgrave(BlenderRNA *brna)
1292 {
1293 StructRNA *srna;
1294 PropertyRNA *prop;
1295
1296 static const EnumPropertyItem prop_musgrave_type[] = {
1297 {TEX_MFRACTAL, "MULTIFRACTAL", 0, "Multifractal", "Use Perlin noise as a basis"},
1298 {TEX_RIDGEDMF,
1299 "RIDGED_MULTIFRACTAL",
1300 0,
1301 "Ridged Multifractal",
1302 "Use Perlin noise with inflection as a basis"},
1303 {TEX_HYBRIDMF,
1304 "HYBRID_MULTIFRACTAL",
1305 0,
1306 "Hybrid Multifractal",
1307 "Use Perlin noise as a basis, with extended controls"},
1308 {TEX_FBM, "FBM", 0, "fBM", "Fractal Brownian Motion, use Brownian noise as a basis"},
1309 {TEX_HTERRAIN, "HETERO_TERRAIN", 0, "Hetero Terrain", "Similar to multifractal"},
1310 {0, NULL, 0, NULL, NULL},
1311 };
1312
1313 srna = RNA_def_struct(brna, "MusgraveTexture", "Texture");
1314 RNA_def_struct_ui_text(srna, "Musgrave", "Procedural musgrave texture");
1315 RNA_def_struct_sdna(srna, "Tex");
1316
1317 prop = RNA_def_property(srna, "musgrave_type", PROP_ENUM, PROP_NONE);
1318 RNA_def_property_enum_sdna(prop, NULL, "stype");
1319 RNA_def_property_enum_items(prop, prop_musgrave_type);
1320 RNA_def_property_ui_text(prop, "Type", "Fractal noise algorithm");
1321 RNA_def_property_update(prop, 0, "rna_Texture_update");
1322
1323 prop = RNA_def_property(srna, "dimension_max", PROP_FLOAT, PROP_NONE);
1324 RNA_def_property_float_sdna(prop, NULL, "mg_H");
1325 RNA_def_property_range(prop, 0.0001, 2);
1326 RNA_def_property_ui_range(prop, 0.0001, 2, 1, 2);
1327 RNA_def_property_ui_text(prop, "Highest Dimension", "Highest fractal dimension");
1328 RNA_def_property_update(prop, 0, "rna_Texture_update");
1329
1330 prop = RNA_def_property(srna, "lacunarity", PROP_FLOAT, PROP_NONE);
1331 RNA_def_property_float_sdna(prop, NULL, "mg_lacunarity");
1332 RNA_def_property_range(prop, 0, 6);
1333 RNA_def_property_ui_range(prop, 0, 6, 1, 2);
1334 RNA_def_property_ui_text(prop, "Lacunarity", "Gap between successive frequencies");
1335 RNA_def_property_update(prop, 0, "rna_Texture_update");
1336
1337 prop = RNA_def_property(srna, "octaves", PROP_FLOAT, PROP_NONE);
1338 RNA_def_property_float_sdna(prop, NULL, "mg_octaves");
1339 RNA_def_property_range(prop, 0, 8);
1340 RNA_def_property_ui_range(prop, 0, 8, 1, 2);
1341 RNA_def_property_ui_text(prop, "Octaves", "Number of frequencies used");
1342 RNA_def_property_update(prop, 0, "rna_Texture_update");
1343
1344 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
1345 RNA_def_property_float_sdna(prop, NULL, "mg_offset");
1346 RNA_def_property_range(prop, 0, 6);
1347 RNA_def_property_ui_range(prop, 0, 6, 1, 2);
1348 RNA_def_property_ui_text(prop, "Offset", "The fractal offset");
1349 RNA_def_property_update(prop, 0, "rna_Texture_update");
1350
1351 prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE);
1352 RNA_def_property_float_sdna(prop, NULL, "mg_gain");
1353 RNA_def_property_range(prop, 0, 6);
1354 RNA_def_property_ui_range(prop, 0, 6, 1, 2);
1355 RNA_def_property_ui_text(prop, "Gain", "The gain multiplier");
1356 RNA_def_property_update(prop, 0, "rna_Texture_update");
1357
1358 prop = RNA_def_property(srna, "noise_intensity", PROP_FLOAT, PROP_NONE);
1359 RNA_def_property_float_sdna(prop, NULL, "ns_outscale");
1360 RNA_def_property_range(prop, 0, 10);
1361 RNA_def_property_ui_range(prop, 0, 10, 1, 2);
1362 RNA_def_property_ui_text(prop, "Noise Intensity", "Intensity of the noise");
1363 RNA_def_property_update(prop, 0, "rna_Texture_update");
1364
1365 prop = RNA_def_property(srna, "noise_scale", PROP_FLOAT, PROP_NONE);
1366 RNA_def_property_float_sdna(prop, NULL, "noisesize");
1367 RNA_def_property_range(prop, 0.0001, FLT_MAX);
1368 RNA_def_property_ui_range(prop, 0.0001, 2, 1, 2);
1369 RNA_def_property_ui_text(prop, "Noise Size", "Scaling for noise input");
1370 RNA_def_property_update(prop, 0, "rna_Texture_update");
1371
1372 prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
1373 RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
1374 RNA_def_property_enum_items(prop, prop_noise_basis_items);
1375 RNA_def_property_ui_text(prop, "Noise Basis", "Noise basis used for turbulence");
1376 RNA_def_property_update(prop, 0, "rna_Texture_update");
1377
1378 prop = RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
1379 RNA_def_property_range(prop, 0.001, 0.1);
1380 RNA_def_property_ui_range(prop, 0.001, 0.1, 1, 2);
1381 RNA_def_property_ui_text(prop, "Nabla", "Size of derivative offset used for calculating normal");
1382 RNA_def_property_update(prop, 0, "rna_Texture_update");
1383 }
1384
rna_def_texture_voronoi(BlenderRNA * brna)1385 static void rna_def_texture_voronoi(BlenderRNA *brna)
1386 {
1387 StructRNA *srna;
1388 PropertyRNA *prop;
1389
1390 static const EnumPropertyItem prop_distance_metric_items[] = {
1391 {TEX_DISTANCE, "DISTANCE", 0, "Actual Distance", "sqrt(x*x+y*y+z*z)"},
1392 {TEX_DISTANCE_SQUARED, "DISTANCE_SQUARED", 0, "Distance Squared", "(x*x+y*y+z*z)"},
1393 {TEX_MANHATTAN,
1394 "MANHATTAN",
1395 0,
1396 "Manhattan",
1397 "The length of the distance in axial directions"},
1398 {TEX_CHEBYCHEV, "CHEBYCHEV", 0, "Chebychev", "The length of the longest Axial journey"},
1399 {TEX_MINKOVSKY_HALF, "MINKOVSKY_HALF", 0, "Minkowski 1/2", "Set Minkowski variable to 0.5"},
1400 {TEX_MINKOVSKY_FOUR, "MINKOVSKY_FOUR", 0, "Minkowski 4", "Set Minkowski variable to 4"},
1401 {TEX_MINKOVSKY,
1402 "MINKOVSKY",
1403 0,
1404 "Minkowski",
1405 "Use the Minkowski function to calculate distance "
1406 "(exponent value determines the shape of the boundaries)"},
1407 {0, NULL, 0, NULL, NULL},
1408 };
1409
1410 static const EnumPropertyItem prop_coloring_items[] = {
1411 /* XXX: OK names / descriptions? */
1412 {TEX_INTENSITY, "INTENSITY", 0, "Intensity", "Only calculate intensity"},
1413 {TEX_COL1, "POSITION", 0, "Position", "Color cells by position"},
1414 {TEX_COL2,
1415 "POSITION_OUTLINE",
1416 0,
1417 "Position and Outline",
1418 "Use position plus an outline based on F2-F1"},
1419 {TEX_COL3,
1420 "POSITION_OUTLINE_INTENSITY",
1421 0,
1422 "Position, Outline, and Intensity",
1423 "Multiply position and outline by intensity"},
1424 {0, NULL, 0, NULL, NULL},
1425 };
1426
1427 srna = RNA_def_struct(brna, "VoronoiTexture", "Texture");
1428 RNA_def_struct_ui_text(srna, "Voronoi", "Procedural voronoi texture");
1429 RNA_def_struct_sdna(srna, "Tex");
1430
1431 prop = RNA_def_property(srna, "weight_1", PROP_FLOAT, PROP_NONE);
1432 RNA_def_property_float_sdna(prop, NULL, "vn_w1");
1433 RNA_def_property_range(prop, -2, 2);
1434 RNA_def_property_ui_text(prop, "Weight 1", "Voronoi feature weight 1");
1435 RNA_def_property_update(prop, 0, "rna_Texture_update");
1436
1437 prop = RNA_def_property(srna, "weight_2", PROP_FLOAT, PROP_NONE);
1438 RNA_def_property_float_sdna(prop, NULL, "vn_w2");
1439 RNA_def_property_range(prop, -2, 2);
1440 RNA_def_property_ui_text(prop, "Weight 2", "Voronoi feature weight 2");
1441 RNA_def_property_update(prop, 0, "rna_Texture_update");
1442
1443 prop = RNA_def_property(srna, "weight_3", PROP_FLOAT, PROP_NONE);
1444 RNA_def_property_float_sdna(prop, NULL, "vn_w3");
1445 RNA_def_property_range(prop, -2, 2);
1446 RNA_def_property_ui_text(prop, "Weight 3", "Voronoi feature weight 3");
1447 RNA_def_property_update(prop, 0, "rna_Texture_update");
1448
1449 prop = RNA_def_property(srna, "weight_4", PROP_FLOAT, PROP_NONE);
1450 RNA_def_property_float_sdna(prop, NULL, "vn_w4");
1451 RNA_def_property_range(prop, -2, 2);
1452 RNA_def_property_ui_text(prop, "Weight 4", "Voronoi feature weight 4");
1453 RNA_def_property_update(prop, 0, "rna_Texture_update");
1454
1455 prop = RNA_def_property(srna, "minkovsky_exponent", PROP_FLOAT, PROP_NONE);
1456 RNA_def_property_float_sdna(prop, NULL, "vn_mexp");
1457 RNA_def_property_range(prop, 0.01, 10);
1458 RNA_def_property_ui_text(prop, "Minkowski Exponent", "Minkowski exponent");
1459 RNA_def_property_update(prop, 0, "rna_Texture_update");
1460
1461 prop = RNA_def_property(srna, "distance_metric", PROP_ENUM, PROP_NONE);
1462 RNA_def_property_enum_sdna(prop, NULL, "vn_distm");
1463 RNA_def_property_enum_items(prop, prop_distance_metric_items);
1464 RNA_def_property_ui_text(
1465 prop,
1466 "Distance Metric",
1467 "Algorithm used to calculate distance of sample points to feature points");
1468 RNA_def_property_update(prop, 0, "rna_Texture_update");
1469
1470 prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
1471 RNA_def_property_enum_sdna(prop, NULL, "vn_coltype");
1472 RNA_def_property_enum_items(prop, prop_coloring_items);
1473 RNA_def_property_ui_text(prop, "Coloring", "");
1474 RNA_def_property_update(prop, 0, "rna_Texture_update");
1475
1476 prop = RNA_def_property(srna, "noise_intensity", PROP_FLOAT, PROP_NONE);
1477 RNA_def_property_float_sdna(prop, NULL, "ns_outscale");
1478 RNA_def_property_range(prop, 0.01, 10);
1479 RNA_def_property_ui_text(prop, "Noise Intensity", "Scales the intensity of the noise");
1480 RNA_def_property_update(prop, 0, "rna_Texture_update");
1481
1482 prop = RNA_def_property(srna, "noise_scale", PROP_FLOAT, PROP_NONE);
1483 RNA_def_property_float_sdna(prop, NULL, "noisesize");
1484 RNA_def_property_range(prop, 0.0001, FLT_MAX);
1485 RNA_def_property_ui_range(prop, 0.0001, 2, 1, 2);
1486 RNA_def_property_ui_text(prop, "Noise Size", "Scaling for noise input");
1487 RNA_def_property_update(prop, 0, "rna_Texture_update");
1488
1489 prop = RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
1490 RNA_def_property_range(prop, 0.001, 0.1);
1491 RNA_def_property_ui_range(prop, 0.001, 0.1, 1, 2);
1492 RNA_def_property_ui_text(prop, "Nabla", "Size of derivative offset used for calculating normal");
1493 RNA_def_property_update(prop, 0, "rna_Texture_update");
1494 }
1495
rna_def_texture_distorted_noise(BlenderRNA * brna)1496 static void rna_def_texture_distorted_noise(BlenderRNA *brna)
1497 {
1498 StructRNA *srna;
1499 PropertyRNA *prop;
1500
1501 srna = RNA_def_struct(brna, "DistortedNoiseTexture", "Texture");
1502 RNA_def_struct_ui_text(srna, "Distorted Noise", "Procedural distorted noise texture");
1503 RNA_def_struct_sdna(srna, "Tex");
1504
1505 prop = RNA_def_property(srna, "distortion", PROP_FLOAT, PROP_NONE);
1506 RNA_def_property_float_sdna(prop, NULL, "dist_amount");
1507 RNA_def_property_range(prop, 0, 10);
1508 RNA_def_property_ui_text(prop, "Distortion Amount", "Amount of distortion");
1509 RNA_def_property_update(prop, 0, "rna_Texture_update");
1510
1511 prop = RNA_def_property(srna, "noise_scale", PROP_FLOAT, PROP_NONE);
1512 RNA_def_property_float_sdna(prop, NULL, "noisesize");
1513 RNA_def_property_range(prop, 0.0001, FLT_MAX);
1514 RNA_def_property_ui_range(prop, 0.0001, 2, 1, 2);
1515 RNA_def_property_ui_text(prop, "Noise Size", "Scaling for noise input");
1516 RNA_def_property_update(prop, 0, "rna_Texture_update");
1517
1518 prop = RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
1519 RNA_def_property_enum_sdna(prop, NULL, "noisebasis2");
1520 RNA_def_property_enum_items(prop, prop_noise_basis_items);
1521 RNA_def_property_ui_text(prop, "Noise Basis", "Noise basis used for turbulence");
1522 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
1523
1524 prop = RNA_def_property(srna, "noise_distortion", PROP_ENUM, PROP_NONE);
1525 RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
1526 RNA_def_property_enum_items(prop, prop_noise_basis_items);
1527 RNA_def_property_ui_text(prop, "Noise Distortion", "Noise basis for the distortion");
1528 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
1529
1530 prop = RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
1531 RNA_def_property_range(prop, 0.001, 0.1);
1532 RNA_def_property_ui_range(prop, 0.001, 0.1, 1, 2);
1533 RNA_def_property_ui_text(prop, "Nabla", "Size of derivative offset used for calculating normal");
1534 RNA_def_property_update(prop, 0, "rna_Texture_update");
1535 }
1536
rna_def_texture(BlenderRNA * brna)1537 static void rna_def_texture(BlenderRNA *brna)
1538 {
1539 StructRNA *srna;
1540 PropertyRNA *prop;
1541
1542 srna = RNA_def_struct(brna, "Texture", "ID");
1543 RNA_def_struct_sdna(srna, "Tex");
1544 RNA_def_struct_ui_text(
1545 srna, "Texture", "Texture data-block used by materials, lights, worlds and brushes");
1546 RNA_def_struct_ui_icon(srna, ICON_TEXTURE_DATA);
1547 RNA_def_struct_refine_func(srna, "rna_Texture_refine");
1548
1549 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1550 /*RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1551 RNA_def_property_enum_sdna(prop, NULL, "type");
1552 RNA_def_property_enum_items(prop, rna_enum_texture_type_items);
1553 RNA_def_property_enum_funcs(prop, NULL, "rna_Texture_type_set", NULL);
1554 RNA_def_property_ui_text(prop, "Type", "");
1555 RNA_def_property_update(prop, 0, "rna_Texture_update");
1556
1557 prop = RNA_def_property(srna, "use_clamp", PROP_BOOLEAN, PROP_NONE);
1558 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TEX_NO_CLAMP);
1559 RNA_def_property_ui_text(prop,
1560 "Clamp",
1561 "Set negative texture RGB and intensity values to zero, for some uses "
1562 "like displacement this option can be disabled to get the full range");
1563 RNA_def_property_update(prop, 0, "rna_Texture_update");
1564
1565 prop = RNA_def_property(srna, "use_color_ramp", PROP_BOOLEAN, PROP_NONE);
1566 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_COLORBAND);
1567 RNA_def_property_boolean_funcs(prop, NULL, "rna_Texture_use_color_ramp_set");
1568 RNA_def_property_ui_text(prop,
1569 "Use Color Ramp",
1570 "Map the texture intensity to the color ramp. "
1571 "Note that the alpha value is used for image textures, "
1572 "enable \"Calculate Alpha\" for images without an alpha channel");
1573 RNA_def_property_update(prop, 0, "rna_Texture_update");
1574
1575 prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL);
1576 RNA_def_property_pointer_sdna(prop, NULL, "coba");
1577 RNA_def_property_struct_type(prop, "ColorRamp");
1578 RNA_def_property_ui_text(prop, "Color Ramp", "");
1579 RNA_def_property_update(prop, 0, "rna_Texture_update");
1580
1581 prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
1582 RNA_def_property_float_sdna(prop, NULL, "bright");
1583 RNA_def_property_range(prop, 0, 2);
1584 RNA_def_property_ui_range(prop, 0, 2, 1, 3);
1585 RNA_def_property_ui_text(prop, "Brightness", "Adjust the brightness of the texture");
1586 RNA_def_property_update(prop, 0, "rna_Texture_update");
1587
1588 prop = RNA_def_property(srna, "contrast", PROP_FLOAT, PROP_NONE);
1589 RNA_def_property_range(prop, 0.0, 5);
1590 RNA_def_property_ui_range(prop, 0, 5, 1, 3);
1591 RNA_def_property_ui_text(prop, "Contrast", "Adjust the contrast of the texture");
1592 RNA_def_property_update(prop, 0, "rna_Texture_update");
1593
1594 prop = RNA_def_property(srna, "saturation", PROP_FLOAT, PROP_NONE);
1595 RNA_def_property_range(prop, 0, 2);
1596 RNA_def_property_ui_range(prop, 0, 2, 1, 3);
1597 RNA_def_property_ui_text(prop, "Saturation", "Adjust the saturation of colors in the texture");
1598 RNA_def_property_update(prop, 0, "rna_Texture_update");
1599
1600 /* RGB Factor */
1601 prop = RNA_def_property(srna, "factor_red", PROP_FLOAT, PROP_NONE);
1602 RNA_def_property_float_sdna(prop, NULL, "rfac");
1603 RNA_def_property_range(prop, 0, 2);
1604 RNA_def_property_ui_range(prop, 0, 2, 1, 3);
1605 RNA_def_property_ui_text(prop, "Factor Red", "");
1606 RNA_def_property_update(prop, 0, "rna_Texture_update");
1607
1608 prop = RNA_def_property(srna, "factor_green", PROP_FLOAT, PROP_NONE);
1609 RNA_def_property_float_sdna(prop, NULL, "gfac");
1610 RNA_def_property_range(prop, 0, 2);
1611 RNA_def_property_ui_range(prop, 0, 2, 1, 3);
1612 RNA_def_property_ui_text(prop, "Factor Green", "");
1613 RNA_def_property_update(prop, 0, "rna_Texture_update");
1614
1615 prop = RNA_def_property(srna, "factor_blue", PROP_FLOAT, PROP_NONE);
1616 RNA_def_property_float_sdna(prop, NULL, "bfac");
1617 RNA_def_property_range(prop, 0, 2);
1618 RNA_def_property_ui_range(prop, 0, 2, 1, 3);
1619 RNA_def_property_ui_text(prop, "Factor Blue", "");
1620 RNA_def_property_update(prop, 0, "rna_Texture_update");
1621
1622 /* Alpha for preview render */
1623 prop = RNA_def_property(srna, "use_preview_alpha", PROP_BOOLEAN, PROP_NONE);
1624 RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PRV_ALPHA);
1625 RNA_def_property_ui_text(prop, "Show Alpha", "Show Alpha in Preview Render");
1626 RNA_def_property_update(prop, 0, "rna_Texture_update");
1627
1628 /* nodetree */
1629 prop = RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE);
1630 RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
1631 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1632 RNA_def_property_ui_text(prop, "Use Nodes", "Make this a node-based texture");
1633 RNA_def_property_update(prop, 0, "rna_Texture_use_nodes_update");
1634
1635 prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
1636 RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
1637 RNA_def_property_clear_flag(prop, PROP_PTR_NO_OWNERSHIP);
1638 RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node-based textures");
1639 RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
1640
1641 rna_def_animdata_common(srna);
1642
1643 /* specific types */
1644 rna_def_texture_clouds(brna);
1645 rna_def_texture_wood(brna);
1646 rna_def_texture_marble(brna);
1647 rna_def_texture_magic(brna);
1648 rna_def_texture_blend(brna);
1649 rna_def_texture_stucci(brna);
1650 rna_def_texture_noise(brna);
1651 rna_def_texture_image(brna);
1652 rna_def_texture_musgrave(brna);
1653 rna_def_texture_voronoi(brna);
1654 rna_def_texture_distorted_noise(brna);
1655 /* XXX add more types here .. */
1656
1657 RNA_api_texture(srna);
1658 }
1659
RNA_def_texture(BlenderRNA * brna)1660 void RNA_def_texture(BlenderRNA *brna)
1661 {
1662 rna_def_texture(brna);
1663 rna_def_mtex(brna);
1664 rna_def_texmapping(brna);
1665 rna_def_colormapping(brna);
1666 }
1667
1668 #endif
1669