[Bf-blender-cvs] [b980cd163a9] master: Cycles: fix compilation of OSL shaders following API change

Kévin Dietrich noreply at git.blender.org
Tue Nov 10 19:05:04 CET 2020


Commit: b980cd163a9d5d77eeffc2e353333e739fa9e719
Author: Kévin Dietrich
Date:   Tue Nov 10 18:49:50 2020 +0100
Branches: master
https://developer.blender.org/rBb980cd163a9d5d77eeffc2e353333e739fa9e719

Cycles: fix compilation of OSL shaders following API change

The names of the parameters are based on those of those of the sockets, so they also need to be updated. This was forgotten about in the previous commit (rBa284e559b90e).

Ref T82561.

===================================================================

M	intern/cycles/kernel/shaders/node_clamp.osl
M	intern/cycles/kernel/shaders/node_gradient_texture.osl
M	intern/cycles/kernel/shaders/node_map_range.osl
M	intern/cycles/kernel/shaders/node_mapping.osl
M	intern/cycles/kernel/shaders/node_math.osl
M	intern/cycles/kernel/shaders/node_mix.osl
M	intern/cycles/kernel/shaders/node_musgrave_texture.osl
M	intern/cycles/kernel/shaders/node_sky_texture.osl
M	intern/cycles/kernel/shaders/node_vector_math.osl
M	intern/cycles/kernel/shaders/node_vector_rotate.osl
M	intern/cycles/kernel/shaders/node_vector_transform.osl
M	intern/cycles/kernel/shaders/node_wave_texture.osl

===================================================================

diff --git a/intern/cycles/kernel/shaders/node_clamp.osl b/intern/cycles/kernel/shaders/node_clamp.osl
index ce9392a0d98..22a1cac7114 100644
--- a/intern/cycles/kernel/shaders/node_clamp.osl
+++ b/intern/cycles/kernel/shaders/node_clamp.osl
@@ -16,11 +16,11 @@
 
 #include "stdcycles.h"
 
-shader node_clamp(string type = "minmax",
+shader node_clamp(string clamp_type = "minmax",
                   float Value = 1.0,
                   float Min = 0.0,
                   float Max = 1.0,
                   output float Result = 0.0)
 {
-  Result = (type == "range" && (Min > Max)) ? clamp(Value, Max, Min) : clamp(Value, Min, Max);
+  Result = (clamp_type == "range" && (Min > Max)) ? clamp(Value, Max, Min) : clamp(Value, Min, Max);
 }
diff --git a/intern/cycles/kernel/shaders/node_gradient_texture.osl b/intern/cycles/kernel/shaders/node_gradient_texture.osl
index e9acebc0572..c7faee0d022 100644
--- a/intern/cycles/kernel/shaders/node_gradient_texture.osl
+++ b/intern/cycles/kernel/shaders/node_gradient_texture.osl
@@ -62,7 +62,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 gradient_type = "linear",
     point Vector = P,
     output float Fac = 0.0,
     output color Color = 0.0)
@@ -72,6 +72,6 @@ shader node_gradient_texture(
   if (use_mapping)
     p = transform(mapping, p);
 
-  Fac = gradient(p, type);
+  Fac = gradient(p, gradient_type);
   Color = color(Fac, Fac, Fac);
 }
diff --git a/intern/cycles/kernel/shaders/node_map_range.osl b/intern/cycles/kernel/shaders/node_map_range.osl
index 1c49027e6dd..2fcc664a80e 100644
--- a/intern/cycles/kernel/shaders/node_map_range.osl
+++ b/intern/cycles/kernel/shaders/node_map_range.osl
@@ -27,7 +27,7 @@ float smootherstep(float edge0, float edge1, float x)
   return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
 }
 
