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/kernel/svm/svm_wave.h
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/kernel/svm/svm_wave.h')
-rw-r--r--intern/cycles/kernel/svm/svm_wave.h32
1 files changed, 19 insertions, 13 deletions
diff --git a/intern/cycles/kernel/svm/svm_wave.h b/intern/cycles/kernel/svm/svm_wave.h
index 64102535f7d..c4763475b47 100644
--- a/intern/cycles/kernel/svm/svm_wave.h
+++ b/intern/cycles/kernel/svm/svm_wave.h
@@ -23,9 +23,10 @@ ccl_device_noinline_cpu float svm_wave(NodeWaveType type,
NodeWaveRingsDirection rings_dir,
NodeWaveProfile profile,
float3 p,
- float detail,
float distortion,
+ float detail,
float dscale,
+ float droughness,
float phase)
{
/* Prevent precision issues on unit coordinates. */
@@ -66,7 +67,7 @@ ccl_device_noinline_cpu float svm_wave(NodeWaveType type,
n += phase;
if (distortion != 0.0f)
- n += distortion * (fractal_noise_3d(p * dscale, detail) * 2.0f - 1.0f);
+ n += distortion * (fractal_noise_3d(p * dscale, detail, droughness) * 2.0f - 1.0f);
if (profile == NODE_WAVE_PROFILE_SIN) {
return 0.5f + 0.5f * sinf(n - M_PI_2_F);
@@ -84,35 +85,40 @@ ccl_device_noinline_cpu float svm_wave(NodeWaveType type,
ccl_device void svm_node_tex_wave(
KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
{
- uint4 defaults1 = read_node(kg, offset);
- uint4 defaults2 = read_node(kg, offset);
+ uint4 node2 = read_node(kg, offset);
+ uint4 node3 = read_node(kg, offset);
/* RNA properties */
uint type_offset, bands_dir_offset, rings_dir_offset, profile_offset;
/* Inputs, Outputs */
- uint co_offset, scale_offset, distortion_offset, detail_offset, dscale_offset, phase_offset;
+ uint co_offset, scale_offset, distortion_offset, detail_offset, dscale_offset, droughness_offset,
+ phase_offset;
uint color_offset, fac_offset;
svm_unpack_node_uchar4(
node.y, &type_offset, &bands_dir_offset, &rings_dir_offset, &profile_offset);
- svm_unpack_node_uchar4(node.z, &co_offset, &scale_offset, &distortion_offset, &detail_offset);
- svm_unpack_node_uchar4(node.w, &dscale_offset, &phase_offset, &color_offset, &fac_offset);
+ svm_unpack_node_uchar3(node.z, &co_offset, &scale_offset, &distortion_offset);
+ svm_unpack_node_uchar4(
+ node.w, &detail_offset, &dscale_offset, &droughness_offset, &phase_offset);
+ svm_unpack_node_uchar2(node2.x, &color_offset, &fac_offset);
float3 co = stack_load_float3(stack, co_offset);
- float scale = stack_load_float_default(stack, scale_offset, defaults1.x);
- float detail = stack_load_float_default(stack, detail_offset, defaults1.y);
- float distortion = stack_load_float_default(stack, distortion_offset, defaults1.z);
- float dscale = stack_load_float_default(stack, dscale_offset, defaults1.w);
- float phase = stack_load_float_default(stack, phase_offset, defaults2.x);
+ float scale = stack_load_float_default(stack, scale_offset, node2.y);
+ float distortion = stack_load_float_default(stack, distortion_offset, node2.z);
+ float detail = stack_load_float_default(stack, detail_offset, node2.w);
+ float dscale = stack_load_float_default(stack, dscale_offset, node3.x);
+ float droughness = stack_load_float_default(stack, droughness_offset, node3.y);
+ float phase = stack_load_float_default(stack, phase_offset, node3.z);
float f = svm_wave((NodeWaveType)type_offset,
(NodeWaveBandsDirection)bands_dir_offset,
(NodeWaveRingsDirection)rings_dir_offset,
(NodeWaveProfile)profile_offset,
co * scale,
- detail,
distortion,
+ detail,
dscale,
+ droughness,
phase);
if (stack_valid(fac_offset))