Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c67
1 files changed, 11 insertions, 56 deletions
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)