-shader node_map_range(string type = "linear",
+shader node_map_range(string range_type = "linear",
                       float Value = 1.0,
                       float FromMin = 0.0,
                       float FromMax = 1.0,
@@ -38,15 +38,15 @@ shader node_map_range(string type = "linear",
 {
   if (FromMax != FromMin) {
     float Factor = Value;
-    if (type == "stepped") {
+    if (range_type == "stepped") {
       Factor = (Value - FromMin) / (FromMax - FromMin);
       Factor = (Steps > 0) ? floor(Factor * (Steps + 1.0)) / Steps : 0.0;
     }
-    else if (type == "smoothstep") {
+    else if (range_type == "smoothstep") {
       Factor = (FromMin > FromMax) ? 1.0 - smoothstep(FromMax, FromMin, Value) :
                                      smoothstep(FromMin, FromMax, Value);
     }
-    else if (type == "smootherstep") {
+    else if (range_type == "smootherstep") {
       Factor = (FromMin > FromMax) ? 1.0 - smootherstep(FromMax, FromMin, Value) :
                                      smootherstep(FromMin, FromMax, Value);
     }
diff --git a/intern/cycles/kernel/shaders/node_mapping.osl b/intern/cycles/kernel/shaders/node_mapping.osl
index 8d204999630..131640685bc 100644
--- a/intern/cycles/kernel/shaders/node_mapping.osl
+++ b/intern/cycles/kernel/shaders/node_mapping.osl
@@ -47,24 +47,24 @@ matrix euler_to_mat(point euler)
   return mat;
 }
 
-shader node_mapping(string type = "point",
+shader node_mapping(string mapping_type = "point",
                     point VectorIn = point(0.0, 0.0, 0.0),
                     point Location = point(0.0, 0.0, 0.0),
                     point Rotation = point(0.0, 0.0, 0.0),
                     point Scale = point(1.0, 1.0, 1.0),
                     output point VectorOut = point(0.0, 0.0, 0.0))
 {
-  if (type == "point") {
+  if (mapping_type == "point") {
     VectorOut = transform(euler_to_mat(Rotation), (VectorIn * Scale)) + Location;
   }
-  else if (type == "texture") {
+  else if (mapping_type == "texture") {
     VectorOut = safe_divide(transform(transpose(euler_to_mat(Rotation)), (VectorIn - Location)),
                             Scale);
   }
-  else if (type == "vector") {
+  else if (mapping_type == "vector") {
     VectorOut = transform(euler_to_mat(Rotation), (VectorIn * Scale));
   }
-  else if (type == "normal") {
+  else if (mapping_type == "normal") {
     VectorOut = normalize((vector)transform(euler_to_mat(Rotation), safe_divide(VectorIn, Scale)));
   }
   else {
diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl
index dbaa7ccb60e..66884610561 100644
--- a/intern/cycles/kernel/shaders/node_math.osl
+++ b/intern/cycles/kernel/shaders/node_math.osl
@@ -18,91 +18,91 @@
 #include "stdcycles.h"
 
 /* OSL asin, acos, and pow functions are safe by default. */
-shader node_math(string type = "add",
+shader node_math(string math_type = "add",
                  float Value1 = 0.5,
                  float Value2 = 0.5,
                  float Value3 = 0.5,
                  output float Value = 0.0)
 {
-  if (type == "add")
+  if (math_type == "add")
     Value = Value1 + Value2;
-  else if (type == "subtract")
+  else if (math_type == "subtract")
     Value = Value1 - Value2;
-  else if (type == "multiply")
+  else if (math_type == "multiply")
     Value = Value1 * Value2;
-  else if (type == "divide")
+  else if (math_type == "divide")
     Value = safe_divide(Value1, Value2);
-  else if (type == "power")
+  else if (math_type == "power")
     Value = pow(Value1, Value2);
-  else if (type == "logarithm")
+  else if (math_type == "logarithm")
     Value = safe_log(Value1, Value2);
-  else if (type == "sqrt")
+  else if (math_type == "sqrt")
     Value = safe_sqrt(Value1);
-  else if (type == "inversesqrt")
+  else if (math_type == "inversesqrt")
     Value = inversesqrt(Value1);
-  else if (type == "absolute")
+  else if (math_type == "absolute")
     Value = fabs(Value1);
-  else if (type == "radians")
+  else if (math_type == "radians")
     Value = radians(Value1);
-  else if (type == "degrees")
+  else if (math_type == "degrees")
     Value = degrees(Value1);
-  else if (type == "minimum")
+  else if (math_type == "minimum")
     Value = min(Value1, Value2);
-  else if (type == "maximum")
+  else if (math_type == "maximum")
     Value = max(Value1, Value2);
-  else if (type == "less_than")
+  else if (math_type == "less_than")
     Value = Value1 < Value2;
-  else if (type == "greater_than")
+  else if (math_type == "greater_than")
     Value = Value1 > Value2;
-  else if (type == "round")
+  else if (math_type == "round")
     Value = floor(Value1 + 0.5);
-  else if (type == "floor")
+  else if (math_type == "floor")
     Value = floor(Value1);
-  else if (type == "ceil")
+  else if (math_type == "ceil")
     Value = ceil(Value1);
-  else if (type == "fraction")
+  else if (math_type == "fraction")
     Value = Value1 - floor(Value1);
-  else if (type == "modulo")
+  else if (math_type == "modulo")
     Value = safe_modulo(Value1, Value2);
-  else if (type == "trunc")
+  else if (math_type == "trunc")
     Value = trunc(Value1);
-  else if (type == "snap")
+  else if (math_type == "snap")
     Value = floor(safe_divide(Value1, Value2)) * Value2;
-  else if (type == "wrap")
+  else if (math_type == "wrap")
     Value = wrap(Value1, Value2, Value3);
-  else if (type == "pingpong")
+  else if (math_type == "pingpong")
     Value = pingpong(Value1, Value2);
-  else if (type == "sine")
+  else if (math_type == "sine")
     Value = sin(Value1);
-  else if (type == "cosine")
+  else if (math_type == "cosine")
     Value = cos(Value1);
-  else if (type == "tangent")
+  else if (math_type == "tangent")
     Value = tan(Value1);
-  else if (type == "sinh")
+  else if (math_type == "sinh")
     Value = sinh(Value1);
-  else if (type == "cosh")
+  else if (math_type == "cosh")
     Value = cosh(Value1);
-  else if (type == "tanh")
+  else if (math_type == "tanh")
     Value = tanh(Value1);
-  else if (type == "arcsine")
+  else if (math_type == "arcsine")
     Value = asin(Value1);
-  else if (type == "arccosine")
+  else if (math_type == "arccosine")
     Value = acos(Value1);
-  else if (type == "arctangent")
+  else if (math_type == "arctangent")
     Value = atan(Value1);
-  else if (type == "arctan2")
+  else if (math_type == "arctan2")
     Value = atan2(Value1, Value2);
-  else if (type == "sign")
+  else if (math_type == "sign")
     Value = sign(Value1);
-  else if (type == "exponent")
+  else if (math_type == "exponent")
     Value = exp(Value1);
-  else if (type == "compare")
+  else if (math_type == "compare")
     Value = ((Value1 == Value2) || (abs(Value1 - Value2) <= max(Value3, 1e-5))) ? 1.0 : 0.0;
-  else if (type == "multiply_add")
+  else if (math_type == "multiply_add")
     Value = Value1 * Value2 + Value3;
-  else if (type == "smoothmin")
+  else if (math_type == "smoothmin")
     Value = smoothmin(Value1, Value2, Value3);
-  else if (type == "smoothmax")
+  else if (math_type == "smoothmax")
     Value = -(smoothmin(-Value1, -Value2, Value3));
   else
     warning("%s", "Unknown math operator!");
diff --git a/intern/cycles/kernel/shaders/node_mix.osl b/intern/cycles/kernel/shaders/node_mix.osl
index a13b4bb7b96..dcd9f014f3e 100644
--- a/intern/cycles/kernel/shaders/node_mix.osl
+++ b/intern/cycles/kernel/shaders/node_mix.osl
@@ -279,7 +279,7 @@ color node_mix_clamp(color col)
   return outcol;
 }
 
-shader node_mix(string type = "mix",
+shader node_mix(string mix_type = "mix",
                 int use_clamp = 0,
                 float Fac = 0.5,
                 color Color1 = 0.0,
@@ -288,41 +288,41 @@ shader node_mix(string type = "mix",
 {
   float t = clamp(Fac, 0.0, 1.0);
 
-  if (type == "mix")
+  if (mix_type == "mix")
     Color = node_mix_blend(t, Color1, Color2);
-  if (type == "add")
+  if (mix_type == "add")
     Color = node_mix_add(t, Color1, Color2);
-  if (type == "multiply")
+  if (mix_type == "multiply")
     Color = node_mix_mul(t, Color1, Color2);
-  if (type == "screen")
+  if (mix_type == "screen")
     Color = node_mix_screen(t, Color1, Color2);
-  if (type == "overlay")
+  if (mix_type == "overlay")
     Color = node_mix_overlay(t, Color1, Color2);
-  if (type == "subtra

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list