diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-05-29 13:24:47 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2016-06-08 22:45:40 +0300 |
commit | 693b15f553799ce8744f148639eca954b48a9600 (patch) | |
tree | ec821e6c5b67e12e9466f7d259a7d18b7ee2fc77 | |
parent | 0ca2f554c4fa597222ef8dec0ffde75958b506e0 (diff) |
Code refactor: add separate RGB to BW node and rename some sockets.
23 files changed, 199 insertions, 148 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 346fe0ca6c4..7aa099e9e2b 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -339,7 +339,7 @@ static ShaderNode *add_node(Scene *scene, node = new HSVNode(); } else if(b_node.is_a(&RNA_ShaderNodeRGBToBW)) { - node = new ConvertNode(SocketType::COLOR, SocketType::FLOAT); + node = new RGBToBWNode(); } else if(b_node.is_a(&RNA_ShaderNodeMath)) { BL::ShaderNodeMath b_math_node(b_node); diff --git a/intern/cycles/kernel/shaders/node_brick_texture.osl b/intern/cycles/kernel/shaders/node_brick_texture.osl index 35e01178ba8..d5e0a7d4c8c 100644 --- a/intern/cycles/kernel/shaders/node_brick_texture.osl +++ b/intern/cycles/kernel/shaders/node_brick_texture.osl @@ -59,10 +59,10 @@ float brick(point p, float mortar_size, float bias, shader node_brick_texture( int use_mapping = 0, matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - float Offset = 0.5, - int OffsetFrequency = 2, - float Squash = 1.0, - int SquashFrequency = 1, + float offset = 0.5, + int offset_frequency = 2, + float squash = 1.0, + int squash_frequency = 1, point Vector = P, color Color1 = 0.2, color Color2 = 0.8, @@ -84,7 +84,7 @@ shader node_brick_texture( color Col = Color1; Fac = brick(p * Scale, MortarSize, Bias, BrickWidth, RowHeight, - Offset, OffsetFrequency, Squash, SquashFrequency, tint); + offset, offset_frequency, squash, squash_frequency, tint); if (Fac != 1.0) { float facm = 1.0 - tint; diff --git a/intern/cycles/kernel/shaders/node_convert_from_color.osl b/intern/cycles/kernel/shaders/node_convert_from_color.osl index 44074317f42..e95a17f6fa1 100644 --- a/intern/cycles/kernel/shaders/node_convert_from_color.osl +++ b/intern/cycles/kernel/shaders/node_convert_from_color.osl @@ -17,18 +17,18 @@ #include "stdosl.h" shader node_convert_from_color( - color Color = 0.0, - output string String = "", - output float Val = 0.0, - output int ValInt = 0, - output vector Vector = vector(0.0, 0.0, 0.0), - output point Point = point(0.0, 0.0, 0.0), - output normal Normal = normal(0.0, 0.0, 0.0)) + color value_color = 0.0, + output string value_string = "", + output float value_float = 0.0, + output int value_int = 0, + output vector value_vector = vector(0.0, 0.0, 0.0), + output point value_point = point(0.0, 0.0, 0.0), + output normal value_normal = normal(0.0, 0.0, 0.0)) { - Val = Color[0] * 0.2126 + Color[1] * 0.7152 + Color[2] * 0.0722; - ValInt = (int)(Color[0] * 0.2126 + Color[1] * 0.7152 + Color[2] * 0.0722); - Vector = vector(Color[0], Color[1], Color[2]); - Point = point(Color[0], Color[1], Color[2]); - Normal = normal(Color[0], Color[1], Color[2]); + value_float = value_color[0] * 0.2126 + value_color[1] * 0.7152 + value_color[2] * 0.0722; + value_int = (int)(value_color[0] * 0.2126 + value_color[1] * 0.7152 + value_color[2] * 0.0722); + value_vector = vector(value_color[0], value_color[1], value_color[2]); + value_point = point(value_color[0], value_color[1], value_color[2]); + value_normal = normal(value_color[0], value_color[1], value_color[2]); } diff --git a/intern/cycles/kernel/shaders/node_convert_from_float.osl b/intern/cycles/kernel/shaders/node_convert_from_float.osl index fc5c79c4c64..a5c2e3b26ad 100644 --- a/intern/cycles/kernel/shaders/node_convert_from_float.osl +++ b/intern/cycles/kernel/shaders/node_convert_from_float.osl @@ -17,18 +17,18 @@ #include "stdosl.h" shader node_convert_from_float( - float Val = 0.0, - output string String = "", - output int ValInt = 0, - output color Color = 0.0, - output vector Vector = vector(0.0, 0.0, 0.0), - output point Point = point(0.0, 0.0, 0.0), - output normal Normal = normal(0.0, 0.0, 0.0)) + float value_float = 0.0, + output string value_string = "", + output int value_int = 0, + output color value_color = 0.0, + output vector value_vector = vector(0.0, 0.0, 0.0), + output point value_point = point(0.0, 0.0, 0.0), + output normal value_normal = normal(0.0, 0.0, 0.0)) { - ValInt = (int)Val; - Color = color(Val, Val, Val); - Vector = vector(Val, Val, Val); - Point = point(Val, Val, Val); - Normal = normal(Val, Val, Val); + value_int = (int)value_float; + value_color = color(value_float, value_float, value_float); + value_vector = vector(value_float, value_float, value_float); + value_point = point(value_float, value_float, value_float); + value_normal = normal(value_float, value_float, value_float); } diff --git a/intern/cycles/kernel/shaders/node_convert_from_int.osl b/intern/cycles/kernel/shaders/node_convert_from_int.osl index 3c3785ebc0d..0e6ae711210 100644 --- a/intern/cycles/kernel/shaders/node_convert_from_int.osl +++ b/intern/cycles/kernel/shaders/node_convert_from_int.osl @@ -17,19 +17,19 @@ #include "stdosl.h" shader node_convert_from_int( - int ValInt = 0, - output string String = "", - output float Val = 0.0, - output color Color = 0.0, - output vector Vector = vector(0.0, 0.0, 0.0), - output point Point = point(0.0, 0.0, 0.0), - output normal Normal = normal(0.0, 0.0, 0.0)) + int value_int = 0, + output string value_string = "", + output float value_float = 0.0, + output color value_color = 0.0, + output vector value_vector = vector(0.0, 0.0, 0.0), + output point value_point = point(0.0, 0.0, 0.0), + output normal value_normal = normal(0.0, 0.0, 0.0)) { - float f = (float)ValInt; - Val = f; - Color = color(f, f, f); - Vector = vector(f, f, f); - Point = point(f, f, f); - Normal = normal(f, f, f); + float f = (float)value_int; + value_float = f; + value_color = color(f, f, f); + value_vector = vector(f, f, f); + value_point = point(f, f, f); + value_normal = normal(f, f, f); } diff --git a/intern/cycles/kernel/shaders/node_convert_from_normal.osl b/intern/cycles/kernel/shaders/node_convert_from_normal.osl index 8ecc56ac8ce..7fffa7f6169 100644 --- a/intern/cycles/kernel/shaders/node_convert_from_normal.osl +++ b/intern/cycles/kernel/shaders/node_convert_from_normal.osl @@ -17,18 +17,18 @@ #include "stdosl.h" shader node_convert_from_normal( - normal Normal = normal(0.0, 0.0, 0.0), - output string String = "", - output float Val = 0.0, - output int ValInt = 0, - output vector Vector = vector(0.0, 0.0, 0.0), - output color Color = 0.0, - output point Point = point(0.0, 0.0, 0.0)) + normal value_normal = normal(0.0, 0.0, 0.0), + output string value_string = "", + output float value_float = 0.0, + output int value_int = 0, + output vector value_vector = vector(0.0, 0.0, 0.0), + output color value_color = 0.0, + output point value_point = point(0.0, 0.0, 0.0)) { - Val = (Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0); - ValInt = (int)((Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0)); - Vector = vector(Normal[0], Normal[1], Normal[2]); - Color = color(Normal[0], Normal[1], Normal[2]); - Point = point(Normal[0], Normal[1], Normal[2]); + value_float = (value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0); + value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0)); + value_vector = vector(value_normal[0], value_normal[1], value_normal[2]); + value_color = color(value_normal[0], value_normal[1], value_normal[2]); + value_point = point(value_normal[0], value_normal[1], value_normal[2]); } diff --git a/intern/cycles/kernel/shaders/node_convert_from_point.osl b/intern/cycles/kernel/shaders/node_convert_from_point.osl index e5913b7a1e4..9e4930296bb 100644 --- a/intern/cycles/kernel/shaders/node_convert_from_point.osl +++ b/intern/cycles/kernel/shaders/node_convert_from_point.osl @@ -17,18 +17,18 @@ #include "stdosl.h" shader node_convert_from_point( - point Point = point(0.0, 0.0, 0.0), - output string String = "", - output float Val = 0.0, - output int ValInt = 0, - output vector Vector = vector(0.0, 0.0, 0.0), - output color Color = 0.0, - output normal Normal = normal(0.0, 0.0, 0.0)) + point value_point = point(0.0, 0.0, 0.0), + output string value_string = "", + output float value_float = 0.0, + output int value_int = 0, + output vector value_vector = vector(0.0, 0.0, 0.0), + output color value_color = 0.0, + output normal value_normal = normal(0.0, 0.0, 0.0)) { - Val = (Point[0] + Point[1] + Point[2]) * (1.0 / 3.0); - ValInt = (int)((Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0)); - Vector = vector(Point[0], Point[1], Point[2]); - Color = color(Point[0], Point[1], Point[2]); - Normal = normal(Point[0], Point[1], Point[2]); + value_float = (value_point[0] + value_point[1] + value_point[2]) * (1.0 / 3.0); + value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0)); + value_vector = vector(value_point[0], value_point[1], value_point[2]); + value_color = color(value_point[0], value_point[1], value_point[2]); + value_normal = normal(value_point[0], value_point[1], value_point[2]); } diff --git a/intern/cycles/kernel/shaders/node_convert_from_string.osl b/intern/cycles/kernel/shaders/node_convert_from_string.osl index 0466734277b..cbc6653eada 100644 --- a/intern/cycles/kernel/shaders/node_convert_from_string.osl +++ b/intern/cycles/kernel/shaders/node_convert_from_string.osl @@ -17,13 +17,13 @@ #include "stdosl.h" shader node_convert_from_string( - string String = "", - output color Color = color(0.0, 0.0, 0.0), - output float Val = 0.0, - output int ValInt = 0, - output vector Vector = vector(0.0, 0.0, 0.0), - output point Point = point(0.0, 0.0, 0.0), - output normal Normal = normal(0.0, 0.0, 0.0)) + string value_string = "", + output color value_color = color(0.0, 0.0, 0.0), + output float value_float = 0.0, + output int value_int = 0, + output vector value_vector = vector(0.0, 0.0, 0.0), + output point value_point = point(0.0, 0.0, 0.0), + output normal value_normal = normal(0.0, 0.0, 0.0)) { } diff --git a/intern/cycles/kernel/shaders/node_convert_from_vector.osl b/intern/cycles/kernel/shaders/node_convert_from_vector.osl index 79c5cb04550..8bdca469b90 100644 --- a/intern/cycles/kernel/shaders/node_convert_from_vector.osl +++ b/intern/cycles/kernel/shaders/node_convert_from_vector.osl @@ -17,18 +17,18 @@ #include "stdosl.h" shader node_convert_from_vector( - vector Vector = vector(0.0, 0.0, 0.0), - output string String = "", - output float Val = 0.0, - output int ValInt = 0, - output color Color = color(0.0, 0.0, 0.0), - output point Point = point(0.0, 0.0, 0.0), - output normal Normal = normal(0.0, 0.0, 0.0)) + vector value_vector = vector(0.0, 0.0, 0.0), + output string value_string = "", + output float value_float = 0.0, + output int value_int = 0, + output color value_color = color(0.0, 0.0, 0.0), + output point value_point = point(0.0, 0.0, 0.0), + output normal value_normal = normal(0.0, 0.0, 0.0)) { - Val = (Vector[0] + Vector[1] + Vector[2]) * (1.0 / 3.0); - ValInt = (int)((Normal[0] + Normal[1] + Normal[2]) * (1.0 / 3.0)); - Color = color(Vector[0], Vector[1], Vector[2]); - Point = point(Vector[0], Vector[1], Vector[2]); - Normal = normal(Vector[0], Vector[1], Vector[2]); + value_float = (value_vector[0] + value_vector[1] + value_vector[2]) * (1.0 / 3.0); + value_int = (int)((value_normal[0] + value_normal[1] + value_normal[2]) * (1.0 / 3.0)); + value_color = color(value_vector[0], value_vector[1], value_vector[2]); + value_point = point(value_vector[0], value_vector[1], value_vector[2]); + value_normal = normal(value_vector[0], value_vector[1], value_vector[2]); } diff --git a/intern/cycles/kernel/shaders/node_gradient_texture.osl b/intern/cycles/kernel/shaders/node_gradient_texture.osl index 52b49688ab3..69e2ee54bdf 100644 --- a/intern/cycles/kernel/shaders/node_gradient_texture.osl +++ b/intern/cycles/kernel/shaders/node_gradient_texture.osl @@ -63,7 +63,7 @@ float gradient(point p, string type) shader node_gradient_texture( int use_mapping = 0, matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - string Type = "Linear", + string type = "Linear", point Vector = P, output float Fac = 0.0, output color Color = 0.0) @@ -73,7 +73,7 @@ shader node_gradient_texture( if (use_mapping) p = transform(mapping, p); - Fac = gradient(p, Type); + Fac = gradient(p, type); Color = color(Fac, Fac, Fac); } diff --git a/intern/cycles/kernel/shaders/node_image_texture.osl b/intern/cycles/kernel/shaders/node_image_texture.osl index d3a347b70db..d09174ff5d3 100644 --- a/intern/cycles/kernel/shaders/node_image_texture.osl +++ b/intern/cycles/kernel/shaders/node_image_texture.osl @@ -62,9 +62,9 @@ color image_texture_lookup(string filename, int use_alpha, int is_float, string interpolation, - string wrap) + string extension) { - color rgb = (color)texture(filename, u, 1.0 - v, "wrap", wrap, "interp", interpolation, "alpha", Alpha); + color rgb = (color)texture(filename, u, 1.0 - v, "wrap", extension, "interp", interpolation, "alpha", Alpha); if (use_alpha) { rgb = color_unpremultiply(rgb, Alpha); diff --git a/intern/cycles/kernel/shaders/node_magic_texture.osl b/intern/cycles/kernel/shaders/node_magic_texture.osl index 55992e3494c..8d6af391e04 100644 --- a/intern/cycles/kernel/shaders/node_magic_texture.osl +++ b/intern/cycles/kernel/shaders/node_magic_texture.osl @@ -93,7 +93,7 @@ color magic(point p, int n, float distortion) shader node_magic_texture( int use_mapping = 0, matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - int Depth = 2, + int depth = 2, float Distortion = 5.0, float Scale = 5.0, point Vector = P, @@ -105,7 +105,7 @@ shader node_magic_texture( if (use_mapping) p = transform(mapping, p); - Color = magic(p * Scale, Depth, Distortion); + Color = magic(p * Scale, depth, Distortion); Fac = (Color[0] + Color[1] + Color[2]) * (1.0 / 3.0); } diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl index 7eef97fd7e8..85eac0b97a6 100644 --- a/intern/cycles/kernel/shaders/node_math.osl +++ b/intern/cycles/kernel/shaders/node_math.osl @@ -50,7 +50,7 @@ float safe_log(float a, float b) shader node_math( string type = "Add", - int Clamp = 0, + int use_clamp = 0, float Value1 = 0.0, float Value2 = 0.0, output float Value = 0.0) @@ -96,7 +96,7 @@ shader node_math( else if (type == "Absolute") Value = fabs(Value1); - if (Clamp) + if (use_clamp) Value = clamp(Value, 0.0, 1.0); } diff --git a/intern/cycles/kernel/shaders/node_mix.osl b/intern/cycles/kernel/shaders/node_mix.osl index 9ef58e4cbba..4a66748ed6a 100644 --- a/intern/cycles/kernel/shaders/node_mix.osl +++ b/intern/cycles/kernel/shaders/node_mix.osl @@ -278,7 +278,7 @@ color node_mix_clamp(color col) shader node_mix( string type = "Mix", - int Clamp = 0, + int use_clamp = 0, float Fac = 0.5, color Color1 = 0.0, color Color2 = 0.0, @@ -323,7 +323,7 @@ shader node_mix( if (type == "Linear Light") Color = node_mix_linear(t, Color1, Color2); - if (Clamp) + if (use_clamp) Color = node_mix_clamp(Color); } diff --git a/intern/cycles/kernel/shaders/node_musgrave_texture.osl b/intern/cycles/kernel/shaders/node_musgrave_texture.osl index 4f95dec910a..2f9f62bcfe8 100644 --- a/intern/cycles/kernel/shaders/node_musgrave_texture.osl +++ b/intern/cycles/kernel/shaders/node_musgrave_texture.osl @@ -187,7 +187,7 @@ float noise_musgrave_ridged_multi_fractal(point p, float H, float lacunarity, shader node_musgrave_texture( int use_mapping = 0, matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - string Type = "fBM", + string type = "fBM", float Dimension = 2.0, float Lacunarity = 1.0, float Detail = 2.0, @@ -210,15 +210,15 @@ shader node_musgrave_texture( p = p * Scale; - if (Type == "Multifractal") + if (type == "Multifractal") Fac = intensity * noise_musgrave_multi_fractal(p, dimension, lacunarity, octaves); - else if (Type == "fBM") + else if (type == "fBM") Fac = intensity * noise_musgrave_fBm(p, dimension, lacunarity, octaves); - else if (Type == "Hybrid Multifractal") + else if (type == "Hybrid Multifractal") Fac = intensity * noise_musgrave_hybrid_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain); - else if (Type == "Ridged Multifractal") + else if (type == "Ridged Multifractal") Fac = intensity * noise_musgrave_ridged_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain); - else if (Type == "Hetero Terrain") + else if (type == "Hetero Terrain") Fac = intensity * noise_musgrave_hetero_terrain(p, dimension, lacunarity, octaves, Offset); Color = color(Fac, Fac, Fac); diff --git a/intern/cycles/kernel/shaders/node_normal.osl b/intern/cycles/kernel/shaders/node_normal.osl index 2d04978fc72..7307971eddd 100644 --- a/intern/cycles/kernel/shaders/node_normal.osl +++ b/intern/cycles/kernel/shaders/node_normal.osl @@ -17,12 +17,12 @@ #include "stdosl.h" shader node_normal( - normal Direction = normal(0.0, 0.0, 0.0), + normal direction = normal(0.0, 0.0, 0.0), normal NormalIn = normal(0.0, 0.0, 0.0), output normal NormalOut = normal(0.0, 0.0, 0.0), output float Dot = 1.0) { - NormalOut = normalize(Direction); + NormalOut = normalize(direction); Dot = dot(NormalOut, normalize(NormalIn)); } diff --git a/intern/cycles/kernel/shaders/node_rgb_ramp.osl b/intern/cycles/kernel/shaders/node_rgb_ramp.osl index 2ab6b6778b7..c0ae74d6b33 100644 --- a/intern/cycles/kernel/shaders/node_rgb_ramp.osl +++ b/intern/cycles/kernel/shaders/node_rgb_ramp.osl @@ -20,7 +20,7 @@ shader node_rgb_ramp( color ramp_color[] = {0.0}, float ramp_alpha[] = {0.0}, - int ramp_interpolate = 1, + int interpolate = 1, float Fac = 0.0, output color Color = 0.0, @@ -38,7 +38,7 @@ shader node_rgb_ramp( Color = ramp_color[i]; Alpha = ramp_alpha[i]; - if (ramp_interpolate && t > 0.0) { + if (interpolate && t > 0.0) { Color = (1.0 - t) * Color + t * ramp_color[i + 1]; Alpha = (1.0 - t) * Alpha + t * ramp_alpha[i + 1]; } diff --git a/intern/cycles/kernel/shaders/node_subsurface_scattering.osl b/intern/cycles/kernel/shaders/node_subsurface_scattering.osl index a67333c5d4e..1877c7e595f 100644 --- a/intern/cycles/kernel/shaders/node_subsurface_scattering.osl +++ b/intern/cycles/kernel/shaders/node_subsurface_scattering.osl @@ -22,13 +22,13 @@ shader node_subsurface_scattering( vector Radius = vector(0.1, 0.1, 0.1), float TextureBlur = 0.0, float Sharpness = 0.0, - string Falloff = "Cubic", + string falloff = "Cubic", normal Normal = N, output closure color BSSRDF = 0) { - if (Falloff == "Gaussian") + if (falloff == "Gaussian") BSSRDF = Color * bssrdf_gaussian(Normal, Scale * Radius, TextureBlur); - else if (Falloff == "Cubic") + else if (falloff == "Cubic") BSSRDF = Color * bssrdf_cubic(Normal, Scale * Radius, TextureBlur, Sharpness); else BSSRDF = Color * bssrdf_burley(Normal, Scale * Radius, TextureBlur, Color); diff --git a/intern/cycles/kernel/shaders/node_voronoi_texture.osl b/intern/cycles/kernel/shaders/node_voronoi_texture.osl index 29e143ae207..bacdd593c7c 100644 --- a/intern/cycles/kernel/shaders/node_voronoi_texture.osl +++ b/intern/cycles/kernel/shaders/node_voronoi_texture.osl @@ -22,7 +22,7 @@ shader node_voronoi_texture( int use_mapping = 0, matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - string Coloring = "Intensity", + string coloring = "Intensity", float Scale = 5.0, point Vector = P, output float Fac = 0.0, @@ -40,7 +40,7 @@ shader node_voronoi_texture( voronoi(p * Scale, 1.0, da, pa); /* Colored output */ - if (Coloring == "Intensity") { + if (coloring == "Intensity") { Fac = fabs(da[0]); Color = color(Fac); } diff --git a/intern/cycles/kernel/shaders/node_wave_texture.osl b/intern/cycles/kernel/shaders/node_wave_texture.osl index 59f61d3b46a..a07742faefc 100644 --- a/intern/cycles/kernel/shaders/node_wave_texture.osl +++ b/intern/cycles/kernel/shaders/node_wave_texture.osl @@ -48,8 +48,8 @@ float wave(point p, string type, string profile, float detail, float distortion, shader node_wave_texture( int use_mapping = 0, matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - string Type = "Bands", - string Profile = "Sine", + string type = "Bands", + string profile = "Sine", float Scale = 5.0, float Distortion = 0.0, float Detail = 2.0, @@ -63,7 +63,7 @@ shader node_wave_texture( if (use_mapping) p = transform(mapping, p); - Fac = wave(p * Scale, Type, Profile, Detail, Distortion, DetailScale); + Fac = wave(p * Scale, type, profile, Detail, Distortion, DetailScale); Color = Fac; } diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index be87e35326e..e57d22b1b13 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -343,6 +343,11 @@ typedef enum NodeNormalMapSpace { NODE_NORMAL_MAP_BLENDER_WORLD, } NodeNormalMapSpace; +typedef enum NodeImageColorSpace { + NODE_COLOR_SPACE_NONE = 0, + NODE_COLOR_SPACE_COLOR = 1, +} NodeImageColorSpace; + typedef enum NodeImageProjection { NODE_IMAGE_PROJ_FLAT = 0, NODE_IMAGE_PROJ_BOX = 1, @@ -350,6 +355,11 @@ typedef enum NodeImageProjection { NODE_IMAGE_PROJ_TUBE = 3, } NodeImageProjection; +typedef enum NodeEnvironmentProjection { + NODE_ENVIRONMENT_EQUIRECTANGULAR = 0, + NODE_ENVIRONMENT_MIRROR_BALL = 1, +} NodeEnvironmentProjection; + typedef enum NodeBumpOffset { NODE_BUMP_OFFSET_CENTER, NODE_BUMP_OFFSET_DX, diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 7f1fcd81c73..359225cf56a 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -433,14 +433,14 @@ void ImageTextureNode::compile(OSLCompiler& compiler) switch(extension) { case EXTENSION_EXTEND: - compiler.parameter("wrap", "clamp"); + compiler.parameter("extension", "clamp"); break; case EXTENSION_CLIP: - compiler.parameter("wrap", "black"); + compiler.parameter("extension", "black"); break; case EXTENSION_REPEAT: default: - compiler.parameter("wrap", "periodic"); + compiler.parameter("extension", "periodic"); break; } @@ -867,7 +867,7 @@ void GradientTextureNode::compile(OSLCompiler& compiler) { tex_mapping.compile(compiler); - compiler.parameter("Type", type); + compiler.parameter("type", type); compiler.add(this, "node_gradient_texture"); } @@ -971,7 +971,7 @@ void VoronoiTextureNode::compile(OSLCompiler& compiler) { tex_mapping.compile(compiler); - compiler.parameter("Coloring", coloring); + compiler.parameter("coloring", coloring); compiler.add(this, "node_voronoi_texture"); } @@ -1051,7 +1051,7 @@ void MusgraveTextureNode::compile(OSLCompiler& compiler) { tex_mapping.compile(compiler); - compiler.parameter("Type", type); + compiler.parameter("type", type); compiler.add(this, "node_musgrave_texture"); } @@ -1135,8 +1135,8 @@ void WaveTextureNode::compile(OSLCompiler& compiler) { tex_mapping.compile(compiler); - compiler.parameter("Type", type); - compiler.parameter("Profile", profile); + compiler.parameter("type", type); + compiler.parameter("profile", profile); compiler.add(this, "node_wave_texture"); } @@ -1186,7 +1186,7 @@ void MagicTextureNode::compile(OSLCompiler& compiler) { tex_mapping.compile(compiler); - compiler.parameter("Depth", depth); + compiler.parameter("depth", depth); compiler.add(this, "node_magic_texture"); } @@ -1311,10 +1311,10 @@ void BrickTextureNode::compile(OSLCompiler& compiler) { tex_mapping.compile(compiler); - compiler.parameter("Offset", offset); - compiler.parameter("OffsetFrequency", offset_frequency); - compiler.parameter("Squash", squash); - compiler.parameter("SquashFrequency", squash_frequency); + compiler.parameter("offset", offset); + compiler.parameter("offset_frequency", offset_frequency); + compiler.parameter("squash", squash); + compiler.parameter("squash_frequency", squash_frequency); compiler.add(this, "node_brick_texture"); } @@ -1504,7 +1504,7 @@ void NormalNode::compile(SVMCompiler& compiler) void NormalNode::compile(OSLCompiler& compiler) { - compiler.parameter_normal("Direction", direction); + compiler.parameter_normal("direction", direction); compiler.add(this, "node_normal"); } @@ -1536,6 +1536,40 @@ void MappingNode::compile(OSLCompiler& compiler) compiler.add(this, "node_mapping"); } +/* RGBToBW */ + +RGBToBWNode::RGBToBWNode() +: ShaderNode("rgb_to_bw") +{ + add_input("Color", SocketType::COLOR); + add_output("Val", SocketType::FLOAT); +} + +bool RGBToBWNode::constant_fold(ShaderGraph * /*graph*/, + ShaderOutput * /*socket*/, + float3 *optimized_value) +{ + if(inputs[0]->link == NULL) { + optimized_value->x = linear_rgb_to_gray(inputs[0]->value()); + return true; + } + + return false; +} + +void RGBToBWNode::compile(SVMCompiler& compiler) +{ + compiler.add_node(NODE_CONVERT, + NODE_CONVERT_CF, + compiler.stack_assign(inputs[0]), + compiler.stack_assign(outputs[0])); +} + +void RGBToBWNode::compile(OSLCompiler& compiler) +{ + compiler.add(this, "node_convert_from_color"); +} + /* Convert */ ConvertNode::ConvertNode(SocketType::Type from_, SocketType::Type to_, bool autoconvert) @@ -1552,40 +1586,40 @@ ConvertNode::ConvertNode(SocketType::Type from_, SocketType::Type to_, bool auto } if(from == SocketType::FLOAT) - add_input("Val", SocketType::FLOAT); + add_input("value_float", SocketType::FLOAT); else if(from == SocketType::INT) - add_input("ValInt", SocketType::INT); + add_input("value_int", SocketType::INT); else if(from == SocketType::COLOR) - add_input("Color", SocketType::COLOR); + add_input("value_color", SocketType::COLOR); else if(from == SocketType::VECTOR) - add_input("Vector", SocketType::VECTOR); + add_input("value_vector", SocketType::VECTOR); else if(from == SocketType::POINT) - add_input("Point", SocketType::POINT); + add_input("value_point", SocketType::POINT); else if(from == SocketType::NORMAL) - add_input("Normal", SocketType::NORMAL); + add_input("value_normal", SocketType::NORMAL); else if(from == SocketType::STRING) - add_input("String", SocketType::STRING); + add_input("value_string", SocketType::STRING); else if(from == SocketType::CLOSURE) - add_input("Closure", SocketType::CLOSURE); + add_input("value_closure", SocketType::CLOSURE); else assert(0); if(to == SocketType::FLOAT) - add_output("Val", SocketType::FLOAT); + add_output("value_float", SocketType::FLOAT); else if(to == SocketType::INT) - add_output("ValInt", SocketType::INT); + add_output("value_int", SocketType::INT); else if(to == SocketType::COLOR) - add_output("Color", SocketType::COLOR); + add_output("value_color", SocketType::COLOR); else if(to == SocketType::VECTOR) - add_output("Vector", SocketType::VECTOR); + add_output("value_vector", SocketType::VECTOR); else if(to == SocketType::POINT) - add_output("Point", SocketType::POINT); + add_output("value_point", SocketType::POINT); else if(to == SocketType::NORMAL) - add_output("Normal", SocketType::NORMAL); + add_output("value_normal", SocketType::NORMAL); else if(to == SocketType::STRING) - add_output("String", SocketType::STRING); + add_output("value_string", SocketType::STRING); else if(to == SocketType::CLOSURE) - add_output("Closure", SocketType::CLOSURE); + add_output("value_closure", SocketType::CLOSURE); else assert(0); } @@ -2176,7 +2210,7 @@ void SubsurfaceScatteringNode::compile(SVMCompiler& compiler) void SubsurfaceScatteringNode::compile(OSLCompiler& compiler) { - compiler.parameter("Falloff", falloff_enum[closure]); + compiler.parameter("falloff", falloff_enum[closure]); compiler.add(this, "node_subsurface_scattering"); } @@ -3366,7 +3400,7 @@ void MixNode::compile(SVMCompiler& compiler) void MixNode::compile(OSLCompiler& compiler) { compiler.parameter("type", type); - compiler.parameter("Clamp", use_clamp); + compiler.parameter("use_clamp", use_clamp); compiler.add(this, "node_mix"); } @@ -4128,7 +4162,7 @@ void MathNode::compile(SVMCompiler& compiler) void MathNode::compile(OSLCompiler& compiler) { compiler.parameter("type", type); - compiler.parameter("Clamp", use_clamp); + compiler.parameter("use_clamp", use_clamp); compiler.add(this, "node_math"); } @@ -4477,7 +4511,7 @@ void RGBRampNode::compile(OSLCompiler& compiler) compiler.parameter_color_array("ramp_color", ramp); compiler.parameter_array("ramp_alpha", ramp_alpha.data(), ramp_alpha.size()); - compiler.parameter("ramp_interpolate", interpolate); + compiler.parameter("interpolate", interpolate); compiler.add(this, "node_rgb_ramp"); } diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 7c06efc8e06..bb77cc452dc 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -362,6 +362,13 @@ public: } }; +class RGBToBWNode : public ShaderNode { +public: + SHADER_NODE_CLASS(RGBToBWNode) + + bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, float3 *optimized_value); +}; + class ConvertNode : public ShaderNode { public: ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert = false); |