diff options
Diffstat (limited to 'source/blender')
22 files changed, 383 insertions, 1163 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 3ba6cd3793e..9543eefd0c7 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -473,23 +473,19 @@ struct ShadeResult; #define SH_NODE_GEOMETRY 141 #define SH_NODE_LIGHT_PATH 142 #define SH_NODE_TEX_IMAGE 143 -#define SH_NODE_TEX_NOISE 144 #define SH_NODE_TEX_SKY 145 -#define SH_NODE_TEX_BLEND 146 +#define SH_NODE_TEX_GRADIENT 146 #define SH_NODE_TEX_VORONOI 147 #define SH_NODE_TEX_MAGIC 148 -#define SH_NODE_TEX_MARBLE 149 -#define SH_NODE_TEX_CLOUDS 150 -#define SH_NODE_TEX_WOOD 151 +#define SH_NODE_TEX_WAVE 149 +#define SH_NODE_TEX_NOISE 150 #define SH_NODE_TEX_MUSGRAVE 152 -#define SH_NODE_TEX_STUCCI 153 -#define SH_NODE_TEX_DISTNOISE 154 #define SH_NODE_TEX_COORD 155 #define SH_NODE_ADD_SHADER 156 #define SH_NODE_TEX_ENVIRONMENT 157 #define SH_NODE_OUTPUT_TEXTURE 158 #define SH_NODE_HOLDOUT 159 -#define SH_NODE_BLEND_WEIGHT 160 +#define SH_NODE_LAYER_WEIGHT 160 #define SH_NODE_VOLUME_TRANSPARENT 161 #define SH_NODE_VOLUME_ISOTROPIC 162 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 4f87c194790..35f32a3b772 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1896,7 +1896,7 @@ static void registerShaderNodes(ListBase *ntypelist) register_node_type_sh_geometry(ntypelist); register_node_type_sh_light_path(ntypelist); register_node_type_sh_fresnel(ntypelist); - register_node_type_sh_blend_weight(ntypelist); + register_node_type_sh_layer_weight(ntypelist); register_node_type_sh_tex_coord(ntypelist); register_node_type_sh_background(ntypelist); @@ -1922,16 +1922,12 @@ static void registerShaderNodes(ListBase *ntypelist) register_node_type_sh_tex_image(ntypelist); register_node_type_sh_tex_environment(ntypelist); register_node_type_sh_tex_sky(ntypelist); - register_node_type_sh_tex_voronoi(ntypelist); - register_node_type_sh_tex_blend(ntypelist); - register_node_type_sh_tex_magic(ntypelist); - register_node_type_sh_tex_marble(ntypelist); - register_node_type_sh_tex_clouds(ntypelist); - register_node_type_sh_tex_wood(ntypelist); - register_node_type_sh_tex_stucci(ntypelist); register_node_type_sh_tex_noise(ntypelist); - register_node_type_sh_tex_distnoise(ntypelist); + register_node_type_sh_tex_wave(ntypelist); + register_node_type_sh_tex_voronoi(ntypelist); register_node_type_sh_tex_musgrave(ntypelist); + register_node_type_sh_tex_gradient(ntypelist); + register_node_type_sh_tex_magic(ntypelist); } static void registerTextureNodes(ListBase *ntypelist) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1c96cd2e05a..4d07242bfc9 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2091,7 +2091,7 @@ static void ntree_tmp_cycles_version_patch(bNodeTree *ntree) if(strcmp(sock->name, "Fresnel") == 0) { bNodeSocket *osock; - node->type = SH_NODE_BLEND_WEIGHT; + node->type = SH_NODE_LAYER_WEIGHT; strcpy(sock->name, "Blend"); for(osock=node->outputs.first; osock; osock=osock->next) @@ -7227,9 +7227,8 @@ static void do_version_ntree_tex_mapping_260(void *UNUSED(data), ID *UNUSED(id), tex_mapping->projz= PROJ_Z; } else if(ELEM7(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_NOISE, SH_NODE_TEX_SKY, - SH_NODE_TEX_BLEND, SH_NODE_TEX_VORONOI, SH_NODE_TEX_MAGIC, SH_NODE_TEX_MARBLE) || - ELEM6(node->type, SH_NODE_TEX_CLOUDS, SH_NODE_TEX_WOOD, SH_NODE_TEX_MUSGRAVE, - SH_NODE_TEX_STUCCI, SH_NODE_TEX_DISTNOISE, SH_NODE_TEX_ENVIRONMENT)) { + SH_NODE_TEX_GRADIENT, SH_NODE_TEX_VORONOI, SH_NODE_TEX_MAGIC, SH_NODE_TEX_WAVE) || + ELEM(node->type, SH_NODE_TEX_MUSGRAVE, SH_NODE_TEX_ENVIRONMENT)) { NodeTexBase *base= node->storage; if(node->type == SH_NODE_TEX_NOISE) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 45713ff2a8f..c27d7e74cd7 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1028,23 +1028,9 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), Poin uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE); } -static void node_shader_buts_tex_blend(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "progression", 0, "", ICON_NONE); - uiItemR(layout, ptr, "axis", 0, "", ICON_NONE); -} - -static void node_shader_buts_tex_clouds(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ - uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE); - uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE); - uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE); -} - -static void node_shader_buts_tex_distnoise(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ - uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE); - uiItemR(layout, ptr, "noise_distortion", 0, "", ICON_NONE); + uiItemR(layout, ptr, "gradient_type", 0, "", ICON_NONE); } static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -1052,42 +1038,21 @@ static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), Po uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE); } -static void node_shader_buts_tex_marble(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "marble_type", 0, "", ICON_NONE); - uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE); - uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE); - uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE); } static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE); - uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE); -} - -static void node_shader_buts_tex_stucci(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ - uiItemR(layout, ptr, "stucci_type", 0, "", ICON_NONE); - uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE); - uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE); } static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "distance_metric", 0, "", ICON_NONE); uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE); } -static void node_shader_buts_tex_wood(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ - uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE); - uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE); - uiItemR(layout, ptr, "wood_type", 0, "", ICON_NONE); - uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE); -} - static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE); @@ -1191,33 +1156,21 @@ static void node_shader_set_butfunc(bNodeType *ntype) case SH_NODE_TEX_ENVIRONMENT: ntype->uifunc= node_shader_buts_tex_image; break; - case SH_NODE_TEX_BLEND: - ntype->uifunc= node_shader_buts_tex_blend; - break; - case SH_NODE_TEX_CLOUDS: - ntype->uifunc= node_shader_buts_tex_clouds; - break; - case SH_NODE_TEX_DISTNOISE: - ntype->uifunc= node_shader_buts_tex_distnoise; + case SH_NODE_TEX_GRADIENT: + ntype->uifunc= node_shader_buts_tex_gradient; break; case SH_NODE_TEX_MAGIC: ntype->uifunc= node_shader_buts_tex_magic; break; - case SH_NODE_TEX_MARBLE: - ntype->uifunc= node_shader_buts_tex_marble; + case SH_NODE_TEX_WAVE: + ntype->uifunc= node_shader_buts_tex_wave; break; case SH_NODE_TEX_MUSGRAVE: ntype->uifunc= node_shader_buts_tex_musgrave; break; - case SH_NODE_TEX_STUCCI: - ntype->uifunc= node_shader_buts_tex_stucci; - break; case SH_NODE_TEX_VORONOI: ntype->uifunc= node_shader_buts_tex_voronoi; break; - case SH_NODE_TEX_WOOD: - ntype->uifunc= node_shader_buts_tex_wood; - break; case SH_NODE_BSDF_GLOSSY: case SH_NODE_BSDF_GLASS: ntype->uifunc= node_shader_buts_glossy; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index d637d6f97bd..07c2885eff7 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -432,10 +432,6 @@ typedef struct NodeTexBase { ColorMapping color_mapping; } NodeTexBase; -typedef struct NodeTexNoise { - NodeTexBase base; -} NodeTexNoise; - typedef struct NodeTexSky { NodeTexBase base; float sun_direction[3]; @@ -452,41 +448,33 @@ typedef struct NodeTexEnvironment { int color_space, pad; } NodeTexEnvironment; -typedef struct NodeTexBlend { +typedef struct NodeTexGradient { NodeTexBase base; - int progression; - int axis; -} NodeTexBlend; + int gradient_type; + int pad; +} NodeTexGradient; -typedef struct NodeTexClouds { +typedef struct NodeTexNoise { NodeTexBase base; - int hard; - int depth; - int basis; - int pad; -} NodeTexClouds; +} NodeTexNoise; typedef struct NodeTexVoronoi { NodeTexBase base; - int distance_metric; int coloring; + int pad; } NodeTexVoronoi; typedef struct NodeTexMusgrave { NodeTexBase base; - int type; - int basis; + int musgrave_type; + int pad; } NodeTexMusgrave; -typedef struct NodeTexMarble { +typedef struct NodeTexWave { NodeTexBase base; - int type; - int wave; - int basis; - int hard; - int depth; + int wave_type; int pad; -} NodeTexMarble; +} NodeTexWave; typedef struct NodeTexMagic { NodeTexBase base; @@ -494,28 +482,6 @@ typedef struct NodeTexMagic { int pad; } NodeTexMagic; -typedef struct NodeTexStucci { - NodeTexBase base; - int type; - int basis; - int hard; - int pad; -} NodeTexStucci; - -typedef struct NodeTexDistortedNoise { - NodeTexBase base; - int basis; - int distortion_basis; -} NodeTexDistortedNoise; - -typedef struct NodeTexWood { - NodeTexBase base; - int type; - int wave; - int basis; - int hard; -} NodeTexWood; - typedef struct NodeShaderAttribute { char name[64]; } NodeShaderAttribute; @@ -545,9 +511,6 @@ typedef struct TexNodeOutput { #define SHD_BLEND_QUADRATIC_SPHERE 5 #define SHD_BLEND_SPHERICAL 6 -#define SHD_BLEND_HORIZONTAL 0 -#define SHD_BLEND_VERTICAL 1 - /* noise basis for textures */ #define SHD_NOISE_PERLIN 0 #define SHD_NOISE_VORONOI_F1 1 @@ -570,10 +533,8 @@ typedef struct TexNodeOutput { #define SHD_VORONOI_MINKOVSKY_4 5 #define SHD_VORONOI_MINKOVSKY 6 -#define SHD_VORONOI_INTENSITY 0 -#define SHD_VORONOI_POSITION 1 -#define SHD_VORONOI_POSITION_OUTLINE 2 -#define SHD_VORONOI_POSITION_OUTLINE_INTENSITY 3 +#define SHD_VORONOI_INTENSITY 0 +#define SHD_VORONOI_CELLS 1 /* musgrave texture */ #define SHD_MUSGRAVE_MULTIFRACTAL 0 @@ -582,26 +543,14 @@ typedef struct TexNodeOutput { #define SHD_MUSGRAVE_RIDGED_MULTIFRACTAL 3 #define SHD_MUSGRAVE_HETERO_TERRAIN 4 -/* marble texture */ -#define SHD_MARBLE_SOFT 0 -#define SHD_MARBLE_SHARP 1 -#define SHD_MARBLE_SHARPER 2 +/* wave texture */ +#define SHD_WAVE_BANDS 0 +#define SHD_WAVE_RINGS 1 #define SHD_WAVE_SINE 0 #define SHD_WAVE_SAW 1 #define SHD_WAVE_TRI 2 -/* stucci texture */ -#define SHD_STUCCI_PLASTIC 0 -#define SHD_STUCCI_WALL_IN 1 -#define SHD_STUCCI_WALL_OUT 2 - -/* wood texture */ -#define SHD_WOOD_BANDS 0 -#define SHD_WOOD_RINGS 1 -#define SHD_WOOD_BAND_NOISE 2 -#define SHD_WOOD_RING_NOISE 3 - /* image/environment texture */ #define SHD_COLORSPACE_LINEAR 0 #define SHD_COLORSPACE_SRGB 1 diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index db80f8906fd..035a05e5124 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1147,12 +1147,6 @@ static void def_sh_tex(StructRNA *srna) RNA_def_property_ui_text(prop, "Color Mapping", "Color mapping settings"); } -static void def_sh_tex_noise(StructRNA *srna) -{ - RNA_def_struct_sdna_from(srna, "NodeTexNoise", "storage"); - def_sh_tex(srna); -} - static void def_sh_tex_sky(StructRNA *srna) { PropertyRNA *prop; @@ -1219,9 +1213,9 @@ static void def_sh_tex_image(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Node_update"); } -static void def_sh_tex_blend(StructRNA *srna) +static void def_sh_tex_gradient(StructRNA *srna) { - static EnumPropertyItem prop_blend_progression[] = { + static EnumPropertyItem prop_gradient_type[] = { {SHD_BLEND_LINEAR, "LINEAR", 0, "Linear", "Creates a linear progression"}, {SHD_BLEND_QUADRATIC, "QUADRATIC", 0, "Quadratic", "Creates a quadratic progression"}, {SHD_BLEND_EASING, "EASING", 0, "Easing", "Creates a progression easing from one step to the next"}, @@ -1231,73 +1225,21 @@ static void def_sh_tex_blend(StructRNA *srna) {SHD_BLEND_RADIAL, "RADIAL", 0, "Radial", "Creates a radial progression"}, {0, NULL, 0, NULL, NULL}}; - static const EnumPropertyItem prop_axis_items[]= { - {SHD_BLEND_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", "Flips the texture's X and Y axis"}, - {SHD_BLEND_VERTICAL, "VERTICAL", 0, "Vertical", "Flips the texture's X and Y axis"}, - {0, NULL, 0, NULL, NULL}}; - - PropertyRNA *prop; - - RNA_def_struct_sdna_from(srna, "NodeTexBlend", "storage"); - def_sh_tex(srna); - - prop= RNA_def_property(srna, "progression", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "progression"); - RNA_def_property_enum_items(prop, prop_blend_progression); - RNA_def_property_ui_text(prop, "Progression", "Sets the style of the color blending"); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "axis"); - RNA_def_property_enum_items(prop, prop_axis_items); - RNA_def_property_ui_text(prop, "Axis", "Flips the texture's X and Y axis"); - RNA_def_property_update(prop, 0, "rna_Node_update"); -} - -static void def_sh_tex_clouds(StructRNA *srna) -{ PropertyRNA *prop; - RNA_def_struct_sdna_from(srna, "NodeTexClouds", "storage"); + RNA_def_struct_sdna_from(srna, "NodeTexGradient", "storage"); def_sh_tex(srna); - prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "basis"); - RNA_def_property_enum_items(prop, prop_noise_basis_items); - RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "hard"); - RNA_def_property_enum_items(prop, prop_noise_type_items); - RNA_def_property_ui_text(prop, "Noise Type", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "depth"); - RNA_def_property_range(prop, 0, 30); - RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise"); + prop= RNA_def_property(srna, "gradient_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_gradient_type); + RNA_def_property_ui_text(prop, "Gradient Type", "Sets the style of the color blending"); RNA_def_property_update(prop, 0, "rna_Node_update"); } -static void def_sh_tex_distnoise(StructRNA *srna) +static void def_sh_tex_noise(StructRNA *srna) { - PropertyRNA *prop; - - RNA_def_struct_sdna_from(srna, "NodeTexDistortedNoise", "storage"); + RNA_def_struct_sdna_from(srna, "NodeTexNoise", "storage"); def_sh_tex(srna); - - prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "basis"); - RNA_def_property_enum_items(prop, prop_noise_basis_items); - RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "noise_distortion", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "distortion_basis"); - RNA_def_property_enum_items(prop, prop_noise_basis_items); - RNA_def_property_ui_text(prop, "Noise Distortion", "Sets the noise basis used for distortion"); - RNA_def_property_update(prop, 0, "rna_Node_update"); } static void def_sh_tex_magic(StructRNA *srna) @@ -1314,50 +1256,6 @@ static void def_sh_tex_magic(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Node_update"); } -static void def_sh_tex_marble(StructRNA *srna) -{ - static EnumPropertyItem prop_marble_stype[] = { - {SHD_MARBLE_SOFT, "SOFT", 0, "Soft", "Uses soft marble"}, - {SHD_MARBLE_SHARP, "SHARP", 0, "Sharp", "Uses more clearly defined marble"}, - {SHD_MARBLE_SHARPER, "SHARPER", 0, "Sharper", "Uses very clearly defined marble"}, - {0, NULL, 0, NULL, NULL}}; - - PropertyRNA *prop; - - RNA_def_struct_sdna_from(srna, "NodeTexMarble", "storage"); - def_sh_tex(srna); - - prop= RNA_def_property(srna, "marble_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_marble_stype); - RNA_def_property_ui_text(prop, "Type", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "basis"); - RNA_def_property_enum_items(prop, prop_noise_basis_items); - RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "hard"); - RNA_def_property_enum_items(prop, prop_noise_type_items); - RNA_def_property_ui_text(prop, "Noise Type", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "depth"); - RNA_def_property_range(prop, 0, 30); - RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise"); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "wave_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "wave"); - RNA_def_property_enum_items(prop, prop_wave_items); - RNA_def_property_ui_text(prop, "Wave Type", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); -} - static void def_sh_tex_musgrave(StructRNA *srna) { static EnumPropertyItem prop_musgrave_type[] = { @@ -1374,67 +1272,17 @@ static void def_sh_tex_musgrave(StructRNA *srna) def_sh_tex(srna); prop= RNA_def_property(srna, "musgrave_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_sdna(prop, NULL, "musgrave_type"); RNA_def_property_enum_items(prop, prop_musgrave_type); RNA_def_property_ui_text(prop, "Type", ""); RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "basis"); - RNA_def_property_enum_items(prop, prop_noise_basis_items); - RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); - RNA_def_property_update(prop, 0, "rna_Node_update"); -} - -static void def_sh_tex_stucci(StructRNA *srna) -{ - static EnumPropertyItem prop_stucci_stype[] = { - {SHD_STUCCI_PLASTIC, "PLASTIC", 0, "Plastic", "Uses standard stucci"}, - {SHD_STUCCI_WALL_IN, "WALL_IN", 0, "Wall in", "Creates Dimples"}, - {SHD_STUCCI_WALL_OUT, "WALL_OUT", 0, "Wall out", "Creates Ridges"}, - {0, NULL, 0, NULL, NULL}}; - - PropertyRNA *prop; - - RNA_def_struct_sdna_from(srna, "NodeTexStucci", "storage"); - def_sh_tex(srna); - - prop= RNA_def_property(srna, "stucci_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_stucci_stype); - RNA_def_property_ui_text(prop, "Type", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "basis"); - RNA_def_property_enum_items(prop, prop_noise_basis_items); - RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "hard"); - RNA_def_property_enum_items(prop, prop_noise_type_items); - RNA_def_property_ui_text(prop, "Noise Type", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); } static void def_sh_tex_voronoi(StructRNA *srna) { - static EnumPropertyItem prop_distance_metric_items[] = { - {SHD_VORONOI_ACTUAL_DISTANCE, "DISTANCE", 0, "Actual Distance", ""}, - {SHD_VORONOI_DISTANCE_SQUARED, "DISTANCE_SQUARED", 0, "Distance Squared", ""}, - {SHD_VORONOI_MANHATTAN, "MANHATTAN", 0, "Manhattan", ""}, - {SHD_VORONOI_CHEBYCHEV, "CHEBYCHEV", 0, "Chebychev", ""}, - {SHD_VORONOI_MINKOVSKY_H, "MINKOVSKY_HALF", 0, "Minkovsky 1/2", ""}, - {SHD_VORONOI_MINKOVSKY_4, "MINKOVSKY_FOUR", 0, "Minkovsky 4", ""}, - {SHD_VORONOI_MINKOVSKY, "MINKOVSKY", 0, "Minkovsky", ""}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_coloring_items[] = { {SHD_VORONOI_INTENSITY, "INTENSITY", 0, "Intensity", "Only calculate intensity"}, - {SHD_VORONOI_POSITION, "POSITION", 0, "Position", "Color cells by position"}, - {SHD_VORONOI_POSITION_OUTLINE, "POSITION_OUTLINE", 0, "Position and Outline", "Use position plus an outline based on F2-F.1"}, - {SHD_VORONOI_POSITION_OUTLINE_INTENSITY, "POSITION_OUTLINE_INTENSITY", 0, "Position, Outline, and Intensity", "Multiply position and outline by intensity"}, + {SHD_VORONOI_CELLS, "CELLS", 0, "Cells", "Color cells by position"}, {0, NULL, 0, NULL, NULL}}; PropertyRNA *prop; @@ -1442,12 +1290,6 @@ static void def_sh_tex_voronoi(StructRNA *srna) RNA_def_struct_sdna_from(srna, "NodeTexVoronoi", "storage"); def_sh_tex(srna); - prop= RNA_def_property(srna, "distance_metric", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "distance_metric"); - RNA_def_property_enum_items(prop, prop_distance_metric_items); - RNA_def_property_ui_text(prop, "Distance Metric", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); - prop= RNA_def_property(srna, "coloring", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "coloring"); RNA_def_property_enum_items(prop, prop_coloring_items); @@ -1455,41 +1297,21 @@ static void def_sh_tex_voronoi(StructRNA *srna) RNA_def_property_update(prop, 0, "rna_Node_update"); } -static void def_sh_tex_wood(StructRNA *srna) +static void def_sh_tex_wave(StructRNA *srna) { - static EnumPropertyItem prop_wood_type_items[] = { - {SHD_WOOD_BANDS, "BANDS", 0, "Bands", "Uses standard wood texture in bands"}, - {SHD_WOOD_RINGS, "RINGS", 0, "Rings", "Uses wood texture in rings"}, - {SHD_WOOD_BAND_NOISE, "BAND_NOISE", 0, "Band Noise", "Adds noise to standard wood"}, - {SHD_WOOD_RING_NOISE, "RING_NOISE", 0, "Ring Noise", "Adds noise to rings"}, + static EnumPropertyItem prop_wave_type_items[] = { + {SHD_WAVE_BANDS, "BANDS", 0, "Bands", "Uses standard wave texture in bands"}, + {SHD_WAVE_RINGS, "RINGS", 0, "Rings", "Uses wave texture in rings"}, {0, NULL, 0, NULL, NULL}}; PropertyRNA *prop; - RNA_def_struct_sdna_from(srna, "NodeTexWood", "storage"); + RNA_def_struct_sdna_from(srna, "NodeTexWave", "storage"); def_sh_tex(srna); - prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "basis"); - RNA_def_property_enum_items(prop, prop_noise_basis_items); - RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence"); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "hard"); - RNA_def_property_enum_items(prop, prop_noise_type_items); - RNA_def_property_ui_text(prop, "Noise Type", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); - - prop= RNA_def_property(srna, "wood_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, prop_wood_type_items); - RNA_def_property_ui_text(prop, "Wood Type", ""); - RNA_def_property_update(prop, 0, "rna_Node_update"); - prop= RNA_def_property(srna, "wave_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "wave"); - RNA_def_property_enum_items(prop, prop_wave_items); + RNA_def_property_enum_sdna(prop, NULL, "wave_type"); + RNA_def_property_enum_items(prop, prop_wave_type_items); RNA_def_property_ui_text(prop, "Wave Type", ""); RNA_def_property_update(prop, 0, "rna_Node_update"); } diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index c74d8943bcf..911501efc04 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -58,7 +58,7 @@ DefNode( ShaderNode, SH_NODE_OUTPUT_LAMP, 0, "OUTPU //DefNode( ShaderNode, SH_NODE_OUTPUT_TEXTURE, 0, "OUTPUT_TEXTURE", OutputTexture, "Texture Output", "" ) DefNode( ShaderNode, SH_NODE_OUTPUT_WORLD, 0, "OUTPUT_WORLD", OutputWorld, "World Output", "" ) DefNode( ShaderNode, SH_NODE_FRESNEL, 0, "FRESNEL", Fresnel, "Fresnel", "" ) -DefNode( ShaderNode, SH_NODE_BLEND_WEIGHT, 0, "BLEND_WEIGHT", BlendWeight, "BlendWeight", "" ) +DefNode( ShaderNode, SH_NODE_LAYER_WEIGHT, 0, "LAYER_WEIGHT", LayerWeight, "LayerWeight", "" ) DefNode( ShaderNode, SH_NODE_MIX_SHADER, 0, "MIX_SHADER", MixShader, "Mix Shader", "" ) DefNode( ShaderNode, SH_NODE_ADD_SHADER, 0, "ADD_SHADER", AddShader, "Add Shader", "" ) @@ -79,17 +79,13 @@ DefNode( ShaderNode, SH_NODE_GEOMETRY, 0, "GE DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LIGHT_PATH", Light_path, "Light_path", "") DefNode( ShaderNode, SH_NODE_TEX_IMAGE, def_sh_tex_image, "TEX_IMAGE", TexImage, "Image Texture", "") DefNode( ShaderNode, SH_NODE_TEX_ENVIRONMENT, def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture", "") -DefNode( ShaderNode, SH_NODE_TEX_NOISE, def_sh_tex_noise, "TEX_NOISE", TexNoise, "Noise Texture", "") DefNode( ShaderNode, SH_NODE_TEX_SKY, def_sh_tex_sky, "TEX_SKY", TexSky, "Sky Texture", "") -DefNode( ShaderNode, SH_NODE_TEX_BLEND, def_sh_tex_blend, "TEX_BLEND", TexBlend, "Blend Texture", "") -DefNode( ShaderNode, SH_NODE_TEX_CLOUDS, def_sh_tex_clouds, "TEX_CLOUDS", TexClouds, "Clouds Texture", "") -DefNode( ShaderNode, SH_NODE_TEX_DISTNOISE, def_sh_tex_distnoise, "TEX_DISTORTED_NOISE", TexDistortedNoise, "Distorted Noise Texture", "") +DefNode( ShaderNode, SH_NODE_TEX_GRADIENT, def_sh_tex_gradient, "TEX_GRADIENT", TexGradient, "Gradient Texture", "") +DefNode( ShaderNode, SH_NODE_TEX_NOISE, def_sh_tex_noise, "TEX_NOISE", TexNoise, "Noise Texture", "") DefNode( ShaderNode, SH_NODE_TEX_MAGIC, def_sh_tex_magic, "TEX_MAGIC", TexMagic, "Magic Texture", "") -DefNode( ShaderNode, SH_NODE_TEX_MARBLE, def_sh_tex_marble, "TEX_MARBLE", TexMarble, "Marble Texture", "") +DefNode( ShaderNode, SH_NODE_TEX_WAVE, def_sh_tex_wave, "TEX_WAVE", TexWave, "Wave Texture", "") DefNode( ShaderNode, SH_NODE_TEX_MUSGRAVE, def_sh_tex_musgrave, "TEX_MUSGRAVE", TexMusgrave, "Musgrave Texture", "") -DefNode( ShaderNode, SH_NODE_TEX_STUCCI, def_sh_tex_stucci, "TEX_STUCCI", TexStucci, "Stucci Texture", "") DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TEX_VORONOI", TexVoronoi, "Voronoi Texture", "") -DefNode( ShaderNode, SH_NODE_TEX_WOOD, def_sh_tex_wood, "TEX_WOOD", TexWood, "Wood Texture", "") DefNode( ShaderNode, SH_NODE_TEX_COORD, 0, "TEX_COORD", TexCoord, "Texture Coordinate", "") DefNode( CompositorNode, CMP_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "" ) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 8ee67fc4f9a..1847fcb8add 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -135,7 +135,7 @@ set(SRC shader/nodes/node_shader_bsdf_velvet.c shader/nodes/node_shader_emission.c shader/nodes/node_shader_fresnel.c - shader/nodes/node_shader_blend_weight.c + shader/nodes/node_shader_layer_weight.c shader/nodes/node_shader_geometry.c shader/nodes/node_shader_holdout.c shader/nodes/node_shader_volume_transparent.c @@ -147,20 +147,16 @@ set(SRC shader/nodes/node_shader_output_material.c shader/nodes/node_shader_output_texture.c shader/nodes/node_shader_output_world.c - shader/nodes/node_shader_tex_blend.c - shader/nodes/node_shader_tex_clouds.c + shader/nodes/node_shader_tex_gradient.c shader/nodes/node_shader_tex_coord.c - shader/nodes/node_shader_tex_distnoise.c - shader/nodes/node_shader_tex_image.c shader/nodes/node_shader_tex_environment.c + shader/nodes/node_shader_tex_image.c shader/nodes/node_shader_tex_magic.c - shader/nodes/node_shader_tex_marble.c shader/nodes/node_shader_tex_musgrave.c shader/nodes/node_shader_tex_noise.c shader/nodes/node_shader_tex_sky.c - shader/nodes/node_shader_tex_stucci.c shader/nodes/node_shader_tex_voronoi.c - shader/nodes/node_shader_tex_wood.c + shader/nodes/node_shader_tex_wave.c shader/nodes/node_shader_noise.h shader/node_shader_tree.c shader/node_shader_util.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index 8f6a6e527f2..52d5f2f5e9c 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -75,7 +75,7 @@ void register_node_type_sh_attribute(ListBase *lb); void register_node_type_sh_geometry(ListBase *lb); void register_node_type_sh_light_path(ListBase *lb); void register_node_type_sh_fresnel(ListBase *lb); -void register_node_type_sh_blend_weight(ListBase *lb); +void register_node_type_sh_layer_weight(ListBase *lb); void register_node_type_sh_tex_coord(ListBase *lb); void register_node_type_sh_background(ListBase *lb); @@ -102,15 +102,11 @@ void register_node_type_sh_tex_image(ListBase *lb); void register_node_type_sh_tex_environment(ListBase *lb); void register_node_type_sh_tex_sky(ListBase *lb); void register_node_type_sh_tex_voronoi(ListBase *lb); -void register_node_type_sh_tex_blend(ListBase *lb); +void register_node_type_sh_tex_gradient(ListBase *lb); void register_node_type_sh_tex_magic(ListBase *lb); -void register_node_type_sh_tex_marble(ListBase *lb); -void register_node_type_sh_tex_clouds(ListBase *lb); -void register_node_type_sh_tex_wood(ListBase *lb); +void register_node_type_sh_tex_wave(ListBase *lb); void register_node_type_sh_tex_musgrave(ListBase *lb); void register_node_type_sh_tex_noise(ListBase *lb); -void register_node_type_sh_tex_stucci(ListBase *lb); -void register_node_type_sh_tex_distnoise(ListBase *lb); #endif diff --git a/source/blender/nodes/shader/nodes/node_shader_blend_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c index f214f765abf..79e5728fab6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_blend_weight.c +++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c @@ -1,5 +1,5 @@ /** - * $Id: node_shader_blend_weight.c 32517 2010-10-16 14:32:17Z campbellbarton $ + * $Id: node_shader_layer_weight.c 32517 2010-10-16 14:32:17Z campbellbarton $ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -29,40 +29,41 @@ #include "../node_shader_util.h" -/* **************** BlendWeight ******************** */ -static bNodeSocketTemplate sh_node_blend_weight_in[]= { +/* **************** Layer Weight ******************** */ + +static bNodeSocketTemplate sh_node_layer_weight_in[]= { { SOCK_FLOAT, 1, "Blend", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_blend_weight_out[]= { +static bNodeSocketTemplate sh_node_layer_weight_out[]= { { SOCK_FLOAT, 0, "Fresnel", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, "Facing", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static void node_shader_exec_blend_weight(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out)) +static void node_shader_exec_layer_weight(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out)) { } -static int node_shader_gpu_blend_weight(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out)) +static int node_shader_gpu_layer_weight(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out)) { return 0; } /* node type definition */ -void register_node_type_sh_blend_weight(ListBase *lb) +void register_node_type_sh_layer_weight(ListBase *lb) { static bNodeType ntype; - node_type_base(&ntype, SH_NODE_BLEND_WEIGHT, "Blend Weight", NODE_CLASS_INPUT, 0); + node_type_base(&ntype, SH_NODE_LAYER_WEIGHT, "Layer Weight", NODE_CLASS_INPUT, 0); node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_blend_weight_in, sh_node_blend_weight_out); + node_type_socket_templates(&ntype, sh_node_layer_weight_in, sh_node_layer_weight_out); node_type_size(&ntype, 150, 60, 200); node_type_init(&ntype, NULL); node_type_storage(&ntype, "", NULL, NULL); - node_type_exec(&ntype, node_shader_exec_blend_weight); - node_type_gpu(&ntype, node_shader_gpu_blend_weight); + node_type_exec(&ntype, node_shader_exec_layer_weight); + node_type_gpu(&ntype, node_shader_gpu_layer_weight); nodeRegisterType(lb, &ntype); }; diff --git a/source/blender/nodes/shader/nodes/node_shader_noise.h b/source/blender/nodes/shader/nodes/node_shader_noise.h index 44aa8f6bb41..7f633820124 100644 --- a/source/blender/nodes/shader/nodes/node_shader_noise.h +++ b/source/blender/nodes/shader/nodes/node_shader_noise.h @@ -444,14 +444,17 @@ MINLINE float noise_wave(int wave, float a) /* Turbulence */ -MINLINE float noise_turbulence(float p[3], int basis, int octaves, int hard) +MINLINE float noise_turbulence(float p[3], int basis, float octaves, int hard) { float fscale = 1.0f; float amp = 1.0f; float sum = 0.0f; - int i; + float rmd; + int i, n; + + octaves = CLAMPIS(octaves, 0.0f, 16.0f); - for(i = 0; i <= octaves; i++) { + for(i = 0; i <= (int)octaves; i++) { float pscale[3] = {fscale*p[0], fscale*p[1], fscale*p[2]}; float t = noise_basis(pscale, basis); @@ -463,7 +466,28 @@ MINLINE float noise_turbulence(float p[3], int basis, int octaves, int hard) fscale *= 2.0f; } - sum *= ((float)(1 << octaves)/(float)((1 << (octaves+1)) - 1)); + rmd = octaves - floor(octaves); + + if(rmd != 0.0f) { + float pscale[3] = {fscale*p[0], fscale*p[1], fscale*p[2]}; + float t = noise_basis(pscale, basis); + float sum2; + + if(hard) + t = fabsf(2.0f*t - 1.0f); + + sum2 = sum + t*amp; + + sum *= ((float)(1 << n)/(float)((1 << (n+1)) - 1)); + sum2 *= ((float)(1 << (n+1))/(float)((1 << (n+2)) - 1)); + + return (1.0f - rmd)*sum + rmd*sum2; + } + else { + sum *= ((float)(1 << n)/(float)((1 << (n+1)) - 1)); + return sum; + } + return sum; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c b/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c deleted file mode 100644 index 12f117995bc..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_tex_clouds.c +++ /dev/null @@ -1,123 +0,0 @@ -/** - * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $ - * - * ***** 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 ***** - */ - -#include "../node_shader_util.h" -#include "node_shader_noise.h" - -static float clouds(int basis, int hard, int depth, float size, float vec[3], float color[3]) -{ - float p[3], pg[3], pb[3]; - - mul_v3_v3fl(p, vec, 1.0f/size); - - pg[0]= p[1]; - pg[1]= p[0]; - pg[2]= p[2]; - - pb[0]= p[1]; - pb[1]= p[2]; - pb[2]= p[0]; - - color[0]= noise_turbulence(p, basis, depth, hard); - color[1]= noise_turbulence(pg, basis, depth, hard); - color[2]= noise_turbulence(pb, basis, depth, hard); - - return color[0]; -} - -/* **************** CLOUDS ******************** */ - -static bNodeSocketTemplate sh_node_tex_clouds_in[]= { - { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { -1, 0, "" } -}; - -static bNodeSocketTemplate sh_node_tex_clouds_out[]= { - { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - -static void node_shader_init_tex_clouds(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) -{ - NodeTexClouds *tex = MEM_callocN(sizeof(NodeTexClouds), "NodeTexClouds"); - default_tex_mapping(&tex->base.tex_mapping); - default_color_mapping(&tex->base.color_mapping); - tex->basis = SHD_NOISE_PERLIN; - tex->hard = 0; - tex->depth = 2; - - node->storage = tex; -} - -static void node_shader_exec_tex_clouds(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - ShaderCallData *scd= (ShaderCallData*)data; - NodeTexClouds *tex= (NodeTexClouds*)node->storage; - bNodeSocket *vecsock = node->inputs.first; - float vec[3], size; - - if(vecsock->link) - nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - else - copy_v3_v3(vec, scd->co); - - nodestack_get_vec(&size, SOCK_FLOAT, in[1]); - - out[1]->vec[0]= clouds(tex->basis, tex->hard, tex->depth, size, vec, out[0]->vec); -} - -static int node_shader_gpu_tex_clouds(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) -{ - if(!in[0].link) - in[0].link = GPU_attribute(CD_ORCO, ""); - - node_shader_gpu_tex_mapping(mat, node, in, out); - - return GPU_stack_link(mat, "node_tex_clouds", in, out); -} - -/* node type definition */ -void register_node_type_sh_tex_clouds(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, SH_NODE_TEX_CLOUDS, "Clouds Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_tex_clouds_in, sh_node_tex_clouds_out); - node_type_size(&ntype, 150, 60, 200); - node_type_init(&ntype, node_shader_init_tex_clouds); - node_type_storage(&ntype, "NodeTexClouds", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, node_shader_exec_tex_clouds); - node_type_gpu(&ntype, node_shader_gpu_tex_clouds); - - nodeRegisterType(lb, &ntype); -}; - diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c b/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c deleted file mode 100644 index 56a87949fc7..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_tex_distnoise.c +++ /dev/null @@ -1,120 +0,0 @@ -/** - * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $ - * - * ***** 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 ***** - */ - -#include "../node_shader_util.h" -#include "node_shader_noise.h" - -static float distorted_noise(float vec[3], float size, int basis, int distortion_basis, float distortion) -{ - float p[3], r[3], p_offset[3], p_noffset[3]; - float offset[3] = {13.5f, 13.5f, 13.5f}; - - mul_v3_v3fl(p, vec, 1.0f/size); - add_v3_v3v3(p_offset, p, offset); - sub_v3_v3v3(p_noffset, p, offset); - - r[0] = noise_basis(p_offset, basis) * distortion; - r[1] = noise_basis(p, basis) * distortion; - r[2] = noise_basis(p_noffset, basis) * distortion; - - add_v3_v3(p, r); - - return noise_basis(p, distortion_basis); /* distorted-domain noise */ -} - -/* **************** OUTPUT ******************** */ - -static bNodeSocketTemplate sh_node_tex_distnoise_in[]= { - { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { SOCK_FLOAT, 1, "Size", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { SOCK_FLOAT, 1, "Distortion", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { -1, 0, "" } -}; - -static bNodeSocketTemplate sh_node_tex_distnoise_out[]= { - { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - -static void node_shader_init_tex_distorted_noise(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) -{ - NodeTexDistortedNoise *tex = MEM_callocN(sizeof(NodeTexDistortedNoise), "NodeTexDistortedNoise"); - default_tex_mapping(&tex->base.tex_mapping); - default_color_mapping(&tex->base.color_mapping); - tex->basis = SHD_NOISE_PERLIN; - tex->distortion_basis = SHD_NOISE_PERLIN; - - node->storage = tex; -} - -static void node_shader_exec_tex_distnoise(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - ShaderCallData *scd= (ShaderCallData*)data; - NodeTexDistortedNoise *tex= (NodeTexDistortedNoise*)node->storage; - bNodeSocket *vecsock = node->inputs.first; - float vec[3], size, distortion; - - if(vecsock->link) - nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - else - copy_v3_v3(vec, scd->co); - - nodestack_get_vec(&size, SOCK_FLOAT, in[1]); - nodestack_get_vec(&distortion, SOCK_FLOAT, in[2]); - - out[0]->vec[0]= distorted_noise(vec, size, tex->basis, tex->distortion_basis, distortion); -} - -static int node_shader_gpu_tex_distnoise(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) -{ - if(!in[0].link) - in[0].link = GPU_attribute(CD_ORCO, ""); - - node_shader_gpu_tex_mapping(mat, node, in, out); - - return GPU_stack_link(mat, "node_tex_distnoise", in, out); -} - -/* node type definition */ -void register_node_type_sh_tex_distnoise(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, SH_NODE_TEX_DISTNOISE, "Distorted Noise Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_tex_distnoise_in, sh_node_tex_distnoise_out); - node_type_size(&ntype, 150, 60, 200); - node_type_init(&ntype, node_shader_init_tex_distorted_noise); - node_type_storage(&ntype, "NodeTexDistortedNoise", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, node_shader_exec_tex_distnoise); - node_type_gpu(&ntype, node_shader_gpu_tex_distnoise); - - nodeRegisterType(lb, &ntype); -}; - diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_blend.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c index 50bafede2aa..71269ba85b6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_blend.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c @@ -17,7 +17,7 @@ * 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. + * The Original Code is Copyright (C) 2005 Gradienter Foundation. * All rights reserved. * * The Original Code is: all of this file. @@ -29,18 +29,12 @@ #include "../node_shader_util.h" -static float blend(float p[3], int type, int axis) +static float gradient(float p[3], int type) { float x, y; - if(axis == SHD_BLEND_VERTICAL) { - x= p[1]; - y= p[0]; - } - else { - x= p[0]; - y= p[1]; - } + x= p[0]; + y= p[1]; if(type == SHD_BLEND_LINEAR) { return (1.0f + x)/2.0f; @@ -75,65 +69,71 @@ static float blend(float p[3], int type, int axis) /* **************** BLEND ******************** */ -static bNodeSocketTemplate sh_node_tex_blend_in[]= { +static bNodeSocketTemplate sh_node_tex_gradient_in[]= { { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_blend_out[]= { +static bNodeSocketTemplate sh_node_tex_gradient_out[]= { + { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static void node_shader_init_tex_blend(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +static void node_shader_init_tex_gradient(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) { - NodeTexBlend *tex = MEM_callocN(sizeof(NodeTexBlend), "NodeTexBlend"); + NodeTexGradient *tex = MEM_callocN(sizeof(NodeTexGradient), "NodeTexGradient"); default_tex_mapping(&tex->base.tex_mapping); default_color_mapping(&tex->base.color_mapping); - tex->progression = SHD_BLEND_LINEAR; - tex->axis = SHD_BLEND_HORIZONTAL; + tex->gradient_type = SHD_BLEND_LINEAR; node->storage = tex; } -static void node_shader_exec_tex_blend(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +static void node_shader_exec_tex_gradient(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { ShaderCallData *scd= (ShaderCallData*)data; - NodeTexBlend *tex= (NodeTexBlend*)node->storage; + NodeTexGradient *tex= (NodeTexGradient*)node->storage; bNodeSocket *vecsock = node->inputs.first; - float vec[3]; + float vec[3], fac; if(vecsock->link) nodestack_get_vec(vec, SOCK_VECTOR, in[0]); else copy_v3_v3(vec, scd->co); - out[0]->vec[0]= blend(vec, tex->progression, tex->axis); + fac= gradient(vec, tex->gradient_type); + CLAMP(fac, 0.0f, 1.0f); + + out[0]->vec[0]= fac; + out[0]->vec[1]= fac; + out[0]->vec[2]= fac; + out[1]->vec[0]= fac; } -static int node_shader_gpu_tex_blend(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) +static int node_shader_gpu_tex_gradient(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) { if(!in[0].link) in[0].link = GPU_attribute(CD_ORCO, ""); node_shader_gpu_tex_mapping(mat, node, in, out); - return GPU_stack_link(mat, "node_tex_blend", in, out); + return GPU_stack_link(mat, "node_tex_gradient", in, out); } /* node type definition */ -void register_node_type_sh_tex_blend(ListBase *lb) +void register_node_type_sh_tex_gradient(ListBase *lb) { static bNodeType ntype; - node_type_base(&ntype, SH_NODE_TEX_BLEND, "Blend Texture", NODE_CLASS_TEXTURE, 0); + node_type_base(&ntype, SH_NODE_TEX_GRADIENT, "Gradient Texture", NODE_CLASS_TEXTURE, 0); node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_tex_blend_in, sh_node_tex_blend_out); + node_type_socket_templates(&ntype, sh_node_tex_gradient_in, sh_node_tex_gradient_out); node_type_size(&ntype, 150, 60, 200); - node_type_init(&ntype, node_shader_init_tex_blend); - node_type_storage(&ntype, "NodeTexBlend", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, node_shader_exec_tex_blend); - node_type_gpu(&ntype, node_shader_gpu_tex_blend); + node_type_init(&ntype, node_shader_init_tex_gradient); + node_type_storage(&ntype, "NodeTexGradient", node_free_standard_storage, node_copy_standard_storage); + node_type_exec(&ntype, node_shader_exec_tex_gradient); + node_type_gpu(&ntype, node_shader_gpu_tex_gradient); nodeRegisterType(lb, &ntype); }; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c index 8d0a2d3fb85..278f141f769 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c @@ -29,56 +29,54 @@ #include "../node_shader_util.h" -static void magic(float rgb[3], float p[3], int n, float turbulence) +static void magic(float rgb[3], float p[3], int n, float distortion) { - float turb = turbulence/5.0f; - float x = sinf((p[0] + p[1] + p[2])*5.0f); float y = cosf((-p[0] + p[1] - p[2])*5.0f); float z = -cosf((-p[0] - p[1] + p[2])*5.0f); if(n > 0) { - x *= turb; - y *= turb; - z *= turb; + x *= distortion; + y *= distortion; + z *= distortion; y = -cosf(x-y+z); - y *= turb; + y *= distortion; if(n > 1) { x= cosf(x-y-z); - x *= turb; + x *= distortion; if(n > 2) { z= sinf(-x-y-z); - z *= turb; + z *= distortion; if(n > 3) { x= -cosf(-x+y-z); - x *= turb; + x *= distortion; if(n > 4) { y= -sinf(-x+y+z); - y *= turb; + y *= distortion; if(n > 5) { y= -cosf(-x+y+z); - y *= turb; + y *= distortion; if(n > 6) { x= cosf(x+y+z); - x *= turb; + x *= distortion; if(n > 7) { z= sinf(x+y-z); - z *= turb; + z *= distortion; if(n > 8) { x= -cosf(-x-y+z); - x *= turb; + x *= distortion; if(n > 9) { y= -sinf(x-y+z); - y *= turb; + y *= distortion; } } } @@ -90,11 +88,11 @@ static void magic(float rgb[3], float p[3], int n, float turbulence) } } - if(turb != 0.0f) { - turb *= 2.0f; - x /= turb; - y /= turb; - z /= turb; + if(distortion != 0.0f) { + distortion *= 2.0f; + x /= distortion; + y /= distortion; + z /= distortion; } rgb[0]= 0.5f - x; @@ -106,12 +104,14 @@ static void magic(float rgb[3], float p[3], int n, float turbulence) static bNodeSocketTemplate sh_node_tex_magic_in[]= { { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { SOCK_FLOAT, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Distortion", 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { -1, 0, "" } }; static bNodeSocketTemplate sh_node_tex_magic_out[]= { { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; @@ -130,16 +130,17 @@ static void node_shader_exec_tex_magic(void *data, bNode *node, bNodeStack **in, ShaderCallData *scd= (ShaderCallData*)data; NodeTexMagic *tex= (NodeTexMagic*)node->storage; bNodeSocket *vecsock = node->inputs.first; - float vec[3], turbulence; + float vec[3], distortion; if(vecsock->link) nodestack_get_vec(vec, SOCK_VECTOR, in[0]); else copy_v3_v3(vec, scd->co); - nodestack_get_vec(&turbulence, SOCK_FLOAT, in[1]); + nodestack_get_vec(&distortion, SOCK_FLOAT, in[1]); - magic(out[0]->vec, vec, tex->depth, turbulence); + magic(out[0]->vec, vec, tex->depth, distortion); + out[1]->vec[0] = (out[0]->vec[0] + out[0]->vec[1] + out[0]->vec[2])*(1.0f/3.0f); } static int node_shader_gpu_tex_magic(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_marble.c b/source/blender/nodes/shader/nodes/node_shader_tex_marble.c deleted file mode 100644 index 3bb999659c9..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_tex_marble.c +++ /dev/null @@ -1,128 +0,0 @@ -/** - * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $ - * - * ***** 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 ***** - */ - -#include "../node_shader_util.h" -#include "node_shader_noise.h" - -static float marble(float vec[3], float size, int type, int wave, int basis, int hard, float turb, int depth) -{ - float p[3]; - float x = vec[0]; - float y = vec[1]; - float z = vec[2]; - float n = 5.0f * (x + y + z); - float mi; - - mul_v3_v3fl(p, vec, 1.0f/size); - - mi = n + turb * noise_turbulence(p, basis, depth, hard); - - mi = noise_wave(wave, mi); - - if(type == SHD_MARBLE_SHARP) - mi = sqrt(mi); - else if(type == SHD_MARBLE_SHARPER) - mi = sqrt(sqrt(mi)); - - return mi; -} - -/* **************** MARBLE ******************** */ - -static bNodeSocketTemplate sh_node_tex_marble_in[]= { - { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { SOCK_FLOAT, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { -1, 0, "" } -}; - -static bNodeSocketTemplate sh_node_tex_marble_out[]= { - { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - -static void node_shader_init_tex_marble(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) -{ - NodeTexMarble *tex = MEM_callocN(sizeof(NodeTexMarble), "NodeTexMarble"); - default_tex_mapping(&tex->base.tex_mapping); - default_color_mapping(&tex->base.color_mapping); - tex->type = SHD_MARBLE_SOFT; - tex->wave = SHD_WAVE_SINE; - tex->basis = SHD_NOISE_PERLIN; - tex->hard = 0; - tex->depth = 2; - - node->storage = tex; -} - -static void node_shader_exec_tex_marble(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - ShaderCallData *scd= (ShaderCallData*)data; - NodeTexMarble *tex= (NodeTexMarble*)node->storage; - bNodeSocket *vecsock = node->inputs.first; - float vec[3], size, turbulence; - - if(vecsock->link) - nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - else - copy_v3_v3(vec, scd->co); - - nodestack_get_vec(&size, SOCK_FLOAT, in[1]); - nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]); - - out[0]->vec[0]= marble(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence, tex->depth); -} - -static int node_shader_gpu_tex_marble(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) -{ - if(!in[0].link) - in[0].link = GPU_attribute(CD_ORCO, ""); - - node_shader_gpu_tex_mapping(mat, node, in, out); - - return GPU_stack_link(mat, "node_tex_marble", in, out); -} - -/* node type definition */ -void register_node_type_sh_tex_marble(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, SH_NODE_TEX_MARBLE, "Marble Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_tex_marble_in, sh_node_tex_marble_out); - node_type_size(&ntype, 150, 60, 200); - node_type_init(&ntype, node_shader_init_tex_marble); - node_type_storage(&ntype, "NodeTexMarble", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, node_shader_exec_tex_marble); - node_type_gpu(&ntype, node_shader_gpu_tex_marble); - - nodeRegisterType(lb, &ntype); -}; - diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c index 7cf33445a5d..cb5a8d7da0b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c @@ -34,12 +34,12 @@ * * H: fractal increment parameter * lacunarity: gap between successive frequencies - * octaves: number of frequencies in the fBm + * detail: number of frequencies in the fBm * * from "Texturing and Modelling: A procedural approach" */ -static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity, float octaves) +static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity, float detail) { float rmd; float value = 0.0f; @@ -47,13 +47,13 @@ static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity float pwHL = pow(lacunarity, -H); int i; - for(i = 0; i < (int)octaves; i++) { + for(i = 0; i < (int)detail; i++) { value += noise_basis(p, basis) * pwr; pwr *= pwHL; mul_v3_fl(p, lacunarity); } - rmd = octaves - floor(octaves); + rmd = detail - floor(detail); if(rmd != 0.0f) value += rmd * noise_basis(p, basis) * pwr; @@ -64,10 +64,10 @@ static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity * * H: highest fractal dimension * lacunarity: gap between successive frequencies - * octaves: number of frequencies in the fBm + * detail: number of frequencies in the fBm */ -static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves) +static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float lacunarity, float detail) { float rmd; float value = 1.0f; @@ -75,13 +75,13 @@ static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float float pwHL = pow(lacunarity, -H); int i; - for(i = 0; i < (int)octaves; i++) { + for(i = 0; i < (int)detail; i++) { value *= (pwr * noise_basis(p, basis) + 1.0f); pwr *= pwHL; mul_v3_fl(p, lacunarity); } - rmd = octaves - floor(octaves); + rmd = detail - floor(detail); if(rmd != 0.0f) value *= (rmd * pwr * noise_basis(p, basis) + 1.0f); /* correct? */ @@ -92,29 +92,29 @@ static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float * * H: fractal dimension of the roughest area * lacunarity: gap between successive frequencies - * octaves: number of frequencies in the fBm + * detail: number of frequencies in the fBm * offset: raises the terrain from `sea level' */ -static float noise_musgrave_hetero_terrain(float p[3], int basis, float H, float lacunarity, float octaves, float offset) +static float noise_musgrave_hetero_terrain(float p[3], int basis, float H, float lacunarity, float detail, float offset) { float value, increment, rmd; float pwHL = pow(lacunarity, -H); float pwr = pwHL; int i; - /* first unscaled octave of function; later octaves are scaled */ + /* first unscaled octave of function; later detail are scaled */ value = offset + noise_basis(p, basis); mul_v3_fl(p, lacunarity); - for(i = 1; i < (int)octaves; i++) { + for(i = 1; i < (int)detail; i++) { increment = (noise_basis(p, basis) + offset) * pwr * value; value += increment; pwr *= pwHL; mul_v3_fl(p, lacunarity); } - rmd = octaves - floor(octaves); + rmd = detail - floor(detail); if(rmd != 0.0f) { increment = (noise_basis(p, basis) + offset) * pwr * value; value += rmd * increment; @@ -127,11 +127,11 @@ static float noise_musgrave_hetero_terrain(float p[3], int basis, float H, float * * H: fractal dimension of the roughest area * lacunarity: gap between successive frequencies - * octaves: number of frequencies in the fBm + * detail: number of frequencies in the fBm * offset: raises the terrain from `sea level' */ -static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves, float offset, float gain) +static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H, float lacunarity, float detail, float offset, float gain) { float result, signal, weight, rmd; float pwHL = pow(lacunarity, -H); @@ -142,7 +142,7 @@ static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H, weight = gain * result; mul_v3_fl(p, lacunarity); - for(i = 1; (weight > 0.001f) && (i < (int)octaves); i++) { + for(i = 1; (weight > 0.001f) && (i < (int)detail); i++) { if(weight > 1.0f) weight = 1.0f; @@ -153,7 +153,7 @@ static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H, mul_v3_fl(p, lacunarity); } - rmd = octaves - floor(octaves); + rmd = detail - floor(detail); if(rmd != 0.0f) result += rmd * ((noise_basis(p, basis) + offset) * pwr); @@ -164,11 +164,11 @@ static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H, * * H: fractal dimension of the roughest area * lacunarity: gap between successive frequencies - * octaves: number of frequencies in the fBm + * detail: number of frequencies in the fBm * offset: raises the terrain from `sea level' */ -static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves, float offset, float gain) +static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H, float lacunarity, float detail, float offset, float gain) { float result, signal, weight; float pwHL = pow(lacunarity, -H); @@ -180,7 +180,7 @@ static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H, result = signal; weight = 1.0f; - for(i = 1; i < (int)octaves; i++) { + for(i = 1; i < (int)detail; i++) { mul_v3_fl(p, lacunarity); weight = CLAMPIS(signal * gain, 0.0f, 1.0f); signal = offset - fabsf(noise_basis(p, basis)); @@ -193,22 +193,23 @@ static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H, return result; } -static float musgrave(int type, int basis, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float size, float vec[3]) +static float musgrave(int type, float dimension, float lacunarity, float detail, float offset, float intensity, float gain, float scale, float vec[3]) { float p[3]; + int basis = SHD_NOISE_PERLIN; - mul_v3_v3fl(p, vec, 1.0f/size); + mul_v3_v3fl(p, vec, scale); if(type == SHD_MUSGRAVE_MULTIFRACTAL) - return intensity*noise_musgrave_multi_fractal(p, basis, dimension, lacunarity, octaves); + return intensity*noise_musgrave_multi_fractal(p, basis, dimension, lacunarity, detail); else if(type == SHD_MUSGRAVE_FBM) - return intensity*noise_musgrave_fBm(p, basis, dimension, lacunarity, octaves); + return intensity*noise_musgrave_fBm(p, basis, dimension, lacunarity, detail); else if(type == SHD_MUSGRAVE_HYBRID_MULTIFRACTAL) - return intensity*noise_musgrave_hybrid_multi_fractal(p, basis, dimension, lacunarity, octaves, offset, gain); + return intensity*noise_musgrave_hybrid_multi_fractal(p, basis, dimension, lacunarity, detail, offset, gain); else if(type == SHD_MUSGRAVE_RIDGED_MULTIFRACTAL) - return intensity*noise_musgrave_ridged_multi_fractal(p, basis, dimension, lacunarity, octaves, offset, gain); + return intensity*noise_musgrave_ridged_multi_fractal(p, basis, dimension, lacunarity, detail, offset, gain); else if(type == SHD_MUSGRAVE_HETERO_TERRAIN) - return intensity*noise_musgrave_hetero_terrain(p, basis, dimension, lacunarity, octaves, offset); + return intensity*noise_musgrave_hetero_terrain(p, basis, dimension, lacunarity, detail, offset); return 0.0f; } @@ -217,16 +218,17 @@ static float musgrave(int type, int basis, float dimension, float lacunarity, fl static bNodeSocketTemplate sh_node_tex_musgrave_in[]= { { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Detail", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f}, { SOCK_FLOAT, 1, "Dimension", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, { SOCK_FLOAT, 1, "Lacunarity", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { SOCK_FLOAT, 1, "Octaves", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { SOCK_FLOAT, 1, "Offset", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Offset", 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { SOCK_FLOAT, 1, "Gain", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, { -1, 0, "" } }; static bNodeSocketTemplate sh_node_tex_musgrave_out[]= { + { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; @@ -236,8 +238,7 @@ static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode* node, NodeTexMusgrave *tex = MEM_callocN(sizeof(NodeTexMusgrave), "NodeTexMusgrave"); default_tex_mapping(&tex->base.tex_mapping); default_color_mapping(&tex->base.color_mapping); - tex->type = SHD_MUSGRAVE_FBM; - tex->basis = SHD_NOISE_PERLIN; + tex->musgrave_type = SHD_MUSGRAVE_FBM; node->storage = tex; } @@ -247,21 +248,25 @@ static void node_shader_exec_tex_musgrave(void *data, bNode *node, bNodeStack ** ShaderCallData *scd= (ShaderCallData*)data; NodeTexMusgrave *tex= (NodeTexMusgrave*)node->storage; bNodeSocket *vecsock = node->inputs.first; - float vec[3], size, dimension, lacunarity, octaves, offset, gain; + float vec[3], fac, scale, dimension, lacunarity, detail, offset, gain; if(vecsock->link) nodestack_get_vec(vec, SOCK_VECTOR, in[0]); else copy_v3_v3(vec, scd->co); - nodestack_get_vec(&size, SOCK_FLOAT, in[1]); - nodestack_get_vec(&dimension, SOCK_FLOAT, in[2]); - nodestack_get_vec(&lacunarity, SOCK_FLOAT, in[3]); - nodestack_get_vec(&octaves, SOCK_FLOAT, in[4]); + nodestack_get_vec(&scale, SOCK_FLOAT, in[1]); + nodestack_get_vec(&detail, SOCK_FLOAT, in[2]); + nodestack_get_vec(&dimension, SOCK_FLOAT, in[3]); + nodestack_get_vec(&lacunarity, SOCK_FLOAT, in[4]); nodestack_get_vec(&offset, SOCK_FLOAT, in[5]); nodestack_get_vec(&gain, SOCK_FLOAT, in[6]); - out[0]->vec[0]= musgrave(tex->type, tex->basis, dimension, lacunarity, octaves, offset, 1.0f, gain, size, vec); + fac= musgrave(tex->musgrave_type, dimension, lacunarity, detail, offset, 1.0f, gain, scale, vec); + out[0]->vec[0]= fac; + out[0]->vec[1]= fac; + out[0]->vec[2]= fac; + out[1]->vec[0]= fac; } static int node_shader_gpu_tex_musgrave(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c index e8fb4737305..8cde640f8b2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c @@ -30,26 +30,49 @@ #include "../node_shader_util.h" #include "node_shader_noise.h" -static float noise_texture_value(float vec[3]) +static float noise_texture(float scale, float detail, float distortion, float vec[3], float color[3]) { - float p[3]; + float p[3], pg[3], pb[3]; + int basis= SHD_NOISE_PERLIN; - mul_v3_v3fl(p, vec, 1e8f); - return cellnoise(p); -} + mul_v3_v3fl(p, vec, scale); -static void noise_texture_color(float rgb[3], float vec[3]) -{ - float p[3]; + if(distortion != 0.0f) { + float r[3], p_offset[3], p_noffset[3]; + float offset[3] = {13.5f, 13.5f, 13.5f}; + + add_v3_v3v3(p_offset, p, offset); + sub_v3_v3v3(p_noffset, p, offset); + + r[0] = noise_basis(p_offset, basis) * distortion; + r[1] = noise_basis(p, basis) * distortion; + r[2] = noise_basis(p_noffset, basis) * distortion; + + add_v3_v3(p, r); + } - mul_v3_v3fl(p, vec, 1e8f); - cellnoise_color(rgb, p); + pg[0]= p[1]; + pg[1]= p[0]; + pg[2]= p[2]; + + pb[0]= p[1]; + pb[1]= p[2]; + pb[2]= p[0]; + + color[0]= noise_turbulence(p, basis, detail, 0); + color[1]= noise_turbulence(pg, basis, detail, 0); + color[2]= noise_turbulence(pb, basis, detail, 0); + + return color[0]; } /* **************** NOISE ******************** */ static bNodeSocketTemplate sh_node_tex_noise_in[]= { - { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Detail", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f}, + { SOCK_FLOAT, 1, "Distortion", 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { -1, 0, "" } }; @@ -72,15 +95,18 @@ static void node_shader_exec_tex_noise(void *data, bNode *node, bNodeStack **in, { ShaderCallData *scd= (ShaderCallData*)data; bNodeSocket *vecsock = node->inputs.first; - float vec[3]; + float vec[3], scale, detail, distortion; if(vecsock->link) nodestack_get_vec(vec, SOCK_VECTOR, in[0]); else copy_v3_v3(vec, scd->co); - noise_texture_color(out[0]->vec, vec); - out[1]->vec[0]= noise_texture_value(vec); + nodestack_get_vec(&scale, SOCK_FLOAT, in[1]); + nodestack_get_vec(&detail, SOCK_FLOAT, in[2]); + nodestack_get_vec(&distortion, SOCK_FLOAT, in[3]); + + out[1]->vec[0]= noise_texture(scale, detail, distortion, vec, out[0]->vec); } static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) @@ -103,7 +129,7 @@ void register_node_type_sh_tex_noise(ListBase *lb) node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out); node_type_size(&ntype, 150, 60, 200); node_type_init(&ntype, node_shader_init_tex_noise); - node_type_storage(&ntype, "", NULL, NULL); + node_type_storage(&ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage); node_type_exec(&ntype, node_shader_exec_tex_noise); node_type_gpu(&ntype, node_shader_gpu_tex_noise); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c b/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c deleted file mode 100644 index 3eb315052a9..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_tex_stucci.c +++ /dev/null @@ -1,123 +0,0 @@ -/** - * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $ - * - * ***** 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 ***** - */ - -#include "../node_shader_util.h" -#include "node_shader_noise.h" - -static float stucci(int type, int basis, int hard, float turbulence, float size, float vec[3]) -{ - float p[3], b2, ofs, r; - - mul_v3_v3fl(p, vec, 1.0f/size); - b2 = noise_basis_hard(p, basis, hard); - ofs = turbulence/200.0f; - - if(type != SHD_STUCCI_PLASTIC) - ofs *= b2*b2; - - p[2] += ofs; - r = noise_basis_hard(p, basis, hard); - - if(type == SHD_STUCCI_WALL_OUT) - r = 1.0f - r; - - return MAX2(r, 0.0f); -} - -/* **************** STUCCI ******************** */ - -static bNodeSocketTemplate sh_node_tex_stucci_in[]= { - { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { SOCK_FLOAT, 1, "Size", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { SOCK_FLOAT, 1, "Turbulence", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { -1, 0, "" } -}; - -static bNodeSocketTemplate sh_node_tex_stucci_out[]= { - { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - -static void node_shader_init_tex_stucci(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) -{ - NodeTexStucci *tex = MEM_callocN(sizeof(NodeTexStucci), "NodeTexStucci"); - default_tex_mapping(&tex->base.tex_mapping); - default_color_mapping(&tex->base.color_mapping); - tex->type = SHD_STUCCI_PLASTIC; - tex->basis = SHD_NOISE_PERLIN; - tex->hard = 0; - - node->storage = tex; -} - -static void node_shader_exec_tex_stucci(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - ShaderCallData *scd= (ShaderCallData*)data; - NodeTexStucci *tex= (NodeTexStucci*)node->storage; - bNodeSocket *vecsock = node->inputs.first; - float vec[3], size, turbulence; - - if(vecsock->link) - nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - else - copy_v3_v3(vec, scd->co); - - nodestack_get_vec(&size, SOCK_FLOAT, in[1]); - nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]); - - out[0]->vec[0]= stucci(tex->type, tex->basis, tex->hard, turbulence, size, vec); -} - -static int node_shader_gpu_tex_stucci(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) -{ - if(!in[0].link) - in[0].link = GPU_attribute(CD_ORCO, ""); - - node_shader_gpu_tex_mapping(mat, node, in, out); - - return GPU_stack_link(mat, "node_tex_stucci", in, out); -} - -/* node type definition */ -void register_node_type_sh_tex_stucci(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, SH_NODE_TEX_STUCCI, "Stucci Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_tex_stucci_in, sh_node_tex_stucci_out); - node_type_size(&ntype, 150, 60, 200); - node_type_init(&ntype, node_shader_init_tex_stucci); - node_type_storage(&ntype, "NodeTexStucci", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, node_shader_exec_tex_stucci); - node_type_gpu(&ntype, node_shader_gpu_tex_stucci); - - nodeRegisterType(lb, &ntype); -}; - diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c index ee8838ca1b3..4045a25de88 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c @@ -30,58 +30,25 @@ #include "../node_shader_util.h" #include "node_shader_noise.h" -static float voronoi_tex(int distance_metric, int coloring, - float weight1, float weight2, float weight3, float weight4, - float exponent, float intensity, float size, float vec[3], float color[3]) +static float voronoi_tex(int coloring, float scale, float vec[3], float color[3]) { - float aw1 = fabsf(weight1); - float aw2 = fabsf(weight2); - float aw3 = fabsf(weight3); - float aw4 = fabsf(weight4); - float sc = (aw1 + aw2 + aw3 + aw4); float da[4]; float pa[4][3]; float fac; float p[3]; - if(sc != 0.0f) - sc = intensity/sc; - /* compute distance and point coordinate of 4 nearest neighbours */ - mul_v3_v3fl(p, vec, 1.0f/size); - voronoi_generic(p, distance_metric, exponent, da, pa); - - /* Scalar output */ - fac = sc * fabsf(weight1*da[0] + weight2*da[1] + weight3*da[2] + weight4*da[3]); + mul_v3_v3fl(p, vec, scale); + voronoi_generic(p, SHD_VORONOI_DISTANCE_SQUARED, 1.0f, da, pa); - /* colored output */ + /* output */ if(coloring == SHD_VORONOI_INTENSITY) { + fac = fabsf(da[0]); color[0]= color[1]= color[2]= fac; } else { - float rgb1[3], rgb2[3], rgb3[3], rgb4[3]; - - cellnoise_color(rgb1, pa[0]); - cellnoise_color(rgb2, pa[1]); - cellnoise_color(rgb3, pa[2]); - cellnoise_color(rgb4, pa[3]); - - mul_v3_v3fl(color, rgb1, aw1); - madd_v3_v3fl(color, rgb2, aw2); - madd_v3_v3fl(color, rgb3, aw3); - madd_v3_v3fl(color, rgb4, aw4); - - if(coloring != SHD_VORONOI_POSITION) { - float t1 = MIN2((da[1] - da[0])*10.0f, 1.0f); - - if(coloring == SHD_VORONOI_POSITION_OUTLINE_INTENSITY) - mul_v3_fl(color, t1*fac); - else if(coloring == SHD_VORONOI_POSITION_OUTLINE) - mul_v3_fl(color, t1*sc); - } - else { - mul_v3_fl(color, sc); - } + cellnoise_color(color, pa[0]); + fac= (color[0] + color[1] + color[2])*(1.0f/3.0f); } return fac; @@ -91,12 +58,7 @@ static float voronoi_tex(int distance_metric, int coloring, static bNodeSocketTemplate sh_node_tex_voronoi_in[]= { { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { SOCK_FLOAT, 1, "Weight1", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, - { SOCK_FLOAT, 1, "Weight2", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, - { SOCK_FLOAT, 1, "Weight3", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, - { SOCK_FLOAT, 1, "Weight4", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, - { SOCK_FLOAT, 1, "Exponent", 2.5f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, + { SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { -1, 0, "" } }; @@ -111,7 +73,6 @@ static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode* node, NodeTexVoronoi *tex = MEM_callocN(sizeof(NodeTexVoronoi), "NodeTexVoronoi"); default_tex_mapping(&tex->base.tex_mapping); default_color_mapping(&tex->base.color_mapping); - tex->distance_metric = SHD_VORONOI_ACTUAL_DISTANCE; tex->coloring = SHD_VORONOI_INTENSITY; node->storage = tex; @@ -122,22 +83,16 @@ static void node_shader_exec_tex_voronoi(void *data, bNode *node, bNodeStack **i ShaderCallData *scd= (ShaderCallData*)data; NodeTexVoronoi *tex= (NodeTexVoronoi*)node->storage; bNodeSocket *vecsock = node->inputs.first; - float vec[3], size, w1, w2, w3, w4, exponent; + float vec[3], scale; if(vecsock->link) nodestack_get_vec(vec, SOCK_VECTOR, in[0]); else copy_v3_v3(vec, scd->co); - nodestack_get_vec(&size, SOCK_FLOAT, in[1]); - nodestack_get_vec(&w1, SOCK_FLOAT, in[2]); - nodestack_get_vec(&w2, SOCK_FLOAT, in[3]); - nodestack_get_vec(&w3, SOCK_FLOAT, in[4]); - nodestack_get_vec(&w4, SOCK_FLOAT, in[5]); - nodestack_get_vec(&exponent, SOCK_FLOAT, in[6]); + nodestack_get_vec(&scale, SOCK_FLOAT, in[1]); - out[1]->vec[0]= voronoi_tex(tex->distance_metric, tex->coloring, w1, w2, w3, w4, - exponent, 1.0f, size, vec, out[0]->vec); + out[1]->vec[0]= voronoi_tex(tex->coloring, scale, vec, out[0]->vec); } static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c new file mode 100644 index 00000000000..a911f615b79 --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c @@ -0,0 +1,129 @@ +/** + * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $ + * + * ***** 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 ***** + */ + +#include "../node_shader_util.h" +#include "node_shader_noise.h" + +static float wave(float vec[3], float scale, int type, float distortion, float detail) +{ + float p[3], w, n; + + mul_v3_v3fl(p, vec, scale); + + if(type == SHD_WAVE_BANDS) + n= (p[0] + p[1] + p[2])*10.0f; + else /* if(type == SHD_WAVE_RINGS) */ + n= len_v3(p)*20.0f; + + w = noise_wave(SHD_WAVE_SINE, n); + + /* XXX size compare! */ + if(distortion != 0.0f) + w += distortion * noise_turbulence(p, SHD_NOISE_PERLIN, detail, 0); + + return w; +} + +/* **************** WAVE ******************** */ + +static bNodeSocketTemplate sh_node_tex_wave_in[]= { + { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Distortion", 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Detail", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f}, + { SOCK_FLOAT, 1, "Detail Scale", 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + { -1, 0, "" } +}; + +static bNodeSocketTemplate sh_node_tex_wave_out[]= { + { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) +{ + NodeTexWave *tex = MEM_callocN(sizeof(NodeTexWave), "NodeTexWave"); + default_tex_mapping(&tex->base.tex_mapping); + default_color_mapping(&tex->base.color_mapping); + tex->wave_type = SHD_WAVE_BANDS; + + node->storage = tex; +} + +static void node_shader_exec_tex_wave(void *data, bNode *node, bNodeStack **in, bNodeStack **out) +{ + ShaderCallData *scd= (ShaderCallData*)data; + NodeTexWave *tex= (NodeTexWave*)node->storage; + bNodeSocket *vecsock = node->inputs.first; + float vec[3], scale, detail, distortion, fac; + + if(vecsock->link) + nodestack_get_vec(vec, SOCK_VECTOR, in[0]); + else + copy_v3_v3(vec, scd->co); + + nodestack_get_vec(&scale, SOCK_FLOAT, in[1]); + nodestack_get_vec(&detail, SOCK_FLOAT, in[1]); + nodestack_get_vec(&distortion, SOCK_FLOAT, in[2]); + + fac= wave(vec, scale, tex->wave_type, distortion, detail); + out[0]->vec[0]= fac; + out[0]->vec[1]= fac; + out[0]->vec[2]= fac; + out[1]->vec[0]= fac; +} + +static int node_shader_gpu_tex_wave(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) +{ + if(!in[0].link) + in[0].link = GPU_attribute(CD_ORCO, ""); + + node_shader_gpu_tex_mapping(mat, node, in, out); + + return GPU_stack_link(mat, "node_tex_wave", in, out); +} + +/* node type definition */ +void register_node_type_sh_tex_wave(ListBase *lb) +{ + static bNodeType ntype; + + node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_tex_wave_in, sh_node_tex_wave_out); + node_type_size(&ntype, 150, 60, 200); + node_type_init(&ntype, node_shader_init_tex_wave); + node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage); + node_type_exec(&ntype, node_shader_exec_tex_wave); + node_type_gpu(&ntype, node_shader_gpu_tex_wave); + + nodeRegisterType(lb, &ntype); +} + diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wood.c b/source/blender/nodes/shader/nodes/node_shader_tex_wood.c deleted file mode 100644 index f1beb8e5d7d..00000000000 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wood.c +++ /dev/null @@ -1,130 +0,0 @@ -/** - * $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $ - * - * ***** 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 ***** - */ - -#include "../node_shader_util.h" -#include "node_shader_noise.h" - -static float wood(float p[3], float size, int type, int wave, int basis, unsigned int hard, float turb) -{ - float x = p[0]; - float y = p[1]; - float z = p[2]; - - if(type == SHD_WOOD_BANDS) { - return noise_wave(wave, (x + y + z)*10.0f); - } - else if(type == SHD_WOOD_RINGS) { - return noise_wave(wave, sqrt(x*x + y*y + z*z)*20.0f); - } - else if (type == SHD_WOOD_BAND_NOISE) { - float psize[3] = {p[0]/size, p[1]/size, p[2]/size}; - float wi = turb*noise_basis_hard(psize, basis, hard); - return noise_wave(wave, (x + y + z)*10.0f + wi); - } - else if (type == SHD_WOOD_RING_NOISE) { - float psize[3] = {p[0]/size, p[1]/size, p[2]/size}; - float wi = turb*noise_basis_hard(psize, basis, hard); - return noise_wave(wave, sqrt(x*x + y*y + z*z)*20.0f + wi); - } - - return 0.0f; -} - -/* **************** WOOD ******************** */ - -static bNodeSocketTemplate sh_node_tex_wood_in[]= { - { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { SOCK_FLOAT, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, - { -1, 0, "" } -}; - -static bNodeSocketTemplate sh_node_tex_wood_out[]= { - { SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } -}; - -static void node_shader_init_tex_wood(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp)) -{ - NodeTexWood *tex = MEM_callocN(sizeof(NodeTexWood), "NodeTexWood"); - default_tex_mapping(&tex->base.tex_mapping); - default_color_mapping(&tex->base.color_mapping); - tex->type = SHD_WOOD_BANDS; - tex->wave = SHD_WAVE_SINE; - tex->basis = SHD_NOISE_PERLIN; - tex->hard = 0; - - node->storage = tex; -} - -static void node_shader_exec_tex_wood(void *data, bNode *node, bNodeStack **in, bNodeStack **out) -{ - ShaderCallData *scd= (ShaderCallData*)data; - NodeTexWood *tex= (NodeTexWood*)node->storage; - bNodeSocket *vecsock = node->inputs.first; - float vec[3], size, turbulence; - - if(vecsock->link) - nodestack_get_vec(vec, SOCK_VECTOR, in[0]); - else - copy_v3_v3(vec, scd->co); - - nodestack_get_vec(&size, SOCK_FLOAT, in[1]); - nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]); - - out[0]->vec[0]= wood(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence); -} - -static int node_shader_gpu_tex_wood(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) -{ - if(!in[0].link) - in[0].link = GPU_attribute(CD_ORCO, ""); - - node_shader_gpu_tex_mapping(mat, node, in, out); - - return GPU_stack_link(mat, "node_tex_wood", in, out); -} - -/* node type definition */ -void register_node_type_sh_tex_wood(ListBase *lb) -{ - static bNodeType ntype; - - node_type_base(&ntype, SH_NODE_TEX_WOOD, "Wood Texture", NODE_CLASS_TEXTURE, 0); - node_type_compatibility(&ntype, NODE_NEW_SHADING); - node_type_socket_templates(&ntype, sh_node_tex_wood_in, sh_node_tex_wood_out); - node_type_size(&ntype, 150, 60, 200); - node_type_init(&ntype, node_shader_init_tex_wood); - node_type_storage(&ntype, "NodeTexWood", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, node_shader_exec_tex_wood); - node_type_gpu(&ntype, node_shader_gpu_tex_wood); - - nodeRegisterType(lb, &ntype); -}; - |