diff options
author | mano-wii <germano.costa@ig.com.br> | 2020-02-06 04:59:29 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2020-02-06 04:59:29 +0300 |
commit | d1112ae0d0e602fcba58c39147cbcd66fe624564 (patch) | |
tree | a9431883a020e7aec5e9e5927b3e76d3e185a79c /source/blender/gpu/shaders | |
parent | cad09e5227df3261662cba4a912605b6ffc671c1 (diff) | |
parent | b4f8e3f01bc91c98cc8b37f9a6f4ab8378e807eb (diff) |
Merge branch 'blender-v2.82-release'
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl | 7 | ||||
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl | 44 |
2 files changed, 24 insertions, 27 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl index df1c0479159..37da918acd6 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl @@ -49,13 +49,6 @@ int quick_floor(float x) return int(x) - ((x < 0) ? 1 : 0); } -float floorfrac(float x, out int i) -{ - float x_floor = floor(x); - i = int(x_floor); - return x - x_floor; -} - /* Vector Math */ vec2 safe_divide(vec2 a, vec2 b) diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl index c184c61c269..cc65b1eb57c 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl @@ -1,3 +1,7 @@ +/* clang-format off */ +#define FLOORFRAC(x, x_int, x_fract) { float x_floor = floor(x); x_int = int(x_floor); x_fract = x - x_floor; } +/* clang-format on */ + /* Bilinear Interpolation: * * v2 v3 @@ -124,7 +128,10 @@ float noise_grad(uint hash, float x, float y, float z, float w) float noise_perlin(float x) { int X; - float fx = floorfrac(x, X); + float fx; + + FLOORFRAC(x, X, fx); + float u = fade(fx); float r = mix(noise_grad(hash_int(X), fx), noise_grad(hash_int(X + 1), fx - 1.0), u); @@ -134,11 +141,11 @@ float noise_perlin(float x) float noise_perlin(vec2 vec) { - int X; - int Y; + int X, Y; + float fx, fy; - float fx = floorfrac(vec.x, X); - float fy = floorfrac(vec.y, Y); + FLOORFRAC(vec.x, X, fx); + FLOORFRAC(vec.y, Y, fy); float u = fade(fx); float v = fade(fy); @@ -155,13 +162,12 @@ float noise_perlin(vec2 vec) float noise_perlin(vec3 vec) { - int X; - int Y; - int Z; + int X, Y, Z; + float fx, fy, fz; - float fx = floorfrac(vec.x, X); - float fy = floorfrac(vec.y, Y); - float fz = floorfrac(vec.z, Z); + FLOORFRAC(vec.x, X, fx); + FLOORFRAC(vec.y, Y, fy); + FLOORFRAC(vec.z, Z, fz); float u = fade(fx); float v = fade(fy); @@ -184,15 +190,13 @@ float noise_perlin(vec3 vec) float noise_perlin(vec4 vec) { - int X; - int Y; - int Z; - int W; - - float fx = floorfrac(vec.x, X); - float fy = floorfrac(vec.y, Y); - float fz = floorfrac(vec.z, Z); - float fw = floorfrac(vec.w, W); + int X, Y, Z, W; + float fx, fy, fz, fw; + + FLOORFRAC(vec.x, X, fx); + FLOORFRAC(vec.y, Y, fy); + FLOORFRAC(vec.z, Z, fz); + FLOORFRAC(vec.w, W, fw); float u = fade(fx); float v = fade(fy); |