2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdosl.h"
|
|
|
|
#include "node_texture.h"
|
|
|
|
|
2012-06-02 21:34:25 +00:00
|
|
|
/* Noise */
|
|
|
|
|
2012-09-04 23:34:08 +00:00
|
|
|
float noise(point p, string basis, float distortion, float detail, float fac, color Color)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-06-02 21:34:25 +00:00
|
|
|
point r;
|
|
|
|
int hard = 0;
|
2012-10-17 01:47:37 +00:00
|
|
|
|
|
|
|
if (distortion != 0.0) {
|
2012-06-02 21:34:25 +00:00
|
|
|
r[0] = noise_basis(p + point(13.5), basis) * distortion;
|
|
|
|
r[1] = noise_basis(p, basis) * distortion;
|
|
|
|
r[2] = noise_basis(p - point(13.5), basis) * distortion;
|
|
|
|
|
|
|
|
p += r;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-09-02 16:06:18 +00:00
|
|
|
fac = noise_turbulence(p, basis, detail, hard);
|
2012-06-02 21:34:25 +00:00
|
|
|
|
2012-09-04 23:34:08 +00:00
|
|
|
Color = color(fac, noise_turbulence(point(p[1], p[0], p[2]), basis, detail, hard),
|
|
|
|
noise_turbulence(point(p[1], p[2], p[0]), basis, detail, hard));
|
|
|
|
|
2012-06-02 21:34:25 +00:00
|
|
|
return fac;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-06-02 22:57:26 +00:00
|
|
|
shader node_noise_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 21:34:25 +00:00
|
|
|
float Distortion = 0.0,
|
|
|
|
float Scale = 5.0,
|
|
|
|
float Detail = 2.0,
|
|
|
|
point Vector = P,
|
2012-09-04 23:34:08 +00:00
|
|
|
output float Fac = 0.0,
|
2012-12-11 16:06:03 +00:00
|
|
|
output color Color = 0.0)
|
2012-06-02 21:34:25 +00:00
|
|
|
{
|
2012-11-20 17:40:10 +00:00
|
|
|
point p = Vector;
|
|
|
|
|
|
|
|
if (use_mapping)
|
|
|
|
p = transform(mapping, p);
|
|
|
|
|
2012-09-04 23:34:08 +00:00
|
|
|
string Basis = "Perlin";
|
2012-11-20 17:40:10 +00:00
|
|
|
Fac = noise(p * Scale, Basis, Distortion, Detail, Fac, Color);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|