[Bf-blender-cvs] [4d62ab00efe] soc-2019-cycles-procedural: Use direct links to musgrave types. Much faster compilation.

OmarSquircleArt noreply at git.blender.org
Thu Jul 4 18:28:47 CEST 2019


Commit: 4d62ab00efebe04c7544bebcce430ae6e66fa4ba
Author: OmarSquircleArt
Date:   Thu Jul 4 18:29:48 2019 +0200
Branches: soc-2019-cycles-procedural
https://developer.blender.org/rB4d62ab00efebe04c7544bebcce430ae6e66fa4ba

Use direct links to musgrave types. Much faster compilation.

===================================================================

M	source/blender/gpu/shaders/gpu_shader_material.glsl
M	source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c

===================================================================

diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 28793aeec94..75d794a9e91 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -3583,8 +3583,21 @@ void node_tex_noise_4d(
  * from "Texturing and Modelling: A procedural approach"
  */
 
-float noise_musgrave_fBm_1d(float p, float H, float lacunarity, float octaves)
+void node_tex_musgrave_fBm_1d(vec3 co,
+                               float w,
+                               float scale,
+                               float detail,
+                               float dimension,
+                               float lac,
+                               float offset,
+                               float gain,
+                               out float fac)
 {
+  float p = w * scale;
+  float H = max(dimension, 1e-5);
+  float octaves = clamp(detail, 0.0, 16.0);
+  float lacunarity = max(lac, 1e-5);
+
   float rmd;
   float value = 0.0;
   float pwr = 1.0;
@@ -3601,7 +3614,7 @@ float noise_musgrave_fBm_1d(float p, float H, float lacunarity, float octaves)
     value += rmd * snoise(p) * pwr;
   }
 
-  return value;
+  fac = value;
 }
 
 /* 1D Musgrave Multifractal
@@ -3611,8 +3624,21 @@ float noise_musgrave_fBm_1d(float p, float H, float lacunarity, float octaves)
  * octaves: number of frequencies in the fBm
  */
 
-float noise_musgrave_multi_fractal_1d(float p, float H, float lacunarity, float octaves)
+void node_tex_musgrave_multi_fractal_1d(vec3 co,
+                                         float w,
+                                         float scale,
+                                         float detail,
+                                         float dimension,
+                                         float lac,
+                                         float offset,
+                                         float gain,
+                                         out float fac)
 {
+  float p = w * scale;
+  float H = max(dimension, 1e-5);
+  float octaves = clamp(detail, 0.0, 16.0);
+  float lacunarity = max(lac, 1e-5);
+
   float rmd;
   float value = 1.0;
   float pwr = 1.0;
@@ -3629,7 +3655,7 @@ float noise_musgrave_multi_fractal_1d(float p, float H, float lacunarity, float
     value *= (rmd * pwr * snoise(p) + 1.0); /* correct? */
   }
 
-  return value;
+  fac = value;
 }
 
 /* 1D Musgrave Heterogeneous Terrain
@@ -3640,9 +3666,21 @@ float noise_musgrave_multi_fractal_1d(float p, float H, float lacunarity, float
  * offset: raises the terrain from `sea level'
  */
 
-float noise_musgrave_hetero_terrain_1d(
-    float p, float H, float lacunarity, float octaves, float offset)
+void node_tex_musgrave_hetero_terrain_1d(vec3 co,
+                                          float w,
+                                          float scale,
+                                          float detail,
+                                          float dimension,
+                                          float lac,
+                                          float offset,
+                                          float gain,
+                                          out float fac)
 {
+  float p = w * scale;
+  float H = max(dimension, 1e-5);
+  float octaves = clamp(detail, 0.0, 16.0);
+  float lacunarity = max(lac, 1e-5);
+
   float value, increment, rmd;
   float pwHL = pow(lacunarity, -H);
   float pwr = pwHL;
@@ -3664,7 +3702,7 @@ float noise_musgrave_hetero_terrain_1d(
     value += rmd * increment;
   }
 
-  return value;
+  fac = value;
 }
 
 /* 1D Hybrid Additive/Multiplicative Multifractal Terrain
@@ -3675,9 +3713,21 @@ float noise_musgrave_hetero_terrain_1d(
  * offset: raises the terrain from `sea level'
  */
 
-float noise_musgrave_hybrid_multi_fractal_1d(
-    float p, float H, float lacunarity, float octaves, float offset, float gain)
+void node_tex_musgrave_hybrid_multi_fractal_1d(vec3 co,
+                                                float w,
+                                                float scale,
+                                                float detail,
+                                                float dimension,
+                                                float lac,
+                                                float offset,
+                                                float gain,
+                                                out float fac)
 {
+  float p = w * scale;
+  float H = max(dimension, 1e-5);
+  float octaves = clamp(detail, 0.0, 16.0);
+  float lacunarity = max(lac, 1e-5);
+
   float result, signal, weight, rmd;
   float pwHL = pow(lacunarity, -H);
   float pwr = pwHL;
@@ -3703,7 +3753,7 @@ float noise_musgrave_hybrid_multi_fractal_1d(
     result += rmd * ((snoise(p) + offset) * pwr);
   }
 
-  return result;
+  fac = result;
 }
 
 /* 1D Ridged Multifractal Terrain
@@ -3714,9 +3764,21 @@ float noise_musgrave_hybrid_multi_fractal_1d(
  * offset: raises the terrain from `sea level'
  */
 
