[Bf-blender-cvs] [1e3effc1850] soc-2019-cycles-procedural: Reconfigure the outputs of the Noise node.

OmarSquircleArt noreply at git.blender.org
Wed Aug 7 22:18:55 CEST 2019


Commit: 1e3effc18501e8fb9a02f12456c07a492c08d57c
Author: OmarSquircleArt
Date:   Wed Aug 7 22:19:53 2019 +0200
Branches: soc-2019-cycles-procedural
https://developer.blender.org/rB1e3effc18501e8fb9a02f12456c07a492c08d57c

Reconfigure the outputs of the Noise node.

We changed the order of outputs so that the Value output is first. We did that because users mostly use the first output, and since noise is most commonly used as a bump texture, roughness textures, or to control other non-color data, it make sense that the first output should be the Value one. Previously, most users used the Color output for practically everything just because it is first in the output list. So reordering should save users some render time without them realizing.

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

M	intern/cycles/kernel/shaders/node_noise_texture.osl
M	intern/cycles/kernel/svm/svm_noisetex.h
M	intern/cycles/render/nodes.cpp
M	source/blender/gpu/shaders/gpu_shader_material.glsl
M	source/blender/nodes/shader/nodes/node_shader_tex_noise.c

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

diff --git a/intern/cycles/kernel/shaders/node_noise_texture.osl b/intern/cycles/kernel/shaders/node_noise_texture.osl
index e2225e454e2..4b100dc21ad 100644
--- a/intern/cycles/kernel/shaders/node_noise_texture.osl
+++ b/intern/cycles/kernel/shaders/node_noise_texture.osl
@@ -24,16 +24,15 @@
 /* To compute the color output of the noise, we either swizzle the
  * components, add a random offset {75, 125, 150}, or do both.
  */
-
 float noise(float p, float detail, float distortion, output color Color)
 {
   if (distortion != 0.0) {
     p += safe_noise(p + 13.5) * distortion;
   }
 
-  float fac = noise_turbulence(p, detail);
-  Color = color(fac, noise_turbulence(p + 75.0, detail), noise_turbulence(p + 125.0, detail));
-  return fac;
+  float value = noise_turbulence(p, detail);
+  Color = color(value, noise_turbulence(p + 75.0, detail), noise_turbulence(p + 125.0, detail));
+  return value;
 }
 
 float noise(vector2 p, float detail, float distortion, output color Color)
@@ -45,11 +44,11 @@ float noise(vector2 p, float detail, float distortion, output color Color)
     p += r;
   }
 
-  float fac = noise_turbulence(p, detail);
-  Color = color(fac,
+  float value = noise_turbulence(p, detail);
+  Color = color(value,
                 noise_turbulence(p + vector2(150.0, 125.0), detail),
                 noise_turbulence(p + vector2(75.0, 125.0), detail));
-  return fac;
+  return value;
 }
 
 float noise(vector3 p, float detail, float distortion, output color Color)
@@ -62,11 +61,11 @@ float noise(vector3 p, float detail, float distortion, output color Color)
     p += r;
   }
 
-  float fac = noise_turbulence(p, detail);
-  Color = color(fac,
+  float value = noise_turbulence(p, detail);
+  Color = color(value,
                 noise_turbulence(vector3(p[1], p[0], p[2]), detail),
                 noise_turbulence(vector3(p[1], p[2], p[0]), detail));
-  return fac;
+  return value;
 }
 
 float noise(vector4 p, float detail, float distortion, output color Color)
@@ -80,22 +79,22 @@ float noise(vector4 p, float detail, float distortion, output color Color)
     p += r;
   }
 
-  float fac = noise_turbulence(p, detail);
-  Color = color(fac,
+  float value = noise_turbulence(p, detail);
+  Color = color(value,
                 noise_turbulence(vector4(p.y, p.w, p.z, p.x), detail),
                 noise_turbulence(vector4(p.y, p.z, p.w, p.x), detail));
-  return fac;
+  return value;
 }
 
 shader node_noise_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 dimensions = "3D",
-                          vector3 Vector = P,
+                          vector3 Vector = vector3(0, 0, 0),
                           float W = 0.0,
                           float Scale = 5.0,
                           float Detail = 2.0,
                           float Distortion = 0.0,
