Cycles / OSL:

* More fixes for r41599, removed clouds and distorted noise textures and ported the Noise texture to OSL. 
ToDo: Color output is still commented, needs a closer look. 

* Some more fixes (comments, uninitialized variables)
This commit is contained in:
Thomas Dinges
2012-06-02 21:34:25 +00:00
parent 298d311bd6
commit 014105f35d
7 changed files with 39 additions and 104 deletions

View File

@@ -7,14 +7,12 @@ set(SRC_OSL
node_background.osl
node_bump.osl
node_camera.osl
node_clouds_texture.osl
node_convert_from_color.osl
node_convert_from_float.osl
node_convert_from_normal.osl
node_convert_from_point.osl
node_convert_from_vector.osl
node_diffuse_bsdf.osl
node_distorted_noise_texture.osl
node_emission.osl
node_environment_texture.osl
node_fresnel.osl

View File

@@ -1,42 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* 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"
/* Turbulence */
shader node_clouds_texture(
string Basis = "Perlin",
int Hard = 0,
int Depth = 2,
float Size = 0.25,
point Vector = P,
output float Fac = 0.0,
output color Color = color(0.0, 0.0, 0.0))
{
float size = nonzero(Size, 1e-5);
point p = Vector/size;
Fac = noise_turbulence(p, Basis, Depth, Hard);
Color[0] = Fac;
Color[1] = noise_turbulence(point(p[1], p[0], p[2]), Basis, Depth, Hard);
Color[2] = noise_turbulence(point(p[1], p[2], p[0]), Basis, Depth, Hard);
}

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* 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"
/* Distorted Noise (variable lacunarity noise) */
float noise_distorted(point p, string basis, string distortion_basis, float distortion)
{
point r;
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;
return noise_basis(p + r, distortion_basis); /* distorted-domain noise */
}
shader node_distorted_noise_texture(
string Basis = "Perlin",
string DistortionBasis = "Perlin",
float Distortion = 1.0,
float Size = 0.25,
point Vector = P,
output float Fac = 0.0)
{
float size = nonzero(Size, 1e-5);
Fac = noise_distorted(Vector/size, Basis, DistortionBasis, Distortion);
}

View File

@@ -19,18 +19,42 @@
#include "stdosl.h"
#include "node_texture.h"
shader node_noise_texture(
point Vector = P,
output color Color = color(0.0, 0.0, 0.0),
output float Fac = 0.0)
/* Noise */
float noise(point p, string basis, float distortion, float detail)
{
point p = Vector*1e8;
point r;
int hard = 0;
float fac = 0.0;
if(distortion != 0.0( {
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;
}
float r = cellnoise(p);
float g = cellnoise(point(p[1], p[0], p[2]));
float b = cellnoise(point(p[1], p[2], p[0]));
Fac = r;
Color = color(r, g, b);
fac = noise_turbulence(p, basis, detail, hard);
return fac;
/*
Color[0] = Fac;
Color[1] = noise_turbulence(point(p[1], p[0], p[2]), basis, detail, hard);
Color[2] = noise_turbulence(point(p[1], p[2], p[0]), basis, detail, hard);
*/
}
shader node_distorted_noise_texture(
string Basis = "Perlin",
float Distortion = 0.0,
float Scale = 5.0,
float Detail = 2.0,
point Vector = P,
output float Fac = 0.0)
{
float scale = nonzero(Scale, 1e-5);
Fac = noise(Vector*scale, Basis, Distortion, Detail);
}

View File

@@ -27,7 +27,8 @@ float wave(point p, float scale, string type, float detail, float distortion, fl
float y = p[1] * scale;
float z = p[2] * scale;
float result, n = 0.0;
float result = 0.0;
float n = 0.0;
if(type == "Bands") {
n = (x + y + z)*10.0);

View File

@@ -18,7 +18,7 @@
CCL_NAMESPACE_BEGIN
/* Clouds */
/* Noise */
__device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color)
{

View File

@@ -755,7 +755,7 @@ void WaveTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("Type", type);
compiler.add(this, "node_marble_texture");
compiler.add(this, "node_wave_texture");
}
/* Magic Texture */