2.5 Nodes:

* Wrapped Texture Nodes: "Blend", "Marble", "Wood", "Clouds", and "Distorted Noise", to use Texture RNA properties.
* Texture RNA properties used in these Nodes, now send an ND_NODE notifier, in addition to the general NC_TEXTURE.
This commit is contained in:
Thomas Dinges 2009-12-05 21:14:31 +00:00
parent 651336d5df
commit 9d2293c464
2 changed files with 50 additions and 82 deletions

@ -1088,89 +1088,56 @@ static void node_texture_buts_bricks(uiLayout *layout, bContext *C, PointerRNA *
uiItemR(col, "Frequency", 0, ptr, "squash_frequency", 0); uiItemR(col, "Frequency", 0, ptr, "squash_frequency", 0);
} }
/* Copied from buttons_shading.c -- needs unifying */
static char* noisebasis_menu()
{
static char nbmenu[256];
sprintf(nbmenu, "Noise Basis %%t|Blender Original %%x%d|Original Perlin %%x%d|Improved Perlin %%x%d|Voronoi F1 %%x%d|Voronoi F2 %%x%d|Voronoi F3 %%x%d|Voronoi F4 %%x%d|Voronoi F2-F1 %%x%d|Voronoi Crackle %%x%d|CellNoise %%x%d", TEX_BLENDER, TEX_STDPERLIN, TEX_NEWPERLIN, TEX_VORONOI_F1, TEX_VORONOI_F2, TEX_VORONOI_F3, TEX_VORONOI_F4, TEX_VORONOI_F2F1, TEX_VORONOI_CRACKLE, TEX_CELLNOISE);
return nbmenu;
}
static void node_texture_buts_proc(uiLayout *layout, bContext *C, PointerRNA *ptr) static void node_texture_buts_proc(uiLayout *layout, bContext *C, PointerRNA *ptr)
{ {
uiBlock *block= uiLayoutAbsoluteBlock(layout); PointerRNA tex_ptr;
bNode *node= ptr->data; bNode *node= ptr->data;
rctf *butr= &node->butr; ID *id= ptr->id.data;
Tex *tex = (Tex *)node->storage; Tex *tex = (Tex *)node->storage;
short x,y,w,h; uiLayout *col, *row;
x = butr->xmin;
y = butr->ymin;
w = butr->xmax - x;
h = butr->ymax - y;
RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr);
col= uiLayoutColumn(layout, 0);
switch( tex->type ) { switch( tex->type ) {
case TEX_BLEND: case TEX_BLEND:
uiBlockBeginAlign( block ); uiItemR(col, "", 0, &tex_ptr, "progression", 0);
uiDefButS( block, MENU, B_NODE_EXEC, row= uiLayoutRow(col, 0);
"Linear %x0|Quad %x1|Ease %x2|Diag %x3|Sphere %x4|Halo %x5|Radial %x6", uiItemR(row, NULL, 0, &tex_ptr, "flip_axis", UI_ITEM_R_EXPAND);
x, y+20, w, 20, &tex->stype, 0, 1, 0, 0, "Blend Type" );
uiDefButBitS(block, TOG, TEX_FLIPBLEND, B_NODE_EXEC, "Flip XY", x, y, w, 20,
&tex->flag, 0, 0, 0, 0, "Flips the direction of the progression 90 degrees");
uiBlockEndAlign( block );
break; break;
case TEX_MARBLE: case TEX_MARBLE:
uiBlockBeginAlign(block); row= uiLayoutRow(col, 0);
uiItemR(row, NULL, 0, &tex_ptr, "stype", UI_ITEM_R_EXPAND);
uiDefButS(block, ROW, B_NODE_EXEC, "Soft", 0*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SOFT, 0, 0, "Uses soft marble"); row= uiLayoutRow(col, 0);
uiDefButS(block, ROW, B_NODE_EXEC, "Sharp", 1*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SHARP, 0, 0, "Uses more clearly defined marble"); uiItemR(row, NULL, 0, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND);
uiDefButS(block, ROW, B_NODE_EXEC, "Sharper", 2*w/3+x, 40+y, w/3, 18, &tex->stype, 2.0, (float)TEX_SHARPER, 0, 0, "Uses very clearly defined marble"); row= uiLayoutRow(col, 0);
uiItemR(row, NULL, 0, &tex_ptr, "noisebasis2", UI_ITEM_R_EXPAND);
uiDefButS(block, ROW, B_NODE_EXEC, "Soft noise", 0*w/2+x, 20+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISESOFT, 0, 0, "Generates soft noise");
uiDefButS(block, ROW, B_NODE_EXEC, "Hard noise", 1*w/2+x, 20+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISEPERL, 0, 0, "Generates hard noise");
uiDefButS(block, ROW, B_NODE_EXEC, "Sin", 0*w/3+x, 0+y, w/3, 18, &tex->noisebasis2, 8.0, 0.0, 0, 0, "Uses a sine wave to produce bands.");
uiDefButS(block, ROW, B_NODE_EXEC, "Saw", 1*w/3+x, 0+y, w/3, 18, &tex->noisebasis2, 8.0, 1.0, 0, 0, "Uses a saw wave to produce bands");
uiDefButS(block, ROW, B_NODE_EXEC, "Tri", 2*w/3+x, 0+y, w/3, 18, &tex->noisebasis2, 8.0, 2.0, 0, 0, "Uses a triangle wave to produce bands");
uiBlockEndAlign(block);
break; break;
case TEX_WOOD: case TEX_WOOD:
uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), x, y+64, w, 18, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence"); uiItemR(col, "", 0, &tex_ptr, "noise_basis", 0);
uiItemR(col, "", 0, &tex_ptr, "stype", 0);
uiBlockBeginAlign(block); row= uiLayoutRow(col, 0);
uiDefButS(block, ROW, B_TEXPRV, "Bands", x, 40+y, w/2, 18, &tex->stype, 2.0, (float)TEX_BANDNOISE, 0, 0, "Uses standard noise"); uiItemR(row, NULL, 0, &tex_ptr, "noisebasis2", UI_ITEM_R_EXPAND);
uiDefButS(block, ROW, B_TEXPRV, "Rings", w/2+x, 40+y, w/2, 18, &tex->stype, 2.0, (float)TEX_RINGNOISE, 0, 0, "Lets Noise return RGB value"); row= uiLayoutRow(col, 0);
uiLayoutSetActive(row, !(RNA_enum_get(&tex_ptr, "stype")==TEX_BAND || RNA_enum_get(&tex_ptr, "stype")==TEX_RING));
uiDefButS(block, ROW, B_NODE_EXEC, "Sin", 0*w/3+x, 20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_SIN, 0, 0, "Uses a sine wave to produce bands."); uiItemR(row, NULL, 0, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND);
uiDefButS(block, ROW, B_NODE_EXEC, "Saw", 1*w/3+x, 20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_SAW, 0, 0, "Uses a saw wave to produce bands");
uiDefButS(block, ROW, B_NODE_EXEC, "Tri", 2*w/3+x, 20+y, w/3, 18, &tex->noisebasis2, 8.0, (float)TEX_TRI, 0, 0, "Uses a triangle wave to produce bands");
uiDefButS(block, ROW, B_NODE_EXEC, "Soft noise", 0*w/2+x, 0+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISESOFT, 0, 0, "Generates soft noise");
uiDefButS(block, ROW, B_NODE_EXEC, "Hard noise", 1*w/2+x, 0+y, w/2, 19, &tex->noisetype, 12.0, (float)TEX_NOISEPERL, 0, 0, "Generates hard noise");
uiBlockEndAlign(block);
break; break;
case TEX_CLOUDS: case TEX_CLOUDS:
uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), x, y+60, w, 18, &tex->noisebasis, 0,0,0,0, "Sets the noise basis used for turbulence"); uiItemR(col, "", 0, &tex_ptr, "noise_basis", 0);
row= uiLayoutRow(col, 0);
uiBlockBeginAlign(block); uiItemR(row, NULL, 0, &tex_ptr, "stype", UI_ITEM_R_EXPAND);
uiDefButS(block, ROW, B_TEXPRV, "B/W", x, y+38, w/2, 18, &tex->stype, 2.0, (float)TEX_DEFAULT, 0, 0, "Uses standard noise"); row= uiLayoutRow(col, 0);
uiDefButS(block, ROW, B_TEXPRV, "Color", w/2+x, y+38, w/2, 18, &tex->stype, 2.0, (float)TEX_COLOR, 0, 0, "Lets Noise return RGB value"); uiItemR(row, NULL, 0, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND);
uiDefButS(block, ROW, B_TEXPRV, "Soft", x, y+20, w/2, 18, &tex->noisetype, 12.0, (float)TEX_NOISESOFT, 0, 0, "Generates soft noise"); uiItemR(col, "Depth", 0, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND);
uiDefButS(block, ROW, B_TEXPRV, "Hard", w/2+x, y+20, w/2, 18, &tex->noisetype, 12.0, (float)TEX_NOISEPERL, 0, 0, "Generates hard noise");
uiBlockEndAlign(block);
uiDefButS(block, NUM, B_TEXPRV, "Depth:", x, y, w, 18, &tex->noisedepth, 0.0, 6.0, 0, 0, "Sets the depth of the cloud calculation");
break; break;
case TEX_DISTNOISE: case TEX_DISTNOISE:
uiBlockBeginAlign(block); uiItemR(col, "", 0, &tex_ptr, "noise_basis", 0);
uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), x, y+18, w, 18, &tex->noisebasis2, 0,0,0,0, "Sets the noise basis to distort"); uiItemR(col, "", 0, &tex_ptr, "noise_distortion", 0);
uiDefButS(block, MENU, B_TEXPRV, noisebasis_menu(), x, y, w, 18, &tex->noisebasis, 0,0,0,0, "Sets the noise basis which does the distortion");
uiBlockEndAlign(block);
break; break;
} }
} }

