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:
authorBrecht Van Lommel <brecht@blender.org>2021-11-02 20:27:54 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-11-02 20:56:25 +0300
commit48e2a15160d276c8080cd8d4f6dc0ba752dbb410 (patch)
tree5552f66d7fa217a12bbdd4fbe0c1e9691c4fb36e /source/blender/gpu
parent978f2cb900b75110a3bc9dbcec9d4aeae5df4565 (diff)
Fix T77681, T92634: noise texture artifacts with high detail
We run into float precision issues here, clamp the number of octaves to one less, which has little to no visual difference. This was empirically determined to work up to 16 before, but with additional inputs like roughness only 15 appears to work. Also adds misisng clamp for the geometry nodes implementation.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl8
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_tex_musgrave.glsl40
2 files changed, 24 insertions, 24 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl
index f25691c1a83..95f2be4bd44 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl
@@ -5,7 +5,7 @@ float fractal_noise(float p, float octaves, float roughness)
float amp = 1.0;
float maxamp = 0.0;
float sum = 0.0;
- octaves = clamp(octaves, 0.0, 16.0);
+ octaves = clamp(octaves, 0.0, 15.0);
int n = int(octaves);
for (int i = 0; i <= n; i++) {
float t = noise(fscale * p);
@@ -34,7 +34,7 @@ float fractal_noise(vec2 p, float octaves, float roughness)
float amp = 1.0;
float maxamp = 0.0;
float sum = 0.0;
- octaves = clamp(octaves, 0.0, 16.0);
+ octaves = clamp(octaves, 0.0, 15.0);
int n = int(octaves);
for (int i = 0; i <= n; i++) {
float t = noise(fscale * p);
@@ -63,7 +63,7 @@ float fractal_noise(vec3 p, float octaves, float roughness)
float amp = 1.0;
float maxamp = 0.0;
float sum = 0.0;
- octaves = clamp(octaves, 0.0, 16.0);
+ octaves = clamp(octaves, 0.0, 15.0);
int n = int(octaves);
for (int i = 0; i <= n; i++) {
float t = noise(fscale * p);
@@ -92,7 +92,7 @@ float fractal_noise(vec4 p, float octaves, float roughness)
float amp = 1.0;
float maxamp = 0.0;
float sum = 0.0;
- octaves = clamp(octaves, 0.0, 16.0);
+ octaves = clamp(octaves, 0.0, 15.0);
int n = int(octaves);
for (int i = 0; i <= n; i++) {
float t = noise(fscale * p);
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 7ecca286acd..586385b7e86 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
@@ -19,7 +19,7 @@ void node_tex_musgrave_fBm_1d(vec3 co,
{
float p = w * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float value = 0.0;
@@ -59,7 +59,7 @@ void node_tex_musgrave_multi_fractal_1d(vec3 co,
{
float p = w * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float value = 1.0;
@@ -100,7 +100,7 @@ void node_tex_musgrave_hetero_terrain_1d(vec3 co,
{
float p = w * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -146,7 +146,7 @@ void node_tex_musgrave_hybrid_multi_fractal_1d(vec3 co,
{
float p = w * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -196,7 +196,7 @@ void node_tex_musgrave_ridged_multi_fractal_1d(vec3 co,
{
float p = w * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -241,7 +241,7 @@ void node_tex_musgrave_fBm_2d(vec3 co,
{
vec2 p = co.xy * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float value = 0.0;
@@ -281,7 +281,7 @@ void node_tex_musgrave_multi_fractal_2d(vec3 co,
{
vec2 p = co.xy * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float value = 1.0;
@@ -322,7 +322,7 @@ void node_tex_musgrave_hetero_terrain_2d(vec3 co,
{
vec2 p = co.xy * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -368,7 +368,7 @@ void node_tex_musgrave_hybrid_multi_fractal_2d(vec3 co,
{
vec2 p = co.xy * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -418,7 +418,7 @@ void node_tex_musgrave_ridged_multi_fractal_2d(vec3 co,
{
vec2 p = co.xy * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -463,7 +463,7 @@ void node_tex_musgrave_fBm_3d(vec3 co,
{
vec3 p = co * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float value = 0.0;
@@ -503,7 +503,7 @@ void node_tex_musgrave_multi_fractal_3d(vec3 co,
{
vec3 p = co * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float value = 1.0;
@@ -544,7 +544,7 @@ void node_tex_musgrave_hetero_terrain_3d(vec3 co,
{
vec3 p = co * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -590,7 +590,7 @@ void node_tex_musgrave_hybrid_multi_fractal_3d(vec3 co,
{
vec3 p = co * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -640,7 +640,7 @@ void node_tex_musgrave_ridged_multi_fractal_3d(vec3 co,
{
vec3 p = co * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -685,7 +685,7 @@ void node_tex_musgrave_fBm_4d(vec3 co,
{
vec4 p = vec4(co, w) * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float value = 0.0;
@@ -725,7 +725,7 @@ void node_tex_musgrave_multi_fractal_4d(vec3 co,
{
vec4 p = vec4(co, w) * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float value = 1.0;
@@ -766,7 +766,7 @@ void node_tex_musgrave_hetero_terrain_4d(vec3 co,
{
vec4 p = vec4(co, w) * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -812,7 +812,7 @@ void node_tex_musgrave_hybrid_multi_fractal_4d(vec3 co,
{
vec4 p = vec4(co, w) * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);
@@ -862,7 +862,7 @@ void node_tex_musgrave_ridged_multi_fractal_4d(vec3 co,
{
vec4 p = vec4(co, w) * scale;
float H = max(dimension, 1e-5);
- float octaves = clamp(detail, 0.0, 16.0);
+ float octaves = clamp(detail, 0.0, 15.0);
float lacunarity = max(lac, 1e-5);
float pwHL = pow(lacunarity, -H);