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.
22
float ramp_lookup(color ramp[RAMP_TABLE_SIZE], float at, int component)
24
float f = clamp((at + 1.0)*0.5, 0.0, 1.0) * (RAMP_TABLE_SIZE - 1);
26
/* clamp int as well in case of NaN */
29
if (i >= RAMP_TABLE_SIZE) i = RAMP_TABLE_SIZE - 1;
30
float t = f - (float)i;
32
float result = ramp[i][component];
35
result = (1.0 - t) * result + t * ramp[i + 1][component];
37
return result*2.0 - 1.0;
40
shader node_vector_curves(
41
color ramp[RAMP_TABLE_SIZE] = {0.0},
43
vector VectorIn = vector(0.0, 0.0, 0.0),
45
output vector VectorOut = vector(0.0, 0.0, 0.0))
47
VectorOut[0] = ramp_lookup(ramp, VectorIn[0], 0);
48
VectorOut[1] = ramp_lookup(ramp, VectorIn[1], 1);
49
VectorOut[2] = ramp_lookup(ramp, VectorIn[2], 2);
51
VectorOut = mix(VectorIn, VectorOut, Fac);