@ -114,6 +114,7 @@ static void rna_Texture_update(bContext *C, PointerRNA *ptr)
WM_event_add_notifier(C, NC_TEXTURE, tex); WM_event_add_notifier(C, NC_TEXTURE, tex);
} }
/* Used for Texture Properties, used (also) for/in Nodes */
static void rna_Texture_nodes_update(bContext *C, PointerRNA *ptr) static void rna_Texture_nodes_update(bContext *C, PointerRNA *ptr)
{ {
Tex *tex= ptr->id.data; Tex *tex= ptr->id.data;
@ -784,25 +785,25 @@ static void rna_def_texture_clouds(BlenderRNA *brna)
RNA_def_property_range(prop, 0, INT_MAX); RNA_def_property_range(prop, 0, INT_MAX);
RNA_def_property_ui_range(prop, 0, 6, 0, 2); RNA_def_property_ui_range(prop, 0, 6, 0, 2);
RNA_def_property_ui_text(prop, "Noise Depth", "Sets the depth of the cloud calculation"); RNA_def_property_ui_text(prop, "Noise Depth", "Sets the depth of the cloud calculation");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisebasis"); RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
RNA_def_property_enum_items(prop, prop_noise_basis_items); RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisetype"); RNA_def_property_enum_sdna(prop, NULL, "noisetype");
RNA_def_property_enum_items(prop, prop_noise_type); RNA_def_property_enum_items(prop, prop_noise_type);
RNA_def_property_ui_text(prop, "Noise Type", ""); RNA_def_property_ui_text(prop, "Noise Type", "");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "stype", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "stype", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "stype"); RNA_def_property_enum_sdna(prop, NULL, "stype");
RNA_def_property_enum_items(prop, prop_clouds_stype); RNA_def_property_enum_items(prop, prop_clouds_stype);
RNA_def_property_ui_text(prop, "Color", ""); RNA_def_property_ui_text(prop, "Color", "");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001, 0.1); RNA_def_property_range(prop, 0.001, 0.1);
@ -851,25 +852,25 @@ static void rna_def_texture_wood(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "noisebasis"); RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
RNA_def_property_enum_items(prop, prop_noise_basis_items); RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisetype"); RNA_def_property_enum_sdna(prop, NULL, "noisetype");
RNA_def_property_enum_items(prop, prop_noise_type); RNA_def_property_enum_items(prop, prop_noise_type);
RNA_def_property_ui_text(prop, "Noise Type", ""); RNA_def_property_ui_text(prop, "Noise Type", "");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "stype", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "stype", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "stype"); RNA_def_property_enum_sdna(prop, NULL, "stype");
RNA_def_property_enum_items(prop, prop_wood_stype); RNA_def_property_enum_items(prop, prop_wood_stype);
RNA_def_property_ui_text(prop, "Pattern", ""); RNA_def_property_ui_text(prop, "Pattern", "");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "noisebasis2", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "noisebasis2", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisebasis2"); RNA_def_property_enum_sdna(prop, NULL, "noisebasis2");
RNA_def_property_enum_items(prop, prop_wood_noisebasis2); RNA_def_property_enum_items(prop, prop_wood_noisebasis2);
RNA_def_property_ui_text(prop, "Noise Basis 2", ""); RNA_def_property_ui_text(prop, "Noise Basis 2", "");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001, 0.1); RNA_def_property_range(prop, 0.001, 0.1);
@ -925,25 +926,25 @@ static void rna_def_texture_marble(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "noisetype"); RNA_def_property_enum_sdna(prop, NULL, "noisetype");
RNA_def_property_enum_items(prop, prop_noise_type); RNA_def_property_enum_items(prop, prop_noise_type);
RNA_def_property_ui_text(prop, "Noise Type", ""); RNA_def_property_ui_text(prop, "Noise Type", "");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "stype", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "stype", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "stype"); RNA_def_property_enum_sdna(prop, NULL, "stype");
RNA_def_property_enum_items(prop, prop_marble_stype); RNA_def_property_enum_items(prop, prop_marble_stype);
RNA_def_property_ui_text(prop, "Pattern", ""); RNA_def_property_ui_text(prop, "Pattern", "");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisebasis"); RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
RNA_def_property_enum_items(prop, prop_noise_basis_items); RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "noisebasis2", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "noisebasis2", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisebasis2"); RNA_def_property_enum_sdna(prop, NULL, "noisebasis2");
RNA_def_property_enum_items(prop, prop_marble_noisebasis2); RNA_def_property_enum_items(prop, prop_marble_noisebasis2);
RNA_def_property_ui_text(prop, "Noise Basis 2", ""); RNA_def_property_ui_text(prop, "Noise Basis 2", "");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001, 0.1); RNA_def_property_range(prop, 0.001, 0.1);
@ -1005,13 +1006,13 @@ static void rna_def_texture_blend(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "stype"); RNA_def_property_enum_sdna(prop, NULL, "stype");
RNA_def_property_enum_items(prop, prop_blend_progression); RNA_def_property_enum_items(prop, prop_blend_progression);
RNA_def_property_ui_text(prop, "Progression", "Sets the style of the color blending"); RNA_def_property_ui_text(prop, "Progression", "Sets the style of the color blending");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "flip_axis", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "flip_axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, prop_flip_axis_items); RNA_def_property_enum_items(prop, prop_flip_axis_items);
RNA_def_property_ui_text(prop, "Flip Axis", "Flips the texture's X and Y axis"); RNA_def_property_ui_text(prop, "Flip Axis", "Flips the texture's X and Y axis");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
} }
@ -1500,13 +1501,13 @@ static void rna_def_texture_distorted_noise(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "noisebasis2"); RNA_def_property_enum_sdna(prop, NULL, "noisebasis2");
RNA_def_property_enum_items(prop, prop_noise_basis_items); RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "noise_distortion", PROP_ENUM, PROP_NONE); prop= RNA_def_property(srna, "noise_distortion", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "noisebasis"); RNA_def_property_enum_sdna(prop, NULL, "noisebasis");
RNA_def_property_enum_items(prop, prop_noise_basis_items); RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Distortion", "Sets the noise basis for the distortion"); RNA_def_property_ui_text(prop, "Noise Distortion", "Sets the noise basis for the distortion");
RNA_def_property_update(prop, 0, "rna_Texture_update"); RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE); prop= RNA_def_property(srna, "nabla", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.001, 0.1); RNA_def_property_range(prop, 0.001, 0.1);