2
* Copyright 2011, Blender Foundation.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#include "node_texture.h"
24
shader node_voronoi_texture(
25
string DistanceMetric = "Actual Distance",
26
string Coloring = "Intensity",
32
float Intensity = 1.0,
35
output float Fac = 0.0,
36
output color Color = color(0.0, 0.0, 0.0))
38
float exponent = max(Exponent, 1e-5);
39
float size = nonzero(Size, 1e-5);
41
float aw1 = fabs(Weight1);
42
float aw2 = fabs(Weight2);
43
float aw3 = fabs(Weight3);
44
float aw4 = fabs(Weight4);
45
float sc = (aw1 + aw2 + aw3 + aw4);
50
/* compute distance and point coordinate of 4 nearest neighbours */
54
voronoi(Vector/size, DistanceMetric, exponent, da, pa);
57
Fac = sc * fabs(Weight1*da[0] + Weight2*da[1] + Weight3*da[2] + Weight4*da[3]);
60
if(Coloring == "Intensity") {
61
Color = color(Fac, Fac, Fac);
64
Color = aw1*cellnoise_color(pa[0]);
65
Color += aw2*cellnoise_color(pa[1]);
66
Color += aw3*cellnoise_color(pa[2]);
67
Color += aw4*cellnoise_color(pa[3]);
69
if(Coloring != "Position") {
70
float t1 = min((da[1] - da[0])*10.0, 1.0);
72
if(Coloring == "Position, Outline, and Intensity")
74
else if(Coloring == "Position and Outline")