Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Moniewski <monio>2020-03-26 16:43:53 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-04-09 22:48:03 +0300
commit054950def946ed7638c2d9c18ef850cbba94d9d7 (patch)
tree6c38c89f8c04be9259a4246b5b0cd5e842951052 /intern/cycles/render/nodes.cpp
parentf3433fcd3bf87c9405fb05c96fde036eb658e8aa (diff)
Shading: add Roughness input to Noise and Wave texture nodes
Currently in fractal_noise functions, each subsequent octave doubles the frequency and reduces the amplitude by half. This patch introduces Roughness input to Noise and Wave nodes. This multiplier determines how quickly the amplitudes of the subsequent octaves decrease. Value of 0.5 will be the default, generating identical noise we had before. Values above 0.5 will increase influence of each octave resulting in more "rough" noise, most interesting pattern changes happen there. Values below 0.5 will result in more "smooth" noise. Differential Revision: https://developer.blender.org/D7065
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r--intern/cycles/render/nodes.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index ac07d91c4ca..4b4958fe3da 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -922,6 +922,7 @@ NODE_DEFINE(NoiseTextureNode)
SOCKET_IN_FLOAT(w, "W", 0.0f);
SOCKET_IN_FLOAT(scale, "Scale", 1.0f);
SOCKET_IN_FLOAT(detail, "Detail", 2.0f);
+ SOCKET_IN_FLOAT(roughness, "Roughness", 0.5f);
SOCKET_IN_FLOAT(distortion, "Distortion", 0.0f);
SOCKET_OUT_FLOAT(fac, "Fac");
@@ -940,6 +941,7 @@ void NoiseTextureNode::compile(SVMCompiler &compiler)
ShaderInput *w_in = input("W");
ShaderInput *scale_in = input("Scale");
ShaderInput *detail_in = input("Detail");
+ ShaderInput *roughness_in = input("Roughness");
ShaderInput *distortion_in = input("Distortion");
ShaderOutput *fac_out = output("Fac");
ShaderOutput *color_out = output("Color");
@@ -948,6 +950,7 @@ void NoiseTextureNode::compile(SVMCompiler &compiler)
int w_stack_offset = compiler.stack_assign_if_linked(w_in);
int scale_stack_offset = compiler.stack_assign_if_linked(scale_in);
int detail_stack_offset = compiler.stack_assign_if_linked(detail_in);
+ int roughness_stack_offset = compiler.stack_assign_if_linked(roughness_in);
int distortion_stack_offset = compiler.stack_assign_if_linked(distortion_in);
int fac_stack_offset = compiler.stack_assign_if_linked(fac_out);
int color_stack_offset = compiler.stack_assign_if_linked(color_out);
@@ -957,11 +960,13 @@ void NoiseTextureNode::compile(SVMCompiler &compiler)
dimensions,
compiler.encode_uchar4(
vector_stack_offset, w_stack_offset, scale_stack_offset, detail_stack_offset),
- compiler.encode_uchar4(distortion_stack_offset, fac_stack_offset, color_stack_offset));
- compiler.add_node(__float_as_int(w),
- __float_as_int(scale),
- __float_as_int(detail),
- __float_as_int(distortion));
+ compiler.encode_uchar4(
+ roughness_stack_offset, distortion_stack_offset, fac_stack_offset, color_stack_offset));
+ compiler.add_node(
+ __float_as_int(w), __float_as_int(scale), __float_as_int(detail), __float_as_int(roughness));
+
+ compiler.add_node(
+ __float_as_int(distortion), SVM_STACK_INVALID, SVM_STACK_INVALID, SVM_STACK_INVALID);
tex_mapping.compile_end(compiler, vector_in, vector_stack_offset);
}
@@ -1343,14 +1348,14 @@ NODE_DEFINE(WaveTextureNode)
profile_enum.insert("tri", NODE_WAVE_PROFILE_TRI);
SOCKET_ENUM(profile, "Profile", profile_enum, NODE_WAVE_PROFILE_SIN);
+ SOCKET_IN_POINT(
+ vector, "Vector", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED);
SOCKET_IN_FLOAT(scale, "Scale", 1.0f);
SOCKET_IN_FLOAT(distortion, "Distortion", 0.0f);
SOCKET_IN_FLOAT(detail, "Detail", 2.0f);
SOCKET_IN_FLOAT(detail_scale, "Detail Scale", 0.0f);
+ SOCKET_IN_FLOAT(detail_roughness, "Detail Roughness", 0.5f);
SOCKET_IN_FLOAT(phase, "Phase Offset", 0.0f);
- SOCKET_IN_POINT(
- vector, "Vector", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED);
-
SOCKET_OUT_COLOR(color, "Color");
SOCKET_OUT_FLOAT(fac, "Fac");
@@ -1368,6 +1373,7 @@ void WaveTextureNode::compile(SVMCompiler &compiler)
ShaderInput *distortion_in = input("Distortion");
ShaderInput *detail_in = input("Detail");
ShaderInput *dscale_in = input("Detail Scale");
+ ShaderInput *droughness_in = input("Detail Roughness");
ShaderInput *phase_in = input("Phase Offset");
ShaderOutput *color_out = output("Color");
ShaderOutput *fac_out = output("Fac");
@@ -1378,20 +1384,22 @@ void WaveTextureNode::compile(SVMCompiler &compiler)
compiler.encode_uchar4(type, bands_direction, rings_direction, profile),
compiler.encode_uchar4(vector_offset,
compiler.stack_assign_if_linked(scale_in),
- compiler.stack_assign_if_linked(distortion_in),
- compiler.stack_assign_if_linked(detail_in)),
- compiler.encode_uchar4(compiler.stack_assign_if_linked(dscale_in),
- compiler.stack_assign_if_linked(phase_in),
- compiler.stack_assign_if_linked(color_out),
- compiler.stack_assign_if_linked(fac_out)));
+ compiler.stack_assign_if_linked(distortion_in)),
+ compiler.encode_uchar4(compiler.stack_assign_if_linked(detail_in),
+ compiler.stack_assign_if_linked(dscale_in),
+ compiler.stack_assign_if_linked(droughness_in),
+ compiler.stack_assign_if_linked(phase_in)));
- compiler.add_node(__float_as_int(scale),
- __float_as_int(detail),
+ compiler.add_node(compiler.encode_uchar4(compiler.stack_assign_if_linked(color_out),
+ compiler.stack_assign_if_linked(fac_out)),
+ __float_as_int(scale),
__float_as_int(distortion),
- __float_as_int(detail_scale));
+ __float_as_int(detail));
- compiler.add_node(
- __float_as_int(phase), SVM_STACK_INVALID, SVM_STACK_INVALID, SVM_STACK_INVALID);
+ compiler.add_node(__float_as_int(detail_scale),
+ __float_as_int(detail_roughness),
+ __float_as_int(phase),
+ SVM_STACK_INVALID);
tex_mapping.compile_end(compiler, vector_in, vector_offset);
}