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>2019-12-06 00:07:43 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-12-07 21:06:27 +0300
commit074c00f9d6cc720461e6c8c7c13ed4e408ef372e (patch)
tree0d4efaa01952af47f5ea7a70cb14d764a2f597af /source/blender/gpu
parent9c1134015c34ff19f3ff27c89321c019c67904b8 (diff)
Shaders: noise and wave distortion now work uniformly instead of diagonally
Previously Noise and Wave texture nodes would use noise functions within a [0,1] range for distortion effects. We either add or subtract noise from coordinates, never do both at same time. This led to the texture drastically shifting on the diagonal axis of a plane / cube. This behavior makes the Distortion input hard to control or animate. Capabilities of driving it with other texture are also limited, diagonal shifting is very apparent. This was fixed by offsetting the noise function to a signed range and making it zero-centered. This way noise is uniformly added and subtracted from coordinates. Texture pattern sticks to main coordinates which makes it way easier to control. This change is not strictly backwards compatible, there is versioning to ensure the scale of the distortion remains similar, but the particular pattern can be a little different. Differential Revision: https://developer.blender.org/D6177
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_tex_noise.glsl20
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_tex_wave.glsl2
2 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_tex_noise.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_tex_noise.glsl
index e56b4a1d135..6aeb23b1f99 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_tex_noise.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_tex_noise.glsl
@@ -37,7 +37,7 @@ void node_noise_texture_1d(
{
float p = w * scale;
if (distortion != 0.0) {
- p += noise(p + random_float_offset(0.0)) * distortion;
+ p += snoise(p + random_float_offset(0.0)) * distortion;
}
value = fractal_noise(p, detail);
@@ -52,8 +52,8 @@ void node_noise_texture_2d(
{
vec2 p = co.xy * scale;
if (distortion != 0.0) {
- p += vec2(noise(p + random_vec2_offset(0.0)) * distortion,
- noise(p + random_vec2_offset(1.0)) * distortion);
+ p += vec2(snoise(p + random_vec2_offset(0.0)) * distortion,
+ snoise(p + random_vec2_offset(1.0)) * distortion);
}
value = fractal_noise(p, detail);
@@ -68,9 +68,9 @@ void node_noise_texture_3d(
{
vec3 p = co * scale;
if (distortion != 0.0) {
- p += vec3(noise(p + random_vec3_offset(0.0)) * distortion,
- noise(p + random_vec3_offset(1.0)) * distortion,
- noise(p + random_vec3_offset(2.0)) * distortion);
+ p += vec3(snoise(p + random_vec3_offset(0.0)) * distortion,
+ snoise(p + random_vec3_offset(1.0)) * distortion,
+ snoise(p + random_vec3_offset(2.0)) * distortion);
}
value = fractal_noise(p, detail);
@@ -85,10 +85,10 @@ void node_noise_texture_4d(
{
vec4 p = vec4(co, w) * scale;
if (distortion != 0.0) {
- p += vec4(noise(p + random_vec4_offset(0.0)) * distortion,
- noise(p + random_vec4_offset(1.0)) * distortion,
- noise(p + random_vec4_offset(2.0)) * distortion,
- noise(p + random_vec4_offset(3.0)) * distortion);
+ p += vec4(snoise(p + random_vec4_offset(0.0)) * distortion,
+ snoise(p + random_vec4_offset(1.0)) * distortion,
+ snoise(p + random_vec4_offset(2.0)) * distortion,
+ snoise(p + random_vec4_offset(3.0)) * distortion);
}
value = fractal_noise(p, detail);
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_tex_wave.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_tex_wave.glsl
index fa79e3dc310..957aa606a79 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_tex_wave.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_tex_wave.glsl
@@ -11,7 +11,7 @@ float calc_wave(
}
if (distortion != 0.0) {
- n += distortion * fractal_noise(p * detail_scale, detail);
+ n += distortion * (fractal_noise(p * detail_scale, detail) * 2.0 - 1.0);
}
if (wave_profile == 0) { /* profile sin */