2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2012-06-02 19:14:14 +00:00
|
|
|
* Copyright 2012, Blender Foundation.
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdosl.h"
|
|
|
|
#include "node_texture.h"
|
|
|
|
|
2012-06-02 19:14:14 +00:00
|
|
|
/* Wave */
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-06-02 19:14:14 +00:00
|
|
|
float wave(point p, float scale, string type, float detail, float distortion, float dscale)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-06-02 19:14:14 +00:00
|
|
|
float x = p[0] * scale;
|
|
|
|
float y = p[1] * scale;
|
|
|
|
float z = p[2] * scale;
|
|
|
|
|
2012-06-02 21:34:25 +00:00
|
|
|
float n = 0.0;
|
2012-06-02 19:14:14 +00:00
|
|
|
|
2012-10-17 01:47:37 +00:00
|
|
|
if (type == "Bands") {
|
|
|
|
n = (x + y + z) * 10.0;
|
2012-06-02 19:14:14 +00:00
|
|
|
}
|
2012-10-17 01:47:37 +00:00
|
|
|
else if (type == "Rings") {
|
|
|
|
n = (sqrt(x * x + y * y + z * z) * 20.0);
|
2012-06-02 19:14:14 +00:00
|
|
|
}
|
2012-10-17 01:47:37 +00:00
|
|
|
|
|
|
|
if (distortion != 0.0) {
|
|
|
|
n = n + (distortion * noise_turbulence(p * dscale, "Perlin", detail, 0));
|
2012-06-02 19:14:14 +00:00
|
|
|
}
|
2013-08-10 00:52:57 +00:00
|
|
|
return 0.5 + 0.5 * sin(n);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-06-02 19:14:14 +00:00
|
|
|
shader node_wave_texture(
|
2012-11-20 17:40:10 +00:00
|
|
|
int use_mapping = 0,
|
|
|
|
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
2012-06-02 19:14:14 +00:00
|
|
|
string Type = "Bands",
|
|
|
|
float Scale = 5.0,
|
2012-09-04 16:00:12 +00:00
|
|
|
float Distortion = 0.0,
|
|
|
|
float Detail = 2.0,
|
2012-09-04 16:47:00 +00:00
|
|
|
float DetailScale = 1.0,
|
2011-04-27 11:58:34 +00:00
|
|
|
point Vector = P,
|
2012-09-04 16:00:12 +00:00
|
|
|
output float Fac = 0.0,
|
2012-12-11 16:06:03 +00:00
|
|
|
output color Color = 0.0)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-11-20 17:40:10 +00:00
|
|
|
point p = Vector;
|
|
|
|
|
|
|
|
if (use_mapping)
|
|
|
|
p = transform(mapping, p);
|
|
|
|
|
|
|
|
Fac = wave(p, Scale, Type, Detail, Distortion, DetailScale);
|
2013-03-10 00:42:47 +00:00
|
|
|
Color = Fac;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|