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 result = 0.0;
|
|
|
|
float n = 0.0;
|
2012-06-02 19:14:14 +00:00
|
|
|
|
|
|
|
if(type == "Bands") {
|
2012-09-02 12:24:04 +00:00
|
|
|
n = (x + y + z)*10.0;
|
2012-06-02 19:14:14 +00:00
|
|
|
}
|
|
|
|
else if(type == "Rings") {
|
|
|
|
n = (sqrt(x*x + y*y + z*z)*20.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(distortion != 0.0) {
|
2012-09-02 16:06:18 +00:00
|
|
|
n = n +(distortion * noise_turbulence(p*dscale, "Perlin", detail, 0));
|
2012-06-02 19:14:14 +00:00
|
|
|
}
|
|
|
|
result = noise_wave("Sine", n);
|
|
|
|
|
|
|
|
return result;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-06-02 19:14:14 +00:00
|
|
|
shader node_wave_texture(
|
|
|
|
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,
|
|
|
|
output color Color = color (0.0, 0.0, 0.0))
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-09-04 16:47:00 +00:00
|
|
|
Fac = wave(Vector, Scale, Type, Detail, Distortion, DetailScale);
|
2012-09-04 16:00:12 +00:00
|
|
|
Color = color(Fac, Fac, Fac);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|