-float noise_musgrave_ridged_multi_fractal_1d(
-    float p, float H, float lacunarity, float octaves, float offset, float gain)
+void node_tex_musgrave_ridged_multi_fractal_1d(vec3 co,
+                                                float w,
+                                                float scale,
+                                                float detail,
+                                                float dimension,
+                                                float lac,
+                                                float offset,
+                                                float gain,
+                                                out float fac)
 {
+  float p = w * scale;
+  float H = max(dimension, 1e-5);
+  float octaves = clamp(detail, 0.0, 16.0);
+  float lacunarity = max(lac, 1e-5);
+
   float result, signal, weight;
   float pwHL = pow(lacunarity, -H);
   float pwr = pwHL;
@@ -3736,7 +3798,7 @@ float noise_musgrave_ridged_multi_fractal_1d(
     pwr *= pwHL;
   }
 
-  return result;
+  fac = result;
 }
 
 /* 2D Musgrave fBm
@@ -3748,8 +3810,21 @@ float noise_musgrave_ridged_multi_fractal_1d(
  * from "Texturing and Modelling: A procedural approach"
  */
 
-float noise_musgrave_fBm_2d(vec2 p, float H, float lacunarity, float octaves)
+void node_tex_musgrave_fBm_2d(vec3 co,
+                               float w,
+                               float scale,
+                               float detail,
+                               float dimension,
+                               float lac,
+                               float offset,
+                               float gain,
+                               out float fac)
 {
+  vec2 p = co.xy * scale;
+  float H = max(dimension, 1e-5);
+  float octaves = clamp(detail, 0.0, 16.0);
+  float lacunarity = max(lac, 1e-5);
+
   float rmd;
   float value = 0.0;
   float pwr = 1.0;
@@ -3766,7 +3841,7 @@ float noise_musgrave_fBm_2d(vec2 p, float H, float lacunarity, float octaves)
     value += rmd * snoise(p) * pwr;
   }
 
-  return value;
+  fac = value;
 }
 
 /* 2D Musgrave Multifractal
@@ -3776,8 +3851,21 @@ float noise_musgrave_fBm_2d(vec2 p, float H, float lacunarity, float octaves)
  * octaves: number of frequencies in the fBm
  */
 
-float noise_musgrave_multi_fractal_2d(vec2 p, float H, float lacunarity, float octaves)
+void node_tex_musgrave_multi_fractal_2d(vec3 co,
+                                         float w,
+                                         float scale,
+                                         float detail,
+                                         float dimension,
+                                         float lac,
+                                         float offset,
+                                         float gain,
+                                         out float fac)
 {
+  vec2 p = co.xy * scale;
+  float H = max(dimension, 1e-5);
+  float octaves = clamp(detail, 0.0, 16.0);
+  float lacunarity = max(lac, 1e-5);
+
   float rmd;
   float value = 1.0;
   float pwr = 1.0;
@@ -3794,7 +3882,7 @@ float noise_musgrave_multi_fractal_2d(vec2 p, float H, float lacunarity, float o
     value *= (rmd * pwr * snoise(p) + 1.0); /* correct? */
   }
 
-  return value;
+  fac = value;
 }
 
 /* 2D Musgrave Heterogeneous Terrain
@@ -3805,9 +3893,21 @@ float noise_musgrave_multi_fractal_2d(vec2 p, float H, float lacunarity, float o
  * offset: raises the terrain from `sea level'
  */
 
-float noise_musgrave_hetero_terrain_2d(
-    vec2 p, float H, float lacunarity, float octaves, float offset)
+void node_tex_musgrave_hetero_terrain_2d(vec3 co,
+                                          float w,
+                                          float scale,
+                                          float detail,
+                                          float dimension,
+                                          float lac,
+                                          float offset,
+                                          float gain,
+                                          out float fac)
 {
+  vec2 p = co.xy * scale;
+  float H = max(dimension, 1e-5);
+  float octaves = clamp(detail, 0.0, 16.0);
+  float lacunarity = max(lac, 1e-5);
+
   float value, increment, rmd;
   float pwHL = pow(lacunarity, -H);
   float pwr = pwHL;
@@ -3829,7 +3929,7 @@ float noise_musgrave_hetero_terrain_2d(
     value += rmd * increment;
   }
 
-  return value;
+  fac = value;
 }
 
 /* 2D Hybrid Additive/Multiplicative Multifractal Terrain
@@ -3840,9 +3940,21 @@ float noise_musgrave_hetero_terrain_2d(
  * offset: raises the terrain from `sea level'
  */
 
-float noise_musgrave_hybrid_multi_fractal_2d(
-    vec2 p, float H, float lacunarity, float octaves, float offset, float gain)
+void node_tex_musgrave_hybrid_multi_fractal_2d(vec3 co,
+                                                float w,
+                                                float scale,
+                                                float detail,
+                                                float dimension,
+                                                float lac,
+                                                float offset,
+                              

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list