diff options
author | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-09-09 22:06:55 +0300 |
---|---|---|
committer | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-09-09 22:06:55 +0300 |
commit | f2176b3ff3c5df9ab43d1b0489e3bb350d1015f6 (patch) | |
tree | f64f3e8453f4c54de37ecd625f6796b43bccd398 /intern/cycles/kernel/shaders/node_musgrave_texture.osl | |
parent | c2d37929b4aaaef87bad1d2e90cc76d0c4765e8d (diff) |
Shading: Extend Musgrave node to other dimensions.
This patch extends Musgrave noise to operate in 1D, 2D, 3D, and 4D
space. The Color output was also removed because it was identical
to the Fac output.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D5566
Diffstat (limited to 'intern/cycles/kernel/shaders/node_musgrave_texture.osl')
-rw-r--r-- | intern/cycles/kernel/shaders/node_musgrave_texture.osl | 742 |
1 files changed, 656 insertions, 86 deletions
diff --git a/intern/cycles/kernel/shaders/node_musgrave_texture.osl b/intern/cycles/kernel/shaders/node_musgrave_texture.osl index 0bf462e2103..8861f9a671a 100644 --- a/intern/cycles/kernel/shaders/node_musgrave_texture.osl +++ b/intern/cycles/kernel/shaders/node_musgrave_texture.osl @@ -16,8 +16,342 @@ #include "stdosl.h" #include "node_noise.h" +#include "vector2.h" +#include "vector4.h" -/* Musgrave fBm +#define vector3 point + +/* 1D Musgrave fBm + * + * H: fractal increment parameter + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * + * from "Texturing and Modelling: A procedural approach" + */ + +float noise_musgrave_fBm_1d(float co, float H, float lacunarity, float octaves) +{ + float p = co; + float value = 0.0; + float pwr = 1.0; + float pwHL = pow(lacunarity, -H); + + for (int i = 0; i < (int)octaves; i++) { + value += safe_snoise(p) * pwr; + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value += rmd * safe_snoise(p) * pwr; + } + + return value; +} + +/* 1D Musgrave Multifractal + * + * H: highest fractal dimension + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + */ + +float noise_musgrave_multi_fractal_1d(float co, float H, float lacunarity, float octaves) +{ + float p = co; + float value = 1.0; + float pwr = 1.0; + float pwHL = pow(lacunarity, -H); + + for (int i = 0; i < (int)octaves; i++) { + value *= (pwr * safe_snoise(p) + 1.0); + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value *= (rmd * pwr * safe_snoise(p) + 1.0); /* correct? */ + } + + return value; +} + +/* 1D Musgrave Heterogeneous Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_hetero_terrain_1d( + float co, float H, float lacunarity, float octaves, float offset) +{ + float p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + /* first unscaled octave of function; later octaves are scaled */ + float value = offset + safe_snoise(p); + p *= lacunarity; + + for (int i = 1; i < (int)octaves; i++) { + float increment = (safe_snoise(p) + offset) * pwr * value; + value += increment; + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + float increment = (safe_snoise(p) + offset) * pwr * value; + value += rmd * increment; + } + + return value; +} + +/* 1D Hybrid Additive/Multiplicative Multifractal Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_hybrid_multi_fractal_1d( + float co, float H, float lacunarity, float octaves, float offset, float gain) +{ + float p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + float value = safe_snoise(p) + offset; + float weight = gain * value; + p *= lacunarity; + + for (int i = 1; (weight > 0.001) && (i < (int)octaves); i++) { + if (weight > 1.0) { + weight = 1.0; + } + + float signal = (safe_snoise(p) + offset) * pwr; + pwr *= pwHL; + value += weight * signal; + weight *= gain * signal; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value += rmd * ((safe_snoise(p) + offset) * pwr); + } + + return value; +} + +/* 1D Ridged Multifractal Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_ridged_multi_fractal_1d( + float co, float H, float lacunarity, float octaves, float offset, float gain) +{ + float p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + float signal = offset - fabs(safe_snoise(p)); + signal *= signal; + float value = signal; + float weight = 1.0; + + for (int i = 1; i < (int)octaves; i++) { + p *= lacunarity; + weight = clamp(signal * gain, 0.0, 1.0); + signal = offset - fabs(safe_snoise(p)); + signal *= signal; + signal *= weight; + value += signal * pwr; + pwr *= pwHL; + } + + return value; +} + +/* 2D Musgrave fBm + * + * H: fractal increment parameter + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * + * from "Texturing and Modelling: A procedural approach" + */ + +float noise_musgrave_fBm_2d(vector2 co, float H, float lacunarity, float octaves) +{ + vector2 p = co; + float value = 0.0; + float pwr = 1.0; + float pwHL = pow(lacunarity, -H); + + for (int i = 0; i < (int)octaves; i++) { + value += safe_snoise(p) * pwr; + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value += rmd * safe_snoise(p) * pwr; + } + + return value; +} + +/* 2D Musgrave Multifractal + * + * H: highest fractal dimension + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + */ + +float noise_musgrave_multi_fractal_2d(vector2 co, float H, float lacunarity, float octaves) +{ + vector2 p = co; + float value = 1.0; + float pwr = 1.0; + float pwHL = pow(lacunarity, -H); + + for (int i = 0; i < (int)octaves; i++) { + value *= (pwr * safe_snoise(p) + 1.0); + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value *= (rmd * pwr * safe_snoise(p) + 1.0); /* correct? */ + } + + return value; +} + +/* 2D Musgrave Heterogeneous Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_hetero_terrain_2d( + vector2 co, float H, float lacunarity, float octaves, float offset) +{ + vector2 p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + /* first unscaled octave of function; later octaves are scaled */ + float value = offset + safe_snoise(p); + p *= lacunarity; + + for (int i = 1; i < (int)octaves; i++) { + float increment = (safe_snoise(p) + offset) * pwr * value; + value += increment; + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + float increment = (safe_snoise(p) + offset) * pwr * value; + value += rmd * increment; + } + + return value; +} + +/* 2D Hybrid Additive/Multiplicative Multifractal Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_hybrid_multi_fractal_2d( + vector2 co, float H, float lacunarity, float octaves, float offset, float gain) +{ + vector2 p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + float value = safe_snoise(p) + offset; + float weight = gain * value; + p *= lacunarity; + + for (int i = 1; (weight > 0.001) && (i < (int)octaves); i++) { + if (weight > 1.0) { + weight = 1.0; + } + + float signal = (safe_snoise(p) + offset) * pwr; + pwr *= pwHL; + value += weight * signal; + weight *= gain * signal; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value += rmd * ((safe_snoise(p) + offset) * pwr); + } + + return value; +} + +/* 2D Ridged Multifractal Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_ridged_multi_fractal_2d( + vector2 co, float H, float lacunarity, float octaves, float offset, float gain) +{ + vector2 p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + float signal = offset - fabs(safe_snoise(p)); + signal *= signal; + float value = signal; + float weight = 1.0; + + for (int i = 1; i < (int)octaves; i++) { + p *= lacunarity; + weight = clamp(signal * gain, 0.0, 1.0); + signal = offset - fabs(safe_snoise(p)); + signal *= signal; + signal *= weight; + value += signal * pwr; + pwr *= pwHL; + } + + return value; +} + +/* 3D Musgrave fBm * * H: fractal increment parameter * lacunarity: gap between successive frequencies @@ -26,58 +360,56 @@ * from "Texturing and Modelling: A procedural approach" */ -float noise_musgrave_fBm(point ip, float H, float lacunarity, float octaves) +float noise_musgrave_fBm_3d(vector3 co, float H, float lacunarity, float octaves) { - float rmd; + vector3 p = co; float value = 0.0; float pwr = 1.0; float pwHL = pow(lacunarity, -H); - int i; - point p = ip; - for (i = 0; i < (int)octaves; i++) { - value += safe_noise(p) * pwr; + for (int i = 0; i < (int)octaves; i++) { + value += safe_snoise(p) * pwr; pwr *= pwHL; p *= lacunarity; } - rmd = octaves - floor(octaves); - if (rmd != 0.0) - value += rmd * safe_noise(p) * pwr; + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value += rmd * safe_snoise(p) * pwr; + } return value; } -/* Musgrave Multifractal +/* 3D Musgrave Multifractal * * H: highest fractal dimension * lacunarity: gap between successive frequencies * octaves: number of frequencies in the fBm */ -float noise_musgrave_multi_fractal(point ip, float H, float lacunarity, float octaves) +float noise_musgrave_multi_fractal_3d(vector3 co, float H, float lacunarity, float octaves) { - float rmd; + vector3 p = co; float value = 1.0; float pwr = 1.0; float pwHL = pow(lacunarity, -H); - int i; - point p = ip; - for (i = 0; i < (int)octaves; i++) { - value *= (pwr * safe_noise(p) + 1.0); + for (int i = 0; i < (int)octaves; i++) { + value *= (pwr * safe_snoise(p) + 1.0); pwr *= pwHL; p *= lacunarity; } - rmd = octaves - floor(octaves); - if (rmd != 0.0) - value *= (rmd * pwr * safe_noise(p) + 1.0); /* correct? */ + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value *= (rmd * pwr * safe_snoise(p) + 1.0); /* correct? */ + } return value; } -/* Musgrave Heterogeneous Terrain +/* 3D Musgrave Heterogeneous Terrain * * H: fractal dimension of the roughest area * lacunarity: gap between successive frequencies @@ -85,36 +417,34 @@ float noise_musgrave_multi_fractal(point ip, float H, float lacunarity, float oc * offset: raises the terrain from `sea level' */ -float noise_musgrave_hetero_terrain( - point ip, float H, float lacunarity, float octaves, float offset) +float noise_musgrave_hetero_terrain_3d( + vector3 co, float H, float lacunarity, float octaves, float offset) { - float value, increment, rmd; + vector3 p = co; float pwHL = pow(lacunarity, -H); float pwr = pwHL; - int i; - point p = ip; /* first unscaled octave of function; later octaves are scaled */ - value = offset + safe_noise(p); + float value = offset + safe_snoise(p); p *= lacunarity; - for (i = 1; i < (int)octaves; i++) { - increment = (safe_noise(p) + offset) * pwr * value; + for (int i = 1; i < (int)octaves; i++) { + float increment = (safe_snoise(p) + offset) * pwr * value; value += increment; pwr *= pwHL; p *= lacunarity; } - rmd = octaves - floor(octaves); + float rmd = octaves - floor(octaves); if (rmd != 0.0) { - increment = (safe_noise(p) + offset) * pwr * value; + float increment = (safe_snoise(p) + offset) * pwr * value; value += rmd * increment; } return value; } -/* Hybrid Additive/Multiplicative Multifractal Terrain +/* 3D Hybrid Additive/Multiplicative Multifractal Terrain * * H: fractal dimension of the roughest area * lacunarity: gap between successive frequencies @@ -122,38 +452,38 @@ float noise_musgrave_hetero_terrain( * offset: raises the terrain from `sea level' */ -float noise_musgrave_hybrid_multi_fractal( - point ip, float H, float lacunarity, float octaves, float offset, float gain) +float noise_musgrave_hybrid_multi_fractal_3d( + vector3 co, float H, float lacunarity, float octaves, float offset, float gain) { - float result, signal, weight, rmd; + vector3 p = co; float pwHL = pow(lacunarity, -H); float pwr = pwHL; - int i; - point p = ip; - result = safe_noise(p) + offset; - weight = gain * result; + float value = safe_snoise(p) + offset; + float weight = gain * value; p *= lacunarity; - for (i = 1; (weight > 0.001) && (i < (int)octaves); i++) { - if (weight > 1.0) + for (int i = 1; (weight > 0.001) && (i < (int)octaves); i++) { + if (weight > 1.0) { weight = 1.0; + } - signal = (safe_noise(p) + offset) * pwr; + float signal = (safe_snoise(p) + offset) * pwr; pwr *= pwHL; - result += weight * signal; + value += weight * signal; weight *= gain * signal; p *= lacunarity; } - rmd = octaves - floor(octaves); - if (rmd != 0.0) - result += rmd * ((safe_noise(p) + offset) * pwr); + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value += rmd * ((safe_snoise(p) + offset) * pwr); + } - return result; + return value; } -/* Ridged Multifractal Terrain +/* 3D Ridged Multifractal Terrain * * H: fractal dimension of the roughest area * lacunarity: gap between successive frequencies @@ -161,73 +491,313 @@ float noise_musgrave_hybrid_multi_fractal( * offset: raises the terrain from `sea level' */ -float noise_musgrave_ridged_multi_fractal( - point ip, float H, float lacunarity, float octaves, float offset, float gain) +float noise_musgrave_ridged_multi_fractal_3d( + vector3 co, float H, float lacunarity, float octaves, float offset, float gain) { - float result, signal, weight; + vector3 p = co; float pwHL = pow(lacunarity, -H); float pwr = pwHL; - int i; - point p = ip; - signal = offset - fabs(safe_noise(p)); + float signal = offset - fabs(safe_snoise(p)); signal *= signal; - result = signal; - weight = 1.0; + float value = signal; + float weight = 1.0; - for (i = 1; i < (int)octaves; i++) { + for (int i = 1; i < (int)octaves; i++) { p *= lacunarity; weight = clamp(signal * gain, 0.0, 1.0); - signal = offset - fabs(safe_noise(p)); + signal = offset - fabs(safe_snoise(p)); signal *= signal; signal *= weight; - result += signal * pwr; + value += signal * pwr; + pwr *= pwHL; + } + + return value; +} + +/* 4D Musgrave fBm + * + * H: fractal increment parameter + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * + * from "Texturing and Modelling: A procedural approach" + */ + +float noise_musgrave_fBm_4d(vector4 co, float H, float lacunarity, float octaves) +{ + vector4 p = co; + float value = 0.0; + float pwr = 1.0; + float pwHL = pow(lacunarity, -H); + + for (int i = 0; i < (int)octaves; i++) { + value += safe_snoise(p) * pwr; + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value += rmd * safe_snoise(p) * pwr; + } + + return value; +} + +/* 4D Musgrave Multifractal + * + * H: highest fractal dimension + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + */ + +float noise_musgrave_multi_fractal_4d(vector4 co, float H, float lacunarity, float octaves) +{ + vector4 p = co; + float value = 1.0; + float pwr = 1.0; + float pwHL = pow(lacunarity, -H); + + for (int i = 0; i < (int)octaves; i++) { + value *= (pwr * safe_snoise(p) + 1.0); + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value *= (rmd * pwr * safe_snoise(p) + 1.0); /* correct? */ + } + + return value; +} + +/* 4D Musgrave Heterogeneous Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_hetero_terrain_4d( + vector4 co, float H, float lacunarity, float octaves, float offset) +{ + vector4 p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + /* first unscaled octave of function; later octaves are scaled */ + float value = offset + safe_snoise(p); + p *= lacunarity; + + for (int i = 1; i < (int)octaves; i++) { + float increment = (safe_snoise(p) + offset) * pwr * value; + value += increment; + pwr *= pwHL; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + float increment = (safe_snoise(p) + offset) * pwr * value; + value += rmd * increment; + } + + return value; +} + +/* 4D Hybrid Additive/Multiplicative Multifractal Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_hybrid_multi_fractal_4d( + vector4 co, float H, float lacunarity, float octaves, float offset, float gain) +{ + vector4 p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + float value = safe_snoise(p) + offset; + float weight = gain * value; + p *= lacunarity; + + for (int i = 1; (weight > 0.001) && (i < (int)octaves); i++) { + if (weight > 1.0) { + weight = 1.0; + } + + float signal = (safe_snoise(p) + offset) * pwr; pwr *= pwHL; + value += weight * signal; + weight *= gain * signal; + p *= lacunarity; + } + + float rmd = octaves - floor(octaves); + if (rmd != 0.0) { + value += rmd * ((safe_snoise(p) + offset) * pwr); } - return result; + return value; } -/* Shader */ +/* 4D Ridged Multifractal Terrain + * + * H: fractal dimension of the roughest area + * lacunarity: gap between successive frequencies + * octaves: number of frequencies in the fBm + * offset: raises the terrain from `sea level' + */ + +float noise_musgrave_ridged_multi_fractal_4d( + vector4 co, float H, float lacunarity, float octaves, float offset, float gain) +{ + vector4 p = co; + float pwHL = pow(lacunarity, -H); + float pwr = pwHL; + + float signal = offset - fabs(safe_snoise(p)); + signal *= signal; + float value = signal; + float weight = 1.0; + + for (int i = 1; i < (int)octaves; i++) { + p *= lacunarity; + weight = clamp(signal * gain, 0.0, 1.0); + signal = offset - fabs(safe_snoise(p)); + signal *= signal; + signal *= weight; + value += signal * pwr; + pwr *= pwHL; + } + + return value; +} shader node_musgrave_texture( int use_mapping = 0, matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), string type = "fBM", + string dimensions = "3D", + point Vector = P, + float W = 0.0, float Dimension = 2.0, - float Lacunarity = 1.0, + float Scale = 5.0, float Detail = 2.0, + float Lacunarity = 1.0, float Offset = 0.0, float Gain = 1.0, - float Scale = 5.0, - point Vector = P, - output float Fac = 0.0, - output color Color = 0.0) + output float Fac = 0.0) { float dimension = max(Dimension, 1e-5); float octaves = clamp(Detail, 0.0, 16.0); float lacunarity = max(Lacunarity, 1e-5); - float intensity = 1.0; - point p = Vector; + vector3 s = Vector; if (use_mapping) - p = transform(mapping, p); - - p = p * Scale; - - if (type == "multifractal") - Fac = intensity * noise_musgrave_multi_fractal(p, dimension, lacunarity, octaves); - else if (type == "fBM") - Fac = intensity * noise_musgrave_fBm(p, dimension, lacunarity, octaves); - else if (type == "hybrid_multifractal") - Fac = intensity * - noise_musgrave_hybrid_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain); - else if (type == "ridged_multifractal") - Fac = intensity * - noise_musgrave_ridged_multi_fractal(p, dimension, lacunarity, octaves, Offset, Gain); - else if (type == "hetero_terrain") - Fac = intensity * noise_musgrave_hetero_terrain(p, dimension, lacunarity, octaves, Offset); - - Color = color(Fac, Fac, Fac); + s = transform(mapping, s); + + if (dimensions == "1D") { + float p = W * Scale; + if (type == "multifractal") { + Fac = noise_musgrave_multi_fractal_1d(p, dimension, lacunarity, octaves); + } + else if (type == "fBM") { + Fac = noise_musgrave_fBm_1d(p, dimension, lacunarity, octaves); + } + else if (type == "hybrid_multifractal") { + Fac = noise_musgrave_hybrid_multi_fractal_1d( + p, dimension, lacunarity, octaves, Offset, Gain); + } + else if (type == "ridged_multifractal") { + Fac = noise_musgrave_ridged_multi_fractal_1d( + p, dimension, lacunarity, octaves, Offset, Gain); + } + else if (type == "hetero_terrain") { + Fac = noise_musgrave_hetero_terrain_1d(p, dimension, lacunarity, octaves, Offset); + } + else { + Fac = 0.0; + } + } + else if (dimensions == "2D") { + vector2 p = vector2(s[0], s[1]) * Scale; + if (type == "multifractal") { + Fac = noise_musgrave_multi_fractal_2d(p, dimension, lacunarity, octaves); + } + else if (type == "fBM") { + Fac = noise_musgrave_fBm_2d(p, dimension, lacunarity, octaves); + } + else if (type == "hybrid_multifractal") { + Fac = noise_musgrave_hybrid_multi_fractal_2d( + p, dimension, lacunarity, octaves, Offset, Gain); + } + else if (type == "ridged_multifractal") { + Fac = noise_musgrave_ridged_multi_fractal_2d( + p, dimension, lacunarity, octaves, Offset, Gain); + } + else if (type == "hetero_terrain") { + Fac = noise_musgrave_hetero_terrain_2d(p, dimension, lacunarity, octaves, Offset); + } + else { + Fac = 0.0; + } + } + else if (dimensions == "3D") { + vector3 p = s * Scale; + if (type == "multifractal") { + Fac = noise_musgrave_multi_fractal_3d(p, dimension, lacunarity, octaves); + } + else if (type == "fBM") { + Fac = noise_musgrave_fBm_3d(p, dimension, lacunarity, octaves); + } + else if (type == "hybrid_multifractal") { + Fac = noise_musgrave_hybrid_multi_fractal_3d( + p, dimension, lacunarity, octaves, Offset, Gain); + } + else if (type == "ridged_multifractal") { + Fac = noise_musgrave_ridged_multi_fractal_3d( + p, dimension, lacunarity, octaves, Offset, Gain); + } + else if (type == "hetero_terrain") { + Fac = noise_musgrave_hetero_terrain_3d(p, dimension, lacunarity, octaves, Offset); + } + else { + Fac = 0.0; + } + } + else if (dimensions == "4D") { + vector4 p = vector4(s[0], s[1], s[2], W) * Scale; + if (type == "multifractal") { + Fac = noise_musgrave_multi_fractal_4d(p, dimension, lacunarity, octaves); + } + else if (type == "fBM") { + Fac = noise_musgrave_fBm_4d(p, dimension, lacunarity, octaves); + } + else if (type == "hybrid_multifractal") { + Fac = noise_musgrave_hybrid_multi_fractal_4d( + p, dimension, lacunarity, octaves, Offset, Gain); + } + else if (type == "ridged_multifractal") { + Fac = noise_musgrave_ridged_multi_fractal_4d( + p, dimension, lacunarity, octaves, Offset, Gain); + } + else if (type == "hetero_terrain") { + Fac = noise_musgrave_hetero_terrain_4d(p, dimension, lacunarity, octaves, Offset); + } + else { + Fac = 0.0; + } + } + else { + Fac = 0.0; + } } |