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:
authorLuis Pereira <LuisPereira>2022-08-26 16:30:59 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-08-26 18:27:43 +0300
commit763cafc2b101d3258cb62b9a966b6d7e7629eb85 (patch)
treec31d77b0dd15c46bb5e318fd2ca3d71de6383a50 /source/blender/gpu/shaders
parenta1c8a17b4d95794ce36ee7db86f98ab818be0ed6 (diff)
Fix T55284: error in Hybrid MultiFractal Musgrave texture
The calculation was revised to address two issues: * Discontinuities occurring when detail was a non-integer greater than 2. * Levels of detail in the interval [0,1) repeating the levels of detail in the interval [1,2). This fixes Cycles, Eevee and geometry nodes. Differential Revision: https://developer.blender.org/D15785
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_tex_musgrave.glsl68
1 files changed, 40 insertions, 28 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_tex_musgrave.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_tex_musgrave.glsl
index 961fe23e67e..7171c5f2b36 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_tex_musgrave.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_tex_musgrave.glsl
@@ -153,13 +153,12 @@ void node_tex_musgrave_hybrid_multi_fractal_1d(vec3 co,
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
- float pwr = pwHL;
- float value = snoise(p) + offset;
- float weight = gain * value;
- p *= lacunarity;
+ float pwr = 1.0;
+ float value = 0.0;
+ float weight = 1.0;
- for (int i = 1; (weight > 0.001f) && (i < int(octaves)); i++) {
+ for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0) {
weight = 1.0;
}
@@ -172,8 +171,12 @@ void node_tex_musgrave_hybrid_multi_fractal_1d(vec3 co,
}
float rmd = octaves - floor(octaves);
- if (rmd != 0.0) {
- value += rmd * ((snoise(p) + offset) * pwr);
+ if ((rmd != 0.0) && (weight > 0.001f)) {
+ if (weight > 1.0) {
+ weight = 1.0;
+ }
+ float signal = (snoise(p) + offset) * pwr;
+ value += rmd * weight * signal;
}
fac = value;
@@ -375,13 +378,12 @@ void node_tex_musgrave_hybrid_multi_fractal_2d(vec3 co,
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
- float pwr = pwHL;
- float value = snoise(p) + offset;
- float weight = gain * value;
- p *= lacunarity;
+ float pwr = 1.0;
+ float value = 0.0;
+ float weight = 1.0;
- for (int i = 1; (weight > 0.001f) && (i < int(octaves)); i++) {
+ for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0) {
weight = 1.0;
}
@@ -394,8 +396,12 @@ void node_tex_musgrave_hybrid_multi_fractal_2d(vec3 co,
}
float rmd = octaves - floor(octaves);
- if (rmd != 0.0) {
- value += rmd * ((snoise(p) + offset) * pwr);
+ if ((rmd != 0.0) && (weight > 0.001f)) {
+ if (weight > 1.0) {
+ weight = 1.0;
+ }
+ float signal = (snoise(p) + offset) * pwr;
+ value += rmd * weight * signal;
}
fac = value;
@@ -597,13 +603,12 @@ void node_tex_musgrave_hybrid_multi_fractal_3d(vec3 co,
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
- float pwr = pwHL;
- float value = snoise(p) + offset;
- float weight = gain * value;
- p *= lacunarity;
+ float pwr = 1.0;
+ float value = 0.0;
+ float weight = 1.0;
- for (int i = 1; (weight > 0.001f) && (i < int(octaves)); i++) {
+ for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0) {
weight = 1.0;
}
@@ -616,8 +621,12 @@ void node_tex_musgrave_hybrid_multi_fractal_3d(vec3 co,
}
float rmd = octaves - floor(octaves);
- if (rmd != 0.0) {
- value += rmd * ((snoise(p) + offset) * pwr);
+ if ((rmd != 0.0) && (weight > 0.001f)) {
+ if (weight > 1.0) {
+ weight = 1.0;
+ }
+ float signal = (snoise(p) + offset) * pwr;
+ value += rmd * weight * signal;
}
fac = value;
@@ -819,13 +828,12 @@ void node_tex_musgrave_hybrid_multi_fractal_4d(vec3 co,
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
- float pwr = pwHL;
- float value = snoise(p) + offset;
- float weight = gain * value;
- p *= lacunarity;
+ float pwr = 1.0;
+ float value = 0.0;
+ float weight = 1.0;
- for (int i = 1; (weight > 0.001f) && (i < int(octaves)); i++) {
+ for (int i = 0; (weight > 0.001f) && (i < int(octaves)); i++) {
if (weight > 1.0) {
weight = 1.0;
}
@@ -838,8 +846,12 @@ void node_tex_musgrave_hybrid_multi_fractal_4d(vec3 co,
}
float rmd = octaves - floor(octaves);
- if (rmd != 0.0) {
- value += rmd * ((snoise(p) + offset) * pwr);
+ if ((rmd != 0.0) && (weight > 0.001f)) {
+ if (weight > 1.0) {
+ weight = 1.0;
+ }
+ float signal = (snoise(p) + offset) * pwr;
+ value += rmd * weight * signal;
}
fac = value;