-                          output float Fac = 0.0,
+                          output float Value = 0.0,
                           output color Color = 0.0)
 {
   vector3 p = Vector;
@@ -105,13 +104,13 @@ shader node_noise_texture(int use_mapping = 0,
   float w = W * Scale;
 
   if (dimensions == "1D")
-    Fac = noise(w, Detail, Distortion, Color);
+    Value = noise(w, Detail, Distortion, Color);
   else if (dimensions == "2D")
-    Fac = noise(vector2(p[0], p[1]), Detail, Distortion, Color);
+    Value = noise(vector2(p[0], p[1]), Detail, Distortion, Color);
   else if (dimensions == "3D")
-    Fac = noise(p, Detail, Distortion, Color);
+    Value = noise(p, Detail, Distortion, Color);
   else if (dimensions == "4D")
-    Fac = noise(vector4(p[0], p[1], p[2], w), Detail, Distortion, Color);
+    Value = noise(vector4(p[0], p[1], p[2], w), Detail, Distortion, Color);
   else
     error("Unknown dimension!");
 }
diff --git a/intern/cycles/kernel/svm/svm_noisetex.h b/intern/cycles/kernel/svm/svm_noisetex.h
index 23a5df235f1..3173ff73fbc 100644
--- a/intern/cycles/kernel/svm/svm_noisetex.h
+++ b/intern/cycles/kernel/svm/svm_noisetex.h
@@ -20,21 +20,21 @@ CCL_NAMESPACE_BEGIN
  * components, add a random offset {75, 125, 150}, or do both.
  */
 ccl_device void tex_noise_1d(
-    float p, float detail, float distortion, bool color_is_needed, float3 *color, float *fac)
+    float p, float detail, float distortion, bool color_is_needed, float *value, float3 *color)
 {
   if (distortion != 0.0f) {
     p += noise_1d(p + 13.5f) * distortion;
   }
 
-  *fac = noise_turbulence_1d(p, detail);
+  *value = noise_turbulence_1d(p, detail);
   if (color_is_needed) {
     *color = make_float3(
-        *fac, noise_turbulence_1d(p + 75.0f, detail), noise_turbulence_1d(p + 125.0f, detail));
+        *value, noise_turbulence_1d(p + 75.0f, detail), noise_turbulence_1d(p + 125.0f, detail));
   }
 }
 
 ccl_device void tex_noise_2d(
-    float2 p, float detail, float distortion, bool color_is_needed, float3 *color, float *fac)
+    float2 p, float detail, float distortion, bool color_is_needed, float *value, float3 *color)
 {
   if (distortion != 0.0f) {
     float2 r;
@@ -43,16 +43,16 @@ ccl_device void tex_noise_2d(
     p += r;
   }
 
-  *fac = noise_turbulence_2d(p, detail);
+  *value = noise_turbulence_2d(p, detail);
   if (color_is_needed) {
-    *color = make_float3(*fac,
+    *color = make_float3(*value,
                          noise_turbulence_2d(p + make_float2(150.0f, 125.0f), detail),
                          noise_turbulence_2d(p + make_float2(75.0f, 125.0f), detail));
   }
 }
 
 ccl_device void tex_noise_3d(
-    float3 p, float detail, float distortion, bool color_is_needed, float3 *color, float *fac)
+    float3 p, float detail, float distortion, bool color_is_needed, float *value, float3 *color)
 {
   if (distortion != 0.0f) {
     float3 r, offset = make_float3(13.5f, 13.5f, 13.5f);
@@ -62,16 +62,16 @@ ccl_device void tex_noise_3d(
     p += r;
   }
 
-  *fac = noise_turbulence_3d(p, detail);
+  *value = noise_turbulence_3d(p, detail);
   if (color_is_needed) {
-    *color = make_float3(*fac,
+    *color = make_float3(*value,
                          noise_turbulence_3d(make_float3(p.y, p.x, p.z), detail),
                          noise_turbulence_3d(make_float3(p.y, p.z, p.x), detail));
   }
 }
 
 ccl_device void tex_noise_4d(
-    float4 p, float detail, float distortion, bool color_is_needed, float3 *color, float *fac)
+    float4 p, float detail, float distortion, bool color_is_needed, float *value, float3 *color)
 {
   if (distortion != 0.0f) {
     float4 r, offset = make_float4(13.5, 13.5, 13.5, 13.5);
@@ -82,9 +82,9 @@ ccl_device void tex_noise_4d(
     p += r;
   }
 
-  *fac = noise_turbulence_4d(p, detail);
+  *value = noise_turbulence_4d(p, detail);
   if (color_is_needed) {
-    *color = make_float3(*fac,
+    *color = make_float3(*value,
                          noise_turbulence_4d(make_float4(p.y, p.w, p.z, p.x), detail),
                          noise_turbulence_4d(make_float4(p.y, p.z, p.w, p.x), detail));
   }
@@ -98,51 +98,55 @@ ccl_device void svm_node_tex_noise(KernelGlobals *kg,
                                    uint offsets2,
                                    int *offset)
 {
-  uint co_offset, w_offset, scale_offset, detail_offset, distortion_offset, fac_offset,
+  uint vector_offset, w_offset, scale_offset, detail_offset, distortion_offset, value_offset,
       color_offset;
 
-  decode_node_uchar4(offsets1, &co_offset, &w_offset, &scale_offset, &detail_offset);
-  decode_node_uchar4(offsets2, &distortion_offset, &color_offset, &fac_offset, NULL);
+  decode_node_uchar4(offsets1, &vector_offset, &w_offset, &scale_offset, &detail_offset);
+  decode_node_uchar4(offsets2, &distortion_offset, &value_offset, &color_offset, NULL);
 
   uint4 node1 = read_node(kg, offset);
 
-  float3 p = stack_load_float3(stack, co_offset);
+  float3 vector = stack_load_float3(stack, vector_offset);
   float w = stack_load_float_default(stack, w_offset, node1.x);
   float scale = stack_load_float_default(stack, scale_offset, node1.y);
   float detail = stack_load_float_default(stack, detail_offset, node1.z);
   float distortion = stack_load_float_default(stack, distortion_offset, node1.w);
 
-  p *= scale;
+  vector *= scale;
   w *= scale;
 
-  float fac;
+  float value;
   float3 color;
 
   switch (dimensions) {
     case 1:
-      tex_noise_1d(w, detail, distortion, stack_valid(color_offset), &color, &fac);
+      tex_noise_1d(w, detail, distortion, stack_valid(color_offset), &value, &color);
       break;
     case 2:
-      tex_noise_2d(
-          make_float2(p.x, p.y), detail, distortion, stack_valid(color_offset), &color, &fac);
+      tex_noise_2d(make_float2(vector.x, vector.y),
+                   detail,
+                   distortion,
+                   stack_valid(color_offset),
+                   &value,
+                   &color);
       break;
     case 3:
-      tex_noise_3d(p, detail, distortion, stack_valid(color_offset), &color, &fac);
+      tex_noise_3d(vector, detail, distortion, stack_valid(color_offset), &value, &color);
       break;
     case 4:
-      tex_noise_4d(make_float4(p.x, p.y, p.z, w),
+      tex_noise_4d(make_float4(vector.x, vector.y, vector.z, w),
                    detail,
                    distortion,
                    stack_valid(color_offset),
-                   &color,
-                   &fac);
+                   &value,
+                   &color);
       break;
     default:
       kernel_assert(0);
   }
 
-  if (stack_valid(fac_offset)) {
-    stack_store_float(stack, fac_offset, fac);
+  if (stack_valid(value_offset)) {
+    stack_store_float(stack, value_offset, value);
   }
   if (stack_valid(color_offset)) {
     stack_store_float3(stack, color_offset, color);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 2e9859e2fb7..2dc9371c5d1 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -906,8 +906,8 @@ NODE_DEFINE(NoiseTextureNode)
   SOCKET_IN_FLOAT(detail, "Detail", 2.0f);
   SOCKET_IN_FLOAT(distortion, "Distortion", 0.0f);
 
+  SOCKET_OUT_FLOAT(value, "Value");
   SOCKET_OUT_COLOR(color, "Color");
-  SOCKET_OUT_FLOAT(fac, "Fac");
 
   return t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list