diff options
author | Germano <germano.costa@ig.com.br> | 2018-02-01 03:31:08 +0300 |
---|---|---|
committer | Germano <germano.costa@ig.com.br> | 2018-02-01 03:31:08 +0300 |
commit | 42ca1fe89cc93929426ab681a5520e5938158a4d (patch) | |
tree | fcd453b726751b3cc02fe9a810cd0d2c193fc559 | |
parent | ea31f0ac3b877eb0df4c47d0c908d11d1bff33e4 (diff) |
gpu_shader_material: Correct incorrect glsl texture of Voronoi, Noise, and Musgrave on some Intel GPUs
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index b54bd213b74..a77e7eb7937 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2478,8 +2478,7 @@ uint hash(int kx, int ky, int kz) float bits_to_01(uint bits) { - float x = float(bits) * (1.0 / float(0xffffffffu)); - return x; + return (float(bits) / 4294967295.0); } float cellnoise(vec3 p) @@ -3314,17 +3313,29 @@ float noise_perlin(float x, float y, float z) float v = noise_fade(fy); float w = noise_fade(fz); - float result; + float noise_u[2], noise_v[2]; + + noise_u[0] = noise_nerp(u, + noise_grad(hash(X, Y, Z), fx, fy, fz), + noise_grad(hash(X + 1, Y, Z), fx - 1.0, fy, fz)); + + noise_u[1] = noise_nerp(u, + noise_grad(hash(X, Y + 1, Z), fx, fy - 1.0, fz), + noise_grad(hash(X + 1, Y + 1, Z), fx - 1.0, fy - 1.0, fz)); + + noise_v[0] = noise_nerp(v, noise_u[0], noise_u[1]); + + noise_u[0] = noise_nerp(u, + noise_grad(hash(X, Y, Z + 1), fx, fy, fz - 1.0), + noise_grad(hash(X + 1, Y, Z + 1), fx - 1.0, fy, fz - 1.0)); + + noise_u[1] = noise_nerp(u, + noise_grad(hash(X, Y + 1, Z + 1), fx, fy - 1.0, fz - 1.0), + noise_grad(hash(X + 1, Y + 1, Z + 1), fx - 1.0, fy - 1.0, fz - 1.0)); + + noise_v[1] = noise_nerp(v, noise_u[0], noise_u[1]); - result = noise_nerp(w, noise_nerp(v, noise_nerp(u, noise_grad(hash(X, Y, Z), fx, fy, fz), - noise_grad(hash(X + 1, Y, Z), fx - 1.0, fy, fz)), - noise_nerp(u, noise_grad(hash(X, Y + 1, Z), fx, fy - 1.0, fz), - noise_grad(hash(X + 1, Y + 1, Z), fx - 1.0, fy - 1.0, fz))), - noise_nerp(v, noise_nerp(u, noise_grad(hash(X, Y, Z + 1), fx, fy, fz - 1.0), - noise_grad(hash(X + 1, Y, Z + 1), fx - 1.0, fy, fz - 1.0)), - noise_nerp(u, noise_grad(hash(X, Y + 1, Z + 1), fx, fy - 1.0, fz - 1.0), - noise_grad(hash(X + 1, Y + 1, Z + 1), fx - 1.0, fy - 1.0, fz - 1.0)))); - return noise_scale3(result); + return noise_scale3(noise_nerp(w, noise_v[0], noise_v[1])); } float noise(vec3 p) |