Cycles: procedural texture nodes reorganization. This will break existing files

using them, but rather do it now that I have the chance still. Highlights:

* Wood and Marble merged into a single Wave texture
* Clouds + Distorted Noise merged into new Noise node
* Blend renamed to Gradient
* Stucci removed, was mostly useful for old bump
* Noise removed, will come back later, didn't actually work yet
* Depth setting is now Detail socket, which accepts float values
* Scale socket instead of Size socket

http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/Textures
This commit is contained in:
Brecht Van Lommel 2011-11-06 21:05:58 +00:00
parent 3bf96250cd
commit fb56dbc2af
42 changed files with 827 additions and 2242 deletions

@ -191,8 +191,8 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
node = new FresnelNode();
break;
}
case BL::ShaderNode::type_BLEND_WEIGHT: {
node = new BlendWeightNode();
case BL::ShaderNode::type_LAYER_WEIGHT: {
node = new LayerWeightNode();
break;
}
case BL::ShaderNode::type_ADD_SHADER: {
@ -316,26 +316,17 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
node = env;
break;
}
case BL::ShaderNode::type_TEX_NOISE: {
BL::ShaderNodeTexNoise b_noise_node(b_node);
NoiseTextureNode *noise = new NoiseTextureNode();
get_tex_mapping(&noise->tex_mapping, b_noise_node.texture_mapping());
node = noise;
break;
}
case BL::ShaderNode::type_TEX_BLEND: {
BL::ShaderNodeTexBlend b_blend_node(b_node);
BlendTextureNode *blend = new BlendTextureNode();
blend->progression = BlendTextureNode::progression_enum[(int)b_blend_node.progression()];
blend->axis = BlendTextureNode::axis_enum[(int)b_blend_node.axis()];
get_tex_mapping(&blend->tex_mapping, b_blend_node.texture_mapping());
node = blend;
case BL::ShaderNode::type_TEX_GRADIENT: {
BL::ShaderNodeTexGradient b_gradient_node(b_node);
GradientTextureNode *gradient = new GradientTextureNode();
gradient->type = GradientTextureNode::type_enum[(int)b_gradient_node.gradient_type()];
get_tex_mapping(&gradient->tex_mapping, b_gradient_node.texture_mapping());
node = gradient;
break;
}
case BL::ShaderNode::type_TEX_VORONOI: {
BL::ShaderNodeTexVoronoi b_voronoi_node(b_node);
VoronoiTextureNode *voronoi = new VoronoiTextureNode();
voronoi->distance_metric = VoronoiTextureNode::distance_metric_enum[(int)b_voronoi_node.distance_metric()];
voronoi->coloring = VoronoiTextureNode::coloring_enum[(int)b_voronoi_node.coloring()];
get_tex_mapping(&voronoi->tex_mapping, b_voronoi_node.texture_mapping());
node = voronoi;
@ -349,67 +340,29 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
node = magic;
break;
}
case BL::ShaderNode::type_TEX_MARBLE: {
BL::ShaderNodeTexMarble b_marble_node(b_node);
MarbleTextureNode *marble = new MarbleTextureNode();
marble->depth = b_marble_node.turbulence_depth();
marble->basis = MarbleTextureNode::basis_enum[(int)b_marble_node.noise_basis()];
marble->type = MarbleTextureNode::type_enum[(int)b_marble_node.marble_type()];
marble->wave = MarbleTextureNode::wave_enum[(int)b_marble_node.wave_type()];
marble->hard = b_marble_node.noise_type() == BL::ShaderNodeTexMarble::noise_type_HARD;
get_tex_mapping(&marble->tex_mapping, b_marble_node.texture_mapping());
node = marble;
case BL::ShaderNode::type_TEX_WAVE: {
BL::ShaderNodeTexWave b_wave_node(b_node);
WaveTextureNode *wave = new WaveTextureNode();
wave->type = WaveTextureNode::type_enum[(int)b_wave_node.wave_type()];
get_tex_mapping(&wave->tex_mapping, b_wave_node.texture_mapping());
node = wave;
break;
}
case BL::ShaderNode::type_TEX_CLOUDS: {
BL::ShaderNodeTexClouds b_clouds_node(b_node);
CloudsTextureNode *clouds = new CloudsTextureNode();
clouds->depth = b_clouds_node.turbulence_depth();
clouds->basis = CloudsTextureNode::basis_enum[(int)b_clouds_node.noise_basis()];
clouds->hard = b_clouds_node.noise_type() == BL::ShaderNodeTexClouds::noise_type_HARD;
get_tex_mapping(&clouds->tex_mapping, b_clouds_node.texture_mapping());
node = clouds;
break;
}
case BL::ShaderNode::type_TEX_WOOD: {
BL::ShaderNodeTexWood b_wood_node(b_node);
WoodTextureNode *wood = new WoodTextureNode();
wood->type = WoodTextureNode::type_enum[(int)b_wood_node.wood_type()];
wood->basis = WoodTextureNode::basis_enum[(int)b_wood_node.noise_basis()];
wood->hard = b_wood_node.noise_type() == BL::ShaderNodeTexWood::noise_type_HARD;
wood->wave = WoodTextureNode::wave_enum[(int)b_wood_node.wave_type()];
get_tex_mapping(&wood->tex_mapping, b_wood_node.texture_mapping());
node = wood;
case BL::ShaderNode::type_TEX_NOISE: {
BL::ShaderNodeTexNoise b_noise_node(b_node);
NoiseTextureNode *noise = new NoiseTextureNode();
get_tex_mapping(&noise->tex_mapping, b_noise_node.texture_mapping());
node = noise;
break;
}
case BL::ShaderNode::type_TEX_MUSGRAVE: {
BL::ShaderNodeTexMusgrave b_musgrave_node(b_node);
MusgraveTextureNode *musgrave = new MusgraveTextureNode();
musgrave->type = MusgraveTextureNode::type_enum[(int)b_musgrave_node.musgrave_type()];
musgrave->basis = MusgraveTextureNode::basis_enum[(int)b_musgrave_node.noise_basis()];
get_tex_mapping(&musgrave->tex_mapping, b_musgrave_node.texture_mapping());
node = musgrave;
break;
}
case BL::ShaderNode::type_TEX_STUCCI: {
BL::ShaderNodeTexStucci b_stucci_node(b_node);
StucciTextureNode *stucci = new StucciTextureNode();
stucci->type = StucciTextureNode::type_enum[(int)b_stucci_node.stucci_type()];
stucci->basis = StucciTextureNode::basis_enum[(int)b_stucci_node.noise_basis()];
stucci->hard = b_stucci_node.noise_type() == BL::ShaderNodeTexStucci::noise_type_HARD;
get_tex_mapping(&stucci->tex_mapping, b_stucci_node.texture_mapping());
node = stucci;
break;
}
case BL::ShaderNode::type_TEX_DISTORTED_NOISE: {
BL::ShaderNodeTexDistortedNoise b_distnoise_node(b_node);
DistortedNoiseTextureNode *distnoise = new DistortedNoiseTextureNode();
distnoise->basis = DistortedNoiseTextureNode::basis_enum[(int)b_distnoise_node.noise_basis()];
distnoise->distortion_basis = DistortedNoiseTextureNode::basis_enum[(int)b_distnoise_node.noise_distortion()];
get_tex_mapping(&distnoise->tex_mapping, b_distnoise_node.texture_mapping());
node = distnoise;
break;
}
case BL::ShaderNode::type_TEX_COORD: {
node = new TextureCoordinateNode();;
break;

@ -42,33 +42,29 @@ set(svm_headers
svm/emissive.h
svm/svm.h
svm/svm_attribute.h
svm/svm_blend.h
svm/svm_bsdf.h
svm/svm_closure.h
svm/svm_clouds.h
svm/svm_convert.h
svm/svm_displace.h
svm/svm_distorted_noise.h
svm/svm_fresnel.h
svm/svm_geometry.h
svm/svm_gradient.h
svm/svm_image.h
svm/svm_light_path.h
svm/svm_magic.h
svm/svm_mapping.h
svm/svm_marble.h
svm/svm_math.h
svm/svm_mix.h
svm/svm_musgrave.h
svm/svm_noise.h
svm/svm_noisetex.h
svm/svm_sky.h
svm/svm_stucci.h
svm/svm_tex_coord.h
svm/svm_texture.h
svm/svm_types.h
svm/svm_value.h
svm/svm_voronoi.h
svm/svm_wood.h
svm/svm_wave.h
svm/volume.h
)

@ -120,29 +120,25 @@ CCL_NAMESPACE_END
#include "svm_texture.h"
#include "svm_attribute.h"
#include "svm_blend.h"
#include "svm_gradient.h"
#include "svm_closure.h"
#include "svm_clouds.h"
#include "svm_noisetex.h"
#include "svm_convert.h"
#include "svm_displace.h"
#include "svm_distorted_noise.h"
#include "svm_fresnel.h"
#include "svm_geometry.h"
#include "svm_image.h"
#include "svm_light_path.h"
#include "svm_magic.h"
#include "svm_mapping.h"
#include "svm_marble.h"
#include "svm_wave.h"
#include "svm_math.h"
#include "svm_mix.h"
#include "svm_musgrave.h"
#include "svm_noisetex.h"
#include "svm_sky.h"
#include "svm_stucci.h"
#include "svm_tex_coord.h"
#include "svm_value.h"
#include "svm_voronoi.h"
#include "svm_wood.h"
CCL_NAMESPACE_BEGIN
@ -206,12 +202,6 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
offset = node.y;
break;
#ifdef __TEXTURES__
case NODE_TEX_NOISE_F:
svm_node_tex_noise_f(sd, stack, node.y, node.z);
break;
case NODE_TEX_NOISE_V:
svm_node_tex_noise_v(sd, stack, node.y, node.z);
break;
case NODE_TEX_IMAGE:
svm_node_tex_image(kg, sd, stack, node);
break;
@ -221,11 +211,11 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
case NODE_TEX_SKY:
svm_node_tex_sky(kg, sd, stack, node.y, node.z);
break;
case NODE_TEX_BLEND:
svm_node_tex_blend(sd, stack, node);
case NODE_TEX_GRADIENT:
svm_node_tex_gradient(sd, stack, node);
break;
case NODE_TEX_CLOUDS:
svm_node_tex_clouds(sd, stack, node);
case NODE_TEX_NOISE:
svm_node_tex_noise(kg, sd, stack, node, &offset);
break;
case NODE_TEX_VORONOI:
svm_node_tex_voronoi(kg, sd, stack, node, &offset);
@ -233,20 +223,11 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
case NODE_TEX_MUSGRAVE:
svm_node_tex_musgrave(kg, sd, stack, node, &offset);
break;
case NODE_TEX_MARBLE:
svm_node_tex_marble(kg, sd, stack, node, &offset);
case NODE_TEX_WAVE:
svm_node_tex_wave(kg, sd, stack, node, &offset);
break;
case NODE_TEX_MAGIC:
svm_node_tex_magic(sd, stack, node);
break;
case NODE_TEX_STUCCI:
svm_node_tex_stucci(kg, sd, stack, node, &offset);
break;
case NODE_TEX_DISTORTED_NOISE:
svm_node_tex_distorted_noise(kg, sd, stack, node, &offset);
break;
case NODE_TEX_WOOD:
svm_node_tex_wood(kg, sd, stack, node, &offset);
svm_node_tex_magic(kg, sd, stack, node, &offset);
break;
#endif
case NODE_GEOMETRY:
@ -285,8 +266,8 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
case NODE_FRESNEL:
svm_node_fresnel(sd, stack, node.y, node.z, node.w);
break;
case NODE_BLEND_WEIGHT:
svm_node_blend_weight(sd, stack, node);
case NODE_LAYER_WEIGHT:
svm_node_layer_weight(sd, stack, node);
break;
case NODE_SET_DISPLACEMENT:
svm_node_set_displacement(sd, stack, node.y);

@ -1,55 +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.
*/
CCL_NAMESPACE_BEGIN
/* Clouds */
__device_inline void svm_clouds(NodeNoiseBasis basis, int hard, int depth, float size, float3 p, float *fac, float3 *color)
{
p /= size;
*fac = noise_turbulence(p, basis, depth, hard);
*color = make_float3(*fac,
noise_turbulence(make_float3(p.y, p.x, p.z), basis, depth, hard),
noise_turbulence(make_float3(p.y, p.z, p.x), basis, depth, hard));
}
__device void svm_node_tex_clouds(ShaderData *sd, float *stack, uint4 node)
{
uint basis, hard, depth;
uint size_offset, co_offset, fac_offset, color_offset;
decode_node_uchar4(node.y, &basis, &hard, &depth, NULL);
decode_node_uchar4(node.z, &size_offset, &co_offset, &fac_offset, &color_offset);
float3 co = stack_load_float3(stack, co_offset);
float size = stack_load_float_default(stack, size_offset, node.w);
size = nonzerof(size, 1e-5f);
float3 color;
float f;
svm_clouds((NodeNoiseBasis)basis, hard, depth, size, co, &f, &color);
if(stack_valid(fac_offset)) stack_store_float(stack, fac_offset, f);
if(stack_valid(color_offset)) stack_store_float3(stack, color_offset, color);
}
CCL_NAMESPACE_END

@ -1,59 +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.
*/
CCL_NAMESPACE_BEGIN
/* Distorted Noise (variable lacunarity noise) */
__device_noinline float svm_distorted_noise(float3 p, float size, NodeNoiseBasis basis, NodeNoiseBasis distortion_basis, float distortion)
{
float3 r;
float3 offset = make_float3(13.5f, 13.5f, 13.5f);
p /= size;
r.x = noise_basis(p + offset, basis) * distortion;
r.y = noise_basis(p, basis) * distortion;
r.z = noise_basis(p - offset, basis) * distortion;
return noise_basis(p + r, distortion_basis); /* distorted-domain noise */
}
__device void svm_node_tex_distorted_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint basis, distortion_basis;
uint size_offset, distortion_offset, co_offset, fac_offset;
decode_node_uchar4(node.y, &basis, &distortion_basis, NULL, NULL);
decode_node_uchar4(node.z, &size_offset, &distortion_offset, &co_offset, &fac_offset);
float3 co = stack_load_float3(stack, co_offset);
float size = stack_load_float_default(stack, size_offset, node2.x);
float distortion = stack_load_float_default(stack, distortion_offset, node2.y);
size = nonzerof(size, 1e-5f);
float f = svm_distorted_noise(co, size, (NodeNoiseBasis)basis,
(NodeNoiseBasis)distortion_basis, distortion);
stack_store_float(stack, fac_offset, f);
}
CCL_NAMESPACE_END

@ -33,7 +33,7 @@ __device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, ui
/* Blend Weight Node */
__device void svm_node_blend_weight(ShaderData *sd, float *stack, uint4 node)
__device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
{
uint blend_offset = node.y;
uint blend_value = node.z;
@ -44,7 +44,7 @@ __device void svm_node_blend_weight(ShaderData *sd, float *stack, uint4 node)
float f;
if(type == NODE_BLEND_WEIGHT_FRESNEL) {
if(type == NODE_LAYER_WEIGHT_FRESNEL) {
float eta = fmaxf(1.0f - blend, 1e-5f);
eta = (sd->flag & SD_BACKFACING)? eta: 1.0f/eta;

@ -18,36 +18,31 @@
CCL_NAMESPACE_BEGIN
/* Blend */
/* Gradient */
__device float svm_blend(float3 p, NodeBlendType type, NodeBlendAxis axis)
__device float svm_gradient(float3 p, NodeBlendType type)
{
float x, y;
float x, y, z;
if(axis == NODE_BLEND_VERTICAL) {
x= p.y;
y= p.x;
}
else {
x= p.x;
y= p.y;
}
x= p.x;
y= p.y;
z= p.z;
if(type == NODE_BLEND_LINEAR) {
return (1.0f + x)/2.0f;
return x;
}
else if(type == NODE_BLEND_QUADRATIC) {
float r = fmaxf((1.0f + x)/2.0f, 0.0f);
float r = fmaxf(x, 0.0f);
return r*r;
}
else if(type == NODE_BLEND_EASING) {
float r = fminf(fmaxf((1.0f + x)/2.0f, 0.0f), 1.0f);
float r = fminf(fmaxf(x, 0.0f), 1.0f);
float t = r*r;
return (3.0f*t - 2.0f*t*r);
}
else if(type == NODE_BLEND_DIAGONAL) {
return (2.0f + x + y)/4.0f;
return (x + y)/2.0f;
}
else if(type == NODE_BLEND_RADIAL) {
return atan2(y, x)/(2.0f*M_PI_F) + 0.5f;
@ -64,15 +59,21 @@ __device float svm_blend(float3 p, NodeBlendType type, NodeBlendAxis axis)
return 0.0f;
}
__device void svm_node_tex_blend(ShaderData *sd, float *stack, uint4 node)
__device void svm_node_tex_gradient(ShaderData *sd, float *stack, uint4 node)
{
float3 co = stack_load_float3(stack, node.z);
uint type, axis;
uint type, co_offset, color_offset, fac_offset;
decode_node_uchar4(node.y, &type, &axis, NULL, NULL);
decode_node_uchar4(node.y, &type, &co_offset, &fac_offset, &color_offset);
float f = svm_blend(co, (NodeBlendType)type, (NodeBlendAxis)axis);
stack_store_float(stack, node.w, f);
float3 co = stack_load_float3(stack, co_offset);
float f = svm_gradient(co, (NodeBlendType)type);
f = clamp(f, 0.0f, 1.0f);
if(stack_valid(fac_offset))
stack_store_float(stack, fac_offset, f);
if(stack_valid(color_offset))
stack_store_float3(stack, color_offset, make_float3(f, f, f));
}
CCL_NAMESPACE_END

@ -20,56 +20,54 @@ CCL_NAMESPACE_BEGIN
/* Magic */
__device_noinline float3 svm_magic(float3 p, int n, float turbulence)
__device_noinline float3 svm_magic(float3 p, int n, float distortion)
{
float turb = turbulence/5.0f;
float x = sinf((p.x + p.y + p.z)*5.0f);
float y = cosf((-p.x + p.y - p.z)*5.0f);
float z = -cosf((-p.x - p.y + p.z)*5.0f);
if(n > 0) {
x *= turb;
y *= turb;
z *= turb;
x *= distortion;
y *= distortion;
z *= distortion;
y = -cosf(x-y+z);
y *= turb;
y *= distortion;
if(n > 1) {
x= cosf(x-y-z);
x *= turb;
x *= distortion;
if(n > 2) {
z= sinf(-x-y-z);
z *= turb;
z *= distortion;
if(n > 3) {
x= -cosf(-x+y-z);
x *= turb;
x *= distortion;
if(n > 4) {
y= -sinf(-x+y+z);
y *= turb;
y *= distortion;
if(n > 5) {
y= -cosf(-x+y+z);
y *= turb;
y *= distortion;
if(n > 6) {
x= cosf(x+y+z);
x *= turb;
x *= distortion;
if(n > 7) {
z= sinf(x+y-z);
z *= turb;
z *= distortion;
if(n > 8) {
x= -cosf(-x-y+z);
x *= turb;
x *= distortion;
if(n > 9) {
y= -sinf(x-y+z);
y *= turb;
y *= distortion;
}
}
}
@ -81,27 +79,35 @@ __device_noinline float3 svm_magic(float3 p, int n, float turbulence)
}
}
if(turb != 0.0f) {
turb *= 2.0f;
x /= turb;
y /= turb;
z /= turb;
if(distortion != 0.0f) {
distortion *= 2.0f;
x /= distortion;
y /= distortion;
z /= distortion;
}
return make_float3(0.5f - x, 0.5f - y, 0.5f - z);
}
__device void svm_node_tex_magic(ShaderData *sd, float *stack, uint4 node)
__device void svm_node_tex_magic(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint depth, turbulence_offset, co_offset, color_offset;
uint depth;
uint scale_offset, distortion_offset, co_offset, fac_offset, color_offset;
decode_node_uchar4(node.y, &depth, &turbulence_offset, &co_offset, &color_offset);
decode_node_uchar4(node.y, &depth, &color_offset, &fac_offset, NULL);
decode_node_uchar4(node.z, &co_offset, &scale_offset, &distortion_offset, NULL);
uint4 node2 = read_node(kg, offset);
float3 co = stack_load_float3(stack, co_offset);
float turbulence = stack_load_float_default(stack, turbulence_offset, node.z);
float scale = stack_load_float_default(stack, scale_offset, node2.x);
float distortion = stack_load_float_default(stack, distortion_offset, node2.y);
float3 color = svm_magic(co, depth, turbulence);
stack_store_float3(stack, color_offset, color);
float3 color = svm_magic(co*scale, depth, distortion);
if(stack_valid(fac_offset))
stack_store_float(stack, fac_offset, average(color));
if(stack_valid(color_offset))
stack_store_float3(stack, color_offset, color);
}
CCL_NAMESPACE_END

@ -1,67 +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.
*/
CCL_NAMESPACE_BEGIN
/* Marble */
__device_noinline float svm_marble(float3 p, float size, NodeMarbleType type, NodeWaveType wave, NodeNoiseBasis basis, int hard, float turb, int depth)
{
float x = p.x;
float y = p.y;
float z = p.z;
float n = 5.0f * (x + y + z);
float mi = n + turb * noise_turbulence(p/size, basis, depth, hard);
mi = noise_wave(wave, mi);
if(type == NODE_MARBLE_SHARP)
mi = sqrt(mi);
else if(type == NODE_MARBLE_SHARPER)
mi = sqrt(sqrt(mi));
return mi;
}
__device void svm_node_tex_marble(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint type, wave, basis, hard;
uint depth;
uint size_offset, turbulence_offset, co_offset, fac_offset;
decode_node_uchar4(node.y, &type, &wave, &basis, &hard);
decode_node_uchar4(node.z, &depth, NULL, NULL, NULL);
decode_node_uchar4(node.w, &size_offset, &turbulence_offset, &co_offset, &fac_offset);
float3 co = stack_load_float3(stack, co_offset);
float size = stack_load_float_default(stack, size_offset, node2.x);
float turbulence = stack_load_float_default(stack, turbulence_offset, node2.y);
size = nonzerof(size, 1e-5f);
float f = svm_marble(co, size, (NodeMarbleType)type, (NodeWaveType)wave,
(NodeNoiseBasis)basis, hard, turbulence, depth);
stack_store_float(stack, fac_offset, f);
}
CCL_NAMESPACE_END

@ -36,14 +36,14 @@ __device_noinline float noise_musgrave_fBm(float3 p, NodeNoiseBasis basis, float
int i;
for(i = 0; i < (int)octaves; i++) {
value += noise_basis(p, basis) * pwr;
value += snoise(p) * pwr;
pwr *= pwHL;
p *= lacunarity;
}
rmd = octaves - floor(octaves);
if(rmd != 0.0f)
value += rmd * noise_basis(p, basis) * pwr;
value += rmd * snoise(p) * pwr;
return value;
}
@ -64,14 +64,14 @@ __device_noinline float noise_musgrave_multi_fractal(float3 p, NodeNoiseBasis ba
int i;
for(i = 0; i < (int)octaves; i++) {
value *= (pwr * noise_basis(p, basis) + 1.0f);
value *= (pwr * snoise(p) + 1.0f);
pwr *= pwHL;
p *= lacunarity;
}
rmd = octaves - floor(octaves);
if(rmd != 0.0f)
value *= (rmd * pwr * noise_basis(p, basis) + 1.0f); /* correct? */
value *= (rmd * pwr * snoise(p) + 1.0f); /* correct? */
return value;
}
@ -92,11 +92,11 @@ __device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis b
int i;
/* first unscaled octave of function; later octaves are scaled */
value = offset + noise_basis(p, basis);
value = offset + snoise(p);
p *= lacunarity;
for(i = 1; i < (int)octaves; i++) {
increment = (noise_basis(p, basis) + offset) * pwr * value;
increment = (snoise(p) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
p *= lacunarity;
@ -104,7 +104,7 @@ __device_noinline float noise_musgrave_hetero_terrain(float3 p, NodeNoiseBasis b
rmd = octaves - floor(octaves);
if(rmd != 0.0f) {
increment = (noise_basis(p, basis) + offset) * pwr * value;
increment = (snoise(p) + offset) * pwr * value;
value += rmd * increment;
}
@ -126,7 +126,7 @@ __device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseB
float pwr = pwHL;
int i;
result = noise_basis(p, basis) + offset;
result = snoise(p) + offset;
weight = gain * result;
p *= lacunarity;
@ -134,7 +134,7 @@ __device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseB
if(weight > 1.0f)
weight = 1.0f;
signal = (noise_basis(p, basis) + offset) * pwr;
signal = (snoise(p) + offset) * pwr;
pwr *= pwHL;
result += weight * signal;
weight *= gain * signal;
@ -143,7 +143,7 @@ __device_noinline float noise_musgrave_hybrid_multi_fractal(float3 p, NodeNoiseB
rmd = octaves - floor(octaves);
if(rmd != 0.0f)
result += rmd * ((noise_basis(p, basis) + offset) * pwr);
result += rmd * ((snoise(p) + offset) * pwr);
return result;
}
@ -163,7 +163,7 @@ __device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseB
float pwr = pwHL;
int i;
signal = offset - fabsf(noise_basis(p, basis));
signal = offset - fabsf(snoise(p));
signal *= signal;
result = signal;
weight = 1.0f;
@ -171,7 +171,7 @@ __device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseB
for(i = 1; i < (int)octaves; i++) {
p *= lacunarity;
weight = clamp(signal * gain, 0.0f, 1.0f);
signal = offset - fabsf(noise_basis(p, basis));
signal = offset - fabsf(snoise(p));
signal *= signal;
signal *= weight;
result += signal * pwr;
@ -183,9 +183,10 @@ __device_noinline float noise_musgrave_ridged_multi_fractal(float3 p, NodeNoiseB
/* Shader */
__device float svm_musgrave(NodeMusgraveType type, NodeNoiseBasis basis, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float size, float3 p)
__device float svm_musgrave(NodeMusgraveType type, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float scale, float3 p)
{
p /= size;
NodeNoiseBasis basis = NODE_NOISE_PERLIN;
p *= scale;
if(type == NODE_MUSGRAVE_MULTIFRACTAL)
return intensity*noise_musgrave_multi_fractal(p, basis, dimension, lacunarity, octaves);
@ -206,31 +207,33 @@ __device void svm_node_tex_musgrave(KernelGlobals *kg, ShaderData *sd, float *st
uint4 node2 = read_node(kg, offset);
uint4 node3 = read_node(kg, offset);
uint type, basis, co_offset, fac_offset;
uint dimension_offset, lacunarity_offset, octaves_offset, offset_offset;
uint gain_offset, size_offset;
uint type, co_offset, color_offset, fac_offset;
uint dimension_offset, lacunarity_offset, detail_offset, offset_offset;
uint gain_offset, scale_offset;
decode_node_uchar4(node.y, &type, &basis, &co_offset, &fac_offset);
decode_node_uchar4(node.z, &dimension_offset, &lacunarity_offset, &octaves_offset, &offset_offset);
decode_node_uchar4(node.z, &gain_offset, &size_offset, NULL, NULL);
decode_node_uchar4(node.y, &type, &co_offset, &color_offset, &fac_offset);
decode_node_uchar4(node.z, &dimension_offset, &lacunarity_offset, &detail_offset, &offset_offset);
decode_node_uchar4(node.z, &gain_offset, &scale_offset, NULL, NULL);
float3 co = stack_load_float3(stack, co_offset);
float dimension = stack_load_float_default(stack, dimension_offset, node2.x);
float lacunarity = stack_load_float_default(stack, lacunarity_offset, node2.y);
float octaves = stack_load_float_default(stack, octaves_offset, node2.z);
float detail = stack_load_float_default(stack, detail_offset, node2.z);
float foffset = stack_load_float_default(stack, offset_offset, node2.w);
float gain = stack_load_float_default(stack, gain_offset, node3.x);
float size = stack_load_float_default(stack, size_offset, node3.y);
float scale = stack_load_float_default(stack, scale_offset, node3.y);
dimension = fmaxf(dimension, 0.0f);
octaves = fmaxf(octaves, 0.0f);
dimension = fmaxf(dimension, 1e-5f);
detail = clamp(detail, 0.0f, 16.0f);
lacunarity = fmaxf(lacunarity, 1e-5f);
size = nonzerof(size, 1e-5f);
float f = svm_musgrave((NodeMusgraveType)type, (NodeNoiseBasis)basis,
dimension, lacunarity, octaves, foffset, 1.0f, gain, size, co);
float f = svm_musgrave((NodeMusgraveType)type,
dimension, lacunarity, detail, foffset, 1.0f, gain, scale, co);
stack_store_float(stack, fac_offset, f);
if(stack_valid(fac_offset))
stack_store_float(stack, fac_offset, f);
if(stack_valid(color_offset))
stack_store_float3(stack, color_offset, make_float3(f, f, f));
}
CCL_NAMESPACE_END

@ -18,30 +18,55 @@
CCL_NAMESPACE_BEGIN
__device float svm_noise_texture_value(float3 p)
/* Clouds */
__device_inline void svm_noise(float3 p, float scale, float detail, float distortion, float *fac, float3 *color)
{
return cellnoise(p*1e8f);
NodeNoiseBasis basis = NODE_NOISE_PERLIN;
int hard = 0;
p *= scale;
if(distortion != 0.0f) {
float3 r, offset = make_float3(13.5f, 13.5f, 13.5f);
r.x = noise_basis(p + offset, basis) * distortion;
r.y = noise_basis(p, basis) * distortion;
r.z = noise_basis(p - offset, basis) * distortion;
p += r;
}
*fac = noise_turbulence(p, basis, detail, hard);
*color = make_float3(*fac,
noise_turbulence(make_float3(p.y, p.x, p.z), basis, detail, hard),
noise_turbulence(make_float3(p.y, p.z, p.x), basis, detail, hard));
}
__device float3 svm_noise_texture_color(float3 p)
__device void svm_node_tex_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
return cellnoise_color(p*1e8f);
}
uint co_offset, scale_offset, detail_offset, distortion_offset, fac_offset, color_offset;
__device void svm_node_tex_noise_f(ShaderData *sd, float *stack, uint co_offset, uint out_offset)
{
decode_node_uchar4(node.y, &co_offset, &scale_offset, &detail_offset, &distortion_offset);
uint4 node2 = read_node(kg, offset);
float scale = stack_load_float_default(stack, scale_offset, node2.x);
float detail = stack_load_float_default(stack, detail_offset, node2.y);
float distortion = stack_load_float_default(stack, distortion_offset, node2.z);
float3 co = stack_load_float3(stack, co_offset);
float f = svm_noise_texture_value(co);
stack_store_float(stack, out_offset, f);
}
float3 color;
float f;
__device void svm_node_tex_noise_v(ShaderData *sd, float *stack, uint co_offset, uint out_offset)
{
float3 co = stack_load_float3(stack, co_offset);
float3 f = svm_noise_texture_color(co);
svm_noise(co, scale, detail, distortion, &f, &color);
stack_store_float3(stack, out_offset, f);
decode_node_uchar4(node.z, &color_offset, &fac_offset, NULL, NULL);
if(stack_valid(fac_offset))
stack_store_float(stack, fac_offset, f);
if(stack_valid(color_offset))
stack_store_float3(stack, color_offset, color);
}
CCL_NAMESPACE_END

@ -1,63 +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.
*/
CCL_NAMESPACE_BEGIN
/* Stucci */
__device_noinline float svm_stucci(NodeStucciType type, NodeNoiseBasis basis, int hard, float turbulence, float size, float3 p)
{
p /= size;
float b2 = noise_basis_hard(p, basis, hard);
float ofs = turbulence/200.0f;
if(type != NODE_STUCCI_PLASTIC)
ofs *= b2*b2;
float r = noise_basis_hard(make_float3(p.x, p.y, p.z+ofs), basis, hard);
if(type == NODE_STUCCI_WALL_OUT)
r = 1.0f - r;
return fmaxf(r, 0.0f);
}
__device void svm_node_tex_stucci(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint type, basis, hard;
uint size_offset, turbulence_offset, co_offset, fac_offset;
decode_node_uchar4(node.y, &type, &basis, &hard, NULL);
decode_node_uchar4(node.z, &size_offset, &turbulence_offset, &co_offset, &fac_offset);
float3 co = stack_load_float3(stack, co_offset);
float size = stack_load_float_default(stack, size_offset, node2.x);
float turbulence = stack_load_float_default(stack, turbulence_offset, node2.y);
size = nonzerof(size, 1e-5f);
float f = svm_stucci((NodeStucciType)type, (NodeNoiseBasis)basis, hard,
turbulence, size, co);
stack_store_float(stack, fac_offset, f);
}
CCL_NAMESPACE_END

@ -213,14 +213,17 @@ __device float noise_wave(NodeWaveType wave, float a)
/* Turbulence */
__device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, int octaves, int hard)
__device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float octaves, int hard)
{
float fscale = 1.0f;
float amp = 1.0f;
float sum = 0.0f;
int i;
int i, n;
for(i = 0; i <= octaves; i++) {
octaves = clamp(octaves, 0.0f, 16.0f);
n= (int)octaves;
for(i = 0; i <= n; i++) {
float t = noise_basis(fscale*p, basis);
if(hard)
@ -231,9 +234,25 @@ __device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, int oct
fscale *= 2.0f;
}
sum *= ((float)(1 << octaves)/(float)((1 << (octaves+1)) - 1));
float rmd = octaves - floor(octaves);
return sum;
if(rmd != 0.0f) {
float t = noise_basis(fscale*p, basis);
if(hard)
t = fabsf(2.0f*t - 1.0f);
float sum2 = sum + t*amp;
sum *= ((float)(1 << n)/(float)((1 << (n+1)) - 1));
sum2 *= ((float)(1 << (n+1))/(float)((1 << (n+2)) - 1));
return (1.0f - rmd)*sum + rmd*sum2;
}
else {
sum *= ((float)(1 << n)/(float)((1 << (n+1)) - 1));
return sum;
}
}
CCL_NAMESPACE_END

@ -44,8 +44,6 @@ typedef enum NodeType {
NODE_CLOSURE_WEIGHT = 500,
NODE_MIX_CLOSURE = 600,
NODE_JUMP = 700,
NODE_TEX_NOISE_F = 800,
NODE_TEX_NOISE_V = 900,
NODE_TEX_IMAGE = 1000,
NODE_TEX_SKY = 1100,
NODE_GEOMETRY = 1200,
@ -57,15 +55,12 @@ typedef enum NodeType {
NODE_CONVERT = 1900,
NODE_FRESNEL = 2000,
NODE_EMISSION_WEIGHT = 2100,
NODE_TEX_BLEND = 2200,
NODE_TEX_GRADIENT = 2200,
NODE_TEX_VORONOI = 2300,
NODE_TEX_MUSGRAVE = 2400,
NODE_TEX_MARBLE = 2500,
NODE_TEX_WAVE = 2500,
NODE_TEX_MAGIC = 2600,
NODE_TEX_STUCCI = 2700,
NODE_TEX_DISTORTED_NOISE = 2800,
NODE_TEX_WOOD = 2900,
NODE_TEX_CLOUDS = 3000,
NODE_TEX_NOISE = 3000,
NODE_SHADER_JUMP = 3100,
NODE_SET_DISPLACEMENT = 3200,
NODE_GEOMETRY_BUMP_DX = 3300,
@ -83,7 +78,7 @@ typedef enum NodeType {
NODE_ATTR_BUMP_DY = 4500,
NODE_TEX_ENVIRONMENT = 4600,
NODE_CLOSURE_HOLDOUT = 4700,
NODE_BLEND_WEIGHT = 4800,
NODE_LAYER_WEIGHT = 4800,
NODE_CLOSURE_VOLUME = 4900
} NodeType;
@ -211,10 +206,8 @@ typedef enum NodeMusgraveType {
} NodeMusgraveType;
typedef enum NodeWoodType {
NODE_WOOD_BANDS,
NODE_WOOD_RINGS,
NODE_WOOD_BAND_NOISE,
NODE_WOOD_RING_NOISE
NODE_WAVE_BANDS,
NODE_WAVE_RINGS
} NodeWoodType;
typedef enum NodeBlendType {
@ -246,14 +239,12 @@ typedef enum NodeStucciType {
typedef enum NodeVoronoiColoring {
NODE_VORONOI_INTENSITY,
NODE_VORONOI_POSITION,
NODE_VORONOI_POSITION_OUTLINE,
NODE_VORONOI_POSITION_OUTLINE_INTENSITY
NODE_VORONOI_CELLS
} NodeVoronoiColoring;
typedef enum NodeBlendWeightType {
NODE_BLEND_WEIGHT_FRESNEL,
NODE_BLEND_WEIGHT_FACING
NODE_LAYER_WEIGHT_FRESNEL,
NODE_LAYER_WEIGHT_FACING
} NodeBlendWeightType;
typedef enum ShaderType {

@ -20,50 +20,25 @@ CCL_NAMESPACE_BEGIN
/* Voronoi */
__device_noinline float4 svm_voronoi(NodeDistanceMetric distance_metric, NodeVoronoiColoring coloring,
float weight1, float weight2, float weight3, float weight4,
float exponent, float intensity, float size, float3 p)
__device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale, float3 p)
{
float aw1 = fabsf(weight1);
float aw2 = fabsf(weight2);
float aw3 = fabsf(weight3);
float aw4 = fabsf(weight4);
float sc = (aw1 + aw2 + aw3 + aw4);
if(sc != 0.0f)
sc = intensity/sc;
/* compute distance and point coordinate of 4 nearest neighbours */
float da[4];
float3 pa[4];
voronoi(p/size, distance_metric, exponent, da, pa);
voronoi(p*scale, NODE_VORONOI_DISTANCE_SQUARED, 1.0f, da, pa);
/* Scalar output */
float fac = sc * fabsf(weight1*da[0] + weight2*da[1] + weight3*da[2] + weight4*da[3]);
/* output */
float fac;
float3 color;
/* colored output */
if(coloring == NODE_VORONOI_INTENSITY) {
fac = fabsf(da[0]);
color = make_float3(fac, fac, fac);
}
else {
color = aw1*cellnoise_color(pa[0]);
color += aw2*cellnoise_color(pa[1]);
color += aw3*cellnoise_color(pa[2]);
color += aw4*cellnoise_color(pa[3]);
if(coloring != NODE_VORONOI_POSITION) {
float t1 = min((da[1] - da[0])*10.0f, 1.0f);
if(coloring == NODE_VORONOI_POSITION_OUTLINE_INTENSITY)
color *= t1*fac;
else if(coloring == NODE_VORONOI_POSITION_OUTLINE)
color *= t1*sc;
}
else {
color *= sc;
}
color = cellnoise_color(pa[0]);
fac= average(color);
}
return make_float4(color.x, color.y, color.z, fac);
@ -71,31 +46,15 @@ __device_noinline float4 svm_voronoi(NodeDistanceMetric distance_metric, NodeVor
__device void svm_node_tex_voronoi(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint4 node3 = read_node(kg, offset);
uint coloring = node.y;
uint scale_offset, co_offset, fac_offset, color_offset;
uint distance_metric, coloring, exponent_offset;
uint size_offset, co_offset, fac_offset, color_offset;
uint weight1_offset, weight2_offset, weight3_offset, weight4_offset;
decode_node_uchar4(node.y, &distance_metric, &coloring, &exponent_offset, NULL);
decode_node_uchar4(node.z, &size_offset, &co_offset, &fac_offset, &color_offset);
decode_node_uchar4(node.w, &weight1_offset, &weight2_offset, &weight3_offset, &weight4_offset);
decode_node_uchar4(node.z, &scale_offset, &co_offset, &fac_offset, &color_offset);
float3 co = stack_load_float3(stack, co_offset);
float weight1 = stack_load_float_default(stack, weight1_offset, node2.x);
float weight2 = stack_load_float_default(stack, weight2_offset, node2.y);
float weight3 = stack_load_float_default(stack, weight3_offset, node2.z);
float weight4 = stack_load_float_default(stack, weight4_offset, node2.w);
float exponent = stack_load_float_default(stack, exponent_offset, node3.x);
float size = stack_load_float_default(stack, size_offset, node3.y);
float scale = stack_load_float_default(stack, scale_offset, node.w);
exponent = fmaxf(exponent, 1e-5f);
size = nonzerof(size, 1e-5f);
float4 result = svm_voronoi((NodeDistanceMetric)distance_metric,
(NodeVoronoiColoring)coloring,
weight1, weight2, weight3, weight4, exponent, 1.0f, size, co);
float4 result = svm_voronoi((NodeVoronoiColoring)coloring, scale, co);
float3 color = make_float3(result.x, result.y, result.z);
float f = result.w;

@ -0,0 +1,65 @@
/*
* 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.
*/
CCL_NAMESPACE_BEGIN
/* Marble */
__device_noinline float svm_wave(NodeWoodType type, float3 p, float scale, float detail, float distortion, float dscale)
{
float w, n;
p *= scale;
if(type == NODE_WAVE_BANDS)
n= (p.x + p.x + p.z)*10.0f;
else /* if(type == NODE_WAVE_RINGS) */
n= len(p)*20.0f;
if(distortion != 0.0f)
n += distortion * noise_turbulence(p*dscale, NODE_NOISE_PERLIN, detail, 0);
w = noise_wave(NODE_WAVE_SINE, n);
return w;
}
__device void svm_node_tex_wave(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint type;
uint co_offset, scale_offset, detail_offset, dscale_offset, distortion_offset, color_offset, fac_offset;
decode_node_uchar4(node.y, &type, &color_offset, &fac_offset, &dscale_offset);
decode_node_uchar4(node.z, &co_offset, &scale_offset, &detail_offset, &distortion_offset);
float3 co = stack_load_float3(stack, co_offset);
float scale = stack_load_float_default(stack, scale_offset, node2.x);
float detail = stack_load_float_default(stack, detail_offset, node2.y);
float distortion = stack_load_float_default(stack, distortion_offset, node2.z);
float dscale = stack_load_float_default(stack, dscale_offset, node2.w);
float f = svm_wave((NodeWoodType)type, co, scale, detail, distortion, dscale);
if(stack_valid(fac_offset)) stack_store_float(stack, fac_offset, f);
if(stack_valid(color_offset)) stack_store_float3(stack, color_offset, make_float3(f, f, f));
}
CCL_NAMESPACE_END

@ -1,69 +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.
*/
CCL_NAMESPACE_BEGIN
/* Wood */
__device_noinline float svm_wood(float3 p, float size, NodeWoodType type, NodeWaveType wave, NodeNoiseBasis basis, uint hard, float turb)
{
float x = p.x;
float y = p.y;
float z = p.z;
if(type == NODE_WOOD_BANDS) {
return noise_wave(wave, (x + y + z)*10.0f);
}
else if(type == NODE_WOOD_RINGS) {
return noise_wave(wave, sqrt(x*x + y*y + z*z)*20.0f);
}
else if (type == NODE_WOOD_BAND_NOISE) {
float wi = turb*noise_basis_hard(p/size, basis, hard);
return noise_wave(wave, (x + y + z)*10.0f + wi);
}
else if (type == NODE_WOOD_RING_NOISE) {
float wi = turb*noise_basis_hard(p/size, basis, hard);
return noise_wave(wave, sqrt(x*x + y*y + z*z)*20.0f + wi);
}
return 0.0f;
}
__device void svm_node_tex_wood(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
uint4 node2 = read_node(kg, offset);
uint type, wave, basis, hard;
uint co_offset, size_offset, turbulence_offset, fac_offset;
decode_node_uchar4(node.y, &type, &wave, &basis, &hard);
decode_node_uchar4(node.z, &co_offset, &size_offset, &turbulence_offset, &fac_offset);
float3 co = stack_load_float3(stack, co_offset);
float size = stack_load_float_default(stack, size_offset, node2.y);
float turbulence = stack_load_float_default(stack, turbulence_offset, node2.z);
size = nonzerof(size, 1e-5f);
float f = svm_wood(co, size, (NodeWoodType)type, (NodeWaveType)wave,
(NodeNoiseBasis)basis, hard, turbulence);
stack_store_float(stack, fac_offset, f);
}
CCL_NAMESPACE_END

@ -353,45 +353,9 @@ void SkyTextureNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_sky_texture");
}
/* Noise Texture */
/* Gradient Texture */
NoiseTextureNode::NoiseTextureNode()
: TextureNode("noise_texture")
{
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Color", SHADER_SOCKET_COLOR);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void NoiseTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *vector_in = input("Vector");
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
if(!color_out->links.empty() || !fac_out->links.empty())
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
if(!color_out->links.empty()) {
compiler.stack_assign(color_out);
compiler.add_node(NODE_TEX_NOISE_V, vector_in->stack_offset, color_out->stack_offset);
}
if(!fac_out->links.empty()) {
compiler.stack_assign(fac_out);
compiler.add_node(NODE_TEX_NOISE_F, vector_in->stack_offset, fac_out->stack_offset);
}
}
void NoiseTextureNode::compile(OSLCompiler& compiler)
{
compiler.add(this, "node_noise_texture");
}
/* Blend Texture */
static ShaderEnum blend_progression_init()
static ShaderEnum gradient_type_init()
{
ShaderEnum enm;
@ -406,160 +370,114 @@ static ShaderEnum blend_progression_init()
return enm;
}
static ShaderEnum blend_axis_init()
ShaderEnum GradientTextureNode::type_enum = gradient_type_init();
GradientTextureNode::GradientTextureNode()
: TextureNode("gradient_texture")
{
ShaderEnum enm;
enm.insert("Horizontal", NODE_BLEND_HORIZONTAL);
enm.insert("Vertical", NODE_BLEND_VERTICAL);
return enm;
}
ShaderEnum BlendTextureNode::progression_enum = blend_progression_init();
ShaderEnum BlendTextureNode::axis_enum = blend_axis_init();
BlendTextureNode::BlendTextureNode()
: TextureNode("blend_texture")
{
progression = ustring("Linear");
axis = ustring("Horizontal");
type = ustring("Linear");
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void BlendTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *vector_in = input("Vector");
ShaderOutput *fac_out = output("Fac");
if(vector_in->link) compiler.stack_assign(vector_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
compiler.stack_assign(fac_out);
compiler.add_node(NODE_TEX_BLEND,
compiler.encode_uchar4(progression_enum[progression], axis_enum[axis]),
vector_in->stack_offset, fac_out->stack_offset);
}
void BlendTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("Progression", progression);
compiler.parameter("Axis", axis);
compiler.add(this, "node_blend_texture");
}
/* Clouds Texture */
static ShaderEnum noise_basis_init()
{
ShaderEnum enm;
enm.insert("Perlin", NODE_NOISE_PERLIN);
enm.insert("Voronoi F1", NODE_NOISE_VORONOI_F1);
enm.insert("Voronoi F2", NODE_NOISE_VORONOI_F2);
enm.insert("Voronoi F3", NODE_NOISE_VORONOI_F3);
enm.insert("Voronoi F4", NODE_NOISE_VORONOI_F4);
enm.insert("Voronoi F2-F1", NODE_NOISE_VORONOI_F2_F1);
enm.insert("Voronoi Crackle", NODE_NOISE_VORONOI_CRACKLE);
enm.insert("Cell Noise", NODE_NOISE_CELL_NOISE);
return enm;
}
ShaderEnum CloudsTextureNode::basis_enum = noise_basis_init();
CloudsTextureNode::CloudsTextureNode()
: TextureNode("clouds_texture")
{
basis = ustring("Perlin");
hard = false;
depth = 2;
add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Color", SHADER_SOCKET_COLOR);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void CloudsTextureNode::compile(SVMCompiler& compiler)
void GradientTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *size_in = input("Size");
ShaderInput *vector_in = input("Vector");
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
if(vector_in->link) compiler.stack_assign(vector_in);
if(size_in->link) compiler.stack_assign(size_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
compiler.stack_assign(color_out);
compiler.stack_assign(fac_out);
if(!fac_out->links.empty())
compiler.stack_assign(fac_out);
if(!color_out->links.empty())
compiler.stack_assign(color_out);
compiler.add_node(NODE_TEX_CLOUDS,
compiler.encode_uchar4(basis_enum[basis], hard, depth),
compiler.encode_uchar4(size_in->stack_offset, vector_in->stack_offset, fac_out->stack_offset, color_out->stack_offset),
__float_as_int(size_in->value.x));
compiler.add_node(NODE_TEX_GRADIENT,
compiler.encode_uchar4(type_enum[type], vector_in->stack_offset, fac_out->stack_offset, color_out->stack_offset));
}
void CloudsTextureNode::compile(OSLCompiler& compiler)
void GradientTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("Hard", (hard)? 1: 0);
compiler.parameter("Depth", depth);
compiler.parameter("Basis", basis);
compiler.add(this, "node_clouds_texture");
compiler.parameter("Type", type);
compiler.add(this, "node_gradient_texture");
}
/* Noise Texture */
NoiseTextureNode::NoiseTextureNode()
: TextureNode("noise_texture")
{
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Detail", SHADER_SOCKET_FLOAT, 2.0f);
add_input("Distortion", SHADER_SOCKET_FLOAT, 0.0f);
add_output("Color", SHADER_SOCKET_COLOR);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void NoiseTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *distortion_in = input("Distortion");
ShaderInput *detail_in = input("Detail");
ShaderInput *scale_in = input("Scale");
ShaderInput *vector_in = input("Vector");
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
if(vector_in->link) compiler.stack_assign(vector_in);
if(scale_in->link) compiler.stack_assign(scale_in);
if(detail_in->link) compiler.stack_assign(detail_in);
if(distortion_in->link) compiler.stack_assign(distortion_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
if(!fac_out->links.empty())
compiler.stack_assign(fac_out);
if(!color_out->links.empty())
compiler.stack_assign(color_out);
compiler.add_node(NODE_TEX_NOISE,
compiler.encode_uchar4(vector_in->stack_offset, scale_in->stack_offset, detail_in->stack_offset, distortion_in->stack_offset),
compiler.encode_uchar4(color_out->stack_offset, fac_out->stack_offset));
compiler.add_node(
__float_as_int(scale_in->value.x),
__float_as_int(detail_in->value.x),
__float_as_int(distortion_in->value.x));
}
void NoiseTextureNode::compile(OSLCompiler& compiler)
{
compiler.add(this, "node_noise_texture");
}
/* Voronoi Texture */
static ShaderEnum distance_metric_init()
{
ShaderEnum enm;
enm.insert("Distance Squared", NODE_VORONOI_DISTANCE_SQUARED);
enm.insert("Actual Distance", NODE_VORONOI_ACTUAL_DISTANCE);
enm.insert("Manhattan", NODE_VORONOI_MANHATTAN);
enm.insert("Chebychev", NODE_VORONOI_CHEBYCHEV);
enm.insert("Minkovsky 1/2", NODE_VORONOI_MINKOVSKY_H);
enm.insert("Minkovsky 4", NODE_VORONOI_MINKOVSKY_4);
enm.insert("Minkovsky", NODE_VORONOI_MINKOVSKY);
return enm;
}
static ShaderEnum voronoi_coloring_init()
{
ShaderEnum enm;
enm.insert("Intensity", NODE_VORONOI_INTENSITY);
enm.insert("Position", NODE_VORONOI_POSITION);
enm.insert("Position and Outline", NODE_VORONOI_POSITION_OUTLINE);
enm.insert("Position, Outline, and Intensity", NODE_VORONOI_POSITION_OUTLINE_INTENSITY);
enm.insert("Cells", NODE_VORONOI_CELLS);
return enm;
}
ShaderEnum VoronoiTextureNode::distance_metric_enum = distance_metric_init();
ShaderEnum VoronoiTextureNode::coloring_enum = voronoi_coloring_init();
VoronoiTextureNode::VoronoiTextureNode()
: TextureNode("voronoi_texture")
{
distance_metric = ustring("Actual Distance");
coloring = ustring("Intensity");
add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
add_input("Weight1", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Weight2", SHADER_SOCKET_FLOAT, 0.0f);
add_input("Weight3", SHADER_SOCKET_FLOAT, 0.0f);
add_input("Weight4", SHADER_SOCKET_FLOAT, 0.0f);
add_input("Exponent", SHADER_SOCKET_FLOAT, 2.5f);
add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Color", SHADER_SOCKET_COLOR);
@ -568,23 +486,13 @@ VoronoiTextureNode::VoronoiTextureNode()
void VoronoiTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *weight1_in = input("Weight1");
ShaderInput *weight2_in = input("Weight2");
ShaderInput *weight3_in = input("Weight3");
ShaderInput *weight4_in = input("Weight4");
ShaderInput *exponent_in = input("Exponent");
ShaderInput *size_in = input("Size");
ShaderInput *scale_in = input("Scale");
ShaderInput *vector_in = input("Vector");
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
if(weight1_in->link) compiler.stack_assign(weight1_in);
if(weight2_in->link) compiler.stack_assign(weight2_in);
if(weight3_in->link) compiler.stack_assign(weight3_in);
if(weight4_in->link) compiler.stack_assign(weight4_in);
if(exponent_in->link) compiler.stack_assign(exponent_in);
if(vector_in->link) compiler.stack_assign(vector_in);
if(size_in->link) compiler.stack_assign(size_in);
if(scale_in->link) compiler.stack_assign(scale_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
@ -593,20 +501,13 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler)
compiler.stack_assign(fac_out);
compiler.add_node(NODE_TEX_VORONOI,
compiler.encode_uchar4(distance_metric_enum[distance_metric], coloring_enum[coloring], exponent_in->stack_offset),
compiler.encode_uchar4(size_in->stack_offset, vector_in->stack_offset, fac_out->stack_offset, color_out->stack_offset),
compiler.encode_uchar4(weight1_in->stack_offset, weight2_in->stack_offset, weight3_in->stack_offset, weight4_in->stack_offset));
compiler.add_node(__float_as_int(weight1_in->value.x),
__float_as_int(weight2_in->value.x),
__float_as_int(weight3_in->value.x),
__float_as_int(weight4_in->value.x));
compiler.add_node(__float_as_int(exponent_in->value.x),
__float_as_int(size_in->value.x));
coloring_enum[coloring],
compiler.encode_uchar4(scale_in->stack_offset, vector_in->stack_offset, fac_out->stack_offset, color_out->stack_offset),
__float_as_int(scale_in->value.x));
}
void VoronoiTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("DistanceMetric", distance_metric);
compiler.parameter("Coloring", coloring);
compiler.add(this, "node_voronoi_texture");
}
@ -627,141 +528,138 @@ static ShaderEnum musgrave_type_init()
}
ShaderEnum MusgraveTextureNode::type_enum = musgrave_type_init();
ShaderEnum MusgraveTextureNode::basis_enum = noise_basis_init();
MusgraveTextureNode::MusgraveTextureNode()
: TextureNode("musgrave_texture")
{
type = ustring("fBM");
basis = ustring("Perlin");
add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Detail", SHADER_SOCKET_FLOAT, 2.0f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_input("Dimension", SHADER_SOCKET_FLOAT, 2.0f);
add_input("Lacunarity", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Octaves", SHADER_SOCKET_FLOAT, 2.0f);
add_input("Offset", SHADER_SOCKET_FLOAT, 0.0f);
add_input("Gain", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Fac", SHADER_SOCKET_FLOAT);
add_output("Color", SHADER_SOCKET_COLOR);
}
void MusgraveTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *vector_in = input("Vector");
ShaderInput *scale_in = input("Scale");
ShaderInput *dimension_in = input("Dimension");
ShaderInput *lacunarity_in = input("Lacunarity");
ShaderInput *octaves_in = input("Octaves");
ShaderInput *detail_in = input("Detail");
ShaderInput *offset_in = input("Offset");
ShaderInput *gain_in = input("Gain");
ShaderInput *size_in = input("Size");
ShaderOutput *fac_out = output("Fac");
ShaderOutput *color_out = output("Color");
if(vector_in->link) compiler.stack_assign(vector_in);
if(dimension_in->link) compiler.stack_assign(dimension_in);
if(lacunarity_in->link) compiler.stack_assign(lacunarity_in);
if(octaves_in->link) compiler.stack_assign(octaves_in);
if(detail_in->link) compiler.stack_assign(detail_in);
if(offset_in->link) compiler.stack_assign(offset_in);
if(gain_in->link) compiler.stack_assign(gain_in);
if(size_in->link) compiler.stack_assign(size_in);
if(scale_in->link) compiler.stack_assign(scale_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
compiler.stack_assign(fac_out);
if(!fac_out->links.empty())
compiler.stack_assign(fac_out);
if(!color_out->links.empty())
compiler.stack_assign(color_out);
compiler.add_node(NODE_TEX_MUSGRAVE,
compiler.encode_uchar4(type_enum[type], basis_enum[basis], vector_in->stack_offset, fac_out->stack_offset),
compiler.encode_uchar4(dimension_in->stack_offset, lacunarity_in->stack_offset, octaves_in->stack_offset, offset_in->stack_offset),
compiler.encode_uchar4(gain_in->stack_offset, size_in->stack_offset));
compiler.encode_uchar4(type_enum[type], vector_in->stack_offset, color_out->stack_offset, fac_out->stack_offset),
compiler.encode_uchar4(dimension_in->stack_offset, lacunarity_in->stack_offset, detail_in->stack_offset, offset_in->stack_offset),
compiler.encode_uchar4(gain_in->stack_offset, scale_in->stack_offset));
compiler.add_node(__float_as_int(dimension_in->value.x),
__float_as_int(lacunarity_in->value.x),
__float_as_int(octaves_in->value.x),
__float_as_int(detail_in->value.x),
__float_as_int(offset_in->value.x));
compiler.add_node(__float_as_int(gain_in->value.x),
__float_as_int(size_in->value.x));
__float_as_int(scale_in->value.x));
}
void MusgraveTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("Type", type);
compiler.parameter("Basis", basis);
compiler.add(this, "node_musgrave_texture");
}
/* Marble Texture */
/* Wave Texture */
static ShaderEnum marble_type_init()
static ShaderEnum wave_type_init()
{
ShaderEnum enm;
enm.insert("Soft", NODE_MARBLE_SOFT);
enm.insert("Sharp", NODE_MARBLE_SHARP);
enm.insert("Sharper", NODE_MARBLE_SHARPER);
enm.insert("Bands", NODE_WAVE_BANDS);
enm.insert("Rings", NODE_WAVE_RINGS);
return enm;
}
static ShaderEnum noise_wave_init()
{
ShaderEnum enm;
ShaderEnum WaveTextureNode::type_enum = wave_type_init();
enm.insert("Sine", NODE_WAVE_SINE);
enm.insert("Saw", NODE_WAVE_SAW);
enm.insert("Tri", NODE_WAVE_TRI);
return enm;
}
ShaderEnum MarbleTextureNode::type_enum = marble_type_init();
ShaderEnum MarbleTextureNode::wave_enum = noise_wave_init();
ShaderEnum MarbleTextureNode::basis_enum = noise_basis_init();
MarbleTextureNode::MarbleTextureNode()
WaveTextureNode::WaveTextureNode()
: TextureNode("marble_texture")
{
type = ustring("Soft");
wave = ustring("Sine");
basis = ustring("Perlin");
hard = false;
depth = 2;
type = ustring("Bands");
add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
add_input("Turbulence", SHADER_SOCKET_FLOAT, 5.0f);
add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Distortion", SHADER_SOCKET_FLOAT, 0.0f);
add_input("Detail", SHADER_SOCKET_FLOAT, 2.0f);
add_input("Detail Scale", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Color", SHADER_SOCKET_COLOR);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void MarbleTextureNode::compile(SVMCompiler& compiler)
void WaveTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *size_in = input("Size");
ShaderInput *turbulence_in = input("Turbulence");
ShaderInput *scale_in = input("Scale");
ShaderInput *distortion_in = input("Distortion");
ShaderInput *dscale_in = input("Detail Scale");
ShaderInput *detail_in = input("Detail");
ShaderInput *vector_in = input("Vector");
ShaderOutput *fac_out = output("Fac");
ShaderOutput *color_out = output("Color");
if(size_in->link) compiler.stack_assign(size_in);
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
if(scale_in->link) compiler.stack_assign(scale_in);
if(detail_in->link) compiler.stack_assign(detail_in);
if(distortion_in->link) compiler.stack_assign(distortion_in);
if(dscale_in->link) compiler.stack_assign(dscale_in);
if(vector_in->link) compiler.stack_assign(vector_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
compiler.stack_assign(fac_out);
compiler.add_node(NODE_TEX_MARBLE,
compiler.encode_uchar4(type_enum[type], wave_enum[wave], basis_enum[basis], hard),
compiler.encode_uchar4(depth),
compiler.encode_uchar4(size_in->stack_offset, turbulence_in->stack_offset, vector_in->stack_offset, fac_out->stack_offset));
compiler.add_node(__float_as_int(size_in->value.x), __float_as_int(turbulence_in->value.x));
if(!fac_out->links.empty())
compiler.stack_assign(fac_out);
if(!color_out->links.empty())
compiler.stack_assign(color_out);
compiler.add_node(NODE_TEX_WAVE,
compiler.encode_uchar4(type_enum[type], color_out->stack_offset, fac_out->stack_offset, dscale_in->stack_offset),
compiler.encode_uchar4(vector_in->stack_offset, scale_in->stack_offset, detail_in->stack_offset, distortion_in->stack_offset));
compiler.add_node(
__float_as_int(scale_in->value.x),
__float_as_int(detail_in->value.x),
__float_as_int(distortion_in->value.x),
__float_as_int(dscale_in->value.x));
}
void MarbleTextureNode::compile(OSLCompiler& compiler)
void WaveTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("Type", type);
compiler.parameter("Wave", wave);
compiler.parameter("Basis", basis);
compiler.parameter("Hard", (hard)? 1: 0);
compiler.parameter("Depth", depth);
compiler.add(this, "node_marble_texture");
}
@ -773,27 +671,40 @@ MagicTextureNode::MagicTextureNode()
{
depth = 2;
add_input("Turbulence", SHADER_SOCKET_FLOAT, 5.0f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_input("Scale", SHADER_SOCKET_FLOAT, 5.0f);
add_input("Distortion", SHADER_SOCKET_FLOAT, 1.0f);
add_output("Color", SHADER_SOCKET_COLOR);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void MagicTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *vector_in = input("Vector");
ShaderInput *turbulence_in = input("Turbulence");
ShaderInput *scale_in = input("Scale");
ShaderInput *distortion_in = input("Distortion");
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
if(vector_in->link) compiler.stack_assign(vector_in);
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
if(distortion_in->link) compiler.stack_assign(distortion_in);
if(scale_in->link) compiler.stack_assign(scale_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
compiler.stack_assign(color_out);
if(!fac_out->links.empty())
compiler.stack_assign(fac_out);
if(!color_out->links.empty())
compiler.stack_assign(color_out);
compiler.add_node(NODE_TEX_MAGIC,
compiler.encode_uchar4(depth, turbulence_in->stack_offset, vector_in->stack_offset, color_out->stack_offset),
__float_as_int(turbulence_in->value.x));
compiler.encode_uchar4(depth, color_out->stack_offset, fac_out->stack_offset),
compiler.encode_uchar4(vector_in->stack_offset, scale_in->stack_offset, distortion_in->stack_offset));
compiler.add_node(
__float_as_int(scale_in->value.x),
__float_as_int(distortion_in->value.x));
}
void MagicTextureNode::compile(OSLCompiler& compiler)
@ -802,178 +713,6 @@ void MagicTextureNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_magic_texture");
}
/* Stucci Texture */
static ShaderEnum stucci_type_init()
{
ShaderEnum enm;
enm.insert("Plastic", NODE_STUCCI_PLASTIC);
enm.insert("Wall In", NODE_STUCCI_WALL_IN);
enm.insert("Wall Out", NODE_STUCCI_WALL_OUT);
return enm;
}
ShaderEnum StucciTextureNode::type_enum = stucci_type_init();
ShaderEnum StucciTextureNode::basis_enum = noise_basis_init();
StucciTextureNode::StucciTextureNode()
: TextureNode("stucci_texture")
{
type = ustring("Plastic");
basis = ustring("Perlin");
hard = false;
add_input("Size", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Turbulence", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void StucciTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *size_in = input("Size");
ShaderInput *turbulence_in = input("Turbulence");
ShaderInput *vector_in = input("Vector");
ShaderOutput *fac_out = output("Fac");
if(size_in->link) compiler.stack_assign(size_in);
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
if(vector_in->link) compiler.stack_assign(vector_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
compiler.stack_assign(fac_out);
compiler.add_node(NODE_TEX_STUCCI,
compiler.encode_uchar4(type_enum[type], basis_enum[basis], hard),
compiler.encode_uchar4(size_in->stack_offset, turbulence_in->stack_offset,
vector_in->stack_offset, fac_out->stack_offset));
compiler.add_node(__float_as_int(size_in->value.x),
__float_as_int(turbulence_in->value.x));
}
void StucciTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("Type", type);
compiler.parameter("Basis", basis);
compiler.parameter("Hard", (hard)? 1: 0);
compiler.add(this, "node_stucci_texture");
}
/* Distorted Noise Texture */
ShaderEnum DistortedNoiseTextureNode::basis_enum = noise_basis_init();
DistortedNoiseTextureNode::DistortedNoiseTextureNode()
: TextureNode("distorted_noise_texture")
{
basis = ustring("Perlin");
distortion_basis = ustring("Perlin");
add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
add_input("Distortion", SHADER_SOCKET_FLOAT, 1.0f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void DistortedNoiseTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *size_in = input("Size");
ShaderInput *distortion_in = input("Distortion");
ShaderInput *vector_in = input("Vector");
ShaderOutput *fac_out = output("Fac");
if(size_in->link) compiler.stack_assign(size_in);
if(distortion_in->link) compiler.stack_assign(distortion_in);
if(vector_in->link) compiler.stack_assign(vector_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
compiler.stack_assign(fac_out);
compiler.add_node(NODE_TEX_DISTORTED_NOISE,
compiler.encode_uchar4(basis_enum[basis], basis_enum[distortion_basis]),
compiler.encode_uchar4(size_in->stack_offset, distortion_in->stack_offset, vector_in->stack_offset, fac_out->stack_offset));
compiler.add_node(__float_as_int(size_in->value.x),
__float_as_int(distortion_in->value.x));
}
void DistortedNoiseTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("Basis", basis);
compiler.parameter("DistortionBasis", distortion_basis);
compiler.add(this, "node_distorted_noise_texture");
}
/* Wood Texture */
static ShaderEnum wood_type_init()
{
ShaderEnum enm;
enm.insert("Bands", NODE_WOOD_BANDS);
enm.insert("Rings", NODE_WOOD_RINGS);
enm.insert("Band Noise", NODE_WOOD_BAND_NOISE);
enm.insert("Ring Noise", NODE_WOOD_RING_NOISE);
return enm;
}
ShaderEnum WoodTextureNode::type_enum = wood_type_init();
ShaderEnum WoodTextureNode::wave_enum = noise_wave_init();
ShaderEnum WoodTextureNode::basis_enum = noise_basis_init();
WoodTextureNode::WoodTextureNode()
: TextureNode("wood_texture")
{
type = ustring("Bands");
wave = ustring("Sine");
basis = ustring("Perlin");
hard = false;
add_input("Size", SHADER_SOCKET_FLOAT, 0.25f);
add_input("Turbulence", SHADER_SOCKET_FLOAT, 5.0f);
add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED);
add_output("Fac", SHADER_SOCKET_FLOAT);
}
void WoodTextureNode::compile(SVMCompiler& compiler)
{
ShaderInput *vector_in = input("Vector");
ShaderInput *size_in = input("Size");
ShaderInput *turbulence_in = input("Turbulence");
ShaderOutput *fac_out = output("Fac");
if(vector_in->link) compiler.stack_assign(vector_in);
if(size_in->link) compiler.stack_assign(size_in);
if(turbulence_in->link) compiler.stack_assign(turbulence_in);
if(!tex_mapping.skip())
tex_mapping.compile(compiler, vector_in->stack_offset, vector_in->stack_offset);
compiler.stack_assign(fac_out);
compiler.add_node(NODE_TEX_WOOD,
compiler.encode_uchar4(type_enum[type], wave_enum[wave], basis_enum[basis], hard),
compiler.encode_uchar4(vector_in->stack_offset, size_in->stack_offset, turbulence_in->stack_offset, fac_out->stack_offset));
compiler.add_node(NODE_TEX_WOOD, make_float3(size_in->value.x, turbulence_in->value.x, 0.0f));
}
void WoodTextureNode::compile(OSLCompiler& compiler)
{
compiler.parameter("Type", type);
compiler.parameter("Wave", wave);
compiler.parameter("Basis", basis);
compiler.parameter("Hard", (hard)? 1: 0);
compiler.add(this, "node_wood_texture");
}
/* Mapping */
MappingNode::MappingNode()
@ -1986,8 +1725,8 @@ void FresnelNode::compile(OSLCompiler& compiler)
/* Blend Weight */
BlendWeightNode::BlendWeightNode()
: ShaderNode("BlendWeight")
LayerWeightNode::LayerWeightNode()
: ShaderNode("LayerWeight")
{
add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, true);
add_input("Blend", SHADER_SOCKET_FLOAT, 0.5f);
@ -1996,7 +1735,7 @@ BlendWeightNode::BlendWeightNode()
add_output("Facing", SHADER_SOCKET_FLOAT);
}
void BlendWeightNode::compile(SVMCompiler& compiler)
void LayerWeightNode::compile(SVMCompiler& compiler)
{
ShaderInput *blend_in = input("Blend");
@ -2006,21 +1745,21 @@ void BlendWeightNode::compile(SVMCompiler& compiler)
ShaderOutput *fresnel_out = output("Fresnel");
if(!fresnel_out->links.empty()) {
compiler.stack_assign(fresnel_out);
compiler.add_node(NODE_BLEND_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
compiler.encode_uchar4(NODE_BLEND_WEIGHT_FRESNEL, fresnel_out->stack_offset));
compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, fresnel_out->stack_offset));
}
ShaderOutput *facing_out = output("Facing");
if(!facing_out->links.empty()) {
compiler.stack_assign(facing_out);
compiler.add_node(NODE_BLEND_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
compiler.encode_uchar4(NODE_BLEND_WEIGHT_FACING, facing_out->stack_offset));
compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, facing_out->stack_offset));
}
}
void BlendWeightNode::compile(OSLCompiler& compiler)
void LayerWeightNode::compile(OSLCompiler& compiler)
{
compiler.add(this, "node_blend_weight");
compiler.add(this, "node_layer_height");
}
/* Output */

@ -97,41 +97,25 @@ public:
SHADER_NODE_CLASS(OutputNode)
};
class GradientTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(GradientTextureNode)
ustring type;
static ShaderEnum type_enum;
};
class NoiseTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(NoiseTextureNode)
};
class BlendTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(BlendTextureNode)
ustring progression;
ustring axis;
static ShaderEnum progression_enum;
static ShaderEnum axis_enum;
};
class CloudsTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(CloudsTextureNode)
bool hard;
int depth;
ustring basis;
static ShaderEnum basis_enum;
};
class VoronoiTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(VoronoiTextureNode)
ustring distance_metric;
ustring coloring;
static ShaderEnum distance_metric_enum;
static ShaderEnum coloring_enum;
};
@ -140,25 +124,16 @@ public:
SHADER_NODE_CLASS(MusgraveTextureNode)
ustring type;
ustring basis;
static ShaderEnum type_enum;
static ShaderEnum basis_enum;
};
class MarbleTextureNode : public TextureNode {
class WaveTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(MarbleTextureNode)
SHADER_NODE_CLASS(WaveTextureNode)
ustring type;
ustring wave;
ustring basis;
bool hard;
int depth;
static ShaderEnum type_enum;
static ShaderEnum wave_enum;
static ShaderEnum basis_enum;
};
class MagicTextureNode : public TextureNode {
@ -168,41 +143,6 @@ public:
int depth;
};
class StucciTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(StucciTextureNode)
ustring type;
ustring basis;
bool hard;
static ShaderEnum type_enum;
static ShaderEnum basis_enum;
};
class DistortedNoiseTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(DistortedNoiseTextureNode)
ustring basis;
ustring distortion_basis;
static ShaderEnum basis_enum;
};
class WoodTextureNode : public TextureNode {
public:
SHADER_NODE_CLASS(WoodTextureNode)
ustring type;
ustring wave;
ustring basis;
bool hard;
static ShaderEnum type_enum;
static ShaderEnum wave_enum;
static ShaderEnum basis_enum;
};
class MappingNode : public ShaderNode {
public:
SHADER_NODE_CLASS(MappingNode)
@ -365,9 +305,9 @@ public:
SHADER_NODE_CLASS(FresnelNode)
};
class BlendWeightNode : public ShaderNode {
class LayerWeightNode : public ShaderNode {
public:
SHADER_NODE_CLASS(BlendWeightNode)
SHADER_NODE_CLASS(LayerWeightNode)
};
class MathNode : public ShaderNode {

@ -21,7 +21,7 @@
CCL_NAMESPACE_BEGIN
static unsigned int hash_int_2d(unsigned int kx, unsigned int ky)
static inline unsigned int hash_int_2d(unsigned int kx, unsigned int ky)
{
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
@ -44,7 +44,7 @@ static unsigned int hash_int_2d(unsigned int kx, unsigned int ky)
#undef rot
}
static unsigned int hash_int(unsigned int k)
static inline unsigned int hash_int(unsigned int k)
{
return hash_int_2d(k, 0);
}

@ -473,23 +473,19 @@ struct ShadeResult;
#define SH_NODE_GEOMETRY 141
#define SH_NODE_LIGHT_PATH 142
#define SH_NODE_TEX_IMAGE 143
#define SH_NODE_TEX_NOISE 144
#define SH_NODE_TEX_SKY 145
#define SH_NODE_TEX_BLEND 146
#define SH_NODE_TEX_GRADIENT 146
#define SH_NODE_TEX_VORONOI 147
#define SH_NODE_TEX_MAGIC 148
#define SH_NODE_TEX_MARBLE 149
#define SH_NODE_TEX_CLOUDS 150
#define SH_NODE_TEX_WOOD 151
#define SH_NODE_TEX_WAVE 149
#define SH_NODE_TEX_NOISE 150
#define SH_NODE_TEX_MUSGRAVE 152
#define SH_NODE_TEX_STUCCI 153
#define SH_NODE_TEX_DISTNOISE 154
#define SH_NODE_TEX_COORD 155
#define SH_NODE_ADD_SHADER 156
#define SH_NODE_TEX_ENVIRONMENT 157
#define SH_NODE_OUTPUT_TEXTURE 158
#define SH_NODE_HOLDOUT 159
#define SH_NODE_BLEND_WEIGHT 160
#define SH_NODE_LAYER_WEIGHT 160
#define SH_NODE_VOLUME_TRANSPARENT 161
#define SH_NODE_VOLUME_ISOTROPIC 162

@ -1896,7 +1896,7 @@ static void registerShaderNodes(ListBase *ntypelist)
register_node_type_sh_geometry(ntypelist);
register_node_type_sh_light_path(ntypelist);
register_node_type_sh_fresnel(ntypelist);
register_node_type_sh_blend_weight(ntypelist);
register_node_type_sh_layer_weight(ntypelist);
register_node_type_sh_tex_coord(ntypelist);
register_node_type_sh_background(ntypelist);
@ -1922,16 +1922,12 @@ static void registerShaderNodes(ListBase *ntypelist)
register_node_type_sh_tex_image(ntypelist);
register_node_type_sh_tex_environment(ntypelist);
register_node_type_sh_tex_sky(ntypelist);
register_node_type_sh_tex_voronoi(ntypelist);
register_node_type_sh_tex_blend(ntypelist);
register_node_type_sh_tex_magic(ntypelist);
register_node_type_sh_tex_marble(ntypelist);
register_node_type_sh_tex_clouds(ntypelist);
register_node_type_sh_tex_wood(ntypelist);
register_node_type_sh_tex_stucci(ntypelist);
register_node_type_sh_tex_noise(ntypelist);
register_node_type_sh_tex_distnoise(ntypelist);
register_node_type_sh_tex_wave(ntypelist);
register_node_type_sh_tex_voronoi(ntypelist);
register_node_type_sh_tex_musgrave(ntypelist);
register_node_type_sh_tex_gradient(ntypelist);
register_node_type_sh_tex_magic(ntypelist);
}
static void registerTextureNodes(ListBase *ntypelist)

@ -2091,7 +2091,7 @@ static void ntree_tmp_cycles_version_patch(bNodeTree *ntree)
if(strcmp(sock->name, "Fresnel") == 0) {
bNodeSocket *osock;
node->type = SH_NODE_BLEND_WEIGHT;
node->type = SH_NODE_LAYER_WEIGHT;
strcpy(sock->name, "Blend");
for(osock=node->outputs.first; osock; osock=osock->next)
@ -7227,9 +7227,8 @@ static void do_version_ntree_tex_mapping_260(void *UNUSED(data), ID *UNUSED(id),
tex_mapping->projz= PROJ_Z;
}
else if(ELEM7(node->type, SH_NODE_TEX_IMAGE, SH_NODE_TEX_NOISE, SH_NODE_TEX_SKY,
SH_NODE_TEX_BLEND, SH_NODE_TEX_VORONOI, SH_NODE_TEX_MAGIC, SH_NODE_TEX_MARBLE) ||
ELEM6(node->type, SH_NODE_TEX_CLOUDS, SH_NODE_TEX_WOOD, SH_NODE_TEX_MUSGRAVE,
SH_NODE_TEX_STUCCI, SH_NODE_TEX_DISTNOISE, SH_NODE_TEX_ENVIRONMENT)) {
SH_NODE_TEX_GRADIENT, SH_NODE_TEX_VORONOI, SH_NODE_TEX_MAGIC, SH_NODE_TEX_WAVE) ||
ELEM(node->type, SH_NODE_TEX_MUSGRAVE, SH_NODE_TEX_ENVIRONMENT)) {
NodeTexBase *base= node->storage;
if(node->type == SH_NODE_TEX_NOISE)

@ -1028,23 +1028,9 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), Poin
uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
}
static void node_shader_buts_tex_blend(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "progression", 0, "", ICON_NONE);
uiItemR(layout, ptr, "axis", 0, "", ICON_NONE);
}
static void node_shader_buts_tex_clouds(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
}
static void node_shader_buts_tex_distnoise(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
uiItemR(layout, ptr, "noise_distortion", 0, "", ICON_NONE);
uiItemR(layout, ptr, "gradient_type", 0, "", ICON_NONE);
}
static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
@ -1052,42 +1038,21 @@ static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), Po
uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
}
static void node_shader_buts_tex_marble(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "marble_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
}
static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
}
static void node_shader_buts_tex_stucci(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "stucci_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE);
}
static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "distance_metric", 0, "", ICON_NONE);
uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
}
static void node_shader_buts_tex_wood(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "noise_basis", 0, "", ICON_NONE);
uiItemR(layout, ptr, "noise_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "wood_type", 0, "", ICON_NONE);
uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
}
static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
@ -1191,33 +1156,21 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_TEX_ENVIRONMENT:
ntype->uifunc= node_shader_buts_tex_image;
break;
case SH_NODE_TEX_BLEND:
ntype->uifunc= node_shader_buts_tex_blend;
break;
case SH_NODE_TEX_CLOUDS:
ntype->uifunc= node_shader_buts_tex_clouds;
break;
case SH_NODE_TEX_DISTNOISE:
ntype->uifunc= node_shader_buts_tex_distnoise;
case SH_NODE_TEX_GRADIENT:
ntype->uifunc= node_shader_buts_tex_gradient;
break;
case SH_NODE_TEX_MAGIC:
ntype->uifunc= node_shader_buts_tex_magic;
break;
case SH_NODE_TEX_MARBLE:
ntype->uifunc= node_shader_buts_tex_marble;
case SH_NODE_TEX_WAVE:
ntype->uifunc= node_shader_buts_tex_wave;
break;
case SH_NODE_TEX_MUSGRAVE:
ntype->uifunc= node_shader_buts_tex_musgrave;
break;
case SH_NODE_TEX_STUCCI:
ntype->uifunc= node_shader_buts_tex_stucci;
break;
case SH_NODE_TEX_VORONOI:
ntype->uifunc= node_shader_buts_tex_voronoi;
break;
case SH_NODE_TEX_WOOD:
ntype->uifunc= node_shader_buts_tex_wood;
break;
case SH_NODE_BSDF_GLOSSY:
case SH_NODE_BSDF_GLASS:
ntype->uifunc= node_shader_buts_glossy;

@ -432,10 +432,6 @@ typedef struct NodeTexBase {
ColorMapping color_mapping;
} NodeTexBase;
typedef struct NodeTexNoise {
NodeTexBase base;
} NodeTexNoise;
typedef struct NodeTexSky {
NodeTexBase base;
float sun_direction[3];
@ -452,41 +448,33 @@ typedef struct NodeTexEnvironment {
int color_space, pad;
} NodeTexEnvironment;
typedef struct NodeTexBlend {
typedef struct NodeTexGradient {
NodeTexBase base;
int progression;
int axis;
} NodeTexBlend;
typedef struct NodeTexClouds {
NodeTexBase base;
int hard;
int depth;
int basis;
int gradient_type;
int pad;
} NodeTexClouds;
} NodeTexGradient;
typedef struct NodeTexNoise {
NodeTexBase base;
} NodeTexNoise;
typedef struct NodeTexVoronoi {
NodeTexBase base;
int distance_metric;
int coloring;
int pad;
} NodeTexVoronoi;
typedef struct NodeTexMusgrave {
NodeTexBase base;
int type;
int basis;
int musgrave_type;
int pad;
} NodeTexMusgrave;
typedef struct NodeTexMarble {
typedef struct NodeTexWave {
NodeTexBase base;
int type;
int wave;
int basis;
int hard;
int depth;
int wave_type;
int pad;
} NodeTexMarble;
} NodeTexWave;
typedef struct NodeTexMagic {
NodeTexBase base;
@ -494,28 +482,6 @@ typedef struct NodeTexMagic {
int pad;
} NodeTexMagic;
typedef struct NodeTexStucci {
NodeTexBase base;
int type;
int basis;
int hard;
int pad;
} NodeTexStucci;
typedef struct NodeTexDistortedNoise {
NodeTexBase base;
int basis;
int distortion_basis;
} NodeTexDistortedNoise;
typedef struct NodeTexWood {
NodeTexBase base;
int type;
int wave;
int basis;
int hard;
} NodeTexWood;
typedef struct NodeShaderAttribute {
char name[64];
} NodeShaderAttribute;
@ -545,9 +511,6 @@ typedef struct TexNodeOutput {
#define SHD_BLEND_QUADRATIC_SPHERE 5
#define SHD_BLEND_SPHERICAL 6
#define SHD_BLEND_HORIZONTAL 0
#define SHD_BLEND_VERTICAL 1
/* noise basis for textures */
#define SHD_NOISE_PERLIN 0
#define SHD_NOISE_VORONOI_F1 1
@ -570,10 +533,8 @@ typedef struct TexNodeOutput {
#define SHD_VORONOI_MINKOVSKY_4 5
#define SHD_VORONOI_MINKOVSKY 6
#define SHD_VORONOI_INTENSITY 0
#define SHD_VORONOI_POSITION 1
#define SHD_VORONOI_POSITION_OUTLINE 2
#define SHD_VORONOI_POSITION_OUTLINE_INTENSITY 3
#define SHD_VORONOI_INTENSITY 0
#define SHD_VORONOI_CELLS 1
/* musgrave texture */
#define SHD_MUSGRAVE_MULTIFRACTAL 0
@ -582,26 +543,14 @@ typedef struct TexNodeOutput {
#define SHD_MUSGRAVE_RIDGED_MULTIFRACTAL 3
#define SHD_MUSGRAVE_HETERO_TERRAIN 4
/* marble texture */
#define SHD_MARBLE_SOFT 0
#define SHD_MARBLE_SHARP 1
#define SHD_MARBLE_SHARPER 2
/* wave texture */
#define SHD_WAVE_BANDS 0
#define SHD_WAVE_RINGS 1
#define SHD_WAVE_SINE 0
#define SHD_WAVE_SAW 1
#define SHD_WAVE_TRI 2
/* stucci texture */
#define SHD_STUCCI_PLASTIC 0
#define SHD_STUCCI_WALL_IN 1
#define SHD_STUCCI_WALL_OUT 2
/* wood texture */
#define SHD_WOOD_BANDS 0
#define SHD_WOOD_RINGS 1
#define SHD_WOOD_BAND_NOISE 2
#define SHD_WOOD_RING_NOISE 3
/* image/environment texture */
#define SHD_COLORSPACE_LINEAR 0
#define SHD_COLORSPACE_SRGB 1

@ -1147,12 +1147,6 @@ static void def_sh_tex(StructRNA *srna)
RNA_def_property_ui_text(prop, "Color Mapping", "Color mapping settings");
}
static void def_sh_tex_noise(StructRNA *srna)
{
RNA_def_struct_sdna_from(srna, "NodeTexNoise", "storage");
def_sh_tex(srna);
}
static void def_sh_tex_sky(StructRNA *srna)
{
PropertyRNA *prop;
@ -1219,9 +1213,9 @@ static void def_sh_tex_image(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_blend(StructRNA *srna)
static void def_sh_tex_gradient(StructRNA *srna)
{
static EnumPropertyItem prop_blend_progression[] = {
static EnumPropertyItem prop_gradient_type[] = {
{SHD_BLEND_LINEAR, "LINEAR", 0, "Linear", "Creates a linear progression"},
{SHD_BLEND_QUADRATIC, "QUADRATIC", 0, "Quadratic", "Creates a quadratic progression"},
{SHD_BLEND_EASING, "EASING", 0, "Easing", "Creates a progression easing from one step to the next"},
@ -1231,73 +1225,21 @@ static void def_sh_tex_blend(StructRNA *srna)
{SHD_BLEND_RADIAL, "RADIAL", 0, "Radial", "Creates a radial progression"},
{0, NULL, 0, NULL, NULL}};
static const EnumPropertyItem prop_axis_items[]= {
{SHD_BLEND_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", "Flips the texture's X and Y axis"},
{SHD_BLEND_VERTICAL, "VERTICAL", 0, "Vertical", "Flips the texture's X and Y axis"},
{0, NULL, 0, NULL, NULL}};
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeTexBlend", "storage");
RNA_def_struct_sdna_from(srna, "NodeTexGradient", "storage");
def_sh_tex(srna);
prop= RNA_def_property(srna, "progression", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "progression");
RNA_def_property_enum_items(prop, prop_blend_progression);
RNA_def_property_ui_text(prop, "Progression", "Sets the style of the color blending");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "axis");
RNA_def_property_enum_items(prop, prop_axis_items);
RNA_def_property_ui_text(prop, "Axis", "Flips the texture's X and Y axis");
prop= RNA_def_property(srna, "gradient_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, prop_gradient_type);
RNA_def_property_ui_text(prop, "Gradient Type", "Sets the style of the color blending");
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_clouds(StructRNA *srna)
static void def_sh_tex_noise(StructRNA *srna)
{
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeTexClouds", "storage");
RNA_def_struct_sdna_from(srna, "NodeTexNoise", "storage");
def_sh_tex(srna);
prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "basis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "hard");
RNA_def_property_enum_items(prop, prop_noise_type_items);
RNA_def_property_ui_text(prop, "Noise Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "depth");
RNA_def_property_range(prop, 0, 30);
RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise");
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_distnoise(StructRNA *srna)
{
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeTexDistortedNoise", "storage");
def_sh_tex(srna);
prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "basis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "noise_distortion", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "distortion_basis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Distortion", "Sets the noise basis used for distortion");
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_magic(StructRNA *srna)
@ -1314,50 +1256,6 @@ static void def_sh_tex_magic(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_marble(StructRNA *srna)
{
static EnumPropertyItem prop_marble_stype[] = {
{SHD_MARBLE_SOFT, "SOFT", 0, "Soft", "Uses soft marble"},
{SHD_MARBLE_SHARP, "SHARP", 0, "Sharp", "Uses more clearly defined marble"},
{SHD_MARBLE_SHARPER, "SHARPER", 0, "Sharper", "Uses very clearly defined marble"},
{0, NULL, 0, NULL, NULL}};
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeTexMarble", "storage");
def_sh_tex(srna);
prop= RNA_def_property(srna, "marble_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_marble_stype);
RNA_def_property_ui_text(prop, "Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "basis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "hard");
RNA_def_property_enum_items(prop, prop_noise_type_items);
RNA_def_property_ui_text(prop, "Noise Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "turbulence_depth", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "depth");
RNA_def_property_range(prop, 0, 30);
RNA_def_property_ui_text(prop, "Depth", "Level of detail in the added turbulent noise");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "wave_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "wave");
RNA_def_property_enum_items(prop, prop_wave_items);
RNA_def_property_ui_text(prop, "Wave Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_musgrave(StructRNA *srna)
{
static EnumPropertyItem prop_musgrave_type[] = {
@ -1374,67 +1272,17 @@ static void def_sh_tex_musgrave(StructRNA *srna)
def_sh_tex(srna);
prop= RNA_def_property(srna, "musgrave_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_sdna(prop, NULL, "musgrave_type");
RNA_def_property_enum_items(prop, prop_musgrave_type);
RNA_def_property_ui_text(prop, "Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "basis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_stucci(StructRNA *srna)
{
static EnumPropertyItem prop_stucci_stype[] = {
{SHD_STUCCI_PLASTIC, "PLASTIC", 0, "Plastic", "Uses standard stucci"},
{SHD_STUCCI_WALL_IN, "WALL_IN", 0, "Wall in", "Creates Dimples"},
{SHD_STUCCI_WALL_OUT, "WALL_OUT", 0, "Wall out", "Creates Ridges"},
{0, NULL, 0, NULL, NULL}};
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeTexStucci", "storage");
def_sh_tex(srna);
prop= RNA_def_property(srna, "stucci_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_stucci_stype);
RNA_def_property_ui_text(prop, "Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "basis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "hard");
RNA_def_property_enum_items(prop, prop_noise_type_items);
RNA_def_property_ui_text(prop, "Noise Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_voronoi(StructRNA *srna)
{
static EnumPropertyItem prop_distance_metric_items[] = {
{SHD_VORONOI_ACTUAL_DISTANCE, "DISTANCE", 0, "Actual Distance", ""},
{SHD_VORONOI_DISTANCE_SQUARED, "DISTANCE_SQUARED", 0, "Distance Squared", ""},
{SHD_VORONOI_MANHATTAN, "MANHATTAN", 0, "Manhattan", ""},
{SHD_VORONOI_CHEBYCHEV, "CHEBYCHEV", 0, "Chebychev", ""},
{SHD_VORONOI_MINKOVSKY_H, "MINKOVSKY_HALF", 0, "Minkovsky 1/2", ""},
{SHD_VORONOI_MINKOVSKY_4, "MINKOVSKY_FOUR", 0, "Minkovsky 4", ""},
{SHD_VORONOI_MINKOVSKY, "MINKOVSKY", 0, "Minkovsky", ""},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem prop_coloring_items[] = {
{SHD_VORONOI_INTENSITY, "INTENSITY", 0, "Intensity", "Only calculate intensity"},
{SHD_VORONOI_POSITION, "POSITION", 0, "Position", "Color cells by position"},
{SHD_VORONOI_POSITION_OUTLINE, "POSITION_OUTLINE", 0, "Position and Outline", "Use position plus an outline based on F2-F.1"},
{SHD_VORONOI_POSITION_OUTLINE_INTENSITY, "POSITION_OUTLINE_INTENSITY", 0, "Position, Outline, and Intensity", "Multiply position and outline by intensity"},
{SHD_VORONOI_CELLS, "CELLS", 0, "Cells", "Color cells by position"},
{0, NULL, 0, NULL, NULL}};
PropertyRNA *prop;
@ -1442,12 +1290,6 @@ static void def_sh_tex_voronoi(StructRNA *srna)
RNA_def_struct_sdna_from(srna, "NodeTexVoronoi", "storage");
def_sh_tex(srna);
prop= RNA_def_property(srna, "distance_metric", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "distance_metric");
RNA_def_property_enum_items(prop, prop_distance_metric_items);
RNA_def_property_ui_text(prop, "Distance Metric", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "coloring", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "coloring");
RNA_def_property_enum_items(prop, prop_coloring_items);
@ -1455,41 +1297,21 @@ static void def_sh_tex_voronoi(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_Node_update");
}
static void def_sh_tex_wood(StructRNA *srna)
static void def_sh_tex_wave(StructRNA *srna)
{
static EnumPropertyItem prop_wood_type_items[] = {
{SHD_WOOD_BANDS, "BANDS", 0, "Bands", "Uses standard wood texture in bands"},
{SHD_WOOD_RINGS, "RINGS", 0, "Rings", "Uses wood texture in rings"},
{SHD_WOOD_BAND_NOISE, "BAND_NOISE", 0, "Band Noise", "Adds noise to standard wood"},
{SHD_WOOD_RING_NOISE, "RING_NOISE", 0, "Ring Noise", "Adds noise to rings"},
static EnumPropertyItem prop_wave_type_items[] = {
{SHD_WAVE_BANDS, "BANDS", 0, "Bands", "Uses standard wave texture in bands"},
{SHD_WAVE_RINGS, "RINGS", 0, "Rings", "Uses wave texture in rings"},
{0, NULL, 0, NULL, NULL}};
PropertyRNA *prop;
RNA_def_struct_sdna_from(srna, "NodeTexWood", "storage");
RNA_def_struct_sdna_from(srna, "NodeTexWave", "storage");
def_sh_tex(srna);
prop= RNA_def_property(srna, "noise_basis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "basis");
RNA_def_property_enum_items(prop, prop_noise_basis_items);
RNA_def_property_ui_text(prop, "Noise Basis", "Sets the noise basis used for turbulence");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "hard");
RNA_def_property_enum_items(prop, prop_noise_type_items);
RNA_def_property_ui_text(prop, "Noise Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "wood_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type");
RNA_def_property_enum_items(prop, prop_wood_type_items);
RNA_def_property_ui_text(prop, "Wood Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
prop= RNA_def_property(srna, "wave_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "wave");
RNA_def_property_enum_items(prop, prop_wave_items);
RNA_def_property_enum_sdna(prop, NULL, "wave_type");
RNA_def_property_enum_items(prop, prop_wave_type_items);
RNA_def_property_ui_text(prop, "Wave Type", "");
RNA_def_property_update(prop, 0, "rna_Node_update");
}

@ -58,7 +58,7 @@ DefNode( ShaderNode, SH_NODE_OUTPUT_LAMP, 0, "OUTPU
//DefNode( ShaderNode, SH_NODE_OUTPUT_TEXTURE, 0, "OUTPUT_TEXTURE", OutputTexture, "Texture Output", "" )
DefNode( ShaderNode, SH_NODE_OUTPUT_WORLD, 0, "OUTPUT_WORLD", OutputWorld, "World Output", "" )
DefNode( ShaderNode, SH_NODE_FRESNEL, 0, "FRESNEL", Fresnel, "Fresnel", "" )
DefNode( ShaderNode, SH_NODE_BLEND_WEIGHT, 0, "BLEND_WEIGHT", BlendWeight, "BlendWeight", "" )
DefNode( ShaderNode, SH_NODE_LAYER_WEIGHT, 0, "LAYER_WEIGHT", LayerWeight, "LayerWeight", "" )
DefNode( ShaderNode, SH_NODE_MIX_SHADER, 0, "MIX_SHADER", MixShader, "Mix Shader", "" )
DefNode( ShaderNode, SH_NODE_ADD_SHADER, 0, "ADD_SHADER", AddShader, "Add Shader", "" )
@ -79,17 +79,13 @@ DefNode( ShaderNode, SH_NODE_GEOMETRY, 0, "GE
DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LIGHT_PATH", Light_path, "Light_path", "")
DefNode( ShaderNode, SH_NODE_TEX_IMAGE, def_sh_tex_image, "TEX_IMAGE", TexImage, "Image Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_ENVIRONMENT, def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_NOISE, def_sh_tex_noise, "TEX_NOISE", TexNoise, "Noise Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_SKY, def_sh_tex_sky, "TEX_SKY", TexSky, "Sky Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_BLEND, def_sh_tex_blend, "TEX_BLEND", TexBlend, "Blend Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_CLOUDS, def_sh_tex_clouds, "TEX_CLOUDS", TexClouds, "Clouds Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_DISTNOISE, def_sh_tex_distnoise, "TEX_DISTORTED_NOISE", TexDistortedNoise, "Distorted Noise Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_GRADIENT, def_sh_tex_gradient, "TEX_GRADIENT", TexGradient, "Gradient Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_NOISE, def_sh_tex_noise, "TEX_NOISE", TexNoise, "Noise Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_MAGIC, def_sh_tex_magic, "TEX_MAGIC", TexMagic, "Magic Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_MARBLE, def_sh_tex_marble, "TEX_MARBLE", TexMarble, "Marble Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_WAVE, def_sh_tex_wave, "TEX_WAVE", TexWave, "Wave Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_MUSGRAVE, def_sh_tex_musgrave, "TEX_MUSGRAVE", TexMusgrave, "Musgrave Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_STUCCI, def_sh_tex_stucci, "TEX_STUCCI", TexStucci, "Stucci Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TEX_VORONOI", TexVoronoi, "Voronoi Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_WOOD, def_sh_tex_wood, "TEX_WOOD", TexWood, "Wood Texture", "")
DefNode( ShaderNode, SH_NODE_TEX_COORD, 0, "TEX_COORD", TexCoord, "Texture Coordinate", "")
DefNode( CompositorNode, CMP_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "" )

@ -135,7 +135,7 @@ set(SRC
shader/nodes/node_shader_bsdf_velvet.c
shader/nodes/node_shader_emission.c
shader/nodes/node_shader_fresnel.c
shader/nodes/node_shader_blend_weight.c
shader/nodes/node_shader_layer_weight.c
shader/nodes/node_shader_geometry.c
shader/nodes/node_shader_holdout.c
shader/nodes/node_shader_volume_transparent.c
@ -147,20 +147,16 @@ set(SRC
shader/nodes/node_shader_output_material.c
shader/nodes/node_shader_output_texture.c
shader/nodes/node_shader_output_world.c
shader/nodes/node_shader_tex_blend.c
shader/nodes/node_shader_tex_clouds.c
shader/nodes/node_shader_tex_gradient.c
shader/nodes/node_shader_tex_coord.c
shader/nodes/node_shader_tex_distnoise.c
shader/nodes/node_shader_tex_image.c
shader/nodes/node_shader_tex_environment.c
shader/nodes/node_shader_tex_image.c
shader/nodes/node_shader_tex_magic.c
shader/nodes/node_shader_tex_marble.c
shader/nodes/node_shader_tex_musgrave.c
shader/nodes/node_shader_tex_noise.c
shader/nodes/node_shader_tex_sky.c
shader/nodes/node_shader_tex_stucci.c
shader/nodes/node_shader_tex_voronoi.c
shader/nodes/node_shader_tex_wood.c
shader/nodes/node_shader_tex_wave.c
shader/nodes/node_shader_noise.h
shader/node_shader_tree.c
shader/node_shader_util.c

@ -75,7 +75,7 @@ void register_node_type_sh_attribute(ListBase *lb);
void register_node_type_sh_geometry(ListBase *lb);
void register_node_type_sh_light_path(ListBase *lb);
void register_node_type_sh_fresnel(ListBase *lb);
void register_node_type_sh_blend_weight(ListBase *lb);
void register_node_type_sh_layer_weight(ListBase *lb);
void register_node_type_sh_tex_coord(ListBase *lb);
void register_node_type_sh_background(ListBase *lb);
@ -102,15 +102,11 @@ void register_node_type_sh_tex_image(ListBase *lb);
void register_node_type_sh_tex_environment(ListBase *lb);
void register_node_type_sh_tex_sky(ListBase *lb);
void register_node_type_sh_tex_voronoi(ListBase *lb);
void register_node_type_sh_tex_blend(ListBase *lb);
void register_node_type_sh_tex_gradient(ListBase *lb);
void register_node_type_sh_tex_magic(ListBase *lb);
void register_node_type_sh_tex_marble(ListBase *lb);
void register_node_type_sh_tex_clouds(ListBase *lb);
void register_node_type_sh_tex_wood(ListBase *lb);
void register_node_type_sh_tex_wave(ListBase *lb);
void register_node_type_sh_tex_musgrave(ListBase *lb);
void register_node_type_sh_tex_noise(ListBase *lb);
void register_node_type_sh_tex_stucci(ListBase *lb);
void register_node_type_sh_tex_distnoise(ListBase *lb);
#endif

@ -1,5 +1,5 @@
/**
* $Id: node_shader_blend_weight.c 32517 2010-10-16 14:32:17Z campbellbarton $
* $Id: node_shader_layer_weight.c 32517 2010-10-16 14:32:17Z campbellbarton $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@ -29,40 +29,41 @@
#include "../node_shader_util.h"
/* **************** BlendWeight ******************** */
static bNodeSocketTemplate sh_node_blend_weight_in[]= {
/* **************** Layer Weight ******************** */
static bNodeSocketTemplate sh_node_layer_weight_in[]= {
{ SOCK_FLOAT, 1, "Blend", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_blend_weight_out[]= {
static bNodeSocketTemplate sh_node_layer_weight_out[]= {
{ SOCK_FLOAT, 0, "Fresnel", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, "Facing", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static void node_shader_exec_blend_weight(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
static void node_shader_exec_layer_weight(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **UNUSED(in), bNodeStack **UNUSED(out))
{
}
static int node_shader_gpu_blend_weight(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out))
static int node_shader_gpu_layer_weight(GPUMaterial *UNUSED(mat), bNode *UNUSED(node), GPUNodeStack *UNUSED(in), GPUNodeStack *UNUSED(out))
{
return 0;
}
/* node type definition */
void register_node_type_sh_blend_weight(ListBase *lb)
void register_node_type_sh_layer_weight(ListBase *lb)
{
static bNodeType ntype;
node_type_base(&ntype, SH_NODE_BLEND_WEIGHT, "Blend Weight", NODE_CLASS_INPUT, 0);
node_type_base(&ntype, SH_NODE_LAYER_WEIGHT, "Layer Weight", NODE_CLASS_INPUT, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_blend_weight_in, sh_node_blend_weight_out);
node_type_socket_templates(&ntype, sh_node_layer_weight_in, sh_node_layer_weight_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);
node_type_exec(&ntype, node_shader_exec_blend_weight);
node_type_gpu(&ntype, node_shader_gpu_blend_weight);
node_type_exec(&ntype, node_shader_exec_layer_weight);
node_type_gpu(&ntype, node_shader_gpu_layer_weight);
nodeRegisterType(lb, &ntype);
};

@ -444,14 +444,17 @@ MINLINE float noise_wave(int wave, float a)
/* Turbulence */
MINLINE float noise_turbulence(float p[3], int basis, int octaves, int hard)
MINLINE float noise_turbulence(float p[3], int basis, float octaves, int hard)
{
float fscale = 1.0f;
float amp = 1.0f;
float sum = 0.0f;
int i;
float rmd;
int i, n;
for(i = 0; i <= octaves; i++) {
octaves = CLAMPIS(octaves, 0.0f, 16.0f);
for(i = 0; i <= (int)octaves; i++) {
float pscale[3] = {fscale*p[0], fscale*p[1], fscale*p[2]};
float t = noise_basis(pscale, basis);
@ -463,7 +466,28 @@ MINLINE float noise_turbulence(float p[3], int basis, int octaves, int hard)
fscale *= 2.0f;
}
sum *= ((float)(1 << octaves)/(float)((1 << (octaves+1)) - 1));
rmd = octaves - floor(octaves);
if(rmd != 0.0f) {
float pscale[3] = {fscale*p[0], fscale*p[1], fscale*p[2]};
float t = noise_basis(pscale, basis);
float sum2;
if(hard)
t = fabsf(2.0f*t - 1.0f);
sum2 = sum + t*amp;
sum *= ((float)(1 << n)/(float)((1 << (n+1)) - 1));
sum2 *= ((float)(1 << (n+1))/(float)((1 << (n+2)) - 1));
return (1.0f - rmd)*sum + rmd*sum2;
}
else {
sum *= ((float)(1 << n)/(float)((1 << (n+1)) - 1));
return sum;
}
return sum;
}

@ -1,123 +0,0 @@
/**
* $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "../node_shader_util.h"
#include "node_shader_noise.h"
static float clouds(int basis, int hard, int depth, float size, float vec[3], float color[3])
{
float p[3], pg[3], pb[3];
mul_v3_v3fl(p, vec, 1.0f/size);
pg[0]= p[1];
pg[1]= p[0];
pg[2]= p[2];
pb[0]= p[1];
pb[1]= p[2];
pb[2]= p[0];
color[0]= noise_turbulence(p, basis, depth, hard);
color[1]= noise_turbulence(pg, basis, depth, hard);
color[2]= noise_turbulence(pb, basis, depth, hard);
return color[0];
}
/* **************** CLOUDS ******************** */
static bNodeSocketTemplate sh_node_tex_clouds_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_clouds_out[]= {
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static void node_shader_init_tex_clouds(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
{
NodeTexClouds *tex = MEM_callocN(sizeof(NodeTexClouds), "NodeTexClouds");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->basis = SHD_NOISE_PERLIN;
tex->hard = 0;
tex->depth = 2;
node->storage = tex;
}
static void node_shader_exec_tex_clouds(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexClouds *tex= (NodeTexClouds*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], size;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
out[1]->vec[0]= clouds(tex->basis, tex->hard, tex->depth, size, vec, out[0]->vec);
}
static int node_shader_gpu_tex_clouds(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
if(!in[0].link)
in[0].link = GPU_attribute(CD_ORCO, "");
node_shader_gpu_tex_mapping(mat, node, in, out);
return GPU_stack_link(mat, "node_tex_clouds", in, out);
}
/* node type definition */
void register_node_type_sh_tex_clouds(ListBase *lb)
{
static bNodeType ntype;
node_type_base(&ntype, SH_NODE_TEX_CLOUDS, "Clouds Texture", NODE_CLASS_TEXTURE, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_clouds_in, sh_node_tex_clouds_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, node_shader_init_tex_clouds);
node_type_storage(&ntype, "NodeTexClouds", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_clouds);
node_type_gpu(&ntype, node_shader_gpu_tex_clouds);
nodeRegisterType(lb, &ntype);
};

@ -1,120 +0,0 @@
/**
* $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "../node_shader_util.h"
#include "node_shader_noise.h"
static float distorted_noise(float vec[3], float size, int basis, int distortion_basis, float distortion)
{
float p[3], r[3], p_offset[3], p_noffset[3];
float offset[3] = {13.5f, 13.5f, 13.5f};
mul_v3_v3fl(p, vec, 1.0f/size);
add_v3_v3v3(p_offset, p, offset);
sub_v3_v3v3(p_noffset, p, offset);
r[0] = noise_basis(p_offset, basis) * distortion;
r[1] = noise_basis(p, basis) * distortion;
r[2] = noise_basis(p_noffset, basis) * distortion;
add_v3_v3(p, r);
return noise_basis(p, distortion_basis); /* distorted-domain noise */
}
/* **************** OUTPUT ******************** */
static bNodeSocketTemplate sh_node_tex_distnoise_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Size", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Distortion", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_distnoise_out[]= {
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static void node_shader_init_tex_distorted_noise(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
{
NodeTexDistortedNoise *tex = MEM_callocN(sizeof(NodeTexDistortedNoise), "NodeTexDistortedNoise");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->basis = SHD_NOISE_PERLIN;
tex->distortion_basis = SHD_NOISE_PERLIN;
node->storage = tex;
}
static void node_shader_exec_tex_distnoise(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexDistortedNoise *tex= (NodeTexDistortedNoise*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], size, distortion;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
nodestack_get_vec(&distortion, SOCK_FLOAT, in[2]);
out[0]->vec[0]= distorted_noise(vec, size, tex->basis, tex->distortion_basis, distortion);
}
static int node_shader_gpu_tex_distnoise(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
if(!in[0].link)
in[0].link = GPU_attribute(CD_ORCO, "");
node_shader_gpu_tex_mapping(mat, node, in, out);
return GPU_stack_link(mat, "node_tex_distnoise", in, out);
}
/* node type definition */
void register_node_type_sh_tex_distnoise(ListBase *lb)
{
static bNodeType ntype;
node_type_base(&ntype, SH_NODE_TEX_DISTNOISE, "Distorted Noise Texture", NODE_CLASS_TEXTURE, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_distnoise_in, sh_node_tex_distnoise_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, node_shader_init_tex_distorted_noise);
node_type_storage(&ntype, "NodeTexDistortedNoise", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_distnoise);
node_type_gpu(&ntype, node_shader_gpu_tex_distnoise);
nodeRegisterType(lb, &ntype);
};

@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* The Original Code is Copyright (C) 2005 Gradienter Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
@ -29,18 +29,12 @@
#include "../node_shader_util.h"
static float blend(float p[3], int type, int axis)
static float gradient(float p[3], int type)
{
float x, y;
if(axis == SHD_BLEND_VERTICAL) {
x= p[1];
y= p[0];
}
else {
x= p[0];
y= p[1];
}
x= p[0];
y= p[1];
if(type == SHD_BLEND_LINEAR) {
return (1.0f + x)/2.0f;
@ -75,65 +69,71 @@ static float blend(float p[3], int type, int axis)
/* **************** BLEND ******************** */
static bNodeSocketTemplate sh_node_tex_blend_in[]= {
static bNodeSocketTemplate sh_node_tex_gradient_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_blend_out[]= {
static bNodeSocketTemplate sh_node_tex_gradient_out[]= {
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static void node_shader_init_tex_blend(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
static void node_shader_init_tex_gradient(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
{
NodeTexBlend *tex = MEM_callocN(sizeof(NodeTexBlend), "NodeTexBlend");
NodeTexGradient *tex = MEM_callocN(sizeof(NodeTexGradient), "NodeTexGradient");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->progression = SHD_BLEND_LINEAR;
tex->axis = SHD_BLEND_HORIZONTAL;
tex->gradient_type = SHD_BLEND_LINEAR;
node->storage = tex;
}
static void node_shader_exec_tex_blend(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
static void node_shader_exec_tex_gradient(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexBlend *tex= (NodeTexBlend*)node->storage;
NodeTexGradient *tex= (NodeTexGradient*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3];
float vec[3], fac;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
out[0]->vec[0]= blend(vec, tex->progression, tex->axis);
fac= gradient(vec, tex->gradient_type);
CLAMP(fac, 0.0f, 1.0f);
out[0]->vec[0]= fac;
out[0]->vec[1]= fac;
out[0]->vec[2]= fac;
out[1]->vec[0]= fac;
}
static int node_shader_gpu_tex_blend(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
static int node_shader_gpu_tex_gradient(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
if(!in[0].link)
in[0].link = GPU_attribute(CD_ORCO, "");
node_shader_gpu_tex_mapping(mat, node, in, out);
return GPU_stack_link(mat, "node_tex_blend", in, out);
return GPU_stack_link(mat, "node_tex_gradient", in, out);
}
/* node type definition */
void register_node_type_sh_tex_blend(ListBase *lb)
void register_node_type_sh_tex_gradient(ListBase *lb)
{
static bNodeType ntype;
node_type_base(&ntype, SH_NODE_TEX_BLEND, "Blend Texture", NODE_CLASS_TEXTURE, 0);
node_type_base(&ntype, SH_NODE_TEX_GRADIENT, "Gradient Texture", NODE_CLASS_TEXTURE, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_blend_in, sh_node_tex_blend_out);
node_type_socket_templates(&ntype, sh_node_tex_gradient_in, sh_node_tex_gradient_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, node_shader_init_tex_blend);
node_type_storage(&ntype, "NodeTexBlend", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_blend);
node_type_gpu(&ntype, node_shader_gpu_tex_blend);
node_type_init(&ntype, node_shader_init_tex_gradient);
node_type_storage(&ntype, "NodeTexGradient", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_gradient);
node_type_gpu(&ntype, node_shader_gpu_tex_gradient);
nodeRegisterType(lb, &ntype);
};

@ -29,56 +29,54 @@
#include "../node_shader_util.h"
static void magic(float rgb[3], float p[3], int n, float turbulence)
static void magic(float rgb[3], float p[3], int n, float distortion)
{
float turb = turbulence/5.0f;
float x = sinf((p[0] + p[1] + p[2])*5.0f);
float y = cosf((-p[0] + p[1] - p[2])*5.0f);
float z = -cosf((-p[0] - p[1] + p[2])*5.0f);
if(n > 0) {
x *= turb;
y *= turb;
z *= turb;
x *= distortion;
y *= distortion;
z *= distortion;
y = -cosf(x-y+z);
y *= turb;
y *= distortion;
if(n > 1) {
x= cosf(x-y-z);
x *= turb;
x *= distortion;
if(n > 2) {
z= sinf(-x-y-z);
z *= turb;
z *= distortion;
if(n > 3) {
x= -cosf(-x+y-z);
x *= turb;
x *= distortion;
if(n > 4) {
y= -sinf(-x+y+z);
y *= turb;
y *= distortion;
if(n > 5) {
y= -cosf(-x+y+z);
y *= turb;
y *= distortion;
if(n > 6) {
x= cosf(x+y+z);
x *= turb;
x *= distortion;
if(n > 7) {
z= sinf(x+y-z);
z *= turb;
z *= distortion;
if(n > 8) {
x= -cosf(-x-y+z);
x *= turb;
x *= distortion;
if(n > 9) {
y= -sinf(x-y+z);
y *= turb;
y *= distortion;
}
}
}
@ -90,11 +88,11 @@ static void magic(float rgb[3], float p[3], int n, float turbulence)
}
}
if(turb != 0.0f) {
turb *= 2.0f;
x /= turb;
y /= turb;
z /= turb;
if(distortion != 0.0f) {
distortion *= 2.0f;
x /= distortion;
y /= distortion;
z /= distortion;
}
rgb[0]= 0.5f - x;
@ -106,12 +104,14 @@ static void magic(float rgb[3], float p[3], int n, float turbulence)
static bNodeSocketTemplate sh_node_tex_magic_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Distortion", 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_magic_out[]= {
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
@ -130,16 +130,17 @@ static void node_shader_exec_tex_magic(void *data, bNode *node, bNodeStack **in,
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexMagic *tex= (NodeTexMagic*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], turbulence;
float vec[3], distortion;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&turbulence, SOCK_FLOAT, in[1]);
nodestack_get_vec(&distortion, SOCK_FLOAT, in[1]);
magic(out[0]->vec, vec, tex->depth, turbulence);
magic(out[0]->vec, vec, tex->depth, distortion);
out[1]->vec[0] = (out[0]->vec[0] + out[0]->vec[1] + out[0]->vec[2])*(1.0f/3.0f);
}
static int node_shader_gpu_tex_magic(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)

@ -1,128 +0,0 @@
/**
* $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "../node_shader_util.h"
#include "node_shader_noise.h"
static float marble(float vec[3], float size, int type, int wave, int basis, int hard, float turb, int depth)
{
float p[3];
float x = vec[0];
float y = vec[1];
float z = vec[2];
float n = 5.0f * (x + y + z);
float mi;
mul_v3_v3fl(p, vec, 1.0f/size);
mi = n + turb * noise_turbulence(p, basis, depth, hard);
mi = noise_wave(wave, mi);
if(type == SHD_MARBLE_SHARP)
mi = sqrt(mi);
else if(type == SHD_MARBLE_SHARPER)
mi = sqrt(sqrt(mi));
return mi;
}
/* **************** MARBLE ******************** */
static bNodeSocketTemplate sh_node_tex_marble_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_marble_out[]= {
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static void node_shader_init_tex_marble(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
{
NodeTexMarble *tex = MEM_callocN(sizeof(NodeTexMarble), "NodeTexMarble");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->type = SHD_MARBLE_SOFT;
tex->wave = SHD_WAVE_SINE;
tex->basis = SHD_NOISE_PERLIN;
tex->hard = 0;
tex->depth = 2;
node->storage = tex;
}
static void node_shader_exec_tex_marble(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexMarble *tex= (NodeTexMarble*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], size, turbulence;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]);
out[0]->vec[0]= marble(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence, tex->depth);
}
static int node_shader_gpu_tex_marble(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
if(!in[0].link)
in[0].link = GPU_attribute(CD_ORCO, "");
node_shader_gpu_tex_mapping(mat, node, in, out);
return GPU_stack_link(mat, "node_tex_marble", in, out);
}
/* node type definition */
void register_node_type_sh_tex_marble(ListBase *lb)
{
static bNodeType ntype;
node_type_base(&ntype, SH_NODE_TEX_MARBLE, "Marble Texture", NODE_CLASS_TEXTURE, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_marble_in, sh_node_tex_marble_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, node_shader_init_tex_marble);
node_type_storage(&ntype, "NodeTexMarble", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_marble);
node_type_gpu(&ntype, node_shader_gpu_tex_marble);
nodeRegisterType(lb, &ntype);
};

@ -34,12 +34,12 @@
*
* H: fractal increment parameter
* lacunarity: gap between successive frequencies
* octaves: number of frequencies in the fBm
* detail: number of frequencies in the fBm
*
* from "Texturing and Modelling: A procedural approach"
*/
static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity, float octaves)
static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity, float detail)
{
float rmd;
float value = 0.0f;
@ -47,13 +47,13 @@ static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity
float pwHL = pow(lacunarity, -H);
int i;
for(i = 0; i < (int)octaves; i++) {
for(i = 0; i < (int)detail; i++) {
value += noise_basis(p, basis) * pwr;
pwr *= pwHL;
mul_v3_fl(p, lacunarity);
}
rmd = octaves - floor(octaves);
rmd = detail - floor(detail);
if(rmd != 0.0f)
value += rmd * noise_basis(p, basis) * pwr;
@ -64,10 +64,10 @@ static float noise_musgrave_fBm(float p[3], int basis, float H, float lacunarity
*
* H: highest fractal dimension
* lacunarity: gap between successive frequencies
* octaves: number of frequencies in the fBm
* detail: number of frequencies in the fBm
*/
static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves)
static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float lacunarity, float detail)
{
float rmd;
float value = 1.0f;
@ -75,13 +75,13 @@ static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float
float pwHL = pow(lacunarity, -H);
int i;
for(i = 0; i < (int)octaves; i++) {
for(i = 0; i < (int)detail; i++) {
value *= (pwr * noise_basis(p, basis) + 1.0f);
pwr *= pwHL;
mul_v3_fl(p, lacunarity);
}
rmd = octaves - floor(octaves);
rmd = detail - floor(detail);
if(rmd != 0.0f)
value *= (rmd * pwr * noise_basis(p, basis) + 1.0f); /* correct? */
@ -92,29 +92,29 @@ static float noise_musgrave_multi_fractal(float p[3], int basis, float H, float
*
* H: fractal dimension of the roughest area
* lacunarity: gap between successive frequencies
* octaves: number of frequencies in the fBm
* detail: number of frequencies in the fBm
* offset: raises the terrain from `sea level'
*/
static float noise_musgrave_hetero_terrain(float p[3], int basis, float H, float lacunarity, float octaves, float offset)
static float noise_musgrave_hetero_terrain(float p[3], int basis, float H, float lacunarity, float detail, float offset)
{
float value, increment, rmd;
float pwHL = pow(lacunarity, -H);
float pwr = pwHL;
int i;
/* first unscaled octave of function; later octaves are scaled */
/* first unscaled octave of function; later detail are scaled */
value = offset + noise_basis(p, basis);
mul_v3_fl(p, lacunarity);
for(i = 1; i < (int)octaves; i++) {
for(i = 1; i < (int)detail; i++) {
increment = (noise_basis(p, basis) + offset) * pwr * value;
value += increment;
pwr *= pwHL;
mul_v3_fl(p, lacunarity);
}
rmd = octaves - floor(octaves);
rmd = detail - floor(detail);
if(rmd != 0.0f) {
increment = (noise_basis(p, basis) + offset) * pwr * value;
value += rmd * increment;
@ -127,11 +127,11 @@ static float noise_musgrave_hetero_terrain(float p[3], int basis, float H, float
*
* H: fractal dimension of the roughest area
* lacunarity: gap between successive frequencies
* octaves: number of frequencies in the fBm
* detail: number of frequencies in the fBm
* offset: raises the terrain from `sea level'
*/
static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves, float offset, float gain)
static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H, float lacunarity, float detail, float offset, float gain)
{
float result, signal, weight, rmd;
float pwHL = pow(lacunarity, -H);
@ -142,7 +142,7 @@ static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H,
weight = gain * result;
mul_v3_fl(p, lacunarity);
for(i = 1; (weight > 0.001f) && (i < (int)octaves); i++) {
for(i = 1; (weight > 0.001f) && (i < (int)detail); i++) {
if(weight > 1.0f)
weight = 1.0f;
@ -153,7 +153,7 @@ static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H,
mul_v3_fl(p, lacunarity);
}
rmd = octaves - floor(octaves);
rmd = detail - floor(detail);
if(rmd != 0.0f)
result += rmd * ((noise_basis(p, basis) + offset) * pwr);
@ -164,11 +164,11 @@ static float noise_musgrave_hybrid_multi_fractal(float p[3], int basis, float H,
*
* H: fractal dimension of the roughest area
* lacunarity: gap between successive frequencies
* octaves: number of frequencies in the fBm
* detail: number of frequencies in the fBm
* offset: raises the terrain from `sea level'
*/
static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H, float lacunarity, float octaves, float offset, float gain)
static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H, float lacunarity, float detail, float offset, float gain)
{
float result, signal, weight;
float pwHL = pow(lacunarity, -H);
@ -180,7 +180,7 @@ static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H,
result = signal;
weight = 1.0f;
for(i = 1; i < (int)octaves; i++) {
for(i = 1; i < (int)detail; i++) {
mul_v3_fl(p, lacunarity);
weight = CLAMPIS(signal * gain, 0.0f, 1.0f);
signal = offset - fabsf(noise_basis(p, basis));
@ -193,22 +193,23 @@ static float noise_musgrave_ridged_multi_fractal(float p[3], int basis, float H,
return result;
}
static float musgrave(int type, int basis, float dimension, float lacunarity, float octaves, float offset, float intensity, float gain, float size, float vec[3])
static float musgrave(int type, float dimension, float lacunarity, float detail, float offset, float intensity, float gain, float scale, float vec[3])
{
float p[3];
int basis = SHD_NOISE_PERLIN;
mul_v3_v3fl(p, vec, 1.0f/size);
mul_v3_v3fl(p, vec, scale);
if(type == SHD_MUSGRAVE_MULTIFRACTAL)
return intensity*noise_musgrave_multi_fractal(p, basis, dimension, lacunarity, octaves);
return intensity*noise_musgrave_multi_fractal(p, basis, dimension, lacunarity, detail);
else if(type == SHD_MUSGRAVE_FBM)
return intensity*noise_musgrave_fBm(p, basis, dimension, lacunarity, octaves);
return intensity*noise_musgrave_fBm(p, basis, dimension, lacunarity, detail);
else if(type == SHD_MUSGRAVE_HYBRID_MULTIFRACTAL)
return intensity*noise_musgrave_hybrid_multi_fractal(p, basis, dimension, lacunarity, octaves, offset, gain);
return intensity*noise_musgrave_hybrid_multi_fractal(p, basis, dimension, lacunarity, detail, offset, gain);
else if(type == SHD_MUSGRAVE_RIDGED_MULTIFRACTAL)
return intensity*noise_musgrave_ridged_multi_fractal(p, basis, dimension, lacunarity, octaves, offset, gain);
return intensity*noise_musgrave_ridged_multi_fractal(p, basis, dimension, lacunarity, detail, offset, gain);
else if(type == SHD_MUSGRAVE_HETERO_TERRAIN)
return intensity*noise_musgrave_hetero_terrain(p, basis, dimension, lacunarity, octaves, offset);
return intensity*noise_musgrave_hetero_terrain(p, basis, dimension, lacunarity, detail, offset);
return 0.0f;
}
@ -217,16 +218,17 @@ static float musgrave(int type, int basis, float dimension, float lacunarity, fl
static bNodeSocketTemplate sh_node_tex_musgrave_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Detail", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f},
{ SOCK_FLOAT, 1, "Dimension", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Lacunarity", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Octaves", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Offset", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Offset", 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Gain", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_musgrave_out[]= {
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
@ -236,8 +238,7 @@ static void node_shader_init_tex_musgrave(bNodeTree *UNUSED(ntree), bNode* node,
NodeTexMusgrave *tex = MEM_callocN(sizeof(NodeTexMusgrave), "NodeTexMusgrave");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->type = SHD_MUSGRAVE_FBM;
tex->basis = SHD_NOISE_PERLIN;
tex->musgrave_type = SHD_MUSGRAVE_FBM;
node->storage = tex;
}
@ -247,21 +248,25 @@ static void node_shader_exec_tex_musgrave(void *data, bNode *node, bNodeStack **
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexMusgrave *tex= (NodeTexMusgrave*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], size, dimension, lacunarity, octaves, offset, gain;
float vec[3], fac, scale, dimension, lacunarity, detail, offset, gain;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
nodestack_get_vec(&dimension, SOCK_FLOAT, in[2]);
nodestack_get_vec(&lacunarity, SOCK_FLOAT, in[3]);
nodestack_get_vec(&octaves, SOCK_FLOAT, in[4]);
nodestack_get_vec(&scale, SOCK_FLOAT, in[1]);
nodestack_get_vec(&detail, SOCK_FLOAT, in[2]);
nodestack_get_vec(&dimension, SOCK_FLOAT, in[3]);
nodestack_get_vec(&lacunarity, SOCK_FLOAT, in[4]);
nodestack_get_vec(&offset, SOCK_FLOAT, in[5]);
nodestack_get_vec(&gain, SOCK_FLOAT, in[6]);
out[0]->vec[0]= musgrave(tex->type, tex->basis, dimension, lacunarity, octaves, offset, 1.0f, gain, size, vec);
fac= musgrave(tex->musgrave_type, dimension, lacunarity, detail, offset, 1.0f, gain, scale, vec);
out[0]->vec[0]= fac;
out[0]->vec[1]= fac;
out[0]->vec[2]= fac;
out[1]->vec[0]= fac;
}
static int node_shader_gpu_tex_musgrave(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)

@ -30,26 +30,49 @@
#include "../node_shader_util.h"
#include "node_shader_noise.h"
static float noise_texture_value(float vec[3])
static float noise_texture(float scale, float detail, float distortion, float vec[3], float color[3])
{
float p[3];
float p[3], pg[3], pb[3];
int basis= SHD_NOISE_PERLIN;
mul_v3_v3fl(p, vec, 1e8f);
return cellnoise(p);
}
mul_v3_v3fl(p, vec, scale);
static void noise_texture_color(float rgb[3], float vec[3])
{
float p[3];
if(distortion != 0.0f) {
float r[3], p_offset[3], p_noffset[3];
float offset[3] = {13.5f, 13.5f, 13.5f};
mul_v3_v3fl(p, vec, 1e8f);
cellnoise_color(rgb, p);
add_v3_v3v3(p_offset, p, offset);
sub_v3_v3v3(p_noffset, p, offset);
r[0] = noise_basis(p_offset, basis) * distortion;
r[1] = noise_basis(p, basis) * distortion;
r[2] = noise_basis(p_noffset, basis) * distortion;
add_v3_v3(p, r);
}
pg[0]= p[1];
pg[1]= p[0];
pg[2]= p[2];
pb[0]= p[1];
pb[1]= p[2];
pb[2]= p[0];
color[0]= noise_turbulence(p, basis, detail, 0);
color[1]= noise_turbulence(pg, basis, detail, 0);
color[2]= noise_turbulence(pb, basis, detail, 0);
return color[0];
}
/* **************** NOISE ******************** */
static bNodeSocketTemplate sh_node_tex_noise_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Detail", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f},
{ SOCK_FLOAT, 1, "Distortion", 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ -1, 0, "" }
};
@ -72,15 +95,18 @@ static void node_shader_exec_tex_noise(void *data, bNode *node, bNodeStack **in,
{
ShaderCallData *scd= (ShaderCallData*)data;
bNodeSocket *vecsock = node->inputs.first;
float vec[3];
float vec[3], scale, detail, distortion;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
noise_texture_color(out[0]->vec, vec);
out[1]->vec[0]= noise_texture_value(vec);
nodestack_get_vec(&scale, SOCK_FLOAT, in[1]);
nodestack_get_vec(&detail, SOCK_FLOAT, in[2]);
nodestack_get_vec(&distortion, SOCK_FLOAT, in[3]);
out[1]->vec[0]= noise_texture(scale, detail, distortion, vec, out[0]->vec);
}
static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
@ -103,7 +129,7 @@ void register_node_type_sh_tex_noise(ListBase *lb)
node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, node_shader_init_tex_noise);
node_type_storage(&ntype, "", NULL, NULL);
node_type_storage(&ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_noise);
node_type_gpu(&ntype, node_shader_gpu_tex_noise);

@ -1,123 +0,0 @@
/**
* $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "../node_shader_util.h"
#include "node_shader_noise.h"
static float stucci(int type, int basis, int hard, float turbulence, float size, float vec[3])
{
float p[3], b2, ofs, r;
mul_v3_v3fl(p, vec, 1.0f/size);
b2 = noise_basis_hard(p, basis, hard);
ofs = turbulence/200.0f;
if(type != SHD_STUCCI_PLASTIC)
ofs *= b2*b2;
p[2] += ofs;
r = noise_basis_hard(p, basis, hard);
if(type == SHD_STUCCI_WALL_OUT)
r = 1.0f - r;
return MAX2(r, 0.0f);
}
/* **************** STUCCI ******************** */
static bNodeSocketTemplate sh_node_tex_stucci_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Size", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Turbulence", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_stucci_out[]= {
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static void node_shader_init_tex_stucci(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
{
NodeTexStucci *tex = MEM_callocN(sizeof(NodeTexStucci), "NodeTexStucci");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->type = SHD_STUCCI_PLASTIC;
tex->basis = SHD_NOISE_PERLIN;
tex->hard = 0;
node->storage = tex;
}
static void node_shader_exec_tex_stucci(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexStucci *tex= (NodeTexStucci*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], size, turbulence;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]);
out[0]->vec[0]= stucci(tex->type, tex->basis, tex->hard, turbulence, size, vec);
}
static int node_shader_gpu_tex_stucci(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
if(!in[0].link)
in[0].link = GPU_attribute(CD_ORCO, "");
node_shader_gpu_tex_mapping(mat, node, in, out);
return GPU_stack_link(mat, "node_tex_stucci", in, out);
}
/* node type definition */
void register_node_type_sh_tex_stucci(ListBase *lb)
{
static bNodeType ntype;
node_type_base(&ntype, SH_NODE_TEX_STUCCI, "Stucci Texture", NODE_CLASS_TEXTURE, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_stucci_in, sh_node_tex_stucci_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, node_shader_init_tex_stucci);
node_type_storage(&ntype, "NodeTexStucci", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_stucci);
node_type_gpu(&ntype, node_shader_gpu_tex_stucci);
nodeRegisterType(lb, &ntype);
};

@ -30,58 +30,25 @@
#include "../node_shader_util.h"
#include "node_shader_noise.h"
static float voronoi_tex(int distance_metric, int coloring,
float weight1, float weight2, float weight3, float weight4,
float exponent, float intensity, float size, float vec[3], float color[3])
static float voronoi_tex(int coloring, float scale, float vec[3], float color[3])
{
float aw1 = fabsf(weight1);
float aw2 = fabsf(weight2);
float aw3 = fabsf(weight3);
float aw4 = fabsf(weight4);
float sc = (aw1 + aw2 + aw3 + aw4);
float da[4];
float pa[4][3];
float fac;
float p[3];
if(sc != 0.0f)
sc = intensity/sc;
/* compute distance and point coordinate of 4 nearest neighbours */
mul_v3_v3fl(p, vec, 1.0f/size);
voronoi_generic(p, distance_metric, exponent, da, pa);
mul_v3_v3fl(p, vec, scale);
voronoi_generic(p, SHD_VORONOI_DISTANCE_SQUARED, 1.0f, da, pa);
/* Scalar output */
fac = sc * fabsf(weight1*da[0] + weight2*da[1] + weight3*da[2] + weight4*da[3]);
/* colored output */
/* output */
if(coloring == SHD_VORONOI_INTENSITY) {
fac = fabsf(da[0]);
color[0]= color[1]= color[2]= fac;
}
else {
float rgb1[3], rgb2[3], rgb3[3], rgb4[3];
cellnoise_color(rgb1, pa[0]);
cellnoise_color(rgb2, pa[1]);
cellnoise_color(rgb3, pa[2]);
cellnoise_color(rgb4, pa[3]);
mul_v3_v3fl(color, rgb1, aw1);
madd_v3_v3fl(color, rgb2, aw2);
madd_v3_v3fl(color, rgb3, aw3);
madd_v3_v3fl(color, rgb4, aw4);
if(coloring != SHD_VORONOI_POSITION) {
float t1 = MIN2((da[1] - da[0])*10.0f, 1.0f);
if(coloring == SHD_VORONOI_POSITION_OUTLINE_INTENSITY)
mul_v3_fl(color, t1*fac);
else if(coloring == SHD_VORONOI_POSITION_OUTLINE)
mul_v3_fl(color, t1*sc);
}
else {
mul_v3_fl(color, sc);
}
cellnoise_color(color, pa[0]);
fac= (color[0] + color[1] + color[2])*(1.0f/3.0f);
}
return fac;
@ -91,12 +58,7 @@ static float voronoi_tex(int distance_metric, int coloring,
static bNodeSocketTemplate sh_node_tex_voronoi_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Weight1", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
{ SOCK_FLOAT, 1, "Weight2", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
{ SOCK_FLOAT, 1, "Weight3", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
{ SOCK_FLOAT, 1, "Weight4", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
{ SOCK_FLOAT, 1, "Exponent", 2.5f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
{ SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ -1, 0, "" }
};
@ -111,7 +73,6 @@ static void node_shader_init_tex_voronoi(bNodeTree *UNUSED(ntree), bNode* node,
NodeTexVoronoi *tex = MEM_callocN(sizeof(NodeTexVoronoi), "NodeTexVoronoi");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->distance_metric = SHD_VORONOI_ACTUAL_DISTANCE;
tex->coloring = SHD_VORONOI_INTENSITY;
node->storage = tex;
@ -122,22 +83,16 @@ static void node_shader_exec_tex_voronoi(void *data, bNode *node, bNodeStack **i
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexVoronoi *tex= (NodeTexVoronoi*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], size, w1, w2, w3, w4, exponent;
float vec[3], scale;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
nodestack_get_vec(&w1, SOCK_FLOAT, in[2]);
nodestack_get_vec(&w2, SOCK_FLOAT, in[3]);
nodestack_get_vec(&w3, SOCK_FLOAT, in[4]);
nodestack_get_vec(&w4, SOCK_FLOAT, in[5]);
nodestack_get_vec(&exponent, SOCK_FLOAT, in[6]);
nodestack_get_vec(&scale, SOCK_FLOAT, in[1]);
out[1]->vec[0]= voronoi_tex(tex->distance_metric, tex->coloring, w1, w2, w3, w4,
exponent, 1.0f, size, vec, out[0]->vec);
out[1]->vec[0]= voronoi_tex(tex->coloring, scale, vec, out[0]->vec);
}
static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)

@ -0,0 +1,129 @@
/**
* $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "../node_shader_util.h"
#include "node_shader_noise.h"
static float wave(float vec[3], float scale, int type, float distortion, float detail)
{
float p[3], w, n;
mul_v3_v3fl(p, vec, scale);
if(type == SHD_WAVE_BANDS)
n= (p[0] + p[1] + p[2])*10.0f;
else /* if(type == SHD_WAVE_RINGS) */
n= len_v3(p)*20.0f;
w = noise_wave(SHD_WAVE_SINE, n);
/* XXX size compare! */
if(distortion != 0.0f)
w += distortion * noise_turbulence(p, SHD_NOISE_PERLIN, detail, 0);
return w;
}
/* **************** WAVE ******************** */
static bNodeSocketTemplate sh_node_tex_wave_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Scale", 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Distortion", 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Detail", 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f},
{ SOCK_FLOAT, 1, "Detail Scale", 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_wave_out[]= {
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static void node_shader_init_tex_wave(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
{
NodeTexWave *tex = MEM_callocN(sizeof(NodeTexWave), "NodeTexWave");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->wave_type = SHD_WAVE_BANDS;
node->storage = tex;
}
static void node_shader_exec_tex_wave(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexWave *tex= (NodeTexWave*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], scale, detail, distortion, fac;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&scale, SOCK_FLOAT, in[1]);
nodestack_get_vec(&detail, SOCK_FLOAT, in[1]);
nodestack_get_vec(&distortion, SOCK_FLOAT, in[2]);
fac= wave(vec, scale, tex->wave_type, distortion, detail);
out[0]->vec[0]= fac;
out[0]->vec[1]= fac;
out[0]->vec[2]= fac;
out[1]->vec[0]= fac;
}
static int node_shader_gpu_tex_wave(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
if(!in[0].link)
in[0].link = GPU_attribute(CD_ORCO, "");
node_shader_gpu_tex_mapping(mat, node, in, out);
return GPU_stack_link(mat, "node_tex_wave", in, out);
}
/* node type definition */
void register_node_type_sh_tex_wave(ListBase *lb)
{
static bNodeType ntype;
node_type_base(&ntype, SH_NODE_TEX_WAVE, "Wave Texture", NODE_CLASS_TEXTURE, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_wave_in, sh_node_tex_wave_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, node_shader_init_tex_wave);
node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_wave);
node_type_gpu(&ntype, node_shader_gpu_tex_wave);
nodeRegisterType(lb, &ntype);
}

@ -1,130 +0,0 @@
/**
* $Id: node_shader_output.c 32517 2010-10-16 14:32:17Z campbellbarton $
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* 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.
*
* The Original Code is Copyright (C) 2005 Blender Foundation.
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "../node_shader_util.h"
#include "node_shader_noise.h"
static float wood(float p[3], float size, int type, int wave, int basis, unsigned int hard, float turb)
{
float x = p[0];
float y = p[1];
float z = p[2];
if(type == SHD_WOOD_BANDS) {
return noise_wave(wave, (x + y + z)*10.0f);
}
else if(type == SHD_WOOD_RINGS) {
return noise_wave(wave, sqrt(x*x + y*y + z*z)*20.0f);
}
else if (type == SHD_WOOD_BAND_NOISE) {
float psize[3] = {p[0]/size, p[1]/size, p[2]/size};
float wi = turb*noise_basis_hard(psize, basis, hard);
return noise_wave(wave, (x + y + z)*10.0f + wi);
}
else if (type == SHD_WOOD_RING_NOISE) {
float psize[3] = {p[0]/size, p[1]/size, p[2]/size};
float wi = turb*noise_basis_hard(psize, basis, hard);
return noise_wave(wave, sqrt(x*x + y*y + z*z)*20.0f + wi);
}
return 0.0f;
}
/* **************** WOOD ******************** */
static bNodeSocketTemplate sh_node_tex_wood_in[]= {
{ SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
{ SOCK_FLOAT, 1, "Size", 0.25f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ SOCK_FLOAT, 1, "Turbulence", 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
{ -1, 0, "" }
};
static bNodeSocketTemplate sh_node_tex_wood_out[]= {
{ SOCK_FLOAT, 0, "Fac", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
static void node_shader_init_tex_wood(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
{
NodeTexWood *tex = MEM_callocN(sizeof(NodeTexWood), "NodeTexWood");
default_tex_mapping(&tex->base.tex_mapping);
default_color_mapping(&tex->base.color_mapping);
tex->type = SHD_WOOD_BANDS;
tex->wave = SHD_WAVE_SINE;
tex->basis = SHD_NOISE_PERLIN;
tex->hard = 0;
node->storage = tex;
}
static void node_shader_exec_tex_wood(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
ShaderCallData *scd= (ShaderCallData*)data;
NodeTexWood *tex= (NodeTexWood*)node->storage;
bNodeSocket *vecsock = node->inputs.first;
float vec[3], size, turbulence;
if(vecsock->link)
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
else
copy_v3_v3(vec, scd->co);
nodestack_get_vec(&size, SOCK_FLOAT, in[1]);
nodestack_get_vec(&turbulence, SOCK_FLOAT, in[2]);
out[0]->vec[0]= wood(vec, size, tex->type, tex->wave, tex->basis, tex->hard, turbulence);
}
static int node_shader_gpu_tex_wood(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
{
if(!in[0].link)
in[0].link = GPU_attribute(CD_ORCO, "");
node_shader_gpu_tex_mapping(mat, node, in, out);
return GPU_stack_link(mat, "node_tex_wood", in, out);
}
/* node type definition */
void register_node_type_sh_tex_wood(ListBase *lb)
{
static bNodeType ntype;
node_type_base(&ntype, SH_NODE_TEX_WOOD, "Wood Texture", NODE_CLASS_TEXTURE, 0);
node_type_compatibility(&ntype, NODE_NEW_SHADING);
node_type_socket_templates(&ntype, sh_node_tex_wood_in, sh_node_tex_wood_out);
node_type_size(&ntype, 150, 60, 200);
node_type_init(&ntype, node_shader_init_tex_wood);
node_type_storage(&ntype, "NodeTexWood", node_free_standard_storage, node_copy_standard_storage);
node_type_exec(&ntype, node_shader_exec_tex_wood);
node_type_gpu(&ntype, node_shader_gpu_tex_wood);
nodeRegisterType(lb, &ntype);
};