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_noisetex.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_noisetex.h')
-rw-r--r--intern/cycles/kernel/svm/svm_noisetex.h91
1 files changed, 60 insertions, 31 deletions
diff --git a/intern/cycles/kernel/svm/svm_noisetex.h b/intern/cycles/kernel/svm/svm_noisetex.h
index 12884c6cb25..920dd7d9d02 100644
--- a/intern/cycles/kernel/svm/svm_noisetex.h
+++ b/intern/cycles/kernel/svm/svm_noisetex.h
@@ -50,24 +50,34 @@ ccl_device_inline float4 random_float4_offset(float seed)
100.0f + hash_float2_to_float(make_float2(seed, 3.0f)) * 100.0f);
}
-ccl_device void noise_texture_1d(
- float co, float detail, float distortion, bool color_is_needed, float *value, float3 *color)
+ccl_device void noise_texture_1d(float co,
+ float detail,
+ float roughness,
+ float distortion,
+ bool color_is_needed,
+ float *value,
+ float3 *color)
{
float p = co;
if (distortion != 0.0f) {
p += snoise_1d(p + random_float_offset(0.0f)) * distortion;
}
- *value = fractal_noise_1d(p, detail);
+ *value = fractal_noise_1d(p, detail, roughness);
if (color_is_needed) {
*color = make_float3(*value,
- fractal_noise_1d(p + random_float_offset(1.0f), detail),
- fractal_noise_1d(p + random_float_offset(2.0f), detail));
+ fractal_noise_1d(p + random_float_offset(1.0f), detail, roughness),
+ fractal_noise_1d(p + random_float_offset(2.0f), detail, roughness));
}
}
-ccl_device void noise_texture_2d(
- float2 co, float detail, float distortion, bool color_is_needed, float *value, float3 *color)
+ccl_device void noise_texture_2d(float2 co,
+ float detail,
+ float roughness,
+ float distortion,
+ bool color_is_needed,
+ float *value,
+ float3 *color)
{
float2 p = co;
if (distortion != 0.0f) {
@@ -75,16 +85,21 @@ ccl_device void noise_texture_2d(
snoise_2d(p + random_float2_offset(1.0f)) * distortion);
}
- *value = fractal_noise_2d(p, detail);
+ *value = fractal_noise_2d(p, detail, roughness);
if (color_is_needed) {
*color = make_float3(*value,
- fractal_noise_2d(p + random_float2_offset(2.0f), detail),
- fractal_noise_2d(p + random_float2_offset(3.0f), detail));
+ fractal_noise_2d(p + random_float2_offset(2.0f), detail, roughness),
+ fractal_noise_2d(p + random_float2_offset(3.0f), detail, roughness));
}
}
-ccl_device void noise_texture_3d(
- float3 co, float detail, float distortion, bool color_is_needed, float *value, float3 *color)
+ccl_device void noise_texture_3d(float3 co,
+ float detail,
+ float roughness,
+ float distortion,
+ bool color_is_needed,
+ float *value,
+ float3 *color)
{
float3 p = co;
if (distortion != 0.0f) {
@@ -93,16 +108,21 @@ ccl_device void noise_texture_3d(
snoise_3d(p + random_float3_offset(2.0f)) * distortion);
}
- *value = fractal_noise_3d(p, detail);
+ *value = fractal_noise_3d(p, detail, roughness);
if (color_is_needed) {
*color = make_float3(*value,
- fractal_noise_3d(p + random_float3_offset(3.0f), detail),
- fractal_noise_3d(p + random_float3_offset(4.0f), detail));
+ fractal_noise_3d(p + random_float3_offset(3.0f), detail, roughness),
+ fractal_noise_3d(p + random_float3_offset(4.0f), detail, roughness));
}
}
-ccl_device void noise_texture_4d(
- float4 co, float detail, float distortion, bool color_is_needed, float *value, float3 *color)
+ccl_device void noise_texture_4d(float4 co,
+ float detail,
+ float roughness,
+ float distortion,
+ bool color_is_needed,
+ float *value,
+ float3 *color)
{
float4 p = co;
if (distortion != 0.0f) {
@@ -112,11 +132,11 @@ ccl_device void noise_texture_4d(
snoise_4d(p + random_float4_offset(3.0f)) * distortion);
}
- *value = fractal_noise_4d(p, detail);
+ *value = fractal_noise_4d(p, detail, roughness);
if (color_is_needed) {
*color = make_float3(*value,
- fractal_noise_4d(p + random_float4_offset(4.0f), detail),
- fractal_noise_4d(p + random_float4_offset(5.0f), detail));
+ fractal_noise_4d(p + random_float4_offset(4.0f), detail, roughness),
+ fractal_noise_4d(p + random_float4_offset(5.0f), detail, roughness));
}
}
@@ -128,21 +148,27 @@ ccl_device void svm_node_tex_noise(KernelGlobals *kg,
uint offsets2,
int *offset)
{
- uint vector_stack_offset, w_stack_offset, scale_stack_offset, detail_stack_offset;
- uint distortion_stack_offset, value_stack_offset, color_stack_offset;
+ uint vector_stack_offset, w_stack_offset, scale_stack_offset;
+ uint detail_stack_offset, roughness_stack_offset, distortion_stack_offset;
+ uint value_stack_offset, color_stack_offset;
svm_unpack_node_uchar4(
offsets1, &vector_stack_offset, &w_stack_offset, &scale_stack_offset, &detail_stack_offset);
- svm_unpack_node_uchar3(
- offsets2, &distortion_stack_offset, &value_stack_offset, &color_stack_offset);
+ svm_unpack_node_uchar4(offsets2,
+ &roughness_stack_offset,
+ &distortion_stack_offset,
+ &value_stack_offset,
+ &color_stack_offset);
- uint4 defaults = read_node(kg, offset);
+ uint4 defaults1 = read_node(kg, offset);
+ uint4 defaults2 = read_node(kg, offset);
float3 vector = stack_load_float3(stack, vector_stack_offset);
- float w = stack_load_float_default(stack, w_stack_offset, defaults.x);
- float scale = stack_load_float_default(stack, scale_stack_offset, defaults.y);
- float detail = stack_load_float_default(stack, detail_stack_offset, defaults.z);
- float distortion = stack_load_float_default(stack, distortion_stack_offset, defaults.w);
+ float w = stack_load_float_default(stack, w_stack_offset, defaults1.x);
+ float scale = stack_load_float_default(stack, scale_stack_offset, defaults1.y);
+ float detail = stack_load_float_default(stack, detail_stack_offset, defaults1.z);
+ float roughness = stack_load_float_default(stack, roughness_stack_offset, defaults1.w);
+ float distortion = stack_load_float_default(stack, distortion_stack_offset, defaults2.x);
vector *= scale;
w *= scale;
@@ -151,11 +177,13 @@ ccl_device void svm_node_tex_noise(KernelGlobals *kg,
float3 color;
switch (dimensions) {
case 1:
- noise_texture_1d(w, detail, distortion, stack_valid(color_stack_offset), &value, &color);
+ noise_texture_1d(
+ w, detail, roughness, distortion, stack_valid(color_stack_offset), &value, &color);
break;
case 2:
noise_texture_2d(make_float2(vector.x, vector.y),
detail,
+ roughness,
distortion,
stack_valid(color_stack_offset),
&value,
@@ -163,11 +191,12 @@ ccl_device void svm_node_tex_noise(KernelGlobals *kg,
break;
case 3:
noise_texture_3d(
- vector, detail, distortion, stack_valid(color_stack_offset), &value, &color);
+ vector, detail, roughness, distortion, stack_valid(color_stack_offset), &value, &color);
break;
case 4:
noise_texture_4d(make_float4(vector.x, vector.y, vector.z, w),
detail,
+ roughness,
distortion,
stack_valid(color_stack_offset),
&value,