diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2016-05-13 08:50:07 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2016-05-13 08:53:03 +0300 |
commit | 545413d8e82348f6e797638ee5d9af10540829d6 (patch) | |
tree | 4afcc5fff49334cf0d856e609024da9c4b31e5b6 /source | |
parent | 0e974d6e917ef2bbf89d26b41eeba69893a74d15 (diff) |
Removed texture nodes.
The node tree type is left alone for now, only the node types are removed.
Diffstat (limited to 'source')
43 files changed, 7 insertions, 3568 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 4ae175fcf7b..794649a122b 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -996,40 +996,7 @@ void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *ntree, bNode *node); /** \name Texture Nodes */ -struct TexResult; - -#define TEX_NODE_OUTPUT 401 -#define TEX_NODE_CHECKER 402 -#define TEX_NODE_TEXTURE 403 -#define TEX_NODE_BRICKS 404 -#define TEX_NODE_MATH 405 -#define TEX_NODE_MIX_RGB 406 -#define TEX_NODE_RGBTOBW 407 -#define TEX_NODE_VALTORGB 408 -#define TEX_NODE_IMAGE 409 -#define TEX_NODE_CURVE_RGB 410 -#define TEX_NODE_INVERT 411 -#define TEX_NODE_HUE_SAT 412 -#define TEX_NODE_CURVE_TIME 413 -#define TEX_NODE_ROTATE 414 -#define TEX_NODE_VIEWER 415 -#define TEX_NODE_TRANSLATE 416 -#define TEX_NODE_COORD 417 -#define TEX_NODE_DISTANCE 418 -#define TEX_NODE_COMPOSE 419 -#define TEX_NODE_DECOMPOSE 420 -#define TEX_NODE_VALTONOR 421 -#define TEX_NODE_SCALE 422 -#define TEX_NODE_AT 423 - -/* 501-599 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */ -#define TEX_NODE_PROC 500 -#define TEX_NODE_PROC_MAX 600 - /* API */ -int ntreeTexTagAnimated(struct bNodeTree *ntree); -void ntreeTexCheckCyclics(struct bNodeTree *ntree); - struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree); void ntreeTexEndExecTree(struct bNodeTreeExec *exec); /** \} */ diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d4551fd0b2c..45007b327ff 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2646,17 +2646,6 @@ void BKE_image_walk_all_users(const Main *mainp, void *customdata, if (tex->type == TEX_IMAGE && tex->ima) { callback(tex->ima, &tex->iuser, customdata); } - - if (tex->nodetree) { - bNode *node; - for (node = tex->nodetree->nodes.first; node; node = node->next) { - if (node->id && node->type == TEX_NODE_IMAGE) { - Image *ima = (Image *)node->id; - ImageUser *iuser = node->storage; - callback(ima, iuser, customdata); - } - } - } } /* image window, compo node users */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 75f899dd597..314ccaf8a9b 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3708,56 +3708,6 @@ static void registerShaderNodes(void) register_node_type_sh_tex_pointdensity(); } -static void registerTextureNodes(void) -{ - register_node_type_tex_group(); - - - register_node_type_tex_math(); - register_node_type_tex_mix_rgb(); - register_node_type_tex_valtorgb(); - register_node_type_tex_rgbtobw(); - register_node_type_tex_valtonor(); - register_node_type_tex_curve_rgb(); - register_node_type_tex_curve_time(); - register_node_type_tex_invert(); - register_node_type_tex_hue_sat(); - register_node_type_tex_coord(); - register_node_type_tex_distance(); - register_node_type_tex_compose(); - register_node_type_tex_decompose(); - - register_node_type_tex_output(); - register_node_type_tex_viewer(); - register_node_type_sh_script(); - register_node_type_sh_tangent(); - register_node_type_sh_normal_map(); - register_node_type_sh_hair_info(); - - register_node_type_tex_checker(); - register_node_type_tex_texture(); - register_node_type_tex_bricks(); - register_node_type_tex_image(); - register_node_type_sh_bsdf_refraction(); - register_node_type_sh_ambient_occlusion(); - - register_node_type_tex_rotate(); - register_node_type_tex_translate(); - register_node_type_tex_scale(); - register_node_type_tex_at(); - - register_node_type_tex_proc_voronoi(); - register_node_type_tex_proc_blend(); - register_node_type_tex_proc_magic(); - register_node_type_tex_proc_marble(); - register_node_type_tex_proc_clouds(); - register_node_type_tex_proc_wood(); - register_node_type_tex_proc_musgrave(); - register_node_type_tex_proc_noise(); - register_node_type_tex_proc_stucci(); - register_node_type_tex_proc_distnoise(); -} - void init_nodesystem(void) { nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh"); @@ -3780,7 +3730,6 @@ void init_nodesystem(void) registerCompositNodes(); registerShaderNodes(); - registerTextureNodes(); } void free_nodesystem(void) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6b7e961a7e9..d2f291c9530 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3035,12 +3035,6 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) else if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) ((ImageUser *)node->storage)->ok = 1; } - else if ( ntree->type==NTREE_TEXTURE) { - if (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) - direct_link_curvemapping(fd, node->storage); - else if (node->type==TEX_NODE_IMAGE) - ((ImageUser *)node->storage)->ok = 1; - } } } link_list(fd, &ntree->links); diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 43ebab7856c..aa18859fa4c 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -856,16 +856,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* and texture trees */ for (tx = main->tex.first; tx; tx = tx->id.next) { - bNode *node; - if (tx->nodetree) { if (tx->nodetree->id.name[0] == '\0') strcpy(tx->nodetree->id.name, "NTTexture Nodetree"); - - /* which_output 0 is now "not specified" */ - for (node = tx->nodetree->nodes.first; node; node = node->next) - if (node->type == TEX_NODE_OUTPUT) - node->custom1++; } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 124b1efddac..60a546ec3ee 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -909,8 +909,6 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree) } else if (ntree->type==NTREE_COMPOSIT && ELEM(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) write_curvemapping(wd, node->storage); - else if (ntree->type==NTREE_TEXTURE && (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) ) - write_curvemapping(wd, node->storage); else if (ntree->type==NTREE_COMPOSIT && node->type==CMP_NODE_MOVIEDISTORTION) { /* pass */ } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 23c6aa37a83..6413d0e86e7 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -2149,16 +2149,6 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, int UNUSED(mute)) /* composite */ if (scene->use_nodes && scene->nodetree) ntreeCompositTagAnimated(scene->nodetree); - - /* update animated texture nodes */ - { - Tex *tex; - for (tex = bmain->tex.first; tex; tex = tex->id.next) - if (tex->use_nodes && tex->nodetree) { - ntreeTexTagAnimated(tex->nodetree); - } - } - } /* diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index ddbd07616bc..38bc46f1c4d 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -276,8 +276,7 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA short multi = ( node->id && ((Tex *)node->id)->use_nodes && - (node->type != CMP_NODE_TEXTURE) && - (node->type != TEX_NODE_TEXTURE) + (node->type != CMP_NODE_TEXTURE) ); uiItemR(layout, ptr, "texture", 0, "", ICON_NONE); @@ -2733,169 +2732,6 @@ static void node_composit_set_butfunc(bNodeType *ntype) } } -/* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */ - -static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ - uiLayout *col; - - col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE); - uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE); - - col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE); - uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE); -} - -static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ - PointerRNA tex_ptr; - bNode *node = ptr->data; - ID *id = ptr->id.data; - Tex *tex = (Tex *)node->storage; - uiLayout *col, *row; - - RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr); - - col = uiLayoutColumn(layout, false); - - switch (tex->type) { - case TEX_BLEND: - uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE); - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - break; - - case TEX_MARBLE: - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - break; - - case TEX_MAGIC: - uiItemR(col, &tex_ptr, "noise_depth", 0, NULL, ICON_NONE); - break; - - case TEX_STUCCI: - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - break; - - case TEX_WOOD: - uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE); - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, false); - uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING))); - uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - break; - - case TEX_CLOUDS: - uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - row = uiLayoutRow(col, false); - uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE); - break; - - case TEX_DISTNOISE: - uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - uiItemR(col, &tex_ptr, "noise_distortion", 0, "", ICON_NONE); - break; - - case TEX_MUSGRAVE: - uiItemR(col, &tex_ptr, "musgrave_type", 0, "", ICON_NONE); - uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); - break; - case TEX_VORONOI: - uiItemR(col, &tex_ptr, "distance_metric", 0, "", ICON_NONE); - if (tex->vn_distm == TEX_MINKOVSKY) { - uiItemR(col, &tex_ptr, "minkovsky_exponent", 0, NULL, ICON_NONE); - } - uiItemR(col, &tex_ptr, "color_mode", 0, "", ICON_NONE); - break; - } -} - -static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr) -{ - uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); -} - -static void node_texture_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) -{ - bNode *node = ptr->data; - PointerRNA iuserptr; - - RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr); - uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0, 0); -} - -static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ - uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE); -} - -/* only once called */ -static void node_texture_set_butfunc(bNodeType *ntype) -{ - if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) { - ntype->draw_buttons = node_texture_buts_proc; - } - else { - switch (ntype->type) { - - case TEX_NODE_MATH: - ntype->draw_buttons = node_buts_math; - break; - - case TEX_NODE_MIX_RGB: - ntype->draw_buttons = node_buts_mix_rgb; - break; - - case TEX_NODE_VALTORGB: - ntype->draw_buttons = node_buts_colorramp; - break; - - case TEX_NODE_CURVE_RGB: - ntype->draw_buttons = node_buts_curvecol; - break; - - case TEX_NODE_CURVE_TIME: - ntype->draw_buttons = node_buts_time; - break; - - case TEX_NODE_TEXTURE: - ntype->draw_buttons = node_buts_texture; - break; - - case TEX_NODE_BRICKS: - ntype->draw_buttons = node_texture_buts_bricks; - break; - - case TEX_NODE_IMAGE: - ntype->draw_buttons = node_texture_buts_image; - ntype->draw_buttons_ex = node_texture_buts_image_ex; - break; - - case TEX_NODE_OUTPUT: - ntype->draw_buttons = node_texture_buts_output; - break; - } - } -} - /* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */ static void node_property_update_default(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) @@ -2993,7 +2829,6 @@ void ED_node_init_butfuncs(void) node_composit_set_butfunc(ntype); node_shader_set_butfunc(ntype); - node_texture_set_butfunc(ntype); /* define update callbacks for socket properties */ node_template_properties_update(ntype); diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index b50df02beae..34618112de6 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -90,10 +90,6 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx snode_update(snode, node); - if (snode->nodetree->type == NTREE_TEXTURE) { - ntreeTexCheckCyclics(snode->edittree); - } - return node; } @@ -314,9 +310,6 @@ static int node_add_file_exec(bContext *C, wmOperator *op) case NTREE_SHADER: type = SH_NODE_TEX_IMAGE; break; - case NTREE_TEXTURE: - type = TEX_NODE_IMAGE; - break; case NTREE_COMPOSIT: type = CMP_NODE_IMAGE; break; diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index e277cd1b9d7..7222a6b9889 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -183,9 +183,6 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node) ED_node_tag_update_id(id); } FOREACH_NODETREE_END } - - if (ntree->type == NTREE_TEXTURE) - ntreeTexCheckCyclics(ntree); } static bool compare_nodes(const bNode *a, const bNode *b) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 067dc7118bd..13ddc25a39a 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -521,9 +521,6 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce) /* called from shading buttons or header */ void ED_node_texture_default(const bContext *C, Tex *tx) { - bNode *in, *out; - bNodeSocket *fromsock, *tosock; - /* but lets check it anyway */ if (tx->nodetree) { if (G.debug & G_DEBUG) @@ -533,17 +530,6 @@ void ED_node_texture_default(const bContext *C, Tex *tx) tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname); - out = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_OUTPUT); - out->locx = 300.0f; out->locy = 300.0f; - - in = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_CHECKER); - in->locx = 10.0f; in->locy = 300.0f; - nodeSetActive(tx->nodetree, in); - - fromsock = in->outputs.first; - tosock = out->inputs.first; - nodeAddLink(tx->nodetree, in, fromsock, out, tosock); - ntreeUpdateTree(CTX_data_main(C), tx->nodetree); } diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 021bc608564..440a57b5c29 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -178,7 +178,7 @@ static char *rna_ColorRamp_path(PointerRNA *ptr) char *node_path; for (node = ntree->nodes.first; node; node = node->next) { - if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) { + if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB)) { if (node->storage == ptr->data) { /* all node color ramp properties called 'color_ramp' * prepend path from ID to the node @@ -266,7 +266,7 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr) bNode *node; for (node = ntree->nodes.first; node; node = node->next) { - if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) { + if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB)) { RNA_pointer_create(id, &RNA_ColorRamp, node->storage, &ramp_ptr); COLRAMP_GETPATH; } @@ -325,7 +325,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * bNode *node; for (node = ntree->nodes.first; node; node = node->next) { - if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) { + if (ELEM(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB)) { ED_node_tag_update_nodetree(bmain, ntree, node); } } diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d38af10ba20..f14f438711d 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -478,20 +478,6 @@ static EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C), Pointer #include "../../nodes/NOD_static_types.h" #undef DefNode } - - if (RNA_struct_is_a(ptr->type, &RNA_TextureNode)) { -#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ - if (STREQ(#Category, "TextureNode")) { \ - tmp.value = ID; \ - tmp.identifier = EnumName; \ - tmp.name = UIName; \ - tmp.description = UIDesc; \ - tmp.icon = ICON_NONE; \ - RNA_enum_item_add(&item, &totitem, &tmp); \ - } -#include "../../nodes/NOD_static_types.h" -#undef DefNode - } RNA_enum_item_end(&item, &totitem); *r_free = true; @@ -699,10 +685,6 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r node = nodeAddNode(C, ntree, type); BLI_assert(node && node->typeinfo); - if (ntree->type == NTREE_TEXTURE) { - ntreeTexCheckCyclics(ntree); - } - ntreeUpdateTree(CTX_data_main(C), ntree); nodeUpdate(ntree, node); WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); @@ -1509,23 +1491,6 @@ static StructRNA *rna_CompositorNode_register( return nt->ext.srna; } -static StructRNA *rna_TextureNode_register( - Main *bmain, ReportList *reports, - void *data, const char *identifier, - StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) -{ - bNodeType *nt = rna_Node_register_base(bmain, reports, &RNA_TextureNode, data, identifier, validate, call, free); - if (!nt) - return NULL; - - nodeRegisterType(nt); - - /* update while blender is running */ - WM_main_add_notifier(NC_NODE | NA_EDITED, NULL); - - return nt->ext.srna; -} - static StructRNA *rna_ObjectNode_id_typef(PointerRNA *ptr) { bNode *node = ptr->data; @@ -6853,68 +6818,6 @@ static void def_cmp_sunbeams(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } -/* -- Texture Nodes --------------------------------------------------------- */ - -static void def_tex_output(StructRNA *srna) -{ - PropertyRNA *prop; - - RNA_def_struct_sdna_from(srna, "TexNodeOutput", "storage"); - - prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Output Name", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); -} - -static void def_tex_image(StructRNA *srna) -{ - PropertyRNA *prop; - - prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "id"); - RNA_def_property_struct_type(prop, "Image"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Image", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "storage"); - RNA_def_property_struct_type(prop, "ImageUser"); - RNA_def_property_ui_text(prop, "Image User", - "Parameters defining the image duration, offset and related settings"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); -} - -static void def_tex_bricks(StructRNA *srna) -{ - PropertyRNA *prop; - - prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "custom3"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Offset Amount", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "offset_frequency", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "custom1"); - RNA_def_property_range(prop, 2, 99); - RNA_def_property_ui_text(prop, "Offset Frequency", "Offset every N rows"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "squash", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "custom4"); - RNA_def_property_range(prop, 0.0f, 99.0f); - RNA_def_property_ui_text(prop, "Squash Amount", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "squash_frequency", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "custom2"); - RNA_def_property_range(prop, 2, 99); - RNA_def_property_ui_text(prop, "Squash Frequency", "Squash every N rows"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); -} - /* -------------------------------------------------------------------------- */ static void rna_def_shader_node(BlenderRNA *brna) @@ -6942,16 +6845,6 @@ static void rna_def_compositor_node(BlenderRNA *brna) RNA_def_function_ui_description(func, "Tag the node for compositor update"); } -static void rna_def_texture_node(BlenderRNA *brna) -{ - StructRNA *srna; - - srna = RNA_def_struct(brna, "TextureNode", "NodeInternal"); - RNA_def_struct_ui_text(srna, "Texture Node", ""); - RNA_def_struct_sdna(srna, "bNode"); - RNA_def_struct_register_funcs(srna, "rna_TextureNode_register", "rna_Node_unregister", NULL); -} - static void rna_def_object_node(BlenderRNA *brna) { StructRNA *srna; @@ -8544,7 +8437,6 @@ void RNA_def_nodetree(BlenderRNA *brna) rna_def_internal_node(brna); rna_def_shader_node(brna); rna_def_compositor_node(brna); - rna_def_texture_node(brna); rna_def_object_node(brna); rna_def_nodetree(brna); @@ -8574,7 +8466,6 @@ void RNA_def_nodetree(BlenderRNA *brna) */ define_specific_node(brna, "ShaderNodeGroup", "ShaderNode", "Group", "", def_group); define_specific_node(brna, "CompositorNodeGroup", "CompositorNode", "Group", "", def_group); - define_specific_node(brna, "TextureNodeGroup", "TextureNode", "Group", "", def_group); def_custom_group(brna); /* special socket types */ diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 1e88585a286..fef66b71d12 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -333,66 +333,6 @@ static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) str[0] = '\0'; } -static int rna_TextureSlot_output_node_get(PointerRNA *ptr) -{ - MTex *mtex = ptr->data; - Tex *tex = mtex->tex; - int cur = mtex->which_output; - - if (tex) { - bNodeTree *ntree = tex->nodetree; - bNode *node; - if (ntree) { - for (node = ntree->nodes.first; node; node = node->next) { - if (node->type == TEX_NODE_OUTPUT) { - if (cur == node->custom1) - return cur; - } - } - } - } - - mtex->which_output = 0; - return 0; -} - - -static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), bool *r_free) -{ - MTex *mtex = ptr->data; - Tex *tex = mtex->tex; - EnumPropertyItem *item = NULL; - int totitem = 0; - - if (tex) { - bNodeTree *ntree = tex->nodetree; - if (ntree) { - EnumPropertyItem tmp = {0, "", 0, "", ""}; - bNode *node; - - tmp.value = 0; - tmp.name = "Not Specified"; - tmp.identifier = "NOT_SPECIFIED"; - RNA_enum_item_add(&item, &totitem, &tmp); - - for (node = ntree->nodes.first; node; node = node->next) { - if (node->type == TEX_NODE_OUTPUT) { - tmp.value = node->custom1; - tmp.name = ((TexNodeOutput *)node->storage)->name; - tmp.identifier = tmp.name; - RNA_enum_item_add(&item, &totitem, &tmp); - } - } - } - } - - RNA_enum_item_end(&item, &totitem); - *r_free = true; - - return item; -} - static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) { Tex *tex = (Tex *)ptr->data; @@ -631,11 +571,6 @@ static void rna_def_mtex(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem output_node_items[] = { - {0, "DUMMY", 0, "Dummy", ""}, - {0, NULL, 0, NULL, NULL} - }; - srna = RNA_def_struct(brna, "TextureSlot", NULL); RNA_def_struct_sdna(srna, "MTex"); RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture"); @@ -704,13 +639,6 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Default Value", "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); - - prop = RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "which_output"); - RNA_def_property_enum_items(prop, output_node_items); - RNA_def_property_enum_funcs(prop, "rna_TextureSlot_output_node_get", NULL, "rna_TextureSlot_output_node_itemf"); - RNA_def_property_ui_text(prop, "Output Node", "Which output node to use, for node-based textures"); - RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); } static void rna_def_filter_common(StructRNA *srna) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index d20881df150..4c8525ae2fd 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -211,31 +211,7 @@ set(SRC shader/node_shader_tree.c shader/node_shader_util.c - texture/nodes/node_texture_at.c - texture/nodes/node_texture_bricks.c - texture/nodes/node_texture_checker.c - texture/nodes/node_texture_common.c - texture/nodes/node_texture_compose.c - texture/nodes/node_texture_coord.c - texture/nodes/node_texture_curves.c - texture/nodes/node_texture_decompose.c - texture/nodes/node_texture_distance.c - texture/nodes/node_texture_hueSatVal.c - texture/nodes/node_texture_image.c - texture/nodes/node_texture_invert.c - texture/nodes/node_texture_math.c - texture/nodes/node_texture_mixRgb.c - texture/nodes/node_texture_output.c - texture/nodes/node_texture_proc.c - texture/nodes/node_texture_rotate.c - texture/nodes/node_texture_scale.c - texture/nodes/node_texture_texture.c - texture/nodes/node_texture_translate.c - texture/nodes/node_texture_valToNor.c - texture/nodes/node_texture_valToRgb.c - texture/nodes/node_texture_viewer.c texture/node_texture_tree.c - texture/node_texture_util.c intern/node_util.c intern/node_exec.c @@ -244,7 +220,6 @@ set(SRC composite/node_composite_util.h shader/node_shader_util.h - texture/node_texture_util.h NOD_common.h NOD_composite.h diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index 9e1a0c926fa..affc176239e 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -214,41 +214,5 @@ DefNode( CompositorNode, CMP_NODE_PLANETRACKDEFORM,def_cmp_planetrackdeform,"PLA DefNode( CompositorNode, CMP_NODE_CORNERPIN, 0, "CORNERPIN", CornerPin, "Corner Pin", "" ) DefNode( CompositorNode, CMP_NODE_SUNBEAMS, def_cmp_sunbeams, "SUNBEAMS", SunBeams, "Sun Beams", "" ) -DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) -DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) -DefNode( TextureNode, TEX_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) -DefNode( TextureNode, TEX_NODE_BRICKS, def_tex_bricks, "BRICKS", Bricks, "Bricks", "" ) -DefNode( TextureNode, TEX_NODE_MATH, def_math, "MATH", Math, "Math", "" ) -DefNode( TextureNode, TEX_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" ) -DefNode( TextureNode, TEX_NODE_RGBTOBW, 0, "RGBTOBW", RGBToBW, "RGB to BW", "" ) -DefNode( TextureNode, TEX_NODE_VALTORGB, def_colorramp, "VALTORGB", ValToRGB, "ColorRamp", "" ) -DefNode( TextureNode, TEX_NODE_IMAGE, def_tex_image, "IMAGE", Image, "Image", "" ) -DefNode( TextureNode, TEX_NODE_CURVE_RGB, def_rgb_curve, "CURVE_RGB", CurveRGB, "RGB Curves", "" ) -DefNode( TextureNode, TEX_NODE_INVERT, 0, "INVERT", Invert, "Invert", "" ) -DefNode( TextureNode, TEX_NODE_HUE_SAT, 0, "HUE_SAT", HueSaturation, "Hue/Saturation", "" ) -DefNode( TextureNode, TEX_NODE_CURVE_TIME, def_time, "CURVE_TIME", CurveTime, "Curve Time", "" ) -DefNode( TextureNode, TEX_NODE_ROTATE, 0, "ROTATE", Rotate, "Rotate", "" ) -DefNode( TextureNode, TEX_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "" ) -DefNode( TextureNode, TEX_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" ) -DefNode( TextureNode, TEX_NODE_COORD, 0, "COORD", Coordinates, "Coordinates", "" ) -DefNode( TextureNode, TEX_NODE_DISTANCE, 0, "DISTANCE", Distance, "Distance", "" ) -DefNode( TextureNode, TEX_NODE_COMPOSE, 0, "COMPOSE", Compose, "Combine RGBA", "" ) -DefNode( TextureNode, TEX_NODE_DECOMPOSE, 0, "DECOMPOSE", Decompose, "Separate RGBA", "" ) -DefNode( TextureNode, TEX_NODE_VALTONOR, 0, "VALTONOR", ValToNor, "Value to Normal", "" ) -DefNode( TextureNode, TEX_NODE_SCALE, 0, "SCALE", Scale, "Scale", "" ) -DefNode( TextureNode, TEX_NODE_AT, 0, "AT", At, "At", "" ) -/* procedural textures */ -DefNode( TextureNode, TEX_NODE_PROC+TEX_VORONOI, 0, "TEX_VORONOI", TexVoronoi, "Voronoi", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_BLEND, 0, "TEX_BLEND", TexBlend, "Blend", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_MAGIC, 0, "TEX_MAGIC", TexMagic, "Magic", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_MARBLE, 0, "TEX_MARBLE", TexMarble, "Marble", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_CLOUDS, 0, "TEX_CLOUDS", TexClouds, "Clouds", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_WOOD, 0, "TEX_WOOD", TexWood, "Wood", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_MUSGRAVE, 0, "TEX_MUSGRAVE", TexMusgrave, "Musgrave", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_NOISE, 0, "TEX_NOISE", TexNoise, "Noise", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_STUCCI, 0, "TEX_STUCCI", TexStucci, "Stucci", "" ) -DefNode( TextureNode, TEX_NODE_PROC+TEX_DISTNOISE, 0, "TEX_DISTNOISE", TexDistNoise, "Distorted Noise", "" ) - - /* undefine macros */ #undef DefNode diff --git a/source/blender/nodes/NOD_texture.h b/source/blender/nodes/NOD_texture.h index 378c96d5882..d4c72f3f790 100644 --- a/source/blender/nodes/NOD_texture.h +++ b/source/blender/nodes/NOD_texture.h @@ -36,48 +36,6 @@ extern struct bNodeTreeType *ntreeType_Texture; - -/* ****************** types array for all texture nodes ****************** */ - void register_node_tree_type_tex(void); -void register_node_type_tex_group(void); - -void register_node_type_tex_math(void); -void register_node_type_tex_mix_rgb(void); -void register_node_type_tex_valtorgb(void); -void register_node_type_tex_valtonor(void); -void register_node_type_tex_rgbtobw(void); -void register_node_type_tex_output(void); -void register_node_type_tex_viewer(void); -void register_node_type_tex_checker(void); -void register_node_type_tex_texture(void); -void register_node_type_tex_bricks(void); -void register_node_type_tex_image(void); -void register_node_type_tex_curve_rgb(void); -void register_node_type_tex_curve_time(void); -void register_node_type_tex_invert(void); -void register_node_type_tex_hue_sat(void); -void register_node_type_tex_coord(void); -void register_node_type_tex_distance(void); - -void register_node_type_tex_rotate(void); -void register_node_type_tex_translate(void); -void register_node_type_tex_scale(void); -void register_node_type_tex_at(void); - -void register_node_type_tex_compose(void); -void register_node_type_tex_decompose(void); - -void register_node_type_tex_proc_voronoi(void); -void register_node_type_tex_proc_blend(void); -void register_node_type_tex_proc_magic(void); -void register_node_type_tex_proc_marble(void); -void register_node_type_tex_proc_clouds(void); -void register_node_type_tex_proc_wood(void); -void register_node_type_tex_proc_musgrave(void); -void register_node_type_tex_proc_noise(void); -void register_node_type_tex_proc_stucci(void); -void register_node_type_tex_proc_distnoise(void); - #endif diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index ca2dd6b80d8..93dde9b163c 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -34,6 +34,7 @@ #include "DNA_texture_types.h" #include "DNA_node_types.h" +#include "DNA_object_types.h" #include "DNA_space_types.h" #include "BLI_listbase.h" @@ -44,14 +45,15 @@ #include "BKE_context.h" #include "BKE_linestyle.h" +#include "BKE_material.h" #include "BKE_node.h" #include "BKE_paint.h" +#include "BKE_texture.h" #include "node_common.h" #include "node_exec.h" #include "node_util.h" #include "NOD_texture.h" -#include "node_texture_util.h" #include "RNA_access.h" @@ -202,27 +204,6 @@ void register_node_tree_type_tex(void) ntreeTypeAdd(tt); } -int ntreeTexTagAnimated(bNodeTree *ntree) -{ - bNode *node; - - if (ntree == NULL) return 0; - - for (node = ntree->nodes.first; node; node = node->next) { - if (node->type == TEX_NODE_CURVE_TIME) { - nodeUpdate(ntree, node); - return 1; - } - else if (node->type == NODE_GROUP) { - if (ntreeTexTagAnimated((bNodeTree *)node->id) ) { - return 1; - } - } - } - - return 0; -} - bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent_key) { bNodeTreeExec *exec; diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c deleted file mode 100644 index 32720364f73..00000000000 --- a/source/blender/nodes/texture/node_texture_util.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/node_texture_util.c - * \ingroup nodes - */ - - -/* - * HOW TEXTURE NODES WORK - * - * In contrast to Shader nodes, which place a color into the output - * stack when executed, Texture nodes place a TexDelegate* there. To - * obtain a color value from this, a node further up the chain reads - * the TexDelegate* from its input stack, and uses tex_call_delegate to - * retrieve the color from the delegate. - * - * comments: (ton) - * - * This system needs recode, a node system should rely on the stack, and - * callbacks for nodes only should evaluate own node, not recursively go - * over other previous ones. - */ - -#include <assert.h> -#include "node_texture_util.h" - - -int tex_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) -{ - return STREQ(ntree->idname, "TextureNodeTree"); -} - -void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag) -{ - node_type_base(ntype, type, name, nclass, flag); - - ntype->poll = tex_node_poll_default; - ntype->insert_link = node_insert_link_default; - ntype->update_internal_links = node_update_internal_links_default; -} - - -static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread) -{ - if (dg->node->need_exec) { - dg->fn(out, params, dg->node, dg->in, thread); - - if (dg->cdata->do_preview) - tex_do_preview(dg->preview, params->previewco, out, dg->cdata->do_manage); - } -} - -static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread) -{ - TexDelegate *dg = in->data; - if (dg) { - tex_call_delegate(dg, in->vec, params, thread); - - if (in->hasoutput && in->sockettype == SOCK_FLOAT) - in->vec[1] = in->vec[2] = in->vec[0]; - } - memcpy(out, in->vec, sz * sizeof(float)); -} - -void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread) -{ - tex_input(out, 3, in, params, thread); -} - -void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread) -{ - tex_input(out, 4, in, params, thread); - - if (in->hasoutput && in->sockettype == SOCK_FLOAT) { - out[1] = out[2] = out[0]; - out[3] = 1; - } - - if (in->hasoutput && in->sockettype == SOCK_VECTOR) { - out[0] = out[0] * 0.5f + 0.5f; - out[1] = out[1] * 0.5f + 0.5f; - out[2] = out[2] * 0.5f + 0.5f; - out[3] = 1; - } -} - -float tex_input_value(bNodeStack *in, TexParams *params, short thread) -{ - float out[4]; - tex_input_vec(out, in, params, thread); - return out[0]; -} - -void params_from_cdata(TexParams *out, TexCallData *in) -{ - out->co = in->co; - out->dxt = in->dxt; - out->dyt = in->dyt; - out->previewco = in->co; - out->osatex = in->osatex; - out->cfra = in->cfra; - out->shi = in->shi; - out->mtex = in->mtex; -} - -void tex_do_preview(bNodePreview *preview, const float coord[2], const float col[4], bool do_manage) -{ - if (preview) { - int xs = ((coord[0] + 1.0f) * 0.5f) * preview->xsize; - int ys = ((coord[1] + 1.0f) * 0.5f) * preview->ysize; - - BKE_node_preview_set_pixel(preview, col, xs, ys, do_manage); - } -} - -void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata) -{ - TexDelegate *dg; - - if (node->flag & NODE_MUTED) { - /* do not add a delegate if the node is muted */ - return; - } - else { - if (!out->data) - /* Freed in tex_end_exec (node.c) */ - dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate"); - else - dg = out->data; - } - - - dg->cdata = cdata; - dg->fn = texfn; - dg->node = node; - dg->preview = execdata->preview; - memcpy(dg->in, in, MAX_SOCKET * sizeof(bNodeStack *)); - dg->type = out->sockettype; -} - -void ntreeTexCheckCyclics(struct bNodeTree *ntree) -{ - bNode *node; - for (node = ntree->nodes.first; node; node = node->next) { - - if (node->type == TEX_NODE_TEXTURE && node->id) { - /* custom2 stops the node from rendering */ - if (node->custom1) { - node->custom2 = 1; - node->custom1 = 0; - } - else { - Tex *tex = (Tex *)node->id; - - node->custom2 = 0; - - node->custom1 = 1; - if (tex->use_nodes && tex->nodetree) { - ntreeTexCheckCyclics(tex->nodetree); - } - node->custom1 = 0; - } - } - - } -} diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h deleted file mode 100644 index 2263c271ccf..00000000000 --- a/source/blender/nodes/texture/node_texture_util.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/node_texture_util.h - * \ingroup nodes - */ - - -#ifndef __NODE_TEXTURE_UTIL_H__ -#define __NODE_TEXTURE_UTIL_H__ - -#include <math.h> -#include <string.h> - -#include "MEM_guardedalloc.h" - -#include "DNA_color_types.h" -#include "DNA_ID.h" -#include "DNA_image_types.h" -#include "DNA_material_types.h" -#include "DNA_node_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" -#include "DNA_texture_types.h" - -#include "BLI_math.h" -#include "BLI_blenlib.h" -#include "BLI_rand.h" -#include "BLI_threads.h" -#include "BLI_utildefines.h" - -#include "BKE_colortools.h" -#include "BKE_global.h" -#include "BKE_image.h" -#include "BKE_main.h" -#include "BKE_material.h" -#include "BKE_node.h" -#include "BKE_texture.h" -#include "BKE_library.h" - -#include "node_util.h" -#include "NOD_texture.h" - -#include "BLT_translation.h" - -#include "IMB_imbuf_types.h" -#include "IMB_imbuf.h" - -#include "RE_pipeline.h" -#include "RE_shader_ext.h" - -typedef struct TexCallData { - TexResult *target; - /* all float[3] */ - float *co; - float *dxt, *dyt; - - int osatex; - bool do_preview; - bool do_manage; - short thread; - short which_output; - int cfra; - - ShadeInput *shi; - MTex *mtex; -} TexCallData; - -typedef struct TexParams { - float *co; - float *dxt, *dyt; - const float *previewco; - int cfra; - int osatex; - - /* optional. we don't really want these here, but image - * textures need to do mapping & color correction */ - ShadeInput *shi; - MTex *mtex; -} TexParams; - -typedef void(*TexFn) (float *out, TexParams *params, bNode *node, bNodeStack **in, short thread); - -typedef struct TexDelegate { - TexCallData *cdata; - TexFn fn; - bNode *node; - bNodePreview *preview; - bNodeStack *in[MAX_SOCKET]; - int type; -} TexDelegate; - - -int tex_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree); -void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag); - -void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread); -void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread); -float tex_input_value(bNodeStack *in, TexParams *params, short thread); - -void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *data); -void tex_do_preview(bNodePreview *preview, const float coord[2], const float col[4], bool do_manage); - -void params_from_cdata(TexParams *out, TexCallData *in); - -#endif diff --git a/source/blender/nodes/texture/nodes/node_texture_at.c b/source/blender/nodes/texture/nodes/node_texture_at.c deleted file mode 100644 index aafb9793d2c..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_at.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): R Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_at.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Texture"), 0.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_VECTOR, 1, N_("Coordinates"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Texture") }, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - TexParams np = *p; - float new_co[3]; - np.co = new_co; - - tex_input_vec(new_co, in[1], p, thread); - tex_input_rgba(out, in[0], &np, thread); -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_at(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_AT, "At", NODE_CLASS_DISTORT, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_size(&ntype, 140, 100, 320); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c deleted file mode 100644 index 02d4ddda47c..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_bricks.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -#include <math.h> - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Bricks 1"), 0.596f, 0.282f, 0.0f, 1.0f }, - { SOCK_RGBA, 1, N_("Bricks 2"), 0.632f, 0.504f, 0.05f, 1.0f }, - { SOCK_RGBA, 1, N_("Mortar"), 0.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_FLOAT, 1, N_("Thickness"), 0.02f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Bias"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("Brick Width"), 0.5f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Row Height"), 0.25f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, ""} -}; - -static void init(bNodeTree *UNUSED(ntree), bNode *node) -{ - node->custom3 = 0.5; /* offset */ - node->custom4 = 1.0; /* squash */ -} - -static float noise(int n) /* fast integer noise */ -{ - int nn; - n = (n >> 13) ^ n; - nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; - return 0.5f * ((float)nn / 1073741824.0f); -} - -static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - const float *co = p->co; - - float x = co[0]; - float y = co[1]; - - int bricknum, rownum; - float offset = 0; - float ins_x, ins_y; - float tint; - - float bricks1[4]; - float bricks2[4]; - float mortar[4]; - - float mortar_thickness = tex_input_value(in[3], p, thread); - float bias = tex_input_value(in[4], p, thread); - float brick_width = tex_input_value(in[5], p, thread); - float row_height = tex_input_value(in[6], p, thread); - - tex_input_rgba(bricks1, in[0], p, thread); - tex_input_rgba(bricks2, in[1], p, thread); - tex_input_rgba(mortar, in[2], p, thread); - - rownum = (int)floor(y / row_height); - - if (node->custom1 && node->custom2) { - brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */ - offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */ - } - - bricknum = (int)floor((x + offset) / brick_width); - - ins_x = (x + offset) - brick_width * bricknum; - ins_y = y - row_height * rownum; - - tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias; - CLAMP(tint, 0.0f, 1.0f); - - if (ins_x < mortar_thickness || ins_y < mortar_thickness || - ins_x > (brick_width - mortar_thickness) || - ins_y > (row_height - mortar_thickness)) - { - copy_v4_v4(out, mortar); - } - else { - copy_v4_v4(out, bricks1); - ramp_blend(MA_RAMP_BLEND, out, tint, bricks2); - } -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_bricks(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, init); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c deleted file mode 100644 index c26a96c6a47..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_checker.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_checker.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" -#include <math.h> - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color1"), 1.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_RGBA, 1, N_("Color2"), 1.0f, 1.0f, 1.0f, 1.0f }, - { SOCK_FLOAT, 1, N_("Size"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 100.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color") }, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float x = p->co[0]; - float y = p->co[1]; - float z = p->co[2]; - float sz = tex_input_value(in[2], p, thread); - - /* 0.00001 because of unit sized stuff */ - int xi = (int)fabs(floor(0.00001f + x / sz)); - int yi = (int)fabs(floor(0.00001f + y / sz)); - int zi = (int)fabs(floor(0.00001f + z / sz)); - - if ( (xi % 2 == yi % 2) == (zi % 2) ) { - tex_input_rgba(out, in[0], p, thread); - } - else { - tex_input_rgba(out, in[1], p, thread); - } -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_checker(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN, NODE_PREVIEW); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c deleted file mode 100644 index 79a4c4e3a6b..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Campbell Barton, Alfredo de Greef, David Millan Escriva, - * Juho Vepsäläinen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_common.c - * \ingroup texnodes - */ - - -#include "DNA_node_types.h" - -#include "BLI_utildefines.h" - -#include "BKE_node.h" - -#include "node_texture_util.h" -#include "NOD_common.h" -#include "node_common.h" -#include "node_exec.h" - -#include "RNA_access.h" - -static void copy_stack(bNodeStack *to, bNodeStack *from) -{ - if (to != from) { - copy_v4_v4(to->vec, from->vec); - to->data = from->data; - to->datatype = from->datatype; - - /* tag as copy to prevent freeing */ - to->is_copy = 1; - } -} - -/**** GROUP ****/ - -static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanceKey key) -{ - bNodeTree *ngroup = (bNodeTree *)node->id; - void *exec; - - if (!ngroup) - return NULL; - - /* initialize the internal node tree execution */ - exec = ntreeTexBeginExecTree_internal(context, ngroup, key); - - return exec; -} - -static void group_freeexec(void *nodedata) -{ - bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata; - - ntreeTexEndExecTree_internal(gexec); -} - -/* Copy inputs to the internal stack. - * This is a shallow copy, no buffers are duplicated here! - */ -static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack) -{ - bNodeTree *ngroup = (bNodeTree *)gnode->id; - bNode *node; - bNodeSocket *sock; - bNodeStack *ns; - int a; - - for (node = ngroup->nodes.first; node; node = node->next) { - if (node->type == NODE_GROUP_INPUT) { - for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) { - if (in[a]) { /* shouldn't need to check this [#36694] */ - ns = node_get_socket_stack(gstack, sock); - if (ns) { - copy_stack(ns, in[a]); - } - } - } - } - } -} - -/* Copy internal results to the external outputs. - */ -static void group_copy_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstack) -{ - bNodeTree *ngroup = (bNodeTree *)gnode->id; - bNode *node; - bNodeSocket *sock; - bNodeStack *ns; - int a; - - for (node = ngroup->nodes.first; node; node = node->next) { - if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) { - for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) { - if (out[a]) { /* shouldn't need to check this [#36694] */ - ns = node_get_socket_stack(gstack, sock); - if (ns) { - copy_stack(out[a], ns); - } - } - } - break; /* only one active output node */ - } - } -} - -static void group_execute(void *data, int thread, struct bNode *node, bNodeExecData *execdata, struct bNodeStack **in, struct bNodeStack **out) -{ - bNodeTreeExec *exec = execdata->data; - bNodeThreadStack *nts; - - if (!exec) - return; - - /* XXX same behavior as trunk: all nodes inside group are executed. - * it's stupid, but just makes it work. compo redesign will do this better. - */ - { - bNode *inode; - for (inode = exec->nodetree->nodes.first; inode; inode = inode->next) - inode->need_exec = 1; - } - - nts = ntreeGetThreadStack(exec, thread); - - group_copy_inputs(node, in, nts->stack); - ntreeExecThreadNodes(exec, nts, data, thread); - group_copy_outputs(node, out, nts->stack); - - ntreeReleaseThreadStack(nts); -} - -void register_node_type_tex_group(void) -{ - static bNodeType ntype; - - /* NB: cannot use sh_node_type_base for node group, because it would map the node type - * to the shared NODE_GROUP integer type id. - */ - node_type_base_custom(&ntype, "TextureNodeGroup", "Group", NODE_CLASS_GROUP, NODE_CONST_OUTPUT); - ntype.type = NODE_GROUP; - ntype.poll = tex_node_poll_default; - ntype.poll_instance = node_group_poll_instance; - ntype.insert_link = node_insert_link_default; - ntype.update_internal_links = node_update_internal_links_default; - ntype.ext.srna = RNA_struct_find("TextureNodeGroup"); - BLI_assert(ntype.ext.srna != NULL); - RNA_struct_blender_type_set(ntype.ext.srna, &ntype); - - node_type_socket_templates(&ntype, NULL, NULL); - node_type_size(&ntype, 140, 60, 400); - node_type_label(&ntype, node_group_label); - node_type_update(&ntype, NULL, node_group_verify); - node_type_exec(&ntype, group_initexec, group_freeexec, group_execute); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c deleted file mode 100644 index 08813667ab4..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_compose.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_compose.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -static bNodeSocketTemplate inputs[] = { - { SOCK_FLOAT, 1, N_("Red"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Green"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Blue"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color") }, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - int i; - for (i = 0; i < 4; i++) - out[i] = tex_input_value(in[i], p, thread); -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_compose(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_COMPOSE, "Combine RGBA", NODE_CLASS_OP_COLOR, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c deleted file mode 100644 index 5221d456b88..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_coord.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Mathias Panzenböck (panzi) <grosser.meister.morti@gmx.net>. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_coord.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -static bNodeSocketTemplate outputs[] = { - { SOCK_VECTOR, 0, N_("Coordinates") }, - { -1, 0, "" } -}; - -static void vectorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **UNUSED(in), short UNUSED(thread)) -{ - copy_v3_v3(out, p->co); -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &vectorfn, data); -} - -void register_node_type_tex_coord(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT, 0); - node_type_socket_templates(&ntype, NULL, outputs); - node_type_storage(&ntype, "", NULL, NULL); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c deleted file mode 100644 index 897157e3f61..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_curves.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -/* **************** CURVE Time ******************** */ - -/* custom1 = sfra, custom2 = efra */ -static bNodeSocketTemplate time_outputs[] = { - { SOCK_FLOAT, 0, N_("Value") }, - { -1, 0, "" } -}; - -static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread)) -{ - /* stack order output: fac */ - float fac = 0.0f; - - if (node->custom1 < node->custom2) - fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1); - - curvemapping_initialize(node->storage); - fac = curvemapping_evaluateF(node->storage, 0, fac); - out[0] = CLAMPIS(fac, 0.0f, 1.0f); -} - -static void time_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &time_colorfn, data); -} - - -static void time_init(bNodeTree *UNUSED(ntree), bNode *node) -{ - node->custom1 = 1; - node->custom2 = 250; - node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); -} - -void register_node_type_tex_curve_time(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT, 0); - node_type_socket_templates(&ntype, NULL, time_outputs); - node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, time_init); - node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_exec(&ntype, node_initexec_curves, NULL, time_exec); - - nodeRegisterType(&ntype); -} - -/* **************** CURVE RGB ******************** */ -static bNodeSocketTemplate rgb_inputs[] = { - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - -static bNodeSocketTemplate rgb_outputs[] = { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, ""} -}; - -static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float cin[4]; - tex_input_rgba(cin, in[0], p, thread); - - curvemapping_evaluateRGBF(node->storage, out, cin); - out[3] = cin[3]; -} - -static void rgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &rgb_colorfn, data); -} - -static void rgb_init(bNodeTree *UNUSED(ntree), bNode *node) -{ - node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); -} - -void register_node_type_tex_curve_rgb(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0); - node_type_socket_templates(&ntype, rgb_inputs, rgb_outputs); - node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, rgb_init); - node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_exec(&ntype, node_initexec_curves, NULL, rgb_exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c deleted file mode 100644 index 4bdc66bdb38..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_decompose.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_decompose.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" -#include <math.h> - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs[] = { - { SOCK_FLOAT, 0, N_("Red") }, - { SOCK_FLOAT, 0, N_("Green") }, - { SOCK_FLOAT, 0, N_("Blue") }, - { SOCK_FLOAT, 0, N_("Alpha") }, - { -1, 0, "" } -}; - -static void valuefn_r(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - tex_input_rgba(out, in[0], p, thread); - *out = out[0]; -} - -static void valuefn_g(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - tex_input_rgba(out, in[0], p, thread); - *out = out[1]; -} - -static void valuefn_b(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - tex_input_rgba(out, in[0], p, thread); - *out = out[2]; -} - -static void valuefn_a(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - tex_input_rgba(out, in[0], p, thread); - *out = out[3]; -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &valuefn_r, data); - tex_output(node, execdata, in, out[1], &valuefn_g, data); - tex_output(node, execdata, in, out[2], &valuefn_b, data); - tex_output(node, execdata, in, out[3], &valuefn_a, data); -} - -void register_node_type_tex_decompose(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_DECOMPOSE, "Separate RGBA", NODE_CLASS_OP_COLOR, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.c b/source/blender/nodes/texture/nodes/node_texture_distance.c deleted file mode 100644 index 76a5b79c7a9..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_distance.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Mathias Panzenböck (panzi) <grosser.meister.morti@gmx.net>. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_distance.c - * \ingroup texnodes - */ - - -#include <math.h> -#include "BLI_math.h" -#include "node_texture_util.h" -#include "NOD_texture.h" - -static bNodeSocketTemplate inputs[] = { - { SOCK_VECTOR, 1, N_("Coordinate 1"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, - { SOCK_VECTOR, 1, N_("Coordinate 2"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, - { -1, 0, "" } -}; - -static bNodeSocketTemplate outputs[] = { - { SOCK_FLOAT, 0, N_("Value") }, - { -1, 0, "" } -}; - -static void valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float co1[3], co2[3]; - - tex_input_vec(co1, in[0], p, thread); - tex_input_vec(co2, in[1], p, thread); - - *out = len_v3v3(co2, co1); -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &valuefn, data); -} - -void register_node_type_tex_distance(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTOR, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_storage(&ntype, "", NULL, NULL); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c deleted file mode 100644 index 154246495f0..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Juho Vepsäläinen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_hueSatVal.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - - -static bNodeSocketTemplate inputs[] = { - { SOCK_FLOAT, 1, N_("Hue"), 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("Factor"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE }, - { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color") }, - { -1, 0, "" } -}; - -static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat, float val, float *in, float fac) -{ - if (fac != 0 && (hue != 0.5f || sat != 1 || val != 1)) { - float col[3], hsv[3], mfac = 1.0f - fac; - - rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2); - hsv[0] += (hue - 0.5f); - if (hsv[0] > 1.0f) hsv[0] -= 1.0f; else if (hsv[0] < 0.0f) hsv[0] += 1.0f; - hsv[1] *= sat; - if (hsv[1] > 1.0f) hsv[1] = 1.0f; else if (hsv[1] < 0.0f) hsv[1] = 0.0f; - hsv[2] *= val; - if (hsv[2] > 1.0f) hsv[2] = 1.0f; else if (hsv[2] < 0.0f) hsv[2] = 0.0f; - hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2); - - out[0] = mfac * in[0] + fac * col[0]; - out[1] = mfac * in[1] + fac * col[1]; - out[2] = mfac * in[2] + fac * col[2]; - } - else { - copy_v4_v4(out, in); - } -} - -static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float hue = tex_input_value(in[0], p, thread); - float sat = tex_input_value(in[1], p, thread); - float val = tex_input_value(in[2], p, thread); - float fac = tex_input_value(in[3], p, thread); - - float col[4]; - tex_input_rgba(col, in[4], p, thread); - - hue += 0.5f; /* [-0.5, 0.5] -> [0, 1] */ - - do_hue_sat_fac(node, out, hue, sat, val, col, fac); - - out[3] = col[3]; -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_hue_sat(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c deleted file mode 100644 index 9b13589f3e1..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_image.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Image")}, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread)) -{ - float x = p->co[0]; - float y = p->co[1]; - Image *ima = (Image *)node->id; - ImageUser *iuser = (ImageUser *)node->storage; - - if (ima) { - ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); - if (ibuf) { - float xsize, ysize; - float xoff, yoff; - int px, py; - - const float *result; - - xsize = ibuf->x / 2; - ysize = ibuf->y / 2; - xoff = yoff = -1; - - px = (int)( (x - xoff) * xsize); - py = (int)( (y - yoff) * ysize); - - if ( (!xsize) || (!ysize) ) return; - - if (!ibuf->rect_float) { - BLI_lock_thread(LOCK_IMAGE); - if (!ibuf->rect_float) - IMB_float_from_rect(ibuf); - BLI_unlock_thread(LOCK_IMAGE); - } - - while (px < 0) px += ibuf->x; - while (py < 0) py += ibuf->y; - while (px >= ibuf->x) px -= ibuf->x; - while (py >= ibuf->y) py -= ibuf->y; - - result = ibuf->rect_float + py * ibuf->x * 4 + px * 4; - copy_v4_v4(out, result); - - BKE_image_release_ibuf(ima, ibuf, NULL); - } - } -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -static void init(bNodeTree *UNUSED(ntree), bNode *node) -{ - ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user"); - node->storage = iuser; - iuser->sfra = 1; - iuser->fie_ima = 2; - iuser->ok = 1; -} - -void register_node_type_tex_image(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW); - node_type_socket_templates(&ntype, NULL, outputs); - node_type_init(&ntype, init); - node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.c b/source/blender/nodes/texture/nodes/node_texture_invert.c deleted file mode 100644 index 82b3d40d686..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_invert.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_invert.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -/* **************** INVERT ******************** */ -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float col[4]; - - tex_input_rgba(col, in[0], p, thread); - - col[0] = 1.0f - col[0]; - col[1] = 1.0f - col[1]; - col[2] = 1.0f - col[2]; - - copy_v3_v3(out, col); - out[3] = col[3]; -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_invert(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c deleted file mode 100644 index 19bc16fb82d..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_math.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - - -/* **************** SCALAR MATH ******************** */ -static bNodeSocketTemplate inputs[] = { - { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE}, - { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE}, - { -1, 0, "" } -}; - -static bNodeSocketTemplate outputs[] = { - { SOCK_FLOAT, 0, N_("Value")}, - { -1, 0, "" } -}; - -static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float in0 = tex_input_value(in[0], p, thread); - float in1 = tex_input_value(in[1], p, thread); - - switch (node->custom1) { - - case NODE_MATH_ADD: - *out = in0 + in1; - break; - case NODE_MATH_SUB: - *out = in0 - in1; - break; - case NODE_MATH_MUL: - *out = in0 * in1; - break; - case NODE_MATH_DIVIDE: - { - if (in1 == 0) /* We don't want to divide by zero. */ - *out = 0.0; - else - *out = in0 / in1; - break; - } - case NODE_MATH_SIN: - { - *out = sinf(in0); - break; - } - case NODE_MATH_COS: - { - *out = cosf(in0); - break; - } - case NODE_MATH_TAN: - { - *out = tanf(in0); - break; - } - case NODE_MATH_ASIN: - { - /* Can't do the impossible... */ - if (in0 <= 1 && in0 >= -1) - *out = asinf(in0); - else - *out = 0.0; - break; - } - case NODE_MATH_ACOS: - { - /* Can't do the impossible... */ - if (in0 <= 1 && in0 >= -1) - *out = acosf(in0); - else - *out = 0.0; - break; - } - case NODE_MATH_ATAN: - { - *out = atan(in0); - break; - } - case NODE_MATH_POW: - { - /* Only raise negative numbers by full integers */ - if (in0 >= 0) { - out[0] = pow(in0, in1); - } - else { - float y_mod_1 = fmod(in1, 1); - if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { - *out = pow(in0, floor(in1 + 0.5f)); - } - else { - *out = 0.0; - } - } - break; - } - case NODE_MATH_LOG: - { - /* Don't want any imaginary numbers... */ - if (in0 > 0 && in1 > 0) - *out = log(in0) / log(in1); - else - *out = 0.0; - break; - } - case NODE_MATH_MIN: - { - if (in0 < in1) - *out = in0; - else - *out = in1; - break; - } - case NODE_MATH_MAX: - { - if (in0 > in1) - *out = in0; - else - *out = in1; - break; - } - case NODE_MATH_ROUND: - { - *out = (in0 < 0) ? (int)(in0 - 0.5f) : (int)(in0 + 0.5f); - break; - } - - case NODE_MATH_LESS: - { - if (in0 < in1) - *out = 1.0f; - else - *out = 0.0f; - break; - } - - case NODE_MATH_GREATER: - { - if (in0 > in1) - *out = 1.0f; - else - *out = 0.0f; - break; - } - - case NODE_MATH_MOD: - { - if (in1 == 0.0f) - *out = 0.0f; - else - *out = fmod(in0, in1); - break; - } - - case NODE_MATH_ABS: - { - *out = fabsf(in0); - break; - } - - default: - { - BLI_assert(0); - break; - } - } - - if (node->custom2 & SHD_MATH_CLAMP) { - CLAMP(*out, 0.0f, 1.0f); - } -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &valuefn, data); -} - -void register_node_type_tex_math(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_label(&ntype, node_math_label); - node_type_storage(&ntype, "", NULL, NULL); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c deleted file mode 100644 index f3f3dd87b0e..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_mixRgb.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -/* **************** MIX RGB ******************** */ -static bNodeSocketTemplate inputs[] = { - { SOCK_FLOAT, 1, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE }, - { SOCK_RGBA, 1, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f }, - { SOCK_RGBA, 1, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color") }, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - float fac = tex_input_value(in[0], p, thread); - float col1[4], col2[4]; - - tex_input_rgba(col1, in[1], p, thread); - tex_input_rgba(col2, in[2], p, thread); - - /* use alpha */ - if (node->custom2 & 1) - fac *= col2[3]; - - CLAMP(fac, 0.0f, 1.0f); - - copy_v4_v4(out, col1); - ramp_blend(node->custom1, out, fac, col2); -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_mix_rgb(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_label(&ntype, node_blend_label); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c deleted file mode 100644 index 57165a8cb09..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2006 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_output.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -/* **************** COMPOSITE ******************** */ -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION}, - { -1, 0, ""} -}; - -/* applies to render pipeline */ -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **UNUSED(out)) -{ - TexCallData *cdata = (TexCallData *)data; - TexResult *target = cdata->target; - - if (cdata->do_preview) { - TexParams params; - params_from_cdata(¶ms, cdata); - - if (in[1] && in[1]->hasinput && !in[0]->hasinput) - tex_input_rgba(&target->tr, in[1], ¶ms, cdata->thread); - else - tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); - tex_do_preview(execdata->preview, params.co, &target->tr, cdata->do_manage); - } - else { - /* 0 means don't care, so just use first */ - if (cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) { - TexParams params; - params_from_cdata(¶ms, cdata); - - tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); - - target->tin = (target->tr + target->tg + target->tb) / 3.0f; - target->talpha = true; - - if (target->nor) { - if (in[1] && in[1]->hasinput) - tex_input_vec(target->nor, in[1], ¶ms, cdata->thread); - else - target->nor = NULL; - } - } - } -} - -static void unique_name(bNode *node) -{ - TexNodeOutput *tno = (TexNodeOutput *)node->storage; - char new_name[sizeof(tno->name)]; - int new_len = 0; - int suffix; - bNode *i; - const char *name = tno->name; - - new_name[0] = '\0'; - i = node; - while (i->prev) i = i->prev; - for (; i; i = i->next) { - if (i == node || - i->type != TEX_NODE_OUTPUT || - !STREQ(name, ((TexNodeOutput *)(i->storage))->name)) - { - continue; - } - - if (new_name[0] == '\0') { - int len = strlen(name); - if (len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) { - new_len = len; - } - else { - suffix = 0; - new_len = len + 4; - if (new_len > (sizeof(tno->name) - 1)) - new_len = (sizeof(tno->name) - 1); - } - - BLI_strncpy(new_name, name, sizeof(tno->name)); - name = new_name; - } - sprintf(new_name + new_len - 4, ".%03d", ++suffix); - } - - if (new_name[0] != '\0') { - BLI_strncpy(tno->name, new_name, sizeof(tno->name)); - } -} - -static void assign_index(struct bNode *node) -{ - bNode *tnode; - int index = 1; - - tnode = node; - while (tnode->prev) - tnode = tnode->prev; - -check_index: - for (; tnode; tnode = tnode->next) - if (tnode->type == TEX_NODE_OUTPUT && tnode != node) - if (tnode->custom1 == index) { - index++; - goto check_index; - } - - node->custom1 = index; -} - -static void init(bNodeTree *UNUSED(ntree), bNode *node) -{ - TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output"); - node->storage = tno; - - strcpy(tno->name, "Default"); - unique_name(node); - assign_index(node); -} - -static void copy(bNodeTree *dest_ntree, bNode *dest_node, bNode *src_node) -{ - node_copy_standard_storage(dest_ntree, dest_node, src_node); - unique_name(dest_node); - assign_index(dest_node); -} - -void register_node_type_tex_output(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW); - node_type_socket_templates(&ntype, inputs, NULL); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, init); - node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy); - node_type_exec(&ntype, NULL, NULL, exec); - - /* Do not allow muting output. */ - node_type_internal_links(&ntype, NULL); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c deleted file mode 100644 index fd2aa695a75..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_proc.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -#include "RE_shader_ext.h" - -/* - * In this file: wrappers to use procedural textures as nodes - */ - - -static bNodeSocketTemplate outputs_both[] = { - { SOCK_RGBA, 0, N_("Color"), 1.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs_color_only[] = { - { SOCK_RGBA, 0, N_("Color") }, - { -1, 0, "" } -}; - -/* Inputs common to all, #defined because nodes will need their own inputs too */ -#define I 2 /* count */ -#define COMMON_INPUTS \ - { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f }, \ - { SOCK_RGBA, 1, "Color 1", 0.0f, 0.0f, 0.0f, 1.0f }, \ - { SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f } - -/* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */ -static void do_proc(float *result, TexParams *p, const float col1[4], const float col2[4], char is_normal, Tex *tex, const short thread) -{ - TexResult texres; - int textype; - - if (is_normal) { - texres.nor = result; - } - else - texres.nor = NULL; - - textype = multitex_nodes(tex, p->co, p->dxt, p->dyt, p->osatex, - &texres, thread, 0, p->shi, p->mtex, NULL); - - if (is_normal) - return; - - if (textype & TEX_RGB) { - copy_v4_v4(result, &texres.tr); - } - else { - copy_v4_v4(result, col1); - ramp_blend(MA_RAMP_BLEND, result, texres.tin, col2); - } -} - -typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, const short thread); - -static void texfn( - float *result, - TexParams *p, - bNode *node, - bNodeStack **in, - char is_normal, - MapFn map_inputs, - short thread) -{ - Tex tex = *((Tex *)(node->storage)); - float col1[4], col2[4]; - tex_input_rgba(col1, in[0], p, thread); - tex_input_rgba(col2, in[1], p, thread); - - map_inputs(&tex, in, p, thread); - - do_proc(result, p, col1, col2, is_normal, &tex, thread); -} - -static int count_outputs(bNode *node) -{ - bNodeSocket *sock; - int num = 0; - for (sock = node->outputs.first; sock; sock = sock->next) { - num++; - } - return num; -} - -/* Boilerplate generators */ - -#define ProcNoInputs(name) \ - static void name##_map_inputs(Tex *UNUSED(tex), bNodeStack **UNUSED(in), TexParams *UNUSED(p), short UNUSED(thread)) \ - {} - -#define ProcDef(name) \ - static void name##_colorfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \ - { \ - texfn(result, p, node, in, 0, &name##_map_inputs, thread); \ - } \ - static void name##_normalfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \ - { \ - texfn(result, p, node, in, 1, &name##_map_inputs, thread); \ - } \ - static void name##_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) \ - { \ - int outs = count_outputs(node); \ - if (outs >= 1) tex_output(node, execdata, in, out[0], &name##_colorfn, data); \ - if (outs >= 2) tex_output(node, execdata, in, out[1], &name##_normalfn, data); \ - } - - -/* --- VORONOI -- */ -static bNodeSocketTemplate voronoi_inputs[] = { - COMMON_INPUTS, - { SOCK_FLOAT, 1, N_("W1"), 1.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("W2"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("W3"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("W4"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, - - { SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.01f, 10.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 4.0f, PROP_UNSIGNED }, - - { -1, 0, "" } -}; -static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) -{ - tex->vn_w1 = tex_input_value(in[I + 0], p, thread); - tex->vn_w2 = tex_input_value(in[I + 1], p, thread); - tex->vn_w3 = tex_input_value(in[I + 2], p, thread); - tex->vn_w4 = tex_input_value(in[I + 3], p, thread); - - tex->ns_outscale = tex_input_value(in[I + 4], p, thread); - tex->noisesize = tex_input_value(in[I + 5], p, thread); -} -ProcDef(voronoi) - -/* --- BLEND -- */ -static bNodeSocketTemplate blend_inputs[] = { - COMMON_INPUTS, - { -1, 0, "" } -}; -ProcNoInputs(blend) -ProcDef(blend) - -/* -- MAGIC -- */ -static bNodeSocketTemplate magic_inputs[] = { - COMMON_INPUTS, - { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static void magic_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) -{ - tex->turbul = tex_input_value(in[I + 0], p, thread); -} -ProcDef(magic) - -/* --- MARBLE --- */ -static bNodeSocketTemplate marble_inputs[] = { - COMMON_INPUTS, - { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static void marble_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I + 0], p, thread); - tex->turbul = tex_input_value(in[I + 1], p, thread); -} -ProcDef(marble) - -/* --- CLOUDS --- */ -static bNodeSocketTemplate clouds_inputs[] = { - COMMON_INPUTS, - { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static void clouds_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I + 0], p, thread); -} -ProcDef(clouds) - -/* --- DISTORTED NOISE --- */ -static bNodeSocketTemplate distnoise_inputs[] = { - COMMON_INPUTS, - { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Distortion"), 1.00f, 0.0f, 0.0f, 0.0f, 0.0000f, 10.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static void distnoise_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I + 0], p, thread); - tex->dist_amount = tex_input_value(in[I + 1], p, thread); -} -ProcDef(distnoise) - -/* --- WOOD --- */ -static bNodeSocketTemplate wood_inputs[] = { - COMMON_INPUTS, - { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static void wood_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I + 0], p, thread); - tex->turbul = tex_input_value(in[I + 1], p, thread); -} -ProcDef(wood) - -/* --- MUSGRAVE --- */ -static bNodeSocketTemplate musgrave_inputs[] = { - COMMON_INPUTS, - { SOCK_FLOAT, 1, N_("H"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Lacunarity"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Octaves"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 8.0f, PROP_UNSIGNED }, - - { SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static void musgrave_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) -{ - tex->mg_H = tex_input_value(in[I + 0], p, thread); - tex->mg_lacunarity = tex_input_value(in[I + 1], p, thread); - tex->mg_octaves = tex_input_value(in[I + 2], p, thread); - tex->ns_outscale = tex_input_value(in[I + 3], p, thread); - tex->noisesize = tex_input_value(in[I + 4], p, thread); -} -ProcDef(musgrave) - -/* --- NOISE --- */ -static bNodeSocketTemplate noise_inputs[] = { - COMMON_INPUTS, - { -1, 0, "" } -}; -ProcNoInputs(noise) -ProcDef(noise) - -/* --- STUCCI --- */ -static bNodeSocketTemplate stucci_inputs[] = { - COMMON_INPUTS, - { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED }, - { -1, 0, "" } -}; -static void stucci_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread) -{ - tex->noisesize = tex_input_value(in[I + 0], p, thread); - tex->turbul = tex_input_value(in[I + 1], p, thread); -} -ProcDef(stucci) - -/* --- */ - -static void init(bNodeTree *UNUSED(ntree), bNode *node) -{ - Tex *tex = MEM_callocN(sizeof(Tex), "Tex"); - node->storage = tex; - - BKE_texture_default(tex); - tex->type = node->type - TEX_NODE_PROC; - - if (tex->type == TEX_WOOD) - tex->stype = TEX_BANDNOISE; - -} - -/* Node type definitions */ -#define TexDef(TEXTYPE, outputs, name, Name) \ -void register_node_type_tex_proc_##name(void) \ -{ \ - static bNodeType ntype; \ - \ - tex_node_type_base(&ntype, TEX_NODE_PROC+TEXTYPE, Name, NODE_CLASS_TEXTURE, NODE_PREVIEW); \ - node_type_socket_templates(&ntype, name##_inputs, outputs); \ - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); \ - node_type_init(&ntype, init); \ - node_type_storage(&ntype, "Tex", node_free_standard_storage, node_copy_standard_storage); \ - node_type_exec(&ntype, NULL, NULL, name##_exec); \ - \ - nodeRegisterType(&ntype); \ -} - -#define C outputs_color_only -#define CV outputs_both - -TexDef(TEX_VORONOI, CV, voronoi, "Voronoi" ) -TexDef(TEX_BLEND, C, blend, "Blend" ) -TexDef(TEX_MAGIC, C, magic, "Magic" ) -TexDef(TEX_MARBLE, CV, marble, "Marble" ) -TexDef(TEX_CLOUDS, CV, clouds, "Clouds" ) -TexDef(TEX_WOOD, CV, wood, "Wood" ) -TexDef(TEX_MUSGRAVE, CV, musgrave, "Musgrave" ) -TexDef(TEX_NOISE, C, noise, "Noise" ) -TexDef(TEX_STUCCI, CV, stucci, "Stucci" ) -TexDef(TEX_DISTNOISE, CV, distnoise, "Distorted Noise" ) diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c deleted file mode 100644 index ff1bd464316..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_rotate.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_rotate.c - * \ingroup texnodes - */ - - -#include <math.h> - -#include "node_texture_util.h" -#include "NOD_texture.h" - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_FLOAT, 1, N_("Turns"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, - { SOCK_VECTOR, 1, N_("Axis"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_DIRECTION }, - { -1, 0, "" } -}; - -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } -}; - -static void rotate(float new_co[3], float a, float ax[3], const float co[3]) -{ - float para[3]; - float perp[3]; - float cp[3]; - - float cos_a = cosf(a * (float)(2 * M_PI)); - float sin_a = sinf(a * (float)(2 * M_PI)); - - // x' = xcosa + n(n.x)(1-cosa) + (x*n)sina - - mul_v3_v3fl(perp, co, cos_a); - mul_v3_v3fl(para, ax, dot_v3v3(co, ax) * (1 - cos_a)); - - cross_v3_v3v3(cp, ax, co); - mul_v3_fl(cp, sin_a); - - new_co[0] = para[0] + perp[0] + cp[0]; - new_co[1] = para[1] + perp[1] + cp[1]; - new_co[2] = para[2] + perp[2] + cp[2]; -} - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float new_co[3], new_dxt[3], new_dyt[3], a, ax[3]; - - a = tex_input_value(in[1], p, thread); - tex_input_vec(ax, in[2], p, thread); - - rotate(new_co, a, ax, p->co); - if (p->osatex) { - rotate(new_dxt, a, ax, p->dxt); - rotate(new_dyt, a, ax, p->dyt); - } - - { - TexParams np = *p; - np.co = new_co; - np.dxt = new_dxt; - np.dyt = new_dyt; - tex_input_rgba(out, in[0], &np, thread); - } -} -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_rotate(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_scale.c b/source/blender/nodes/texture/nodes/node_texture_scale.c deleted file mode 100644 index 4643ba224c4..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_scale.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_scale.c - * \ingroup texnodes - */ - - -#include <math.h> -#include "node_texture_util.h" - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_VECTOR, 1, N_("Scale"), 1.0f, 1.0f, 1.0f, 0.0f, -10.0f, 10.0f, PROP_XYZ }, - { -1, 0, "" } -}; - -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float scale[3], new_co[3], new_dxt[3], new_dyt[3]; - TexParams np = *p; - - np.co = new_co; - np.dxt = new_dxt; - np.dyt = new_dyt; - - tex_input_vec(scale, in[1], p, thread); - - mul_v3_v3v3(new_co, p->co, scale); - if (p->osatex) { - mul_v3_v3v3(new_dxt, p->dxt, scale); - mul_v3_v3v3(new_dyt, p->dyt, scale); - } - - tex_input_rgba(out, in[0], &np, thread); -} -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_scale(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c deleted file mode 100644 index 1fd0a55dc63..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_texture.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -#include "RE_shader_ext.h" - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color1"), 1.0f, 1.0f, 1.0f, 1.0f }, - { SOCK_RGBA, 1, N_("Color2"), 0.0f, 0.0f, 0.0f, 1.0f }, - { -1, 0, "" } -}; - -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color") }, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - Tex *nodetex = (Tex *)node->id; - static float red[] = {1, 0, 0, 1}; - static float white[] = {1, 1, 1, 1}; - float co[3], dxt[3], dyt[3]; - - copy_v3_v3(co, p->co); - if (p->osatex) { - copy_v3_v3(dxt, p->dxt); - copy_v3_v3(dyt, p->dyt); - } - else { - zero_v3(dxt); - zero_v3(dyt); - } - - if (node->custom2 || node->need_exec == 0) { - /* this node refers to its own texture tree! */ - copy_v4_v4(out, (fabsf(co[0] - co[1]) < 0.01f) ? white : red); - } - else if (nodetex) { - TexResult texres; - int textype; - float nor[] = {0, 0, 0}; - float col1[4], col2[4]; - - tex_input_rgba(col1, in[0], p, thread); - tex_input_rgba(col2, in[1], p, thread); - - texres.nor = nor; - textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex, - &texres, thread, 0, p->shi, p->mtex, NULL); - - if (textype & TEX_RGB) { - copy_v4_v4(out, &texres.tr); - } - else { - copy_v4_v4(out, col1); - ramp_blend(MA_RAMP_BLEND, out, texres.tin, col2); - } - } -} - -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_texture(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.c b/source/blender/nodes/texture/nodes/node_texture_translate.c deleted file mode 100644 index 4ee1b5b2f44..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_translate.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_translate.c - * \ingroup texnodes - */ - - -#include <math.h> -#include "node_texture_util.h" -#include "NOD_texture.h" - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_VECTOR, 1, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_TRANSLATION }, - { -1, 0, "" } -}; - -static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } -}; - -static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float offset[3], new_co[3]; - TexParams np = *p; - np.co = new_co; - - tex_input_vec(offset, in[1], p, thread); - - new_co[0] = p->co[0] + offset[0]; - new_co[1] = p->co[1] + offset[1]; - new_co[2] = p->co[2] + offset[2]; - - tex_input_rgba(out, in[0], &np, thread); -} -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &colorfn, data); -} - -void register_node_type_tex_translate(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.c b/source/blender/nodes/texture/nodes/node_texture_valToNor.c deleted file mode 100644 index aeca75c8b6e..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_valToNor.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Jucas. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_valToNor.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" - -static bNodeSocketTemplate inputs[] = { - { SOCK_FLOAT, 1, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("Nabla"), 0.025f, 0.0f, 0.0f, 0.0f, 0.001f, 0.1f, PROP_UNSIGNED }, - { -1, 0, "" } -}; - -static bNodeSocketTemplate outputs[] = { - { SOCK_VECTOR, 0, N_("Normal") }, - { -1, 0, "" } -}; - -static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float new_co[3]; - const float *co = p->co; - - float nabla = tex_input_value(in[1], p, thread); - float val; - float nor[3]; - - TexParams np = *p; - np.co = new_co; - - val = tex_input_value(in[0], p, thread); - - new_co[0] = co[0] + nabla; - new_co[1] = co[1]; - new_co[2] = co[2]; - nor[0] = tex_input_value(in[0], &np, thread); - - new_co[0] = co[0]; - new_co[1] = co[1] + nabla; - nor[1] = tex_input_value(in[0], &np, thread); - - new_co[1] = co[1]; - new_co[2] = co[2] + nabla; - nor[2] = tex_input_value(in[0], &np, thread); - - out[0] = val - nor[0]; - out[1] = val - nor[1]; - out[2] = val - nor[2]; -} -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &normalfn, data); -} - -void register_node_type_tex_valtonor(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTOR, 0); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c deleted file mode 100644 index a49d82d27a9..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_valToRgb.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" -#include "IMB_colormanagement.h" - -/* **************** VALTORGB ******************** */ -static bNodeSocketTemplate valtorgb_in[] = { - { SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - { -1, 0, "" } -}; -static bNodeSocketTemplate valtorgb_out[] = { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } -}; - -static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) -{ - if (node->storage) { - float fac = tex_input_value(in[0], p, thread); - - do_colorband(node->storage, fac, out); - } -} - -static void valtorgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &valtorgb_colorfn, data); -} - -static void valtorgb_init(bNodeTree *UNUSED(ntree), bNode *node) -{ - node->storage = add_colorband(true); -} - -void register_node_type_tex_valtorgb(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0); - node_type_socket_templates(&ntype, valtorgb_in, valtorgb_out); - node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, valtorgb_init); - node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, NULL, NULL, valtorgb_exec); - - nodeRegisterType(&ntype); -} - -/* **************** RGBTOBW ******************** */ -static bNodeSocketTemplate rgbtobw_in[] = { - { SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; -static bNodeSocketTemplate rgbtobw_out[] = { - { SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - - -static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) -{ - float cin[4]; - tex_input_rgba(cin, in[0], p, thread); - *out = IMB_colormanagement_get_luminance(cin); -} - -static void rgbtobw_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) -{ - tex_output(node, execdata, in, out[0], &rgbtobw_valuefn, data); -} - -void register_node_type_tex_rgbtobw(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0); - node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out); - node_type_exec(&ntype, NULL, NULL, rgbtobw_exec); - - nodeRegisterType(&ntype); -} diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c deleted file mode 100644 index 4168e7a16e7..00000000000 --- a/source/blender/nodes/texture/nodes/node_texture_viewer.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2005 Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Robin Allen - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/nodes/texture/nodes/node_texture_viewer.c - * \ingroup texnodes - */ - - -#include "node_texture_util.h" -#include "NOD_texture.h" -#include <math.h> - -static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Color"), 1.0f, 0.0f, 0.0f, 1.0f }, - { -1, 0, "" } -}; -static bNodeSocketTemplate outputs[] = { - { -1, 0, "" } -}; - -static void exec(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *execdata, bNodeStack **in, bNodeStack **UNUSED(out)) -{ - TexCallData *cdata = (TexCallData *)data; - - if (cdata->do_preview) { - TexParams params; - float col[4]; - params_from_cdata(¶ms, cdata); - - tex_input_rgba(col, in[0], ¶ms, cdata->thread); - tex_do_preview(execdata->preview, params.previewco, col, cdata->do_manage); - } -} - -void register_node_type_tex_viewer(void) -{ - static bNodeType ntype; - - tex_node_type_base(&ntype, TEX_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - - /* Do not allow muting viewer node. */ - node_type_internal_links(&ntype, NULL); - - nodeRegisterType(&ntype); -} |